diff --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp index 0dcff2eae05e7..b0957a4c0fc01 100644 --- a/clang-tools-extra/clangd/AST.cpp +++ b/clang-tools-extra/clangd/AST.cpp @@ -194,6 +194,100 @@ bool isImplementationDetail(const Decl *D) { D->getASTContext().getSourceManager()); } +// Whether T is const in a loose sense - is a variable with this type readonly? +bool isConst(QualType T) { + if (T.isNull()) + return false; + T = T.getNonReferenceType(); + if (T.isConstQualified()) + return true; + if (const auto *AT = T->getAsArrayTypeUnsafe()) + return isConst(AT->getElementType()); + if (isConst(T->getPointeeType())) + return true; + return false; +} + +bool isConst(const Decl *D) { + if (llvm::isa(D) || llvm::isa(D)) + return true; + if (llvm::isa(D) || llvm::isa(D) || + llvm::isa(D) || llvm::isa(D)) { + if (isConst(llvm::cast(D)->getType())) + return true; + } + if (const auto *OCPD = llvm::dyn_cast(D)) { + if (OCPD->isReadOnly()) + return true; + } + if (const auto *MPD = llvm::dyn_cast(D)) { + if (!MPD->hasSetter()) + return true; + } + if (const auto *CMD = llvm::dyn_cast(D)) { + if (CMD->isConst()) + return true; + } + if (const auto *FD = llvm::dyn_cast(D)) + return isConst(FD->getReturnType()); + return false; +} + +bool isStatic(const Decl *D) { + if (const auto *CMD = llvm::dyn_cast(D)) + return CMD->isStatic(); + if (const VarDecl *VD = llvm::dyn_cast(D)) + return VD->isStaticDataMember() || VD->isStaticLocal(); + if (const auto *OPD = llvm::dyn_cast(D)) + return OPD->isClassProperty(); + if (const auto *OMD = llvm::dyn_cast(D)) + return OMD->isClassMethod(); + if (const auto *FD = llvm::dyn_cast(D)) + return FD->isStatic(); + return false; +} + +bool isAbstract(const Decl *D) { + if (const auto *CMD = llvm::dyn_cast(D)) + return CMD->isPureVirtual(); + if (const auto *CRD = llvm::dyn_cast(D)) + return CRD->hasDefinition() && CRD->isAbstract(); + return false; +} + +bool isVirtual(const Decl *D) { + if (const auto *CMD = llvm::dyn_cast(D)) + return CMD->isVirtual(); + return false; +} + +bool isFinal(const Decl *D) { + if (const auto *CRD = dyn_cast(D)) + return CRD->hasAttr(); + + if (const auto *CRD = dyn_cast(D)) + return CRD->hasAttr(); + + return false; +} + +bool isUniqueDefinition(const NamedDecl *Decl) { + if (auto *Func = dyn_cast(Decl)) + return Func->isThisDeclarationADefinition(); + if (auto *Klass = dyn_cast(Decl)) + return Klass->isThisDeclarationADefinition(); + if (auto *Iface = dyn_cast(Decl)) + return Iface->isThisDeclarationADefinition(); + if (auto *Proto = dyn_cast(Decl)) + return Proto->isThisDeclarationADefinition(); + if (auto *Var = dyn_cast(Decl)) + return Var->isThisDeclarationADefinition(); + return isa(Decl) || + isa(Decl) || + isa(Decl) || isa(Decl) || + isa(Decl); +} + SourceLocation nameLocation(const clang::Decl &D, const SourceManager &SM) { auto L = D.getLocation(); // For `- (void)foo` we want `foo` not the `-`. diff --git a/clang-tools-extra/clangd/AST.h b/clang-tools-extra/clangd/AST.h index 2b83595e5b8e9..ef1c95d26153e 100644 --- a/clang-tools-extra/clangd/AST.h +++ b/clang-tools-extra/clangd/AST.h @@ -154,6 +154,42 @@ bool isImplicitTemplateInstantiation(const NamedDecl *D); /// explicit specialization. bool isExplicitTemplateSpecialization(const NamedDecl *D); +// Whether T is const in a loose sense - is a variable with this type readonly? +bool isConst(QualType T); + +// Whether D is const in a loose sense (should it be highlighted as such?) +// FIXME: This is separate from whether *a particular usage* can mutate D. +// We may want V in V.size() to be readonly even if V is mutable. +bool isConst(const Decl *D); + +// "Static" means many things in C++, only some get the "static" modifier. +// +// Meanings that do: +// - Members associated with the class rather than the instance. +// This is what 'static' most often means across languages. +// - static local variables +// These are similarly "detached from their context" by the static keyword. +// In practice, these are rarely used inside classes, reducing confusion. +// +// Meanings that don't: +// - Namespace-scoped variables, which have static storage class. +// This is implicit, so the keyword "static" isn't so strongly associated. +// If we want a modifier for these, "global scope" is probably the concept. +// - Namespace-scoped variables/functions explicitly marked "static". +// There the keyword changes *linkage* , which is a totally different concept. +// If we want to model this, "file scope" would be a nice modifier. +// +// This is confusing, and maybe we should use another name, but because "static" +// is a standard LSP modifier, having one with that name has advantages. +bool isStatic(const Decl *D); +// Indicates whether declaration D is abstract in cases where D is a struct or a class. +bool isAbstract(const Decl *D); +// Indicates whether declaration D is virtual in cases where D is a method. +bool isVirtual(const Decl *D); +// Indicates whether declaration D is final in cases where D is a struct, class or method. +bool isFinal(const Decl *D); +// Indicates whether declaration D is a unique definition (as opposed to a declaration). +bool isUniqueDefinition(const NamedDecl *Decl); /// Returns a nested name specifier loc of \p ND if it was present in the /// source, e.g. /// void ns::something::foo() -> returns 'ns::something' diff --git a/clang-tools-extra/clangd/FindSymbols.cpp b/clang-tools-extra/clangd/FindSymbols.cpp index 7655a39d5ba1f..e8a6bca17215c 100644 --- a/clang-tools-extra/clangd/FindSymbols.cpp +++ b/clang-tools-extra/clangd/FindSymbols.cpp @@ -188,6 +188,49 @@ std::string getSymbolName(ASTContext &Ctx, const NamedDecl &ND) { return printName(Ctx, ND); } +std::vector getSymbolTags(const NamedDecl &ND) { + std::vector Tags; + + if (ND.isDeprecated()) + Tags.push_back(SymbolTag::Deprecated); + + if (isConst(&ND)) + Tags.push_back(SymbolTag::ReadOnly); + + if (isStatic(&ND)) + Tags.push_back(SymbolTag::Static); + + if (isVirtual(&ND)) + Tags.push_back(SymbolTag::Virtual); + + if (isAbstract(&ND)) + Tags.push_back(SymbolTag::Abstract); + + if (isFinal(&ND)) + Tags.push_back(SymbolTag::Final); + + if (isUniqueDefinition(&ND)) + Tags.push_back(SymbolTag::Definition); + else if (!isa(ND)) + Tags.push_back(SymbolTag::Declaration); + + switch (ND.getAccess()) { + case AS_public: + Tags.push_back(SymbolTag::Public); + break; + case AS_protected: + Tags.push_back(SymbolTag::Protected); + break; + case AS_private: + Tags.push_back(SymbolTag::Private); + break; + default: + break; + } + + return Tags; +} + std::string getSymbolDetail(ASTContext &Ctx, const NamedDecl &ND) { PrintingPolicy P(Ctx.getPrintingPolicy()); P.SuppressScope = true; @@ -242,6 +285,7 @@ std::optional declToSym(ASTContext &Ctx, const NamedDecl &ND) { SI.range = Range{sourceLocToPosition(SM, SymbolRange->getBegin()), sourceLocToPosition(SM, SymbolRange->getEnd())}; SI.detail = getSymbolDetail(Ctx, ND); + SI.tags = getSymbolTags(ND); SourceLocation NameLoc = ND.getLocation(); SourceLocation FallbackNameLoc; diff --git a/clang-tools-extra/clangd/Protocol.cpp b/clang-tools-extra/clangd/Protocol.cpp index 560b8e00ed377..9926f2dd63de5 100644 --- a/clang-tools-extra/clangd/Protocol.cpp +++ b/clang-tools-extra/clangd/Protocol.cpp @@ -964,6 +964,8 @@ llvm::json::Value toJSON(const DocumentSymbol &S) { Result["children"] = S.children; if (S.deprecated) Result["deprecated"] = true; + if (!S.tags.empty()) + Result["tags"] = S.tags; // FIXME: workaround for older gcc/clang return std::move(Result); } diff --git a/clang-tools-extra/clangd/Protocol.h b/clang-tools-extra/clangd/Protocol.h index 2248572060431..607551f1b2d9e 100644 --- a/clang-tools-extra/clangd/Protocol.h +++ b/clang-tools-extra/clangd/Protocol.h @@ -1104,6 +1104,29 @@ struct CodeAction { }; llvm::json::Value toJSON(const CodeAction &); +enum class SymbolTag { + Deprecated = 1, + Private = 2, + Package = 3, + Protected = 4, + Public = 5, + Internal= 6, + File = 7, + Static = 8, + Abstract = 9, + Final = 10, + Sealed = 11, + Transient = 12, + Volatile = 13, + Synchronized = 14, + Virtual = 15, + Nullable = 16, + NonNull = 17, + Declaration = 18, + Definition = 19, + ReadOnly = 20, +}; +llvm::json::Value toJSON(SymbolTag); /// Represents programming constructs like variables, classes, interfaces etc. /// that appear in a document. Document symbols can be hierarchical and they /// have two ranges: one that encloses its definition and one that points to its @@ -1121,6 +1144,9 @@ struct DocumentSymbol { /// Indicates if this symbol is deprecated. bool deprecated = false; + /// Tags for this symbol, e.g public, private, static, const etc. + std::vector tags; + /// The range enclosing this symbol not including leading/trailing whitespace /// but everything else like comments. This information is typically used to /// determine if the clients cursor is inside the symbol to reveal in the @@ -1572,8 +1598,6 @@ struct ResolveTypeHierarchyItemParams { bool fromJSON(const llvm::json::Value &, ResolveTypeHierarchyItemParams &, llvm::json::Path); -enum class SymbolTag { Deprecated = 1 }; -llvm::json::Value toJSON(SymbolTag); /// The parameter of a `textDocument/prepareCallHierarchy` request. struct CallHierarchyPrepareParams : public TextDocumentPositionParams {}; diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp index ab720ebe6b47f..f53343951d7de 100644 --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp +++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "SemanticHighlighting.h" +#include "AST.h" #include "Config.h" #include "FindTarget.h" #include "ParsedAST.h" @@ -77,23 +78,6 @@ bool canHighlightName(DeclarationName Name) { llvm_unreachable("invalid name kind"); } -bool isUniqueDefinition(const NamedDecl *Decl) { - if (auto *Func = dyn_cast(Decl)) - return Func->isThisDeclarationADefinition(); - if (auto *Klass = dyn_cast(Decl)) - return Klass->isThisDeclarationADefinition(); - if (auto *Iface = dyn_cast(Decl)) - return Iface->isThisDeclarationADefinition(); - if (auto *Proto = dyn_cast(Decl)) - return Proto->isThisDeclarationADefinition(); - if (auto *Var = dyn_cast(Decl)) - return Var->isThisDeclarationADefinition(); - return isa(Decl) || - isa(Decl) || - isa(Decl) || isa(Decl) || - isa(Decl); -} - std::optional kindForType(const Type *TP, const HeuristicResolver *Resolver); std::optional kindForDecl(const NamedDecl *D, @@ -192,91 +176,6 @@ std::optional kindForType(const Type *TP, return std::nullopt; } -// Whether T is const in a loose sense - is a variable with this type readonly? -bool isConst(QualType T) { - if (T.isNull()) - return false; - T = T.getNonReferenceType(); - if (T.isConstQualified()) - return true; - if (const auto *AT = T->getAsArrayTypeUnsafe()) - return isConst(AT->getElementType()); - if (isConst(T->getPointeeType())) - return true; - return false; -} - -// Whether D is const in a loose sense (should it be highlighted as such?) -// FIXME: This is separate from whether *a particular usage* can mutate D. -// We may want V in V.size() to be readonly even if V is mutable. -bool isConst(const Decl *D) { - if (llvm::isa(D) || llvm::isa(D)) - return true; - if (llvm::isa(D) || llvm::isa(D) || - llvm::isa(D) || llvm::isa(D)) { - if (isConst(llvm::cast(D)->getType())) - return true; - } - if (const auto *OCPD = llvm::dyn_cast(D)) { - if (OCPD->isReadOnly()) - return true; - } - if (const auto *MPD = llvm::dyn_cast(D)) { - if (!MPD->hasSetter()) - return true; - } - if (const auto *CMD = llvm::dyn_cast(D)) { - if (CMD->isConst()) - return true; - } - return false; -} - -// "Static" means many things in C++, only some get the "static" modifier. -// -// Meanings that do: -// - Members associated with the class rather than the instance. -// This is what 'static' most often means across languages. -// - static local variables -// These are similarly "detached from their context" by the static keyword. -// In practice, these are rarely used inside classes, reducing confusion. -// -// Meanings that don't: -// - Namespace-scoped variables, which have static storage class. -// This is implicit, so the keyword "static" isn't so strongly associated. -// If we want a modifier for these, "global scope" is probably the concept. -// - Namespace-scoped variables/functions explicitly marked "static". -// There the keyword changes *linkage* , which is a totally different concept. -// If we want to model this, "file scope" would be a nice modifier. -// -// This is confusing, and maybe we should use another name, but because "static" -// is a standard LSP modifier, having one with that name has advantages. -bool isStatic(const Decl *D) { - if (const auto *CMD = llvm::dyn_cast(D)) - return CMD->isStatic(); - if (const VarDecl *VD = llvm::dyn_cast(D)) - return VD->isStaticDataMember() || VD->isStaticLocal(); - if (const auto *OPD = llvm::dyn_cast(D)) - return OPD->isClassProperty(); - if (const auto *OMD = llvm::dyn_cast(D)) - return OMD->isClassMethod(); - return false; -} - -bool isAbstract(const Decl *D) { - if (const auto *CMD = llvm::dyn_cast(D)) - return CMD->isPureVirtual(); - if (const auto *CRD = llvm::dyn_cast(D)) - return CRD->hasDefinition() && CRD->isAbstract(); - return false; -} - -bool isVirtual(const Decl *D) { - if (const auto *CMD = llvm::dyn_cast(D)) - return CMD->isVirtual(); - return false; -} - bool isDependent(const Decl *D) { if (isa(D)) return true; diff --git a/clang-tools-extra/clangd/test/symbol-tags.test b/clang-tools-extra/clangd/test/symbol-tags.test new file mode 100644 index 0000000000000..3d4821ae32081 --- /dev/null +++ b/clang-tools-extra/clangd/test/symbol-tags.test @@ -0,0 +1,293 @@ +# COM: Checks the extraction of symbol tags. + +# RUN: clangd -lit-test < %s | FileCheck %s +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{"textDocument":{"documentSymbol":{"hierarchicalDocumentSymbolSupport":true}},"workspace":{"symbol":{"symbolKind":{"valueSet": [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26]}}}},"trace":"off"}} +--- +{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///main.cpp","languageId":"cpp","version":1, + "text": + "class AbstractClass{\n public:\n virtual ~AbstractClass() = default;\n virtual void f1() = 0;\n void f2() const;\n protected: \n void f3(){}\n private: \n static void f4(){} \n }; void AbstractClass::f2() const {} \n class ImplClass final: public AbstractClass { \n public: \n void f1() final {}};" +}}} +--- +{"jsonrpc":"2.0","id":2,"method":"textDocument/documentSymbol","params":{"textDocument":{"uri":"test:///main.cpp"}}} +# CHECK: "id": 2, +# CHECK-NEXT: "jsonrpc": "2.0", +# CHECK-NEXT: "result": [ +# CHECK-NEXT: { +# CHECK-NEXT: "children": [ +# CHECK-NEXT: { +# CHECK-NEXT: "kind": 9, +# CHECK-NEXT: "name": "~AbstractClass", +# CHECK-NEXT: "range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 35, +# CHECK-NEXT: "line": 2 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 1, +# CHECK-NEXT: "line": 2 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "selectionRange": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 10, +# CHECK-NEXT: "line": 2 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 9, +# CHECK-NEXT: "line": 2 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "tags": [ +# CHECK-NEXT: 15, +# CHECK-NEXT: 19, +# CHECK-NEXT: 5 +# CHECK-NEXT: ] +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "detail": "void ()", +# CHECK-NEXT: "kind": 6, +# CHECK-NEXT: "name": "f1", +# CHECK-NEXT: "range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 22, +# CHECK-NEXT: "line": 3 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 1, +# CHECK-NEXT: "line": 3 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "selectionRange": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 16, +# CHECK-NEXT: "line": 3 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 14, +# CHECK-NEXT: "line": 3 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "tags": [ +# CHECK-NEXT: 15, +# CHECK-NEXT: 9, +# CHECK-NEXT: 18, +# CHECK-NEXT: 5 +# CHECK-NEXT: ] +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "detail": "void () const", +# CHECK-NEXT: "kind": 6, +# CHECK-NEXT: "name": "f2", +# CHECK-NEXT: "range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 16, +# CHECK-NEXT: "line": 4 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 1, +# CHECK-NEXT: "line": 4 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "selectionRange": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 8, +# CHECK-NEXT: "line": 4 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 6, +# CHECK-NEXT: "line": 4 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "tags": [ +# CHECK-NEXT: 20, +# CHECK-NEXT: 18, +# CHECK-NEXT: 5 +# CHECK-NEXT: ] +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "detail": "void ()", +# CHECK-NEXT: "kind": 6, +# CHECK-NEXT: "name": "f3", +# CHECK-NEXT: "range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 12, +# CHECK-NEXT: "line": 6 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 1, +# CHECK-NEXT: "line": 6 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "selectionRange": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 8, +# CHECK-NEXT: "line": 6 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 6, +# CHECK-NEXT: "line": 6 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "tags": [ +# CHECK-NEXT: 19, +# CHECK-NEXT: 4 +# CHECK-NEXT: ] +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "detail": "void ()", +# CHECK-NEXT: "kind": 6, +# CHECK-NEXT: "name": "f4", +# CHECK-NEXT: "range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 19, +# CHECK-NEXT: "line": 8 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 1, +# CHECK-NEXT: "line": 8 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "selectionRange": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 15, +# CHECK-NEXT: "line": 8 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 13, +# CHECK-NEXT: "line": 8 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "tags": [ +# CHECK-NEXT: 8, +# CHECK-NEXT: 19, +# CHECK-NEXT: 2 +# CHECK-NEXT: ] +# CHECK-NEXT: } +# CHECK-NEXT: ], +# CHECK-NEXT: "detail": "class", +# CHECK-NEXT: "kind": 5, +# CHECK-NEXT: "name": "AbstractClass", +# CHECK-NEXT: "range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 2, +# CHECK-NEXT: "line": 9 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 0, +# CHECK-NEXT: "line": 0 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "selectionRange": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 19, +# CHECK-NEXT: "line": 0 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 6, +# CHECK-NEXT: "line": 0 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "tags": [ +# CHECK-NEXT: 9, +# CHECK-NEXT: 19 +# CHECK-NEXT: ] +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "detail": "void () const", +# CHECK-NEXT: "kind": 6, +# CHECK-NEXT: "name": "AbstractClass::f2", +# CHECK-NEXT: "range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 37, +# CHECK-NEXT: "line": 9 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 4, +# CHECK-NEXT: "line": 9 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "selectionRange": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 26, +# CHECK-NEXT: "line": 9 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 24, +# CHECK-NEXT: "line": 9 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "tags": [ +# CHECK-NEXT: 20, +# CHECK-NEXT: 19, +# CHECK-NEXT: 5 +# CHECK-NEXT: ] +# CHECK-NEXT: }, +# CHECK-NEXT: { +# CHECK-NEXT: "children": [ +# CHECK-NEXT: { +# CHECK-NEXT: "detail": "void ()", +# CHECK-NEXT: "kind": 6, +# CHECK-NEXT: "name": "f1", +# CHECK-NEXT: "range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 19, +# CHECK-NEXT: "line": 12 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 1, +# CHECK-NEXT: "line": 12 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "selectionRange": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 8, +# CHECK-NEXT: "line": 12 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 6, +# CHECK-NEXT: "line": 12 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "tags": [ +# CHECK-NEXT: 15, +# CHECK-NEXT: 10, +# CHECK-NEXT: 19, +# CHECK-NEXT: 5 +# CHECK-NEXT: ] +# CHECK-NEXT: } +# CHECK-NEXT: ], +# CHECK-NEXT: "detail": "class", +# CHECK-NEXT: "kind": 5, +# CHECK-NEXT: "name": "ImplClass", +# CHECK-NEXT: "range": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 20, +# CHECK-NEXT: "line": 12 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 1, +# CHECK-NEXT: "line": 10 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "selectionRange": { +# CHECK-NEXT: "end": { +# CHECK-NEXT: "character": 16, +# CHECK-NEXT: "line": 10 +# CHECK-NEXT: }, +# CHECK-NEXT: "start": { +# CHECK-NEXT: "character": 7, +# CHECK-NEXT: "line": 10 +# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "tags": [ +# CHECK-NEXT: 10, +# CHECK-NEXT: 19 +# CHECK-NEXT: ] +# CHECK-NEXT: } +# CHECK-NEXT: ] +# CHECK-NEXT:} + +--- +{"jsonrpc":"2.0","id":3,"method":"shutdown"} +--- +{"jsonrpc":"2.0","method":"exit"} diff --git a/clang-tools-extra/clangd/test/symbols.test b/clang-tools-extra/clangd/test/symbols.test index af5d74123630e..40115f2496e50 100644 --- a/clang-tools-extra/clangd/test/symbols.test +++ b/clang-tools-extra/clangd/test/symbols.test @@ -56,7 +56,10 @@ # CHECK-NEXT: "character": {{.*}}, # CHECK-NEXT: "line": {{.*}} # CHECK-NEXT: } -# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "tags": [ +# CHECK-NEXT: 18 +# CHECK-NEXT: ] # CHECK-NEXT: }, # CHECK-NEXT: { # CHECK-NEXT: "detail": "int ()", @@ -81,7 +84,10 @@ # CHECK-NEXT: "character": {{.*}}, # CHECK-NEXT: "line": {{.*}} # CHECK-NEXT: } -# CHECK-NEXT: } +# CHECK-NEXT: }, +# CHECK-NEXT: "tags": [ +# CHECK-NEXT: 19 +# CHECK-NEXT: ] # CHECK-NEXT: } # CHECK-NEXT: ] # CHECK-NEXT:}