@@ -18,7 +18,7 @@ import (
1818 "context"
1919 "fmt"
2020 "github.com/cloudwego/abcoder/lang/java"
21- javaparser "github.com/cloudwego/abcoder/lang/java/parser"
21+ "github.com/cloudwego/abcoder/lang/java/parser"
2222 "maps"
2323 "os"
2424 "path/filepath"
@@ -373,12 +373,12 @@ func (c *Collector) ScannerByTreeSitter(ctx context.Context) ([]*DocumentSymbol,
373373 // Java uses parsing pom method to obtain hierarchical relationships
374374 if c .Language == uniast .Java {
375375 rootPomPath := filepath .Join (c .repo , "pom.xml" )
376- rootModule , err := javaparser .ParseMavenProject (rootPomPath )
376+ rootModule , err := parser .ParseMavenProject (rootPomPath )
377377 if err != nil {
378378 // 尝试直接遍历文件
379379 modulePaths = append (modulePaths , c .repo )
380380 } else {
381- modulePaths = javaparser .GetModulePaths (rootModule )
381+ modulePaths = parser .GetModulePaths (rootModule )
382382 }
383383 // Collect all module paths from the maven project structure
384384 }
@@ -431,7 +431,7 @@ func (c *Collector) ScannerByTreeSitter(ctx context.Context) ([]*DocumentSymbol,
431431 if err != nil {
432432 return err
433433 }
434- tree , err := javaparser .Parse (ctx , content )
434+ tree , err := parser .Parse (ctx , content )
435435 if err != nil {
436436 log .Error ("parse file %s failed: %v" , path , err )
437437 return nil // continue with next file
@@ -464,7 +464,7 @@ func (c *Collector) collectFields(node *sitter.Node, uri DocumentURI, content []
464464 if node == nil {
465465 return
466466 }
467- q , err := sitter .NewQuery ([]byte ("(field_declaration) @field" ), javaparser .GetLanguage (c .CollectOption .Language ))
467+ q , err := sitter .NewQuery ([]byte ("(field_declaration) @field" ), parser .GetLanguage (c .CollectOption .Language ))
468468 if err != nil {
469469 // Or handle the error more gracefully
470470 return
@@ -598,21 +598,21 @@ func (c *Collector) findDefinitionLocation(ref *DocumentSymbol) Location {
598598func (c * Collector ) walk (node * sitter.Node , uri DocumentURI , content []byte , file * uniast.File , parent * DocumentSymbol ) {
599599 switch node .Type () {
600600 case "package_declaration" :
601- pkgNameNode := javaparser .FindChildIdentifier (node )
601+ pkgNameNode := parser .FindChildIdentifier (node )
602602 if pkgNameNode != nil {
603603 file .Package = uniast .PkgPath (pkgNameNode .Content (content ))
604604 }
605605 return // no need to walk children
606606
607607 case "import_declaration" :
608- importPathNode := javaparser .FindChildIdentifier (node )
608+ importPathNode := parser .FindChildIdentifier (node )
609609 if importPathNode != nil {
610610 file .Imports = append (file .Imports , uniast.Import {Path : importPathNode .Content (content )})
611611 }
612612 return // no need to walk children of import declaration
613613
614614 case "class_declaration" , "interface_declaration" , "enum_declaration" :
615- nameNode := javaparser .FindChildIdentifier (node )
615+ nameNode := parser .FindChildIdentifier (node )
616616 if nameNode == nil {
617617 return // anonymous class, skip
618618 }
@@ -904,12 +904,12 @@ func (c *Collector) recursiveParseTypes(node *sitter.Node, content []byte, uri D
904904
905905 // For a generic type like "List<String>", we want to parse "List" and "String" separately.
906906 // The main type identifier (e.g., "List")
907- typeNode := javaparser .FindChildByType (node , "type" )
907+ typeNode := parser .FindChildByType (node , "type" )
908908 if typeNode != nil {
909909 c .recursiveParseTypes (typeNode , content , uri , symbols , false )
910910 }
911911 // The type arguments (e.g., "<String>")
912- argsNode := javaparser .FindChildByType (node , "type_arguments" )
912+ argsNode := parser .FindChildByType (node , "type_arguments" )
913913 if argsNode != nil {
914914 for i := 0 ; i < int (argsNode .ChildCount ()); i ++ {
915915 c .recursiveParseTypes (argsNode .Child (i ), content , uri , symbols , false )
@@ -938,7 +938,7 @@ func (c *Collector) recursiveParseTypes(node *sitter.Node, content []byte, uri D
938938 }
939939 * symbols = append (* symbols , typeSym )
940940 case "super_interfaces" :
941- typeNode := javaparser .FindChildByType (node , "type_list" )
941+ typeNode := parser .FindChildByType (node , "type_list" )
942942 if typeNode != nil {
943943 c .recursiveParseTypes (typeNode , content , uri , symbols , true )
944944 }
@@ -1396,8 +1396,8 @@ func nodeToLocation(node *sitter.Node, uri DocumentURI, content []byte) Location
13961396 end := node .EndPoint ()
13971397
13981398 // 将Tree-sitter的UTF-8字节位置转换为LSP的UTF-16字符位置
1399- startLine , startChar := javaparser .Utf8ToUtf16Position (content , start .Row , start .Column )
1400- endLine , endChar := javaparser .Utf8ToUtf16Position (content , end .Row , end .Column )
1399+ startLine , startChar := parser .Utf8ToUtf16Position (content , start .Row , start .Column )
1400+ endLine , endChar := parser .Utf8ToUtf16Position (content , end .Row , end .Column )
14011401
14021402 return Location {
14031403 URI : uri ,
@@ -1409,7 +1409,7 @@ func nodeToLocation(node *sitter.Node, uri DocumentURI, content []byte) Location
14091409}
14101410
14111411func toLSPPosition (content []byte , Row , Column uint32 ) Position {
1412- startLine , startChar := javaparser .Utf8ToUtf16Position (content , Row , Column )
1412+ startLine , startChar := parser .Utf8ToUtf16Position (content , Row , Column )
14131413 return Position {Line : startLine , Character : startChar }
14141414}
14151415
@@ -1443,7 +1443,7 @@ func (c *Collector) parseMethodInvocations(bodyNode *sitter.Node, content []byte
14431443 // and extract name and object from there.
14441444 query , err := sitter .NewQuery ([]byte (`
14451445 (argument_list) @args
1446- ` ), javaparser .GetLanguage (c .CollectOption .Language ))
1446+ ` ), parser .GetLanguage (c .CollectOption .Language ))
14471447 if err != nil {
14481448 log .Error ("Failed to create method invocation query: %v" , err )
14491449 return
@@ -1583,7 +1583,7 @@ func (c *Collector) parseMethodSignature(node *sitter.Node, content []byte) stri
15831583 }
15841584
15851585 // 获取方法名
1586- nameNode := javaparser .FindChildIdentifier (node )
1586+ nameNode := parser .FindChildIdentifier (node )
15871587 if nameNode == nil {
15881588 return ""
15891589 }
0 commit comments