Git Product home page Git Product logo

Comments (4)

jrfaller avatar jrfaller commented on July 19, 2024

Hi!
I believe this is just a numeric identifier of the node within its AST.

Regards!

from gumtree.

ConductedClever avatar ConductedClever commented on July 19, 2024

Hi.

But the parse trees do not have any identifier. How should I map those data together?

For example I have this parse tree:

{
        "root": {
                "type": "15",
                "typeLabel": "CompilationUnit",
                "pos": "0",
                "length": "545",
                "children": [
                        {
                                "type": "55",
                                "typeLabel": "TypeDeclaration",
                                "pos": "50",
                                "length": "493",
                                "children": [
                                        {
                                                "type": "83",
                                                "label": "public",
                                                "typeLabel": "Modifier",
                                                "pos": "50",
                                                "length": "6",
                                                "children": []
                                        },
                                        {
                                                "type": "42",
                                                "label": "MathUtils4M0",
                                                "typeLabel": "SimpleName",
                                                "pos": "63",
                                                "length": "12",
                                                "children": []
                                        },
...
}

and this diff:

Match VariableDeclarationFragment(48) to VariableDeclarationFragment(46)
Match VariableDeclarationExpression(29) to VariableDeclarationExpression(29)
Match Block(65) to Block(63)
Match VariableDeclarationStatement(24) to VariableDeclarationStatement(24)
Match SimpleName: max(53) to SimpleName: max(51)
Match NumberLiteral: 0(17) to NumberLiteral: 0(17)
Match ReturnStatement(62) to ReturnStatement(60)
Match TypeDeclaration(67) to TypeDeclaration(65)
Match IfStatement(58) to IfStatement(56)
Match ForStatement(60) to ForStatement(58)
Match InfixExpression: <(34) to InfixExpression: <(34)
Match PrimitiveType: int(20) to PrimitiveType: int(20)
Match Block(59) to Block(57)
Match VariableDeclarationFragment(28) to VariableDeclarationFragment(28)
Match InfixExpression: <(15) to InfixExpression: <(15)
Match ArrayAccess(41) to ArrayAccess(41)
Match SimpleName: max(21) to SimpleName: max(21)
Match Block(57) to Block(55)
Match Block(19) to Block(19)
Match ArrayAccess(46) to ArrayAccess(44)
Match Modifier: public(2) to Modifier: public(2)
Match NullLiteral(11) to NullLiteral(11)
Match QualifiedName: numbers.length(31) to QualifiedName: numbers.length(31)
Match SimpleName: temp(54) to SimpleName: temp(52)
Match SimpleName: max(51) to SimpleName: max(49)
Match InfixExpression: ||(16) to InfixExpression: ||(16)
Match CompilationUnit(68) to CompilationUnit(66)
Match PrimitiveType: int(25) to PrimitiveType: int(25)
Match SimpleName: i(30) to SimpleName: i(30)
Match InfixExpression: *(33) to InfixExpression: *(33)
Match ArrayType: int[](7) to ArrayType: int[](7)
Match QualifiedName: Integer.MIN_VALUE(22) to QualifiedName: Integer.MIN_VALUE(22)
Match InfixExpression: >(52) to InfixExpression: >=(50)
Match SimpleName: numbers(42) to SimpleName: numbers(42)
Match InfixExpression: ==(12) to InfixExpression: ==(12)
Match Dimension(6) to Dimension(6)
Match ExpressionStatement(56) to ExpressionStatement(54)
Match SimpleName: getMaxAdjacentSum(4) to SimpleName: getMaxAdjacentSum(4)
Match Assignment: =(55) to Assignment: =(53)
Match PrimitiveType: int(5) to PrimitiveType: int(5)
Match SimpleName: numbers(8) to SimpleName: numbers(8)
Match VariableDeclarationFragment(23) to VariableDeclarationFragment(23)
Match Block(63) to Block(61)
Match ReturnStatement(18) to ReturnStatement(18)
Match PostfixExpression: ++(36) to PostfixExpression: ++(36)
Match MethodDeclaration(66) to MethodDeclaration(64)
Match SimpleName: temp(38) to SimpleName: temp(38)
Match SingleVariableDeclaration(9) to SingleVariableDeclaration(9)
Match InfixExpression: +(47) to InfixExpression: +(45)
Match QualifiedName: numbers.length(13) to QualifiedName: numbers.length(13)
Match NumberLiteral: 1(32) to NumberLiteral: 1(32)
Match Modifier: public(0) to Modifier: public(0)
Match IfStatement(64) to IfStatement(62)
Match SimpleName: i(26) to SimpleName: i(26)
Match NumberLiteral: 0(27) to NumberLiteral: 0(27)
Match VariableDeclarationStatement(49) to VariableDeclarationStatement(47)
Match SimpleName: numbers(10) to SimpleName: numbers(10)
Match SimpleName: i(40) to SimpleName: i(40)
Match NumberLiteral: 2(14) to NumberLiteral: 2(14)
Match SimpleName: numbers(39) to SimpleName: numbers(39)
Match SimpleName: i(35) to SimpleName: i(35)
Match PrimitiveType: int(37) to PrimitiveType: int(37)
Match SimpleName: max(61) to SimpleName: max(59)
Match PrimitiveType: int(3) to PrimitiveType: int(3)
Match SimpleName: temp(50) to SimpleName: temp(48)
Match SimpleName: MathUtils4M0(1) to SimpleName: MathUtils4M0(1)
Update InfixExpression: >(52) to >=
Insert SimpleName: i(43) into ArrayAccess(44) at 1
Delete SimpleName: i(43)
Delete NumberLiteral: 1(44)
Delete InfixExpression: +(45)

How should I know where is ArrayAccess(44) at 1 in the AST tree?
Thanks in advance.

from gumtree.

chinux23 avatar chinux23 commented on July 19, 2024

I don't know how 44 is at in AST. But I looked at the source code, it's pretty easy to modify the output in json form. If you use java, you can use the library directly. The library already has all the information related to AST node id. It's just not exposed in the command line output. If anyone is interested. I can submit a patch to add more output info in the comandline output.

from gumtree.

ConductedClever avatar ConductedClever commented on July 19, 2024

You are right @chinux23. By now I need to know which node has action and which line and which character it belongs to. I am calling the .\gumtree from C# process runner and I think your patch will really help me.

from gumtree.

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.