Step 149: add Java parser and generator

This commit is contained in:
Bill
2026-02-09 18:54:52 -07:00
parent fa030c0186
commit 52b54575ec
12 changed files with 1324 additions and 3 deletions

View File

@@ -402,6 +402,8 @@ public:
targetLanguage = "javascript";
} else if (path.substr(path.find_last_of(".") + 1) == "ts") {
targetLanguage = "typescript";
} else if (path.substr(path.find_last_of(".") + 1) == "java") {
targetLanguage = "java";
}
// Parse the content using the appropriate tree-sitter parser
@@ -416,6 +418,8 @@ public:
module = TreeSitterParser::parseJavaScript(content);
} else if (targetLanguage == "typescript") {
module = TreeSitterParser::parseTypeScript(content);
} else if (targetLanguage == "java") {
module = TreeSitterParser::parseJava(content);
} else {
// For unknown languages, create a basic module with the content
module = std::make_unique<Module>();
@@ -451,6 +455,8 @@ public:
targetLanguage = "javascript";
} else if (path.substr(path.find_last_of(".") + 1) == "ts") {
targetLanguage = "typescript";
} else if (path.substr(path.find_last_of(".") + 1) == "java") {
targetLanguage = "java";
}
}
@@ -471,6 +477,9 @@ public:
} else if (targetLanguage == "typescript") {
TypeScriptGenerator gen;
content = gen.generate(ast);
} else if (targetLanguage == "java") {
JavaGenerator gen;
content = gen.generate(ast);
} else {
// Default to Python generator for unknown languages
PythonGenerator gen;