File tree Expand file tree Collapse file tree
server/src/languages/tolk/psi Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -165,6 +165,8 @@ export class Reference {
165165 }
166166
167167 public processResolveVariants ( proc : ScopeProcessor , state : ResolveState ) : boolean {
168+ proc = this . visibleCompletionProcessor ( proc , state )
169+
168170 if ( this . elementIsDeclarationName ( ) ) {
169171 // foo: Int
170172 // ^^^ our element
@@ -185,6 +187,22 @@ export class Reference {
185187 this . processUnqualifiedResolve ( proc , state )
186188 }
187189
190+ private visibleCompletionProcessor ( proc : ScopeProcessor , state : ResolveState ) : ScopeProcessor {
191+ if ( ! state . get ( "completion" ) || ! this . element . file . isInContractsDir ) {
192+ return proc
193+ }
194+
195+ return new ( class implements ScopeProcessor {
196+ public execute ( node : TolkNode , nodeState : ResolveState ) : boolean {
197+ if ( node . file . fromActon && ! node . file . fromStdlib ) {
198+ return true
199+ }
200+
201+ return proc . execute ( node , nodeState )
202+ }
203+ } ) ( )
204+ }
205+
188206 private elementIsDeclarationName ( ) : boolean {
189207 // foo: int
190208 // ^^^ maybe this
Original file line number Diff line number Diff line change @@ -44,6 +44,14 @@ export class TolkFile extends File {
4444 return this . uri . endsWith ( ".test.tolk" )
4545 }
4646
47+ public get isInContractsDir ( ) : boolean {
48+ const actonToml = ActonToml . discover ( this . uri )
49+ if ( ! actonToml ) return false
50+
51+ const relative = path . relative ( actonToml . workingDir , this . path ) . replace ( / \\ / g, "/" )
52+ return relative === "contracts" || relative . startsWith ( "contracts/" )
53+ }
54+
4755 public symbolAt ( offset : number ) : string {
4856 return this . content [ offset ] ?? ""
4957 }
You can’t perform that action at this time.
0 commit comments