-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix container types calculation #1055
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, it looks mostly good (found only one wrongly computed container in the grammar).
@@ -418,7 +411,7 @@ export function isGroup(item: unknown): item is Group { | |||
} | |||
|
|||
export interface Keyword extends AbstractElement { | |||
readonly $container: Alternatives | Assignment | CharacterRange | CrossReference | Grammar | Group | NegatedToken | ParserRule | TerminalAlternatives | TerminalGroup | TerminalRule | UnorderedGroup | UntilToken; | |||
readonly $container: CharacterRange; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong: CharacterRange is not the only possible container of Keyword.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@spoenemann, it's correctly for the current calculation:
Keyword
is used in the assignment in the only one place -- inCharacterRange
- One more usage is the rule
PredicatedKeyword
that infersKeyword
-- 1) the interfacePredicatedKeyword
will not be generated by the grammar definition, so no its income to container types; 2) if we would have the interfacePredicatedKeyword
, it would be a child ofKeyword
-- no income to container type, too, because we don't lift children container types in parents anymore - Other usages are in type alternatives and are ignored by the new algorithm:
AssignableTerminal
,CrossRefTerminal
,AbstractTerminal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a rather complex chain of unassigned rule calls here:
Alternatives > ConditionalBranch > UnorderedGroup > Group > AbstractToken > AbstractTokenWithCardinality > AbstractTerminal > Keyword
Alternatives has two possible containers: Group and ParserRule. Keyword should inherit those containers.
I've seen that in simpler examples of unassigned rule calls, the container types are fine. So maybe this is just a special case for which we can create an issue, but we ignore it for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By my understanding it's not an issue, but an expected behaviour for the current algorithm.
The moment is the algorithm is working with inferred / declared types (from the ast.ts
, basically) and not with parser rules content. That means, not all information that you can see in the .langium
is available for the algorithm. As a result:
- Most of types with the names from the chain doesn't exist
Group
andParserRule
contain onlyAbstractElement
and notAlternatives
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok let's ignore the issue for now and get back to it in case it turns out to be a real problem. I created #1063 so we don't forget.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Closes #150.
Examples:
X
has no container types --A
andB
, too