Skip to content

Commit 7fe4745

Browse files
authored
Merge pull request #108 from mageshwaranr/scala-support-v1
Add Scala support to repository analysis
2 parents 9ed15ba + 737a5e3 commit 7fe4745

15 files changed

Lines changed: 989 additions & 2 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ tests/*
4545
!tests/test_processing_order_update.py
4646
!tests/test_leaf_selection.py
4747
!tests/test_artifact_analyzer.py
48+
!tests/test_scala_analyzer.py
4849

4950
# Jupyter
5051
*.ipynb

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ CodeWiki is an open-source framework for **automated repository-level documentat
149149

150150
### Supported Languages
151151

152-
**🐍 Python** • **☕ Java** • **🟨 JavaScript** • **🔷 TypeScript** • **⚙️ C** • **🔧 C++** • **🪟 C#** • **🎯 Kotlin** • **🐘 PHP** • **💎 Ruby**
152+
**🐍 Python** • **☕ Java** • **🟨 JavaScript** • **🔷 TypeScript** • **⚙️ C** • **🔧 C++** • **🪟 C#** • **🎯 Kotlin** • **🐘 PHP** • **💎 Ruby** • **🔺 Scala**
153153

154154
---
155155

‎codewiki/cli/utils/repo_validator.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
".kt", # Kotlin
3232
".kts", # Kotlin Scripts
3333
".rb", # Ruby
34+
".scala", # Scala
35+
".sc", # Scala Scripts
3436
}
3537

3638

‎codewiki/cli/utils/validation.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def detect_supported_languages(directory: Path) -> list[tuple[str, int]]:
166166
"PHP": [".php", ".phtml", ".inc"],
167167
"Kotlin": [".kt", ".kts"],
168168
"Ruby": [".rb"],
169+
"Scala": [".scala", ".sc"],
169170
}
170171

171172
# Directories to exclude from counting

‎codewiki/mcp/tools/analysis.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ def _detect_via_mtime(
226226
".kt",
227227
".kts",
228228
".rb",
229+
".scala",
230+
".sc",
229231
}
230232

231233
changed: list[str] = []

‎codewiki/src/be/dependency_analyzer/analysis/analysis_service.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ def _filter_supported_languages(self, code_files: list[dict]) -> list[dict]:
354354
"go",
355355
"rust",
356356
"kotlin",
357+
"scala",
357358
}
358359

359360
return [
@@ -375,6 +376,7 @@ def _get_supported_languages(self) -> list[str]:
375376
"php",
376377
"ruby",
377378
"kotlin",
379+
"scala",
378380
]
379381

380382
def _cleanup_repository(self, temp_dir: str):

‎codewiki/src/be/dependency_analyzer/analysis/call_graph_analyzer.py‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,8 @@ def _analyze_code_file(self, repo_dir: str, file_info: dict):
253253
self._analyze_php_file(file_path, content, repo_dir)
254254
elif language == "ruby":
255255
self._analyze_ruby_file(file_path, content, repo_dir)
256+
elif language == "scala":
257+
self._analyze_scala_file(file_path, content, repo_dir)
256258
# else:
257259
# logger.warning(
258260
# f"Unsupported language for call graph analysis: {language} for file {file_path}"
@@ -508,6 +510,28 @@ def _analyze_ruby_file(self, file_path: str, content: str, repo_dir: str):
508510
except Exception:
509511
logger.exception(f"Failed to analyze Ruby file {file_path}")
510512

513+
def _analyze_scala_file(self, file_path: str, content: str, repo_dir: str):
514+
"""
515+
Analyze Scala file using tree-sitter based analyzer.
516+
517+
Args:
518+
file_path: Relative path to the Scala file
519+
content: File content string
520+
repo_dir: Repository base directory
521+
"""
522+
from codewiki.src.be.dependency_analyzer.analyzers.scala import analyze_scala_file
523+
524+
try:
525+
functions, relationships = analyze_scala_file(file_path, content, repo_path=repo_dir)
526+
527+
for func in functions:
528+
func_id = func.id if func.id else f"{file_path}:{func.name}"
529+
self.functions[func_id] = func
530+
531+
self.call_relationships.extend(relationships)
532+
except Exception:
533+
logger.exception(f"Failed to analyze Scala file {file_path}")
534+
511535
def _resolve_call_relationships(self):
512536
"""
513537
Resolve function call relationships across all languages.
@@ -804,6 +828,8 @@ def _generate_visualization_data(self) -> dict:
804828
node_classes.append("lang-php")
805829
elif file_ext == ".rb":
806830
node_classes.append("lang-ruby")
831+
elif file_ext in [".scala", ".sc"]:
832+
node_classes.append("lang-scala")
807833

808834
cytoscape_elements.append(
809835
{

‎codewiki/src/be/dependency_analyzer/analyzers/artifact.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,7 @@ def is_artifact_file_node(node: Any) -> bool:
241241
"build.gradle.kts",
242242
"settings.gradle",
243243
"settings.gradle.kts",
244+
"build.sbt",
244245
"Package.swift",
245246
"pubspec.yaml",
246247
"Pipfile",
@@ -293,7 +294,7 @@ def is_artifact_file_node(node: Any) -> bool:
293294
"Gruntfile.js",
294295
"Herebyfile.mjs",
295296
}
296-
_BUILD_EXTS = {".gn", ".gni", ".gradle", ".rake", ".mk", ".cmake", ".bzl", ".ninja"}
297+
_BUILD_EXTS = {".gn", ".gni", ".gradle", ".rake", ".mk", ".cmake", ".bzl", ".ninja", ".sbt"}
297298
_BUILD_CONFIG_RE = re.compile(r"^(webpack|rollup|vite|esbuild|tsup|babel)\.config\.[cm]?[jt]s$")
298299
_BUILD_TOPS = {"build", "rakelib", "cmake"}
299300
_TEST_INFRA_NAMES = {
@@ -427,6 +428,8 @@ def classify_artifact(
427428
".cs",
428429
".php",
429430
".kt",
431+
".scala",
432+
".sc",
430433
}:
431434
if name in _TEST_INFRA_NAMES:
432435
return "test_infra"

0 commit comments

Comments
 (0)