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

Reply via email to