atom / language-java

Java package for Atom
Other
62 stars 58 forks source link

Variable camelCase name is incorrectly highlighted in a statement with "instanceof" #229

Closed Eskibear closed 4 years ago

Eskibear commented 4 years ago

Description

Steps to Reproduce

Stupid sample code below, one keypoint is, name of the varible before instanceof has to contains an upper case letter.

public class App 
{
    static interface IA {}
    static class Foo implements IA {}
    static class Bar implements IA {}

    public static boolean main(String[] args )
    {
        IA nameWithUpperCaseLetter = new Foo();
        if (nameWithUpperCaseLetter instanceof Foo || nameWithUpperCaseLetter instanceof Bar) {
            return nameWithUpperCaseLetter instanceof Foo || nameWithUpperCaseLetter instanceof Bar;
        }
        return nameWithUpperCaseLetter instanceof Bar;
    }
}

Expected behavior: All instanceof to be correctly highlighted.

Actual behavior: In return statements, instanceof is even not recognized as a token.

image

sadikovi commented 4 years ago

Simpler repro code and different examples:

class A {
  boolean func1() {
    // highlighting is correct
    return aa instanceof Test; 
  }

  boolean func2() {
    // highlighting is broken for a variable aaBB
    return aaBB instanceof Test;
  }
}
class A {
  void func() {
    // also broken
    boolean test = aaBB instanceof Test;
  }
}
sadikovi commented 4 years ago

Thanks for reporting. I will take a look.