mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Set up a 'Parse' namespace. (#3161)
Continuing on #3070. I moved ParseTree::Node to just Parse::Node, versus Parse::Tree::Node. Other name changes are just removing "Parse" or "Parser" prefixes. In EnumBase, I'm directly defining operator<< because the ostream.h approach just isn't working, not for either of Parse::State nor Parse::NodeKind. Errors look like: ```toolchain/parser/parser_context.cpp:449:34: error: invalid operands to binary expression ('llvm::raw_ostream' and 'const Carbon::Parse::State') output << "\t" << i << ".\t" << entry.state; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~ ``` The expected template in `Carbon::` is not in the error list; I only see the: ``` ./common/ostream.h:112:6: note: candidate template ignored: requirement 'std::is_base_of_v<std::ostream, llvm::raw_ostream>' was not satisfied [with S = llvm::raw_ostream, T = Carbon::Parse::State] auto operator<<(S& standard_out, const T& value) -> S& { ^ ``` I'm still prodding at this, but not seeing an obvious fix. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>
This commit is contained in:
co-authored by
Richard Smith
parent
64687aa7d1
commit
7157445f97
@@ -75,11 +75,11 @@ auto LanguageServer::onReply(llvm::json::Value /*id*/,
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns the text of first child of kind ParseNodeKind::Name.
|
||||
static auto getName(ParseTree& p, ParseTree::Node node)
|
||||
// Returns the text of first child of kind Parse::NodeKind::Name.
|
||||
static auto getName(Parse::Tree& p, Parse::Node node)
|
||||
-> std::optional<llvm::StringRef> {
|
||||
for (auto ch : p.children(node)) {
|
||||
if (p.node_kind(ch) == ParseNodeKind::Name) {
|
||||
if (p.node_kind(ch) == Parse::NodeKind::Name) {
|
||||
return p.GetNodeText(ch);
|
||||
}
|
||||
}
|
||||
@@ -96,23 +96,23 @@ void LanguageServer::OnDocumentSymbol(
|
||||
|
||||
auto buf = SourceBuffer::CreateFromFile(vfs, file);
|
||||
auto lexed = TokenizedBuffer::Lex(*buf, NullDiagnosticConsumer());
|
||||
auto parsed = ParseTree::Parse(lexed, NullDiagnosticConsumer(), nullptr);
|
||||
auto parsed = Parse::Tree::Parse(lexed, NullDiagnosticConsumer(), nullptr);
|
||||
std::vector<clang::clangd::DocumentSymbol> result;
|
||||
for (const auto& node : parsed.postorder()) {
|
||||
clang::clangd::SymbolKind symbol_kind;
|
||||
switch (parsed.node_kind(node)) {
|
||||
case ParseNodeKind::FunctionDeclaration:
|
||||
case ParseNodeKind::FunctionDefinitionStart:
|
||||
case Parse::NodeKind::FunctionDeclaration:
|
||||
case Parse::NodeKind::FunctionDefinitionStart:
|
||||
symbol_kind = clang::clangd::SymbolKind::Function;
|
||||
break;
|
||||
case ParseNodeKind::Namespace:
|
||||
case Parse::NodeKind::Namespace:
|
||||
symbol_kind = clang::clangd::SymbolKind::Namespace;
|
||||
break;
|
||||
case ParseNodeKind::InterfaceDefinitionStart:
|
||||
case ParseNodeKind::NamedConstraintDefinitionStart:
|
||||
case Parse::NodeKind::InterfaceDefinitionStart:
|
||||
case Parse::NodeKind::NamedConstraintDefinitionStart:
|
||||
symbol_kind = clang::clangd::SymbolKind::Interface;
|
||||
break;
|
||||
case ParseNodeKind::ClassDefinitionStart:
|
||||
case Parse::NodeKind::ClassDefinitionStart:
|
||||
symbol_kind = clang::clangd::SymbolKind::Class;
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user