Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Java syntax highlighting errors #127

Closed
aeschli opened this issue Feb 13, 2018 · 8 comments
Closed

Java syntax highlighting errors #127

aeschli opened this issue Feb 13, 2018 · 8 comments

Comments

@aeschli
Copy link
Contributor

aeschli commented Feb 13, 2018

The built-in Java Textmate grammar has several highlighting inconsistencies/errors.
atom/language-java (7a42895)

  • Variables/constants starting with a capital letter are scoped as storage.type.java
  • Angle brackets are inconsistently scoped, either as
    • keyword.operator.comparison.java
    • keyword.operator.bitwise.java
    • punctuation.bracket.angle.java
  • Fields are highlighted incorrectly/differently depending on access modifier
  • See images below

screen shot 2018-02-11 at 11 42 22

Steps to reproduce:

  1. Use built in Monokai color theme (or other colorful theme)
  2. Set syntax to "Java"
  3. Write completely normal Java code or paste the following example code:
public class Main {
    // with/without access modifier:
    public
    Set<Map.Entry<K, V>> entrySet0;
    Set<Map.Entry<K, V>> entrySet1;

    public static void main(String[] args) {
        Set<Map.Entry<K, V>> entrySet0;
        Node<K, V> m = someNode;
        Node<K, V> first = (Node<K, V>) someValue;
    }

    public static void method() {
        final int MY_CONSTANT = 0;
        int a = MY_CONSTANT + 1;

        int A = 1, B = 2;
        boolean less = A < B;
    }
}

screen shot 2018-02-11 at 11 43 23

Copied from original issue: microsoft/vscode#43414

@aeschli
Copy link
Contributor Author

aeschli commented Feb 13, 2018

From @H-C-H on February 12, 2018 8:16

Here is the same code rendered in Sublime Text. Seems to get it right.

screen shot 2018-02-12 at 09 14 43

@aeschli
Copy link
Contributor Author

aeschli commented Feb 13, 2018

@H-C-H FYI

@sadikovi
Copy link
Contributor

sadikovi commented Feb 13, 2018

Could you provide version of Atom and/or language-java package?

Highlighting works for me on the latest master branch: 7a42895.
Here is the screenshot:
highlight

Variables/constants starting with a capital letter are scoped as storage.type.java

Yes, this is the problem highlighted in #76.

The rest (angle brackets highlighting) should be highlighted correctly. Yes, there are inconsistency with scopes. Normal generic types are highlighted correctly with punctuation.bracket.angle.java. Example of (Node<K, V>) someValue uses keyword.operator.comparison.java for some weird reason - will have a look.

So it looks like there are 3 problems:

  • Capital letters variables (Capital variables tokenized as storage types #76).
  • Problems with highlighting generics when class name has dots, e.g. Set<Map.Entry<K, V>>.
  • Generic angle brackets have the wrong scope in situations like something = (A<B>) value.

Will try addressing the latter and see what we can do about capitalised variables.

@sadikovi
Copy link
Contributor

ping @50Wliu

@aeschli
Copy link
Contributor Author

aeschli commented Feb 13, 2018

It's with the current master of atom/language-java (7a42895)
Your evaluation makes sense, thanks!

@sadikovi
Copy link
Contributor

Sorry, forgot to fetch upstream. Still the same highlighting as on image above - no random red angle brackets for Sets.

@sadikovi
Copy link
Contributor

All good! Will try fixing it - thanks for reporting!

@sadikovi
Copy link
Contributor

After the discussion on the maintainer chat I decided to close this issue, because it contains more than reported problem (3 actually) - see the comment above (#127 (comment)).

Instead, I have created and linked separate issues (created from this one), see all links above (issues 76, 131, 132). Will try addressing those as soon as I can.

Please, refer to those issues if you have a specific information or want to help with fixing them. Thanks!

ping @50Wliu @lee-dohm.

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

No branches or pull requests

2 participants