@@ -179,6 +179,36 @@ export class Reference {
179
179
if ( qualifierType === null ) return true
180
180
181
181
if ( qualifierType instanceof StructTy || qualifierType instanceof MessageTy ) {
182
+ if ( qualifier . node . type === "identifier" ) {
183
+ const resolved = Reference . resolve ( new NamedNode ( qualifier . node , qualifier . file ) )
184
+ if ( resolved instanceof Struct || resolved instanceof Message ) {
185
+ // found `Foo.fromCell` case
186
+ const prefix = resolved instanceof Struct ? "AnyStruct_" : "AnyMessage_"
187
+
188
+ const fromCellName = prefix + "fromCell"
189
+ const fromCell = index . elementByName ( IndexKey . Funs , fromCellName )
190
+ if ( fromCell ) {
191
+ const newState = state . withValue (
192
+ "search-name" ,
193
+ prefix + this . element . name ( ) ,
194
+ )
195
+ if ( ! proc . execute ( fromCell , newState ) ) return false
196
+ }
197
+
198
+ const fromSliceName = prefix + "fromSlice"
199
+ const fromSlice = index . elementByName ( IndexKey . Funs , fromSliceName )
200
+ if ( fromSlice ) {
201
+ const newState = state . withValue (
202
+ "search-name" ,
203
+ prefix + this . element . name ( ) ,
204
+ )
205
+ if ( ! proc . execute ( fromSlice , newState ) ) return false
206
+ }
207
+
208
+ return true
209
+ }
210
+ }
211
+
182
212
const nodeStruct = index . elementByName ( IndexKey . Primitives , "AnyStruct" )
183
213
if ( nodeStruct ) {
184
214
const structPrimitiveTy = new PrimitiveTy ( "AnyStruct" , nodeStruct , null )
@@ -418,6 +448,13 @@ export class Reference {
418
448
public execute ( node : Node , state : ResolveState ) : boolean {
419
449
if ( ! ( node instanceof Fun ) ) return true
420
450
if ( node . withSelf ( ) ) return true // don't add methods to unqualified completion
451
+ if (
452
+ node . name ( ) . startsWith ( "AnyStruct_" ) ||
453
+ node . name ( ) . startsWith ( "AnyMessage_" )
454
+ ) {
455
+ // this functions in fact static methods
456
+ return true
457
+ }
421
458
return proc . execute ( node , state )
422
459
}
423
460
} ) ( )
0 commit comments