matthiasblaesing commented on code in PR #4808:
URL: https://github.com/apache/netbeans/pull/4808#discussion_r1000942703
##########
java/languages.antlr/src/org/netbeans/modules/languages/antlr/v4/Antlr4ParserResult.java:
##########
@@ -113,38 +123,52 @@ public void
exitTokensSpec(ANTLRv4Parser.TokensSpecContext ctx) {
public void exitChannelsSpec(ANTLRv4Parser.ChannelsSpecContext
ctx) {
List<ANTLRv4Parser.IdentifierContext> ids =
ctx.idList().identifier();
for (ANTLRv4Parser.IdentifierContext id : ids) {
- addReference(getIdentifierToken(id));
+ addReference(ReferenceType.CHANNEL,
getIdentifierToken(id));
}
}
@Override
public void exitModeSpec(ANTLRv4Parser.ModeSpecContext ctx) {
if (ctx.identifier() != null) {
- addReference(getIdentifierToken(ctx.identifier()));
+ addReference(ReferenceType.MODE,
getIdentifierToken(ctx.identifier()));
}
}
- public void addReference(Token token) {
+ public void addReference(ReferenceType type, Token token) {
OffsetRange range = new OffsetRange(token.getStartIndex(),
token.getStopIndex() + 1);
String name = token.getText();
- Reference ref = new Reference(name, range);
+ Reference ref = new Reference(type, name, range);
references.put(ref.name, ref);
}
};
}
+ private void collectReferences(FileObject fo, Map<String, Reference> refs,
Set<String> visited) {
+ if (!visited.contains(fo.getName())) {
+ refs.putAll(references);
+ visited.add(fo.getName());
+ for (String im : imports) {
+ FileObject ifo = getFileObject().getParent().getFileObject(im
+ ".g4");
+ if (ifo != null) {
+ Antlr4ParserResult pr = (Antlr4ParserResult)
AntlrParser.getParserResult(ifo);
Review Comment:
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists