tree-sitter-java icon indicating copy to clipboard operation
tree-sitter-java copied to clipboard

`local_variable_declaration` is generated instead of method declaration/definition

Open bronikkk opened this issue 4 years ago • 0 comments

Problem description

Consider the following file:

import static java.lang.annotation.RetentionPolicy.RUNTIME;

import java.lang.annotation.Retention;
import org.junit.Test;
import org.junit.runners.JUnit4;

/** @author [email protected] (Liam Miller-Cushon) */
@RunWith(JUnit4.class)
public class SuggestedFixesTest {

  /** Edit modifiers type. */
  @Retention(RUNTIME)
  public @interface EditModifiers {
    String[] value() default {};

    EditKind kind() default EditKind.ADD;

    /** Kind of edit. */
    enum EditKind {
      ADD,
      REMOVE
    }
  }

  @Test
  public void addAtBeginningOfLine() {
  }
}

Expected parse tree output (optional)

Parse tree without ERROR nodes

Actual parse tree output (optional)

  1. constant_declaration has ERROR child node instead of identifier.
  2. local_variable_declaration with a fake ';' child node is generated instead of a method definition node for addAtBeginningOfLine (looks like this error is induced by error # 1).
  3. ERROR node as the parent of formal_parameters node for addAtBeginningOfLine method ((looks like this error is induced by error # 1).

Notes

I realize that the code snippet above can be further minimized.

bronikkk avatar Jul 15 '21 19:07 bronikkk