File tree Expand file tree Collapse file tree 4 files changed +29
-3
lines changed
Expand file tree Collapse file tree 4 files changed +29
-3
lines changed Original file line number Diff line number Diff line change @@ -354,6 +354,10 @@ public class IndexMembers(SearchContext context)
354354 {
355355 return new LuaSymbol ( string . Empty , arrayType . BaseType , new VirtualInfo ( ) ) ;
356356 }
357+ else if ( type is LuaGenericType genericType )
358+ {
359+ return FindGenericTypeMember ( genericType , indexExpr ) ;
360+ }
357361 else if ( type is LuaNamedType namedType && indexExpr . IndexKeyExpr is { } indexKeyExpr )
358362 {
359363 var keyType = context . Infer ( indexKeyExpr ) ;
@@ -426,4 +430,26 @@ public class IndexMembers(SearchContext context)
426430
427431 return null ;
428432 }
433+
434+ private LuaSymbol ? FindGenericTypeMember ( LuaGenericType type , LuaIndexExprSyntax indexExpr )
435+ {
436+ if ( type . Name == "table" )
437+ {
438+ if ( type . GenericArgs . Count != 2 )
439+ {
440+ return null ;
441+ }
442+
443+ if ( indexExpr . IndexKeyExpr is { } indexKeyExpr )
444+ {
445+ var keyType = context . Infer ( indexKeyExpr ) ;
446+ if ( keyType . SubTypeOf ( type . GenericArgs [ 0 ] , context ) )
447+ {
448+ return new LuaSymbol ( string . Empty , type . GenericArgs [ 1 ] , new VirtualInfo ( ) ) ;
449+ }
450+ }
451+ }
452+
453+ return null ;
454+ }
429455}
Original file line number Diff line number Diff line change @@ -68,7 +68,7 @@ private IEnumerable<ReferenceResult> GlobalReferences(LuaSymbol symbol)
6868
6969 foreach ( var nameExpr in nameExprs )
7070 {
71- if ( context . FindDeclaration ( nameExpr ) == symbol )
71+ if ( IsReferenceTo ( nameExpr , symbol ) )
7272 {
7373 references . Add ( new ReferenceResult ( nameExpr . Location , nameExpr ) ) ;
7474 }
Original file line number Diff line number Diff line change @@ -166,7 +166,7 @@ public LuaDocTypeSyntax? TypeField
166166 {
167167 if ( i + 1 < finish )
168168 {
169- var element = Tree . GetElement ( i ) ;
169+ var element = Tree . GetElement ( i + 1 ) ;
170170 if ( element is LuaDocTypeSyntax typeSyntax )
171171 {
172172 return typeSyntax ;
Original file line number Diff line number Diff line change @@ -220,7 +220,7 @@ public LuaExprSyntax? IndexKeyExpr
220220 {
221221 if ( i + 1 < finish )
222222 {
223- var element = Tree . GetElement ( i ) ;
223+ var element = Tree . GetElement ( i + 1 ) ;
224224 if ( element is LuaExprSyntax exprSyntax )
225225 {
226226 return exprSyntax ;
You can’t perform that action at this time.
0 commit comments