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

fix(grammar): The TSG grammar for Java does not handle the static_initializer node #475

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

drestrepom
Copy link

  • Add the static_initializer node for the Java grammar, this node may contain multiple statements, such as initializing variables or executing functions

…tializer node

- Add the static_initializer node for the Java grammar, this node may
  contain multiple statements, such as initializing variables or
  executing functions
@drestrepom drestrepom requested a review from a team as a code owner January 30, 2025 01:00
@drestrepom
Copy link
Author

Here, a demonstration of what happens when that node is not handled

test/decl/static_initializer.java: failed to build stack graph
    0: Error executing statement edge @class_body.defs -> @declaration.defs at (225, 3)
       src/stack-graphs.tsg:225:3:
       225 |   edge @class_body.defs -> @declaration.defs
           |   ^
       in stanza
       src/stack-graphs.tsg:224:1:
       224 | (class_body (_)@declaration)@class_body {
           | ^
       matching (class_body) node
       test/decl/static_initializer.java:1:17:
       1 | class TestClass {
         |                 ^
    1: Evaluating edge sink
    2: Undefined scoped variable [syntax node static_initializer (2, 3)].defs

Error: Failed to build graph for test/decl/static_initializer.java
error: test failed, to rerun pass `--test test`

This is an example of using this node in a concurred repository

https://github.com/OWASP-Benchmark/BenchmarkJava/blob/master/src/main/java/org/owasp/benchmark/helpers/DatabaseHelper.java#L46

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

Successfully merging this pull request may close these issues.

2 participants