Custom Scope Provider to propose and accept values according to the specified type #1244
-
Hello, For a personal project, I'm trying to design a small ERA (Entity-Relation-Attribute) language to describe metamodel. Here is a small example of my language:
To do that, I tried to take inspiration from your guide about class member scoping (thanks you really much for this guide) but I'm still a bit confused about how to proceed. override getScope(context: ReferenceInfo): Scope {
if (context.property === 'literalRef') {
console.log(context.container.$type)
if(isEnumerationLiteralValue(context.container)) {
const literalValue = context.container;
if(isAttributeMember(literalValue.$container)) {
const attributeMember = literalValue.$container
if(isEnumerationType(attributeMember.type)) {
return this.createScopeForNodes(attributeMember.type.enumerationRef.ref!.literals);
}
}
}
}
return super.getScope(context);
} And here is a fragment of my interfaces generated by Langium: interface Entity {
name: string
members: Member[]
}
interface Enumeration {
name: string
literals: EnumerationLiteral[]
}
interface EnumerationLiteral {
name: string
}
type Member = …. | AttributeMember
interface AttributeMember {
name: string
type: AttributeType
value?: Value
}
type AttributeType = ... | EnumerationType
interface EnumerationType {
enumerationRef: @Enumeration
}
type Value = ... | EnumerationLiteralValue
interface EnumerationLiteralValue {
literalRef: @EnumerationLiteral
} The function works almost the way I want it to, the correct values are accepted and the goto works as expected. However, when I put my cursor just after the Can you give me some advice on how to achieve my goals? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
maybe you are also running into #1216, |
Beta Was this translation helpful? Give feedback.
maybe you are also running into #1216,
you can try if backporting #1239 solves your issue