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

Function call + array accessor + new operator introduces extra meta.function-call.java scopes #180

Closed
felixhao28 opened this issue Dec 3, 2018 · 3 comments · Fixed by #214
Assignees

Comments

@felixhao28
Copy link

Description

public class A {
    void f() {
        int a = 1;
        g(education[new Random()]);
        g(education[new Random()]);
        g(education[new Random()]);
        g(education[new Random()]);
        g(education[new Random()]);
        g(education[new Random()]);
        g(education[new Random()]);
        g(education[new Random()]);
        int a = 1;
    }

    void g(Object o) {
        int a = 1;
    }
}

image

Expected behavior: [What you expect to happen]

As you can see, although the highlight is still correct, there are more meta.function-call.java than we need.

@sadikovi
Copy link
Contributor

sadikovi commented Dec 3, 2018

Can you include the language-java version that you are testing against?

@felixhao28
Copy link
Author

d48e713

@sadikovi
Copy link
Contributor

sadikovi commented Dec 6, 2018

This is a weird one. I will have a look.

@sadikovi sadikovi self-assigned this Dec 6, 2018
sadikovi pushed a commit that referenced this issue Nov 28, 2019
…ttern

### Description of the Change

* Dot should also end  'anonymous-classes-and-new', in order to propery highlight method call of temporary variable created by 'new'.

* Question mark should also end 'anonymous-classes-and-new', in order to proper break out circumstances like `new Random() ? true : false`;

* Right square brace should also end 'anonymous-classes-and-new', for circumstances like `[new Random()]`.

* Xor should also end `anonymous-classes-and-new`, for circumstances like `new Integer(1) ^ new Integer(2)`.

### Alternate Designs

~~Non was considered.~~

Having to enumerate these much punctuations made me think of proposing a general and simple regex to end new expression. But soon I found out that I couldn't find a way to tell when `)` or `]` is met, whether there will be a `{}` block next to it.

### Benefits

* The meaning of dot method call by variable and new-variable is consistent.
* Every punctuation that could end a new expression is covered.

### Possible Drawbacks

No obvious drawback.

### Applicable Issues

Fix #213 -> dot
Fix #179 -> question mark
Fix #180 -> right square
Fix #192 -> xor
sadikovi added a commit that referenced this issue Nov 28, 2019
### 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

Refactors and moves the test case for #180 into a separate test.

### Alternate Designs

N/A

### Benefits

N/A

### Possible Drawbacks

N/A

### Applicable Issues

Relates to #180
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