/** Given index into string, compute the line and char position in line */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); }
/** Given an IP (code location), get it's range in source template then * return it's template line:col. */ public String getSourceLocation() { if ( ip<0 || self.impl==null ) return null; Interval I = self.impl.sourceMap[ip]; if ( I==null ) return null; // get left edge and get line/col int i = I.a; Coordinate loc = Misc.getLineCharPosition(self.impl.template, i); return loc.toString(); }
/** Given an IP (code location), get it's range in source template then * return it's template line:col. */ public String getSourceLocation() { if ( ip<0 || self==null || self.impl==null ) return null; Interval I = self.impl.sourceMap[ip]; if ( I==null ) return null; // get left edge and get line/col int i = I.a; Coordinate loc = Misc.getLineCharPosition(self.impl.template, i); return loc.toString(); }
/** Given an ip (code location), get it's range in source template then * return it's template line:col. */ public String getSourceLocation() { if ( ip<0 ) return null; Interval I = self.impl.sourceMap[ip]; if ( I==null ) return null; // get left edge and get line/col int i = I.a; Coordinate loc = Misc.getLineCharPosition(self.impl.template, i); return loc.toString(); }
/** * Given {@code index} into string {@code s}, compute the line and char * position in line. */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); } }
/** Given an IP (code location), get it's range in source template then * return it's template line:col. */ public String getSourceLocation() { if ( ip<0 || self==null || self.impl==null ) return null; Interval I = self.impl.sourceMap[ip]; if ( I==null ) return null; // get left edge and get line/col int i = I.a; Coordinate loc = Misc.getLineCharPosition(self.impl.template, i); return loc.toString(); }
/** * Given {@code index} into string {@code s}, compute the line and char * position in line. */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); } }
/** Given an IP (code location), get it's range in source template then * return it's template line:col. */ public String getSourceLocation() { if ( ip<0 || self.impl==null ) return null; Interval I = self.impl.sourceMap[ip]; if ( I==null ) return null; // get left edge and get line/col int i = I.a; Coordinate loc = Misc.getLineCharPosition(self.impl.template, i); return loc.toString(); }
/** * Given {@code index} into string {@code s}, compute the line and char * position in line. */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); } }
/** Given an IP (code location), get it's range in source template then * return it's template line:col. */ public String getSourceLocation() { if ( ip<0 || self==null || self.impl==null ) return null; Interval I = self.impl.sourceMap[ip]; if ( I==null ) return null; // get left edge and get line/col int i = I.a; Coordinate loc = Misc.getLineCharPosition(self.impl.template, i); return loc.toString(); }
/** * Given {@code index} into string {@code s}, compute the line and char * position in line. */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); } }
/** Given an IP (code location), get it's range in source template then * return it's template line:col. */ public String getSourceLocation() { if ( ip<0 || self.impl==null ) return null; Interval I = self.impl.sourceMap[ip]; if ( I==null ) return null; // get left edge and get line/col int i = I.a; Coordinate loc = Misc.getLineCharPosition(self.impl.template, i); return loc.toString(); }
/** * Given {@code index} into string {@code s}, compute the line and char * position in line. */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); } }
/** Given an IP (code location), get it's range in source template then * return it's template line:col. */ public String getSourceLocation() { if ( ip<0 || self.impl==null ) return null; Interval I = self.impl.sourceMap[ip]; if ( I==null ) return null; // get left edge and get line/col int i = I.a; Coordinate loc = Misc.getLineCharPosition(self.impl.template, i); return loc.toString(); }
/** * Given {@code index} into string {@code s}, compute the line and char * position in line. */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); } }
/** * Given {@code index} into string {@code s}, compute the line and char * position in line. */ public static Coordinate getLineCharPosition(String s, int index) { int line = 1; int charPos = 0; int p = 0; while ( p < index ) { // don't care about s[index] itself; count before if ( s.charAt(p)=='\n' ) { line++; charPos=0; } else charPos++; p++; } return new Coordinate(line,charPos); } }