Step 149: add Java parser and generator
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user