-
Notifications
You must be signed in to change notification settings - Fork 821
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
More precise code-completion for ANTLRv4 Grammars #4808
Conversation
Sorry, hadn't a chance to review (and no-one else had) prior to branching. Please make a call and rebase onto delivery if you think this should go into 16-rc2. |
for (String im : imports) { | ||
FileObject ifo = getFileObject().getParent().getFileObject(im + ".g4"); | ||
if (ifo != null) { | ||
Antlr4ParserResult pr = (Antlr4ParserResult) AntlrParser.getParserResult(ifo); |
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.
Won't this blow when grammar files form a cycle? Assuming we have a direct cycle A -> B, B -> A, then:
- user ask for the parser result for file A
- the parse process will hit this section and ask for the parser result for file B
- the parser result is not found in the cache, so the parsing for B is invoked
- parsing for B will hit this section and ask for the parser result of file A
The cycle is closed. I just noticed, that we access other files from the parser. I think this is an error. This kind of error checking needs to be done outside the parser, then you can access the parser results sequentially and build whatever structure you need.
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 will also create stale errors - if you add a definition to import, there is no reason to invoke the Parser for the including file.
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.
You're right. I hope the new implementation is looking better.
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.
If I understand this correctly this works safely because a hard reference to the Antlr4ParserResult
s is kept and thus we will not recurse indefinitely. Lets get this in.
Yes for the time the imports are processed we keep a hard reference on the results. |
Well, just a quick one. Lexer grammars, can only reference fragments inside rules, pure parser grammars cannot reference fragments. Add some heuristic to support lexercommands as well. + icons