Crystal: Allow to find modules and classes using crystal tool

Created on 9 Sep 2017  路  7Comments  路  Source: crystal-lang/crystal

Hi people!

Currently crystal tool hierarchy isn't showing class location.

class MiClase
end

a = MiClase.new
a
$ crystal tool hierarchy mi_clase.cr -e MiClase --no-color
- class Object (4 bytes)
  |
  +- class Reference (4 bytes)
     |
     +- class MiClase (4 bytes)

I think it is very useful to find clases using extensions like vscode-crystal-lang

This idea was suggested by @Qwerp-Derp

Can you add support for finding the definition of a function/class/module/etc., like with other language plugins in VSCode?
So for example, in this code:

def foo
  Bar::Baz(10)
end

If I go to Bar and right-click, and select "Peek definition", it should bring me to where Bar is defined

Some similar to https://github.com/crystal-lang/crystal/issues/4766

/cc @MakeNowJust :sweat_smile:

All 7 comments

I think we can have the docs tool output JSON format and include location of types and methods. That way you can solve your use case by using that.

4746 implements this already. For types it is an array locations, for methods and macros it's source_link. Though the latter could certainly be improved.

4746 implements this already.

Hi @straight-shoota, Would be possible to output modules and classes in JSON using crystal tool command?

What command do you refer to? crystal tool hierarchy can already output JSON (--format json).

@straight-shoota I mean class and module location file:line:column to be able to use it within extensions

For the hierarchy command or docs?

It should be easily doable to include this in the docs JSON. I don't know much about the hierarchy tool, but since it works on ASTNodes it should be no big deal as well.

Have someone looked into this yet? Otherwise I might to help the editor integrations out there.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

asterite picture asterite  路  71Comments

sergey-kucher picture sergey-kucher  路  66Comments

RX14 picture RX14  路  62Comments

farleyknight picture farleyknight  路  64Comments

ezrast picture ezrast  路  84Comments