Detect java project root.
Credit to Close
@@ -33,6 +33,8 @@ def getRootPath(filepath: str, languageId: str) -> str:
or os.path.exists(os.path.join(folder, "setup.py")))
elif languageId == "cs":
rootPath = traverseUp(filepath, isDotnetRoot)
+ elif languageId == "java":
+ rootPath = traverseUp(filepath, isJavaRoot)
# TODO: detect for other filetypes
if not rootPath:
rootPath = traverseUp(
@@ -67,6 +69,16 @@ def isDotnetRoot(folder: str) -> bool:
return False
+def isJavaRoot(folder: str) -> bool:
+ if os.path.exists(os.path.join(folder, ".project")):
+ return True
+
+ if os.path.exists(os.path.join(folder, "pom.xml")):
+ return True
+
+ return False
+
+
def pathToURI(filepath: str) -> str:
if not os.path.isabs(filepath):
return None
