Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should changing the file/path of a source location keep the offset&length information? #821

Open
DavyLandman opened this issue Jun 4, 2015 · 4 comments

Comments

@DavyLandman
Copy link
Member

Both @joukestoel and I have recently run into this confusion:

rascal>x = |file:///test/path/file.name|(10,30);
loc: |file:///test/path/file.name|(10,30)

rascal>x[path="/other/file.name"]
loc: |file:///other/file.name|(10,30)

the location keeps the offset & length, I think that perhaps certain changes in the path should drop the offset information?

So what do you think, what would be more expected/consistent? And are there certain changes that might not drop the offset information?

@tvdstorm
Copy link
Member

tvdstorm commented Jun 4, 2015

This needs to be documented. Let's not add magic. You change the path, you change the path only. What if the change in path represents a move? Then you might want to keep position info.

@PaulKlint
Copy link
Member

I agree with @tvdstorm: the user can control all aspects of the location let's not introduce too much magic here. What we should also document is that the position information can be added in function call style. The other day I wrote this: getSearchPathLocation(l.path)(l.offset, l.length, l.begin,l.end) and that is very handy -- and explicit: get another location but preserve the original position information.

@DavyLandman
Copy link
Member Author

You could also have written:

originalLoc[path=otherLoc.path]

And I see the point in not adding magic.

@DavyLandman
Copy link
Member Author

A wait, it's the other way around in your example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants