Skip to content

Commit 67483fb

Browse files
authored
feat(tolk): don't show .acton symbols in contract/ (#295)
1 parent 6e54ece commit 67483fb

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

server/src/languages/tolk/psi/Reference.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff 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

server/src/languages/tolk/psi/TolkFile.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)