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/12 03:04:04 UTC

[GitHub] [netbeans] lkishalmi commented on a diff in pull request #4773: Improve support for ANTLRv4 Grammars

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


##########
java/languages.antlr/src/org/netbeans/modules/languages/antlr/AntlrParserResult.java:
##########
@@ -93,20 +101,37 @@ protected boolean processingFinished() {
 
     public static class Reference {
         public final String name;
-        public FileObject source;
-        public OffsetRange defOffset;
-        public final List<OffsetRange> occurances = new ArrayList<>();
+        public final OffsetRange defOffset;
 
-        public Reference(String name, FileObject source, OffsetRange defOffset) {
+        public Reference(String name, OffsetRange defOffset) {
             this.name = name;
-            this.source = source;
             this.defOffset = defOffset;
         }
     }
 
     protected final FileObject getFileObject() {
         return getSnapshot().getSource().getFileObject();
     }
+    
+    public final List<? extends OffsetRange> getOccurrences(String refName) {
+        ArrayList<OffsetRange> ret = new ArrayList<>();
+        if (references.containsKey(refName)) {
+            ret.add(references.get(refName).defOffset);
+        }
+        if (occurrences.containsKey(refName)) {
+            ret.addAll(occurrences.get(refName));
+        }
+        return !ret.isEmpty() ? ret : Collections.emptyList();
+    } 
+    
+    protected final void markOccurrence(String refName, OffsetRange or) {
+        List<OffsetRange> ol = occurrences.get(refName);
+        if (ol == null) {
+            ol = new ArrayList<>();
+            occurrences.put(refName, ol);
+        }
+        ol.add(or);

Review Comment:
   Thanks! I've learned something new today!



-- 
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