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

[kt] Suggestion: Highlight common scope functions #256

Open
wesalvaro opened this issue Jul 23, 2019 · 1 comment
Open

[kt] Suggestion: Highlight common scope functions #256

wesalvaro opened this issue Jul 23, 2019 · 1 comment

Comments

@wesalvaro
Copy link

Scope functions are very important to the readability of Kotlin as they can change the context or introduce a variable without much fanfare. I would recommend that we highlight scope functions similar to a when block. This should include all the obvious scope functions (also, apply, let, run, and with). I also think it should include other methods that introduce a scope (e.g. forEach)

foo.apply {  // apply should be highlighted
  bar().forEach {  // forEach should be highlighted
    // ...
  }
  addListener("click") {  // No special highlight
    // ...
  }
}

It looks like GitHub's highlighter already highlights apply.

marijnh added a commit that referenced this issue Jul 26, 2019
@marijnh
Copy link
Member

marijnh commented Jul 26, 2019

Since I'm not that familiar with Kotlin, I really don't know what the obvious scope functions should be. Also note that a mode like this can only match the property names, without having any clue about the type of the thing that they are a property of, so highlighting run will highlight any run property, even when it's not actually the method you are thinking of.

Attached patch adds support for trailing lambda arguments to the mode (I had missed them in the grammar before), and will mark methods and functions called this way with a callee type. Does that help? If you want something different, please be specific.

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