atom/language-java

Error in scopes for java when calling methods in array literal with TextMate

Closed this issue · 2 comments

Copied from microsoft/vscode#75121

(I've tested in the last version of VSCode insiders and the bug is present as well)

  • VSCode Version: 1.35.0
  • OS Version: 10.14.5

Steps to Reproduce:

  1. write a java file and set the language mode to java
  2. in any method write a array literal and call a method in the value list (e.g. Object.clone())
  3. observe the syntax coloring now gone wild

In this example if you uncomment the bug-causing line public from SomeConstructor gets scoped as meta.class.body.java, meta.class.java, source.java

public class TestBug {

    static Object[] someTest;

    static {
        // Uncomment this to see the bug
        // someTest = new Object[] {someArgs[0].clone(), someArgs[1].clone()};
    }
    public SomeConstructor(Object[] someArgs) {

    }
}

Here are some exemple of the wrong coloring with the line commented (no bug) and not commented (bug active). Notice public:

testBug_inactive

testBug_active

NB:

  • this also works in static methods and in a static initialization block but not in the assignment of a static field at declaration.
  • this does not work at the declaration of the field (static or not)
  • the issue only impact method declared below the method in which the line is written
  • somehow writing it in a static block and right after as the declaration of a field cancels it (see below)

[EDIT: better description and better image]magic cancel : we can see that the static initialization block alter the coloring of the visibility of the next field however the next methods are not altered
testBug_weird_2

Does this issue occur when all extensions are disabled?: Yes

Thanks for reporting, I root caused the issue, will try fixing it in the next few days.

This is a variant of #172.