Fraunhofer-AISEC / cpg

A library to extract Code Property Graphs from C/C++, Java, Go, Python, Ruby and every other language through LLVM-IR.
https://fraunhofer-aisec.github.io/cpg/
Apache License 2.0
246 stars 59 forks source link

Java Frontend: EnumConstantDeclarations do not save their arguments #1546

Closed robinmaisch closed 2 days ago

robinmaisch commented 3 weeks ago

Currently, enum constants only save their name, so their arguments get lost. The arguments are delivered by the Java Parser API, so I hope it is easy to add a property for them.

I am not sure how you decide whether to safe AST children as fields or create edges for them, and also I would not know how to integrate it into the DeclarationBuilder so that other language modules are not affected, so I'd rather leave this one up to you.

(I'm sorry that I did not get around to give feedback on your last proposed fix, but I did not run into any more trouble so far. Thanks!)

Example:

public enum ChessPiece {
      PAWN("Bauer",1),
      KNIGHT("Springer", 3),
      BISHOP("Läufer", 3),
      ROOK("Turm", 5),
      QUEEN("Dame", 9),
      KING("König", -1);

      private final String name;
      private final int value;

      ChessPiece(String name, int value) {...}
}