crystal-lang-tools / sublime-crystal

Crystal syntax highlighting for Sublime Text
Other
86 stars 18 forks source link

Add `entity.name` scopes to property definitions #54

Open faultyserver opened 6 years ago

faultyserver commented 6 years ago

See https://www.sublimetext.com/docs/3/scope_naming.html#entity. entity scopes are used to populate the symbol list and enable the "Jump to Definition" behavior.

An example:

class Foo
  property bar : String

  def baz; end
end

foo = Foo.new
foo.baz
foo.bar

Putting the cursor in the word baz in foo.baz and then pressing alt+cmnd+down will jump to the definition of baz on Foo (or if there are multiple definitions of it, it brings up a palette to jump between definitions).

However, doing the same on bar does not jump to the definition because there is no actual function definition in the source code.

I think that jumping to property definitions should be supported, and they use a scope like entity.name.property instead of entity.name.function to be semantically accurate.

I know there's some effort to do this with Scry, but it can also just be done with the symbol scoping so why not at least start there. It's not a perfect solution and doesn't address issues with jumping to things defined by macros, but it's a good step towards that and would feel more consistent overall.