Manipulating location is failing because of < and > in location

86 views Asked by At

I have a location

|java+class:///smallsql/database/CommandDrop|(114,115,<3,68>,<8,5>)

which I would like to convert to

|project://SmallSQL/src/smallsql/database/CommandDrop.java|(114,115,<3,68>,<8,5>).

I want to do this by using toString, then manipulate the resulting String and then apply a toLocation. However, this is failing because toString will turn < into \< and similar for >. Now toLocation will see it as a malformed URI. Anyone any idea?

1

There are 1 answers

1
Jurgen Vinju On

If you want to manipulate a path of a location, keeping the rest the same, just do it like this:

myLoc.path = myManipulation(myLoc.path);

where myManipulation is a function.

But to me it seems you just want to resolve the logical location to a physical one:

import IO;
myLoc = resolveLocation(myLoc);

Mind you, the project's M3 model must have been registered before using analysis::m3::Registry::registerProject otherwise the resolution won't work.

You can also directly look up the path you need by looking it up in the M3 model's declarations table.