GithubHelp home page GithubHelp logo

Comments (6)

MFKoelmans avatar MFKoelmans commented on May 28, 2024 1

I found a hacky workaround: adding a semicolon before the closing parenthesis of the try. It is redundant there, but it fixes the highlighting of the following code.

from language-java.

50Wliu avatar 50Wliu commented on May 28, 2024

The best way to implement this is to create a separate rule for try-with-resources, because currently the variable assignment rule waits for the ending semicolon before terminating.

from language-java.

MoritzKn avatar MoritzKn commented on May 28, 2024

Yeah, it isn't a normal assignment any way.
Normal assignment looks like this:

AssignmentExpression:
  ConditionalExpression 
  Assignment
Assignment:
  LeftHandSide AssignmentOperator Expression
LeftHandSide:
  ExpressionName 
  FieldAccess 
  ArrayAccess
AssignmentOperator:
  (one of)  =  *=  /=  %=  +=  -=  <<=  >>=  >>>=  &=  ^=  |=

The "Resource" from the try-with-resources statement dosen't support komplex assignments (+= etc.) for example.

from language-java.

sadikovi avatar sadikovi commented on May 28, 2024

Thanks for workaround! I managed to patch code for it to work:

diff --git a/grammars/java.cson b/grammars/java.cson
index 7c20d99..75bc3bf 100644
--- a/grammars/java.cson
+++ b/grammars/java.cson
@@ -1199,7 +1199,7 @@
         \\s*(=|;)
       )
     '''
-    'end': '(?=;)'
+    'end': '(?=;|\\))'
     'name': 'meta.definition.variable.java'
     'patterns': [
       {
@@ -1216,7 +1216,7 @@
         'beginCaptures':
           '0':
             'name': 'keyword.operator.assignment.java'
-        'end': '(?=;)'
+        'end': '(?=;|\\))'
         'patterns': [
           {
             'include': '#code'

This is hacky as well, however, passes all tests in master branch.

from language-java.

garyrussell avatar garyrussell commented on May 28, 2024

Are there any plans to merge this or fix the problem some other way?

from language-java.

sadikovi avatar sadikovi commented on May 28, 2024

There is an open pull request to fix this issue, but it needs to be revisited and rebased. Will get back to it soon.

from language-java.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.