You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by GitBox <gi...@apache.org> on 2022/10/24 06:33:23 UTC

[GitHub] [netbeans] lkishalmi commented on a diff in pull request #4808: More precise code-completion for ANTLRv4 Grammars

lkishalmi commented on code in PR #4808:
URL: https://github.com/apache/netbeans/pull/4808#discussion_r1002921048


##########
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:
   You're right. I hope the new implementation is looking better.



-- 
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: notifications-unsubscribe@netbeans.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists