Java package for Atom
Clone or download
sadikovi Update 'variables' and 'member-variables' patterns to handle semicolo…
…n behaviour (#146)

### 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 `variables` and `member-variables` patterns and changes the behaviour of the `` scope. This is done to fix #88 (try-with-resources issue) to handle `;`.

I propose to define `` to be just declaration part without the following expression to initialise the variable, e.g. `[int a] = 5;` or `[int a];`, where `[...]` is ``. This results in the right hand side not having the scope, but I could potentially define and assign another one, like `` or something similar.

After patch (also passes test case mentioned in the issue):
class A {
  void func() {
    try (Buffer a = new Buffer()) {
      str = "str";

    try (
      Buffer a = new Buffer();
      Buffer b = new Buffer();
      Buffer c = new Buffer()
    ) {
      str = "str";

<img width="294" alt="after-patch" src="">

I updated the existing tests to remove `` wherever it is not needed, and added more tests to check the correct behaviour.

### Alternate Designs
Alternative design was considered where we apply a hack to `end` by listing `)` as another terminating character. This is a very small fix (4-8 characters change), but could potentially result in other issues, such as triggering close on closing paren (see #88 (comment)).

Another alternative design was proposed in #124, but it is more intrusive and results in duplicating variables pattern code and increases maintenance cost, since both patterns must be updated in case of any changes.

### Benefits
Fixes issue when not using `;` (which is allowed by specification) would break the highlighting.
Potentially helps to fix other problems related to variable highlighting.

### Possible Drawbacks
We remove `` scope from the expression that follows `=`. The left hand side is okay. Arguably, the right hand side should not be scoped as variable definition.

### Applicable Issues
Fixes #88
Relates to PR #124
Latest commit 2f20bc5 Jul 14, 2018

Java language support in Atom

macOS Build Status Windows Build Status Dependency Status

Add syntax highlighting and snippets to Java/JSP files in Atom.

Originally converted from the Java TextMate bundle.

Contributions are greatly appreciated. Please fork this repository and open a pull request to add snippets, make grammar tweaks, etc.