-
Hello, I have a pretty big builtin library which contains classes that is used in my language. From looking on a couple of other threads, and going through the documentation it looks like
Option 1 does work, but it comes with a performance-hit.. Am I misunderstanding how this works, and if so is there a recommended way of doing this? Any advice is appreciated! :) //Eivind |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Hey @ejfasting, I believe you're pretty much there. Recomputing the global scope is always quite expensive, which is why the private documentCache: DocumentCache<string, Scope>;
...
protected override getGlobalScope(referenceType: string, context: ReferenceInfo): Scope {
const document = AstUtils.getDocument(context.container);
const currentUri = document.uri;
return this.documentCache.get(currentUri, referenceType, () => {
const currentDir = dirname(currentUri.path);
const uris = new Set<string>();
uris.add(document.textDocument.uri);
uris.add("builtins:/library");
const grammar = document.parseResult.value as Grammar;
for (const fileImport of grammar.includes) {
const filePath = join(currentDir, fileImport.file);
const uri = currentUri.with({ path: filePath });
uris.add(uri.toString());
}
return new MapScope(this.indexManager.allElements(referenceType, uris));
});
} |
Beta Was this translation helpful? Give feedback.
Hey @ejfasting,
I believe you're pretty much there. Recomputing the global scope is always quite expensive, which is why the
DefaultScopeProvider
caches the global scope. You should be able to do the same to fix the performance issue: