Git Product home page Git Product logo

Comments (6)

jtulach avatar jtulach commented on May 18, 2024

Possible, or as an option deprecate remove Source.getPath() what it is good for anyway?

from graal.

pniederw avatar pniederw commented on May 18, 2024

@jtulach Just like it can be useful to get the URL a Source was loaded from, it can be useful to get the file path it was loaded from, as long as getPath() only returns non-null if loaded from a file (or explicitly set). Because I couldn't get earlier versions of Source to behave consistently in this regard, I had to retain this information by associating each Source with an object of my own that tells how the Source was constructed. However, this breaks down in certain cases, e.g. when the Source has not been constructed by my own code (think polyglot).

from graal.

jtulach avatar jtulach commented on May 18, 2024

The same information should be available from the getURI() method:

if (source.getURI().getScheme().equals("file")) {
  File f = new File(source.getURI());
}

We want to use getURI() as a persistent identification of source. Thus I recommend to rely on that one rather than using getPath() which doesn't have any real meaning (as far as I can tell) and I'd like to get rid of it, if possible.

from graal.

pniederw avatar pniederw commented on May 18, 2024

@jtulach That's pretty much what I ended up with. Do you also plan to get rid of getURL()?

from graal.

jtulach avatar jtulach commented on May 18, 2024

Right. That method seems really obsolete now when there is getURI().

from graal.

pniederw avatar pniederw commented on May 18, 2024

For my language, it makes a difference whether a Source has been loaded from a file or (possibly a file://) URL. However, I'm keeping track of this on my own, and have given up on the idea that I can deduce this from Source. Hence, having getPath() and getURL() is no longer essential to me. Closing.

from graal.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.