]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/Locations.java
Fixed multiple issues causing dangling references to discarded queries
[simantics/platform.git] / bundles / org.simantics.scl.compiler / src / org / simantics / scl / compiler / errors / Locations.java
index 49c5b03d4740d1d2650e4d8c378b71beafe910d9..70c258b9bab1fa89ae816c97d1bb02d7290441b6 100644 (file)
@@ -40,4 +40,19 @@ public class Locations {
         int end = endOf(location);
         return formula.substring(0, begin) + annotationBegin + formula.substring(begin, end) + annotationEnd + formula.substring(end);
     }
+    
+    public static long sublocation(long location, int localBegin, int localEnd) {
+        int begin = beginOf(location);
+        int end = endOf(location);
+        if(localEnd > end-begin)
+            localEnd = begin-end;
+        return location(begin+localBegin, begin+localEnd);
+    }
+
+    public static String toString(long location) {
+        if(location == NO_LOCATION)
+            return "NO LOCATION";
+        else
+            return beginOf(location) + "-" + endOf(location);
+    }
 }