@@ -1041,10 +1041,11 @@ func (i *indexer) QueryReferences(ctx context.Context, opts *types.QueryReferenc
10411041 continue
10421042 } // 只处理 类、接口、函数、方法
10431043 // 是定义,查找它的引用。当前采用遍历的方式(通过import过滤)
1044+ position := types .ToPosition (s .Range )
10441045 def := & types.RelationNode {
10451046 FilePath : fileElementTable .Path ,
10461047 SymbolName : s .Name ,
1047- Position : types . ToPosition ( s . Range ) ,
1048+ Position : & position ,
10481049 NodeType : string (proto .ElementTypeFromProto (s .ElementType )),
10491050 Children : make ([]* types.RelationNode , 0 ),
10501051 }
@@ -1087,10 +1088,11 @@ func (i *indexer) findSymbolReferences(ctx context.Context, projectUuid string,
10871088 }
10881089 // 引用
10891090 if v , ok := definitionNames [element .Name ]; ok {
1091+ position := types .ToPosition (element .Range )
10901092 v .Children = append (v .Children , & types.RelationNode {
10911093 FilePath : elementTable .Path ,
10921094 SymbolName : element .Name ,
1093- Position : types . ToPosition ( element . Range ) ,
1095+ Position : & position ,
10941096 NodeType : string (proto .ElementTypeFromProto (element .ElementType )),
10951097 })
10961098 }
@@ -1416,11 +1418,12 @@ func (i *indexer) queryCallGraphBySymbol(ctx context.Context, projectUuid string
14161418 i .logger .Error ("failed to get parameters from extra data, err: %v" , err )
14171419 continue
14181420 }
1421+ position := types .ToPosition (symbol .Range )
14191422 node := & types.RelationNode {
14201423 SymbolName : symbol .Name ,
14211424 FilePath : filePath ,
14221425 NodeType : string (types .NodeTypeDefinition ),
1423- Position : types . ToPosition ( symbol . Range ) ,
1426+ Position : & position ,
14241427 Children : make ([]* types.RelationNode , 0 ),
14251428 }
14261429 callee := & CalleeInfo {
@@ -1467,11 +1470,12 @@ func (i *indexer) queryCallGraphByLineRange(ctx context.Context, projectUuid str
14671470 i .logger .Error ("failed to get parameters from extra data, err: %v" , err )
14681471 continue
14691472 }
1473+ position := types .ToPosition (symbol .Range )
14701474 node := & types.RelationNode {
14711475 SymbolName : symbol .Name ,
14721476 FilePath : filePath ,
14731477 NodeType : string (types .NodeTypeDefinition ),
1474- Position : types . ToPosition ( symbol . Range ) ,
1478+ Position : & position ,
14751479 Children : make ([]* types.RelationNode , 0 ),
14761480 }
14771481 callee := & CalleeInfo {
@@ -1578,7 +1582,7 @@ func (i *indexer) buildCallGraphBFS(ctx context.Context, projectUuid string, roo
15781582 callerNode := & types.RelationNode {
15791583 FilePath : caller .FilePath ,
15801584 SymbolName : caller .SymbolName ,
1581- Position : caller .Position ,
1585+ Position : & caller .Position ,
15821586 NodeType : string (types .NodeTypeReference ),
15831587 Children : make ([]* types.RelationNode , 0 ),
15841588 }
0 commit comments