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

Java scopes break when there are many Exceptions with a newline #205

Closed
alexr00 opened this issue Aug 30, 2019 · 1 comment · Fixed by #217
Closed

Java scopes break when there are many Exceptions with a newline #205

alexr00 opened this issue Aug 30, 2019 · 1 comment · Fixed by #217

Comments

@alexr00
Copy link

alexr00 commented Aug 30, 2019

From @JoeyRxy microsoft/vscode#78445

Snippet. Notice that there is an newline in the catch clause between some exception types.

public static void main(String[] args) {
	try {
		// something
	} catch (NoSuchMethodException | SecurityException | 
InstantiationException | llegalAccessException | IllegalArgumentException | invocationTargetException e) {
		e.printStackTrace();
	}
}

Only the last exception type on each line get the scope:
storage.type.java
meta.function-call.java
source.java

The other exception types get scope:
meta.function-call.java
source.java

@sadikovi
Copy link
Contributor

Looks similar to this: #186

sadikovi pushed a commit that referenced this issue Nov 27, 2019
### Description of the Change

Relax the too restrictive begin expression for catch block for following reasons:

* The begin pattern is not suitable for dealing with multi-line pattern.
* any comments between `catch` and `(` would also break the highlighting.

Leave the catch keywork be would just be fine, since syntax highlighting should only be responsible for happy path.

### Alternate Designs

Any other design would introduce new complexity.

### Benefits

* Can correctly highlight when caught exceptions are split in multiple lines
* Can correctly highlight when '(' is placed in a new line after `catch`
* Can correctly highlight when there is comment between `catch` and '('
* Reduces the complexity

### Possible Drawbacks

More like a `right` hightlight for wrong syntax in code.

### Applicable Issues

Fix #205 
FIx microsoft/vscode-java-pack#259
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants