When processing textDocument/documentSymbol, function scoped static variables may be better not to be reported
Opened this issue · 1 comments
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).
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);
}