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

Syntax highlighting is not working with comment #114

Closed
snjeza opened this issue Oct 25, 2017 · 10 comments
Closed

Syntax highlighting is not working with comment #114

snjeza opened this issue Oct 25, 2017 · 10 comments

Comments

@snjeza
Copy link
Contributor

snjeza commented Oct 25, 2017

VS Code 1.18

The VS Code master:

syntax2
The VS Code master with microsoft/vscode#36786:

syntax3

Test2.java

package pckg;

public class Test2 
implements Int {
    private JPanel plottingSurface = new JPanel() /* {
        @Override
        public Dimension getPreferredSize() {
            return new Dimension(400, 300);
        }
        @Override
        protected void paintComponent(Graphics g) {
            super.paintComponent(g);
        }
    }*/;

    public static <M extends Map<Integer, String>> 
boolean TestGet(Supplier<M> c) {
 //TODO write unit test for get
 //Setup
 Map<Integer, String> map = c.get();
 return false;
}
}

Copied from microsoft/vscode#36786 (comment)

See microsoft/vscode#36688, redhat-developer/vscode-java#338 and microsoft/vscode#36786

@sadikovi
Copy link
Contributor

sadikovi commented Oct 25, 2017

Interesting. Several observations:

  1. Inline comments work okay, if function definition is on the same line, e.g.

Works:

public static <M extends Map<Integer, String>> boolean TestGet(Supplier<M> c) {
  // works
}

Does not work:

public static <M extends Map<Integer, String>> 
boolean TestGet(Supplier<M> c) {
  // does not work
}
  1. Multi-line comments work if starting /* does not follow new keyword.

Works:

private JPanel plottingSurface = /*new JPanel() {
    @Override
    public Dimension getPreferredSize() {
        return new Dimension(400, 300);
    }
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
    }
}*/;

Does not work:

private JPanel plottingSurface = new /*JPanel() {
    @Override
    public Dimension getPreferredSize() {
        return new Dimension(400, 300);
    }
    @Override
    protected void paintComponent(Graphics g) {
        super.paintComponent(g);
    }
}*/;

I will have a closer look today, if there aren't any objections.

@winstliu
Copy link
Contributor

@sadikovi thanks for jumping so quickly on this. I already have a fix for the new comments and am looking into the second method issue now.

@sadikovi
Copy link
Contributor

Nice! Thanks @50Wliu! That is really good that you have a fix for it.
I was just doing routine morning check:)

@winstliu
Copy link
Contributor

I'm going to say the multiline method signature is a wontfix due to the conflicting member-variables match.

@snjeza
Copy link
Contributor Author

snjeza commented Oct 25, 2017

The following patch fixes member-variables:

diff --git a/grammars/java.cson b/grammars/java.cson
index 5975c1d..b248160 100644
--- a/grammars/java.cson
+++ b/grammars/java.cson
@@ -1254,4 +1254,7 @@
       {
         'include': '#variables'
       }
+      {
+        'include': '#comments'
+      }
     ]

@sadikovi
Copy link
Contributor

sadikovi commented Oct 25, 2017

@snjeza Nice fix!

I confirm that it solves the comment problem, although we still need to do some work to fix the method signature highlight (tested on latest master with patch - please, correct me if I am wrong) as @50Wliu mentioned:

screenshot from 2017-10-26 11 26 41

@ghost
Copy link

ghost commented Jan 9, 2018

Is this issue related to:

catch (IOException /*| AWSNullStreamException*/ e)

In VSCode, current stable, the comment is not highlighted like a comment.

@sadikovi
Copy link
Contributor

sadikovi commented Jan 10, 2018

@tristan957-expero Nah, does not look like it, but I might be wrong here.
I managed to fix it with following diff:

Edit: Actually diff below is already enough to fix it. We don't expect comments like
this catch /* test */ (

diff --git a/grammars/java.cson b/grammars/java.cson
index 55c3967..4297dcc 100644
--- a/grammars/java.cson
+++ b/grammars/java.cson
@@ -590,6 +590,9 @@
               {
                 'include': '#parameters'
               }
+              {
+                'include': '#comments'
+              }
             ]
           }
           {

I think we should open a PR to fix this!

@sadikovi
Copy link
Contributor

sadikovi commented Jan 11, 2018

@50Wliu should we close this issue? You fixed the main problem with highlighting and we patched separate issue raised in the comments. Or is there anything else we need to do? Thanks!

@winstliu
Copy link
Contributor

Yeah, I'm in favor of closing this issue. For people who are still experiencing problems with comments when Atom 1.25 is released, please create new issues so that we can specifically target them :).

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

3 participants