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

[Scala] Class names in annotation "paths" #735

Closed
wbond opened this issue Dec 15, 2016 · 6 comments
Closed

[Scala] Class names in annotation "paths" #735

wbond opened this issue Dec 15, 2016 · 6 comments
Labels

Comments

@wbond
Copy link
Member

wbond commented Dec 15, 2016

Related to #605

Can annotation identifier "paths" contain class names (with a capital first letter)? If so, we should update

push:
- meta_content_scope: meta.annotation.identifier.scala
- match: '({{plainid}})(\.)'
captures:
2: punctuation.accessor.scala
- match: '{{plainid}}'
scope: variable.annotation.scala
set: annotation-parameters
to scope them with support.class.

@djspiewak @gwenzek

@djspiewak
Copy link
Contributor

djspiewak commented Dec 15, 2016

Scala classes can have upper- or lower-case names, though it is more strongly conventional to upper-case than in other languages (due to the way it interacts with certain type system features. Conversely, "bare" (non-class) types or package names can also have upper-case names.

Also, the plainid regex in the Scala mode matches upper-case names. It only excludes symbolic names.

I'm not sure I understand why support.class would be an appropriate scope for a component of the annotation. For example:

@scala.annotation.BeanProperty

Why would BeanProperty be support.class as opposed to just variable.annotation? What about without quantification?

@BeanProperty

And why would that be scoped differently from this:

@scala.annotation.tailrec
@tailrec

The definition of these two annotations is almost identical (they're both classes), but you seem to be proposing scoping them differently?

@wbond
Copy link
Member Author

wbond commented Dec 15, 2016

I am working off of the scoping we use for function calls, that is, the final identifier in a path is the only one that gets variable.function. Preceding identifiers may be namespaces or classes, so applying variable.function to them would be wrong. Similarly, it would seem "wrong" to me to apply variable.annotation to any classes in the annotation path. Additionally, I wouldn't want any accessors to have the scope variable ever.

@wbond
Copy link
Member Author

wbond commented Dec 15, 2016

Mostly, I just figured all but the final identifier in an annotation would get the same scope they would when not in an annotation.

@djspiewak
Copy link
Contributor

djspiewak commented Dec 15, 2016

That's fair, though I think syntactically it might look a little weird because the @ is to the far left (whereas function calls have nothing to the left). Additionally, in the original version of the proposal, the "annotation scope" (whatever it ended up being) was supposed to be applied to the @, overlapping the punctuation scope. Is that changed now?

If it's unchanged, it will end up with this rather odd situation where variable.annotation starts, then stops after one character and is replaced by "normal" scoping, and then starts again for a single identifier.

FWIW, nearly all editors which have any scoping at all for Java/Scala annotations tend to scope the entire token string, including quantifiers.

@wbond
Copy link
Member Author

wbond commented Dec 15, 2016

Right now variable.annotation (at least in Scala) is only applied to the identifier part, not the @. That was my intention with my summary comment in #709.

Personally I'm not a huge fan of the single-color annotations. Things like that tend to look broken to me since they cause every bit of the syntax to run together, including class names, accessors, symbols, etc.

I've opened #737 to discuss the general topic.

@wbond
Copy link
Member Author

wbond commented Feb 15, 2019

Closing this in favor of #737

@wbond wbond closed this as completed Feb 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants