|
Re: Compute offset from position (line,col) [message #1840287 is a reply to message #1840283] |
Sun, 11 April 2021 16:05   |
|
hi, i have no idea for that. maybe you can recycle InternalNodeModelUtils like
public class X extends InternalNodeModelUtils {
public static int doit(String text, int line, int column) {
//TODO test and zero baseing etc
int[] linebreaks = computeLineBreaks(text);
System.out.println(linebreaks[line]);
return linebreaks[line] + column;
}
public static void main(String[] args) {
String model = "a\n" +
"bb\n" +
"ccc\n" +
"dddd\n";
int doit = doit(model, 3-1,2);
System.out.println(doit);
System.out.println(model.charAt(doit));
}
}
Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
|
|
|
|
Powered by
FUDForum. Page generated in 0.02271 seconds