X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.scl.compiler%2Fsrc%2Forg%2Fsimantics%2Fscl%2Fcompiler%2Ferrors%2FLocations.java;h=70c258b9bab1fa89ae816c97d1bb02d7290441b6;hb=1dfeb7d5c49b1391cd9d877e1eddab18995cb151;hp=49c5b03d4740d1d2650e4d8c378b71beafe910d9;hpb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/Locations.java b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/Locations.java index 49c5b03d4..70c258b9b 100644 --- a/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/Locations.java +++ b/bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/errors/Locations.java @@ -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); + } }