Skip to content

Commit dd223a0

Browse files
committed
feat: add Objective-C support for code analysis and update documentation
1 parent 89f03e5 commit dd223a0

File tree

4 files changed

+96
-4
lines changed

4 files changed

+96
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,5 @@ CLAUDE.md
4747
.claude_chat/
4848
claude_*
4949
COMMIT_MESSAGE.txt
50+
51+
.llm-context/

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,9 @@ This server integrates with the [Model Context Protocol](https://modelcontextpro
2727
- **Regex Search**: Full regex pattern matching with safety validation to prevent ReDoS attacks
2828
- **Fuzzy Search**: Native fuzzy matching with ugrep, or word boundary patterns for other tools
2929
- **File Analysis**: Get detailed insights about file structure, imports, classes, methods, and complexity
30-
- **Java Support**: Comprehensive analysis including packages, classes, interfaces, enums, and methods
31-
- **Python/JavaScript Support**: Functions, classes, and import analysis
30+
- **Java Support**: Comprehensive analysis including packages, classes, interfaces, enums, and methods
31+
- **Objective-C Support**: Full analysis including interfaces, implementations, methods, properties, protocols, and categories
32+
- **Python/JavaScript Support**: Functions, classes, and import analysis
3233
- **Smart Filtering**: Automatically ignores build directories, dependencies, and non-code files
3334
- **Persistent Storage**: Caches indexes for improved performance across sessions
3435
- **Lazy Loading**: Search tools are detected only when needed for optimal startup performance
@@ -52,6 +53,7 @@ The server supports multiple programming languages and file extensions including
5253
- Scala (.scala)
5354
- Shell scripts (.sh, .bash)
5455
- Zig (.zig)
56+
- **Objective-C/Objective-C++** (.m, .mm)
5557
- Web files (.html, .css, .scss, .less, .sass, .stylus, .styl)
5658
- Template engines (.hbs, .handlebars, .ejs, .pug)
5759
- **Database & SQL**:

README_zh.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
- **模糊搜尋**:ugrep 的原生模糊匹配功能,或其他工具的詞邊界模式匹配
2525
- **檔案分析**:取得有關檔案結構、匯入、類別、方法和複雜性的詳細資訊
2626
- **Java 支援**:全面分析包括套件、類別、介面、列舉和方法
27-
- **Python/JavaScript 支援**:函式、類別和匯入分析
27+
- **Objective-C 支援**:完整分析包括介面、實作、方法、屬性、協定和分類
28+
- **Python/JavaScript 支援**:函式、類別和匯入分析
2829
- **智慧篩選**:自動忽略建構目錄、相依套件和非程式碼檔案
2930
- **持久儲存**:快取索引以提高跨工作階段的效能
3031
- **延遲載入**:僅在需要時偵測搜尋工具,優化啟動效能
@@ -48,6 +49,7 @@
4849
- Scala (.scala)
4950
- Shell 指令碼 (.sh, .bash)
5051
- Zig (.zig)
52+
- **Objective-C/Objective-C++** (.m, .mm)
5153
- Web 檔案 (.html, .css, .scss, .less, .sass, .stylus, .styl)
5254
- 模板引擎 (.hbs, .handlebars, .ejs, .pug)
5355
- **資料庫與 SQL**

src/code_index_mcp/server.py

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@
3939
'.hbs', '.handlebars', '.ejs', '.pug',
4040
# Modern frontend
4141
'.astro', '.mdx',
42+
# Objective-C
43+
'.m', '.mm',
4244
# Database and SQL
4345
'.sql', '.ddl', '.dml', '.mysql', '.postgresql', '.psql', '.sqlite',
4446
'.mssql', '.oracle', '.ora', '.db2',
@@ -602,6 +604,90 @@ def get_file_summary(file_path: str, ctx: Context) -> Dict[str, Any]:
602604
"enum_count": len(enums),
603605
})
604606

607+
elif ext in ['.m', '.mm']:
608+
# Objective-C/Objective-C++ analysis
609+
imports = []
610+
interfaces = []
611+
implementations = []
612+
methods = []
613+
properties = []
614+
protocols = []
615+
categories = []
616+
617+
for i, line in enumerate(lines):
618+
line = line.strip()
619+
620+
# Check for imports
621+
if line.startswith('#import ') or line.startswith('#include '):
622+
imports.append(line)
623+
624+
# Check for @interface declarations
625+
if line.startswith('@interface '):
626+
interface_name = line.replace('@interface ', '').split(':')[0].split('<')[0].strip()
627+
interfaces.append({
628+
"line": i + 1,
629+
"name": interface_name
630+
})
631+
632+
# Check if it's a category
633+
if '(' in line and ')' in line:
634+
category_name = line[line.find('(')+1:line.find(')')]
635+
categories.append({
636+
"line": i + 1,
637+
"name": f"{interface_name} ({category_name})"
638+
})
639+
640+
# Check for @implementation declarations
641+
if line.startswith('@implementation '):
642+
impl_name = line.replace('@implementation ', '').split(':')[0].split('<')[0].strip()
643+
implementations.append({
644+
"line": i + 1,
645+
"name": impl_name
646+
})
647+
648+
# Check for @protocol declarations
649+
if line.startswith('@protocol '):
650+
protocol_name = line.replace('@protocol ', '').split('<')[0].split(':')[0].strip()
651+
protocols.append({
652+
"line": i + 1,
653+
"name": protocol_name
654+
})
655+
656+
# Check for @property declarations
657+
if line.startswith('@property '):
658+
property_def = line.replace('@property ', '').split(';')[0].strip()
659+
properties.append({
660+
"line": i + 1,
661+
"definition": property_def
662+
})
663+
664+
# Check for method declarations and definitions
665+
if line.startswith('- (') or line.startswith('+ ('):
666+
method_type = "instance" if line.startswith('- (') else "class"
667+
method_content = line.strip()
668+
methods.append({
669+
"line": i + 1,
670+
"type": method_type,
671+
"signature": method_content
672+
})
673+
674+
summary.update({
675+
"imports": imports,
676+
"interfaces": interfaces,
677+
"implementations": implementations,
678+
"methods": methods,
679+
"properties": properties,
680+
"protocols": protocols,
681+
"categories": categories,
682+
"import_count": len(imports),
683+
"interface_count": len(interfaces),
684+
"implementation_count": len(implementations),
685+
"method_count": len(methods),
686+
"property_count": len(properties),
687+
"protocol_count": len(protocols),
688+
"category_count": len(categories),
689+
})
690+
605691
return summary
606692
except Exception as e:
607693
return {"error": f"Error analyzing file: {e}"}
@@ -878,4 +964,4 @@ def main():
878964
if __name__ == '__main__':
879965
# Set path to project root
880966
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
881-
main()
967+
main()

0 commit comments

Comments
 (0)