Git Product home page Git Product logo

Comments (7)

steindani avatar steindani commented on August 19, 2024

Please also consider making locations public.

In my usecase I don't want to use the parser more than once. I had problems with separate source codes with matching BindingIdentifiers resulting in the same Java Object and this was not an expected result. So I wouldn't mind if I did not have to pass the whole parser object forward, only the location information.

from shift-java.

michaelficarra avatar michaelficarra commented on August 19, 2024

Haha yeah, I expected this to be horribly broken right now. I will be adding location tests soon. Go ahead and send a PR to make the locations table public, but I'm not sure yet how I feel about that.

from shift-java.

bakkot avatar bakkot commented on August 19, 2024

@steindani, if we don't end up making it public (or in the meantime), you can always just subclass ParserWithLocation; something like:

public class ParserExposingLocationTable extends ParserWithLocation {
    public HashTable<Node, SourceSpan> getLocationTable() {
         return locations;
    }
}

from shift-java.

steindani avatar steindani commented on August 19, 2024

Thanks!

– Right now I'm fine with passing the parser, but this might need a better solution. It's not a burning problem. (Maybe a getter, since this way the variable couldn't be set from the outside, but the current "structure" could be acquired?)

– Is it the expected behaviour from the parser to result in the same Java Object for the same BindingIdentifier after using the same parser on two different sources? Is there some kind of caching?

– I did not have time yet to test it out, but the locations might have a one-off error. I've noticed it with the FunctionDeclarations, the start location is always marking the previous (empty) line. The end location seems to be fine.

from shift-java.

steindani avatar steindani commented on August 19, 2024

Oh, right. Thanks, @bakkot!

from shift-java.

bakkot avatar bakkot commented on August 19, 2024

They shouldn't be giving you the same object, but we've overridden equality on nodes. So if you're comparing using .equals, two nodes with identical properties will compare appear as equal.

The locations table is actually using equality instead of identity, which is a bug; I've fixed it in #106.

from shift-java.

steindani avatar steindani commented on August 19, 2024

Yeah, I've made the same mistake, instead of using IdentityHashMap I've
used HashMap in my code while converting the AST. Thanks for pointing
out!
On Mar 25, 2016 00:16, "Kevin Gibbons" [email protected] wrote:

They shouldn't be giving you the same object, but we've overridden
equality on nodes. So if you're comparing using .equals, two nodes with
identical properties will compare appear as equal.

The locations table is actually using equality instead of identity, which
is a bug; I've fixed it in #106
#106.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#104 (comment)

from shift-java.

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.