Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlighting of this in property getter #50

Closed
Lexikos opened this issue Oct 29, 2021 · 2 comments
Closed

Highlighting of this in property getter #50

Lexikos opened this issue Oct 29, 2021 · 2 comments

Comments

@Lexikos
Copy link

Lexikos commented Oct 29, 2021

this is not highlighted on the second line:

class X {
    static Y[z] => this.A[1]
            || this.B[1] := C
}

but without [z], this is highlighted correctly:

class X {
    static Y => this.A[z]
            || this.B[z] := C
}
@thqby
Copy link
Owner

thqby commented Oct 30, 2021

Format 1 may also be followed by the block. such as

static x[y,
  z] {   ; \w+\[
  if (1) {
    ...
  }
}

Textmate does not support backtracking to previous lines, so continuation lines in the format 1 are broken, and the continuation line that operator at the end of the line is supported.

In the following format, the two cases are distinguishable. x => and x {
End conditions can be treated differently.

@Lexikos
Copy link
Author

Lexikos commented Oct 30, 2021

I am not looking for workarounds - I'm not going to write my code based on whether your extension highlights this.

Why do you need to differentiate between these cases? 99% of the time, if the variable this is inside a class body, it refers to the hidden this parameter.

In my scripts, you'd get it right more often by highlighting this unconditionally. I don't really care whether it's highlighted, but having it highlighted sometimes and then sometimes not without apparent reason has been bugging me.

I figured out another cause - it isn't highlighted inside switch.

class A {
    B() {
        switch {
        case 1:
            return this
        }
    }
}

Textmate does not support backtracking

It gets highlighted in methods, and not inside global functions, or inside nested functions when this has been explicitly declared local. Lack of backtracking support apparently doesn't prevent that; why should it matter at all?

What happens when the extension fails to detect the line continuation? Does it revert to assuming the expression resides directly in the class body? If so, it should still be highlighted. This should also be highlighted, and is not:

class A {
    a := 1
    b := this.a
}

this is also valid for static initializers (in v2); it refers to the class itself.

@thqby thqby closed this as completed Oct 31, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants