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

Allow to find modules and classes using crystal tool #4941

Closed
faustinoaq opened this issue Sep 9, 2017 · 7 comments · Fixed by #7742
Closed

Allow to find modules and classes using crystal tool #4941

faustinoaq opened this issue Sep 9, 2017 · 7 comments · Fixed by #7742

Comments

@faustinoaq
Copy link
Contributor

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 #4766

/cc @makenowjust 😅

@asterite
Copy link
Member

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.

@straight-shoota
Copy link
Member

#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.

@faustinoaq
Copy link
Contributor Author

#4746 implements this already.

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

@straight-shoota
Copy link
Member

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

@faustinoaq
Copy link
Contributor Author

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

@straight-shoota
Copy link
Member

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.

@baelter
Copy link

baelter commented Sep 30, 2018

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

makenowjust added a commit to makenowjust/crystal that referenced this issue May 5, 2019
bcardiff pushed a commit that referenced this issue May 15, 2019
)

* Refactor `ImplementationVisitor#visit(Call)` by early return

* Implementation: allow to lookup implementations of class and module

Closes #4941

* Implementation: add specs for looking up classes and modules implementations

* Implementation: use target_type to lookup alias type implementation

* Implementation: add const spec
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

Successfully merging a pull request may close this issue.

4 participants