Offset in method location

182 views Asked by At

I have a location |project://SmallSQL/src/smallsql/database/SQLParser.java|(10257,10257,<305,60>,<371,5>).

However, because the line final class SQLParser { appears to be on line 39, there is an offset of 38, meaning that line 305 actually refers to line 343 (and 371 to 309). I would like to see this offset be reflected in the location. Is that possible, and if so, how? If not, how can I calculate the offset myself?

In addition, the starting line can also be on another location, for example when doc is present before the class. For example in |project://SmallSQL/src/smallsql/database/ExpressionFunctionBitLen.java|(302,302,<11,25>,<13,2>).

Addendum: the locations I am using have been built up by a conversion, i.e., |java+class:///smallqsl/database/SQLParser|(10257,10257,<305,60>,<371,5>) was converted to |project://SmallSQL/src/smallsql/database/SQLParser.java|(10257,10257,<305,60>,<371,5>).

1

There are 1 answers

8
Jurgen Vinju On

If you use resolveLocation from the IO module, the offsets will be changed accordingly and properly automatically.

You can also do the resolution yourselves, by looking the right location directly in the M3@declarations table.

resolvedLoc = myM3Model@declarations[myLogicalLocation];