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

Conversation

sadikovi
Copy link
Contributor

@sadikovi sadikovi commented May 30, 2018

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions

Description of the Change

This PR updates the code for scopes meta.catch.java and meta.throwables.java and fixes scoping of exception class names and/or parameters.

For meta.catch.java we are currently include parameters scope, which is not exactly correct, because parameters are assumed to be storage + variable, but in the case of catch block, you could see something like this Exception1 | Exception2 err, so we would only highlight the second case. I replaced it with the pattern that scopes | as separator and require storage and optional variable name.

For meta.throwables.java we are currently including object-types scope, which is also not 100% correct, because they assume storage followed by variable, but in throws you could see something like this throws Exception1, Exception2. I changed it to just parse storage type.

class MyClass {
  public void set(String str) throws Exception3, Exception4 {
    try {
      // some code
    } catch (Exception1 | Exception2 e) {
      throw new Exception3();
    }
  }
}

Before:
before

After:
after

Alternate Designs

I was considering updating parameters and object-types scopes, but I found that it would be rather massive change, which might cause the regression in other parts. So I went with this fairly straightforward approach.

Benefits

Fixes issue of scoping exceptions in catch and throws.

Possible Drawbacks

None that I found, it does not affect existing scopes.

Applicable Issues

Closes #138

@sadikovi sadikovi changed the title fix catch and throws clauses Fix meta.catch.java and meta.throwables.java scopes May 30, 2018
@sadikovi sadikovi requested a review from winstliu May 30, 2018 06:45
@sadikovi
Copy link
Contributor Author

@50Wliu could you have a look at this PR? Thanks!

{
'include': '#parameters'
'match': '\\|'
'name': 'punctuation.catch.separator'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.java

'name': 'punctuation.catch.separator'
}
{
'match': '([a-zA-Z$_][\\.a-zA-Z0-9$_]*)\\s*(\\w+)*'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be (\\w+)? instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. I will update the code.

{
'include': '#object-types'
'match': ','
'name': 'punctuation.throwables.separator'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.java

I also think this can use the standard comma separator scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, you are right. Will update.

@sadikovi
Copy link
Contributor Author

@50Wliu thanks for review! I updated the code, would you mind taking a look again? Thanks.

@sadikovi sadikovi merged commit b9f1a85 into atom:master Jun 2, 2018
@sadikovi sadikovi deleted the fix-catch-throws-exceptions-scope branch June 2, 2018 07:50
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 this pull request may close these issues.

Missing scopes on comma and xor

2 participants