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

[search] nimgrep option to only search for declarations of a given symbol #7419

Closed
3 tasks
timotheecour opened this issue Mar 27, 2018 · 4 comments
Closed
3 tasks

Comments

@timotheecour
Copy link
Member

timotheecour commented Mar 27, 2018

I'd like to have an equivalent of D's dscanner --declaration (cf https://github.com/dlang-community/D-Scanner), also present in other languages ; I couldn't find it in nimgrep

my workaround is to use:

nimgrep -w --ignoreStyle lines **/*.nim| grep -E '(iterator|proc|template|macro)'

but that's very brittle (eg doesn't doesn't work with other types of declarations (eg macros, types, variables, constants etc) and gets fooled by comments.

This is needed for integration with other tools (eg go to declaration)

EDIT

  • also, finding certain symbols can be tricky, eg: defer which seems like it could be a macro but is instead something magic defined here:compiler/transf.nim ; a tool should be able to find the defnition of these as well, eg using lexer.TokTypeToStr
  • for starred symbols, this can be tried:
    nimgrep --ignoreStyle --ext:nim --recursive --oneline "newException\*"
  • also, need a way to find declarations of symbols defined in blocks, eg enum, type etc.

  • also, need a way to find definitions of magic symbols, eg:

proc instantiationInfo*(index = -1, fullPaths = false): tuple[
    filename: string, line: int, column: int] {.magic: "InstantiationInfo", noSideEffect.}
# is actually implemented in compiler/semmagic.nim:
proc semInstantiationInfo(c: PContext, n: PNode)
@data-man
Copy link
Contributor

I implemented nim ctags <file.nim> but this command should be improved.
It's in my ToDos. :)

@timotheecour
Copy link
Member Author

nimsuggest may be a better starting point for that instead of nimgrep

@Araq
Copy link
Member

Araq commented Apr 16, 2018

Indeed.

@timotheecour timotheecour changed the title nimgrep option to only search for declarations of a given symbol [search] nimgrep option to only search for declarations of a given symbol Aug 1, 2018
@Araq
Copy link
Member

Araq commented Sep 2, 2018

Closing in favor of #8747.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants