Skip to content
Discussion options

You must be logged in to vote

Overriding getGlobalScope and returning an empty scope works. Here's the minimal code for modifying the Hello World project to enforce file-scoping.

Add file hello-world-scope-provider.ts with contents:

import type { Scope } from 'langium';
import { EMPTY_SCOPE } from 'langium';
import { DefaultScopeProvider } from 'langium';

/**
 * Scope provider that restricts scope to a single file
 */
export class HelloWorldScopeProvider extends DefaultScopeProvider {
    protected override getGlobalScope(referenceType: string): Scope {
        return EMPTY_SCOPE;
    }
}

Like in the other examples modify HelloWorldModule in hello-world-module.ts to inject this scope provider:

// ...
export const Hel…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@drhagen
Comment options

@cdietrich
Comment options

@drhagen
Comment options

Answer selected by drhagen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants