Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

feat: register ScalaParser in ParserRouter and IngestionService

riley0227b6acd37e3b4d
diff --git a/memory-layer/src/main/scala/ix/memory/ingestion/IngestionService.scala b/memory-layer/src/main/scala/ix/memory/ingestion/IngestionService.scala
index e860d4e6..9ecf6198 100644
--- a/memory-layer/src/main/scala/ix/memory/ingestion/IngestionService.scala
+++ b/memory-layer/src/main/scala/ix/memory/ingestion/IngestionService.scala
@@ -36,6 +36,7 @@ class IngestionService(parserRouter: ParserRouter, writeApi: GraphWriteApi, quer
val fp = filePath.toString
extractor = if (fp.endsWith(".py")) "tree-sitter-python/1.0"
else if (fp.endsWith(".ts") || fp.endsWith(".tsx")) "typescript-parser/1.0"
+ else if (fp.endsWith(".scala") || fp.endsWith(".sc")) "scala-parser/1.0"
else if (fp.endsWith(".json") || fp.endsWith(".yaml") || fp.endsWith(".yml") || fp.endsWith(".toml") || fp.endsWith(".ini") || fp.endsWith(".conf") || fp.endsWith(".properties") || fp.endsWith(".env")) "config-parser/1.0"
else if (fp.endsWith(".md") || fp.endsWith(".mdx") || fp.endsWith(".rst") || fp.endsWith(".txt")) "markdown-parser/1.0"
else "text-parser/1.0"
@@ -96,6 +97,7 @@ class IngestionService(parserRouter: ParserRouter, writeApi: GraphWriteApi, quer
val extensions = language match {
case Some("python") => Set(".py")
case Some("typescript") => Set(".ts", ".tsx")
+ case Some("scala") => Set(".scala", ".sc")
case Some("config") => Set(".json", ".yaml", ".yml", ".toml")
case Some("markdown") => Set(".md")
case _ => Set(
diff --git a/memory-layer/src/main/scala/ix/memory/ingestion/ParserRouter.scala b/memory-layer/src/main/scala/ix/memory/ingestion/ParserRouter.scala
index 5df0539c..a5d24632 100644
--- a/memory-layer/src/main/scala/ix/memory/ingestion/ParserRouter.scala
+++ b/memory-layer/src/main/scala/ix/memory/ingestion/ParserRouter.scala
@@ -1,6 +1,6 @@
package ix.memory.ingestion
-import ix.memory.ingestion.parsers.{ConfigParser, MarkdownParser, TreeSitterPythonParser, TypeScriptParser}
+import ix.memory.ingestion.parsers.{ConfigParser, MarkdownParser, ScalaParser, TreeSitterPythonParser, TypeScriptParser}
/**
* Routes file paths to the appropriate language parser.
@@ -12,10 +12,12 @@ class ParserRouter {
private val tsParser = new TypeScriptParser()
private val configParser = new ConfigParser()
private val markdownParser = new MarkdownParser()
+ private val scalaParser = new ScalaParser()
def parserFor(filePath: String): Option[Parser] = {
if (filePath.endsWith(".py")) Some(pythonParser)
else if (filePath.endsWith(".ts") || filePath.endsWith(".tsx")) Some(tsParser)
+ else if (filePath.endsWith(".scala") || filePath.endsWith(".sc")) Some(scalaParser)
else if (filePath.endsWith(".json") || filePath.endsWith(".yaml") || filePath.endsWith(".yml") || filePath.endsWith(".toml")) Some(configParser)
else if (filePath.endsWith(".md")) Some(markdownParser)
else None
diff --git a/memory-layer/src/main/scala/ix/memory/ingestion/parsers/ScalaParser.scala b/memory-layer/src/main/scala/ix/memory/ingestion/parsers/ScalaParser.scala
index c6b1e685..9d0be11c 100644
--- a/memory-layer/src/main/scala/ix/memory/ingestion/parsers/ScalaParser.scala
+++ b/memory-layer/src/main/scala/ix/memory/ingestion/parsers/ScalaParser.scala
@@ -1,6 +1,6 @@
package ix.memory.ingestion.parsers
-import ix.memory.ingestion.{ParseResult, ParsedEntity, ParsedRelationship}
+import ix.memory.ingestion.{Parser, ParseResult, ParsedEntity, ParsedRelationship}
import ix.memory.model.NodeKind
import io.circe.Json
@@ -12,7 +12,7 @@ import scala.util.matching.Regex
* Extracts: traits, classes, case classes, objects, methods (def), and imports.
* Uses brace counting for block boundary detection.
*/
-class ScalaParser {
+class ScalaParser extends Parser {
// Patterns for Scala constructs
private val TraitPattern: Regex = """^\s*(?:sealed\s+|abstract\s+|private\s+|protected\s+)*trait\s+(\w+)""".r