Rename Name -> IdentifierName given that we have several other kinds of parse nodes that represent names. (#3453)

Factor out common checking handling for the different kinds of
unqualified names
This commit is contained in:
Richard Smith
2023-12-07 01:48:14 +00:00
committed by GitHub
parent bf8697113a
commit fe6f7b4330
201 changed files with 712 additions and 725 deletions
+7 -6
View File
@@ -76,12 +76,13 @@ auto LanguageServer::onReply(llvm::json::Value /*id*/,
return true;
}
// Returns the text of first child of kind Parse::NodeKind::Name.
static auto GetName(const SharedValueStores& value_stores,
const Lex::TokenizedBuffer& tokens, const Parse::Tree& p,
Parse::NodeId node) -> std::optional<llvm::StringRef> {
// Returns the text of first child of kind Parse::NodeKind::IdentifierName.
static auto GetIdentifierName(const SharedValueStores& value_stores,
const Lex::TokenizedBuffer& tokens,
const Parse::Tree& p, Parse::NodeId node)
-> std::optional<llvm::StringRef> {
for (auto ch : p.children(node)) {
if (p.node_kind(ch) == Parse::NodeKind::Name) {
if (p.node_kind(ch) == Parse::NodeKind::IdentifierName) {
return value_stores.identifiers().Get(
tokens.GetIdentifier(p.node_token(node)));
}
@@ -123,7 +124,7 @@ void LanguageServer::OnDocumentSymbol(
continue;
}
if (auto name = GetName(value_stores, lexed, parsed, node)) {
if (auto name = GetIdentifierName(value_stores, lexed, parsed, node)) {
auto tok = parsed.node_token(node);
clang::clangd::Position pos{lexed.GetLineNumber(tok) - 1,
lexed.GetColumnNumber(tok) - 1};