Comments (6)
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.
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.
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.
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.
Are there any plans to merge this or fix the problem some other way?
from language-java.
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)
- Enum not correctly hightlighted when mixed with constructor and code overrides HOT 1
- Inconsistency of variable and new-variable method call
- Inconsistency of type highlighting in new expression
- Catch parameter not correctly highlighted when declared in new line or with a comment in between HOT 4
- Scope variables in expressions HOT 3
- Custom color for arguments used in method body
- Java 14's new record keyword is not highlighted properly HOT 5
- Field has different pattern if "this" is omitted HOT 1
- Syntax highlighting is broken with array syntax HOT 1
- Wrong highlighting on 'new' keyword on inner classes HOT 6
- Variable camelCase name is incorrectly highlighted in a statement with "instanceof" HOT 2
- Highlight 'yield' keyword in switch statement
- Highlight keyword 'sealed' for Java 15 HOT 2
- Tree-sitter compatibility work
- Add support for `non-sealed` keyword HOT 4
- Java tree-sitter syntax highlighting does not parse annotations correctly HOT 1
- Java tree-sitter grammar does not consistently highlight constants
- @link highlighting broken when linking to class HOT 1
- module name and comments not highlighted in module-info.java HOT 4
- <unknown> is deprecated. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from language-java.