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

When processing textDocument/documentSymbol, function scoped static variables may be better not to be reported #77

Open
geza-herman opened this issue Feb 16, 2020 · 1 comment

Comments

@geza-herman
Copy link

As I understand, the current textDocument/documentSymbol reports symbols, which can be useful in source code navigation, like imenu of emacs. So it doesn't report local variables, for example. But it reports function scoped static variables. This has a negative effect on imenu: we cannot select the function itself, only the static variables in it.

Here's a little discussion about this: emacs-lsp/lsp-mode#1424

I think it's worth considering ignoring function scoped static variables as well (not just "proper" local variables).

@acowley
Copy link
Contributor

acowley commented Feb 27, 2020

I was wrestling with the same issue, making imenu useless for jumping to function definitions. I had figured it was an emacs issue, and was stumped until I happened to come across @geza-herman's investigations. I've been using the following patch for a few days now, and it seems to do just what I want without causing any trouble that I've noticed.

diff --git a/src/indexer.hh b/src/indexer.hh
index cd4669a9..a06a743b 100644
--- a/src/indexer.hh
+++ b/src/indexer.hh
@@ -247,7 +247,7 @@ struct VarDef : NameMixin<VarDef> {
             parent_kind == SymbolKind::StaticMethod ||
             parent_kind == SymbolKind::Constructor) &&
            (storage == clang::SC_None || storage == clang::SC_Auto ||
-            storage == clang::SC_Register);
+            storage == clang::SC_Register || storage == clang::SC_Static);
   }

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.

2 participants