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 macros using tool implementations. #4766

Closed
faustinoaq opened this issue Jul 31, 2017 · 10 comments
Closed

Allow to find macros using tool implementations. #4766

faustinoaq opened this issue Jul 31, 2017 · 10 comments

Comments

@faustinoaq
Copy link
Contributor

Currently crystal tool implementations works for methods and functions, but not for macros.

I know crystal tool expand but it doesn't show enough information:

macro imprime(texto)
  puts "{{texto}}"
end

imprime hola

Using tool expand with the code above:

>>> crystal tool expand -c /home/user/sample.cr:5:1 /home/user/sample.cr
1 expansion found
expansion 1:
   imprime(hola)

~> puts("hola")

It doesn't show information about location or position.

It's very useful for editor support and tooling, see: https://github.com/faustinoaq/vscode-crystal-lang/issues/4

I think would be useful to add location info to crystal tool expand or allow to find macros using crystal tool implementations.

@faustinoaq faustinoaq changed the title Allow to found macro using tool implementation. Allow to find macro using tool implementation. Jul 31, 2017
@faustinoaq faustinoaq changed the title Allow to find macro using tool implementation. Allow to find macros using tool implementation. Jul 31, 2017
@faustinoaq faustinoaq changed the title Allow to find macros using tool implementation. Allow to find macros using tool implementations. Jul 31, 2017
@makenowjust
Copy link
Contributor

Okay, I try to implement this. But current compiler does not keep the information wanted by you (Thus crystal tool expand and crystal tool implementations can't show this.), so I should modify the compiler a bit. Sorry, I needs some days to implement this. Please wait.

@makenowjust
Copy link
Contributor

Implementing this on crystall tool implementations is very difficult because crystal tool implementations treats AST nodes after macro expansion.

@faustinoaq
Copy link
Contributor Author

So, adding location info to tool expand is the right way.

@makenowjust
Copy link
Contributor

Implement done. I'll write spec, then open a new pull request tomorrow. I am in bed now. Good night.

@faustinoaq
Copy link
Contributor Author

@makenowjust Thanks you so much! Good Night 😄

@makenowjust
Copy link
Contributor

Screen shot:

2017-08-01 19 18 04

Interesting point is the line # expand the macro 'imprime' (/Users/makenowjust/Projects/labo/crystal/a.cr:1:1).

@faustinoaq This is what you want, okay?

@straight-shoota
Copy link
Member

Wow, @makenowjust you say you need some days to implement and an hour later you're done? Crazy guy 🥇
But what's wrong with your colors? There is so little contrast in your screenshot...

@makenowjust
Copy link
Contributor

@straight-shoota I like little contrast color, but I should have taken care it when show to others. Sorry 🙇

@faustinoaq
Copy link
Contributor Author

faustinoaq commented Aug 2, 2017 via email

@makenowjust
Copy link
Contributor

@faustinoaq Of course, yes. And this JSON structure is same as crystal tool implementations output, so I think it is easy to fix editor extension for this.

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

3 participants