diff --git a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h --- a/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h +++ b/clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h @@ -19,6 +19,7 @@ #include "clang/ExtractAPI/API.h" #include "clang/ExtractAPI/Serialization/SerializerBase.h" +#include "llvm/ADT/SmallVector.h" #include "llvm/Support/JSON.h" #include "llvm/Support/VersionTuple.h" #include "llvm/Support/raw_ostream.h" @@ -45,6 +46,25 @@ /// The Symbol Graph format version used by this serializer. static const VersionTuple FormatVersion; + using PathComponentStack = llvm::SmallVector; + /// The current path component stack. + /// + /// Note: this is used to serialize the ``pathComponents`` field of symbols in + /// the Symbol Graph. + PathComponentStack PathComponents; + + /// A helper type to manage PathComponents correctly using RAII. + struct PathComponentGuard { + PathComponentGuard(PathComponentStack &PC, StringRef Component) : PC(PC) { + PC.emplace_back(Component); + } + + ~PathComponentGuard() { PC.pop_back(); } + + private: + PathComponentStack &PC; + }; + public: /// Serialize the APIs in \c APISet in the Symbol Graph format. /// @@ -126,6 +146,13 @@ /// Serialize a macro defintion record. void serializeMacroDefinitionRecord(const MacroDefinitionRecord &Record); + /// Push a component to the current path components stack. + /// + /// \param Component The component to push onto the path components stack. + /// \return A PathComponentGuard responsible for removing the latest + /// component from the stack on scope exit. + LLVM_NODISCARD PathComponentGuard makePathComponentGuard(StringRef Component); + public: SymbolGraphSerializer(const APISet &API, StringRef ProductName, APISerializerOption Options = {}) diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp --- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp +++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp @@ -90,27 +90,35 @@ return Platform; } +/// Serialize a source position. +Object serializeSourcePosition(const PresumedLoc &Loc) { + assert(Loc.isValid() && "invalid source position"); + + Object SourcePosition; + SourcePosition["line"] = Loc.getLine(); + SourcePosition["character"] = Loc.getColumn(); + + return SourcePosition; +} + /// Serialize a source location in file. /// /// \param Loc The presumed location to serialize. /// \param IncludeFileURI If true, include the file path of \p Loc as a URI. /// Defaults to false. -Object serializeSourcePosition(const PresumedLoc &Loc, +Object serializeSourceLocation(const PresumedLoc &Loc, bool IncludeFileURI = false) { - assert(Loc.isValid() && "invalid source position"); - - Object SourcePosition; - SourcePosition["line"] = Loc.getLine(); - SourcePosition["character"] = Loc.getColumn(); + Object SourceLocation; + serializeObject(SourceLocation, "position", serializeSourcePosition(Loc)); if (IncludeFileURI) { std::string FileURI = "file://"; // Normalize file path to use forward slashes for the URI. FileURI += sys::path::convert_to_slash(Loc.getFilename()); - SourcePosition["uri"] = FileURI; + SourceLocation["uri"] = FileURI; } - return SourcePosition; + return SourceLocation; } /// Serialize a source range with begin and end locations. @@ -449,12 +457,16 @@ serializeObject(Obj, "names", serializeNames(Record)); serializeObject( Obj, "location", - serializeSourcePosition(Record.Location, /*IncludeFileURI=*/true)); + serializeSourceLocation(Record.Location, /*IncludeFileURI=*/true)); serializeObject(Obj, "availbility", serializeAvailability(Record.Availability)); serializeObject(Obj, "docComment", serializeDocComment(Record.Comment)); serializeArray(Obj, "declarationFragments", serializeDeclarationFragments(Record.Declaration)); + // TODO: Once we keep track of symbol access information serialize it + // correctly here. + Obj["accessLevel"] = "public"; + serializeArray(Obj, "pathComponents", Array(PathComponents)); return Obj; } @@ -483,18 +495,21 @@ } void SymbolGraphSerializer::serializeGlobalRecord(const GlobalRecord &Record) { + auto GlobalPathComponentGuard = makePathComponentGuard(Record.Name); + auto Obj = serializeAPIRecord(Record); if (!Obj) return; if (Record.GlobalKind == GVKind::Function) - serializeObject(*Obj, "parameters", + serializeObject(*Obj, "functionSignature", serializeFunctionSignature(Record.Signature)); Symbols.emplace_back(std::move(*Obj)); } void SymbolGraphSerializer::serializeEnumRecord(const EnumRecord &Record) { + auto EnumPathComponentGuard = makePathComponentGuard(Record.Name); auto Enum = serializeAPIRecord(Record); if (!Enum) return; @@ -502,7 +517,10 @@ Symbols.emplace_back(std::move(*Enum)); for (const auto &Constant : Record.Constants) { + auto EnumConstantPathComponentGuard = + makePathComponentGuard(Constant->Name); auto EnumConstant = serializeAPIRecord(*Constant); + if (!EnumConstant) continue; @@ -512,6 +530,7 @@ } void SymbolGraphSerializer::serializeStructRecord(const StructRecord &Record) { + auto StructPathComponentGuard = makePathComponentGuard(Record.Name); auto Struct = serializeAPIRecord(Record); if (!Struct) return; @@ -519,7 +538,9 @@ Symbols.emplace_back(std::move(*Struct)); for (const auto &Field : Record.Fields) { + auto StructFieldPathComponentGuard = makePathComponentGuard(Field->Name); auto StructField = serializeAPIRecord(*Field); + if (!StructField) continue; @@ -530,6 +551,7 @@ void SymbolGraphSerializer::serializeObjCContainerRecord( const ObjCContainerRecord &Record) { + auto ObjCContainerPathComponentGuard = makePathComponentGuard(Record.Name); auto ObjCContainer = serializeAPIRecord(Record); if (!ObjCContainer) return; @@ -539,7 +561,9 @@ // Record instance variables and that the instance variables are members of // the container. for (const auto &Ivar : Record.Ivars) { + auto IvarPathComponentGuard = makePathComponentGuard(Ivar->Name); auto ObjCIvar = serializeAPIRecord(*Ivar); + if (!ObjCIvar) continue; @@ -549,7 +573,9 @@ // Record methods and that the methods are members of the container. for (const auto &Method : Record.Methods) { + auto MethodPathComponentGuard = makePathComponentGuard(Method->Name); auto ObjCMethod = serializeAPIRecord(*Method); + if (!ObjCMethod) continue; @@ -559,7 +585,9 @@ // Record properties and that the properties are members of the container. for (const auto &Property : Record.Properties) { + auto PropertyPathComponentGuard = makePathComponentGuard(Property->Name); auto ObjCProperty = serializeAPIRecord(*Property); + if (!ObjCProperty) continue; @@ -581,13 +609,20 @@ void SymbolGraphSerializer::serializeMacroDefinitionRecord( const MacroDefinitionRecord &Record) { + auto MacroPathComponentGuard = makePathComponentGuard(Record.Name); auto Macro = serializeAPIRecord(Record); + if (!Macro) return; Symbols.emplace_back(std::move(*Macro)); } +SymbolGraphSerializer::PathComponentGuard +SymbolGraphSerializer::makePathComponentGuard(StringRef Component) { + return PathComponentGuard(PathComponents, Component); +} + Object SymbolGraphSerializer::serialize() { Object Root; serializeObject(Root, "metadata", serializeMetadata()); @@ -617,7 +652,7 @@ serializeMacroDefinitionRecord(*Macro.second); Root["symbols"] = std::move(Symbols); - Root["relationhips"] = std::move(Relationships); + Root["relationships"] = std::move(Relationships); return Root; } diff --git a/clang/test/ExtractAPI/enum.c b/clang/test/ExtractAPI/enum.c --- a/clang/test/ExtractAPI/enum.c +++ b/clang/test/ExtractAPI/enum.c @@ -55,7 +55,7 @@ "vendor": "apple" } }, - "relationhips": [ + "relationships": [ { "kind": "memberOf", "source": "c:@E@Vehicle@Bicycle", @@ -104,6 +104,7 @@ ], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -153,8 +154,10 @@ "identifier": "c.enum" }, "location": { - "character": 6, - "line": 2, + "position": { + "character": 6, + "line": 2 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -165,9 +168,13 @@ } ], "title": "Vehicle" - } + }, + "pathComponents": [ + "Vehicle" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -183,8 +190,10 @@ "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 3, + "position": { + "character": 3, + "line": 3 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -195,9 +204,14 @@ } ], "title": "Bicycle" - } + }, + "pathComponents": [ + "Vehicle", + "Bicycle" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -213,8 +227,10 @@ "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 4, + "position": { + "character": 3, + "line": 4 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -225,9 +241,14 @@ } ], "title": "Car" - } + }, + "pathComponents": [ + "Vehicle", + "Car" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -260,8 +281,10 @@ "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 5, + "position": { + "character": 3, + "line": 5 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -272,9 +295,14 @@ } ], "title": "Train" - } + }, + "pathComponents": [ + "Vehicle", + "Train" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -290,8 +318,10 @@ "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 6, + "position": { + "character": 3, + "line": 6 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -302,9 +332,14 @@ } ], "title": "Ship" - } + }, + "pathComponents": [ + "Vehicle", + "Ship" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -320,8 +355,10 @@ "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 7, + "position": { + "character": 3, + "line": 7 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -332,9 +369,14 @@ } ], "title": "Airplane" - } + }, + "pathComponents": [ + "Vehicle", + "Airplane" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -367,8 +409,10 @@ "identifier": "c.enum" }, "location": { - "character": 6, - "line": 10, + "position": { + "character": 6, + "line": 10 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -379,9 +423,13 @@ } ], "title": "Direction" - } + }, + "pathComponents": [ + "Direction" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -397,8 +445,10 @@ "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 11, + "position": { + "character": 3, + "line": 11 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -409,9 +459,14 @@ } ], "title": "North" - } + }, + "pathComponents": [ + "Direction", + "North" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -427,8 +482,10 @@ "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 12, + "position": { + "character": 3, + "line": 12 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -439,9 +496,14 @@ } ], "title": "East" - } + }, + "pathComponents": [ + "Direction", + "East" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -457,8 +519,10 @@ "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 13, + "position": { + "character": 3, + "line": 13 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -469,9 +533,14 @@ } ], "title": "South" - } + }, + "pathComponents": [ + "Direction", + "South" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "identifier", @@ -487,8 +556,10 @@ "identifier": "c.enum.case" }, "location": { - "character": 3, - "line": 14, + "position": { + "character": 3, + "line": 14 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -499,7 +570,11 @@ } ], "title": "West" - } + }, + "pathComponents": [ + "Direction", + "West" + ] } ] } diff --git a/clang/test/ExtractAPI/global_record.c b/clang/test/ExtractAPI/global_record.c --- a/clang/test/ExtractAPI/global_record.c +++ b/clang/test/ExtractAPI/global_record.c @@ -51,9 +51,10 @@ "vendor": "apple" } }, - "relationhips": [], + "relationships": [], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -78,8 +79,10 @@ "identifier": "c.var" }, "location": { - "character": 5, - "line": 1, + "position": { + "character": 5, + "line": 1 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -90,9 +93,13 @@ } ], "title": "num" - } + }, + "pathComponents": [ + "num" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -261,29 +268,7 @@ } ] }, - "identifier": { - "interfaceLanguage": "c", - "precise": "c:@F@add" - }, - "kind": { - "displayName": "Function", - "identifier": "c.func" - }, - "location": { - "character": 6, - "line": 9, - "uri": "file://INPUT_DIR/input.h" - }, - "names": { - "subHeading": [ - { - "kind": "identifier", - "spelling": "add" - } - ], - "title": "add" - }, - "parameters": { + "functionSignature": { "parameters": [ { "declarationFragments": [ @@ -363,7 +348,34 @@ "spelling": "void" } ] - } + }, + "identifier": { + "interfaceLanguage": "c", + "precise": "c:@F@add" + }, + "kind": { + "displayName": "Function", + "identifier": "c.func" + }, + "location": { + "position": { + "character": 6, + "line": 9 + }, + "uri": "file://INPUT_DIR/input.h" + }, + "names": { + "subHeading": [ + { + "kind": "identifier", + "spelling": "add" + } + ], + "title": "add" + }, + "pathComponents": [ + "add" + ] } ] } diff --git a/clang/test/ExtractAPI/global_record_multifile.c b/clang/test/ExtractAPI/global_record_multifile.c --- a/clang/test/ExtractAPI/global_record_multifile.c +++ b/clang/test/ExtractAPI/global_record_multifile.c @@ -53,9 +53,10 @@ "vendor": "apple" } }, - "relationhips": [], + "relationships": [], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -80,8 +81,10 @@ "identifier": "c.var" }, "location": { - "character": 5, - "line": 1, + "position": { + "character": 5, + "line": 1 + }, "uri": "file://INPUT_DIR/input1.h" }, "names": { @@ -92,9 +95,13 @@ } ], "title": "num" - } + }, + "pathComponents": [ + "num" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -263,29 +270,7 @@ } ] }, - "identifier": { - "interfaceLanguage": "c", - "precise": "c:@F@add" - }, - "kind": { - "displayName": "Function", - "identifier": "c.func" - }, - "location": { - "character": 6, - "line": 7, - "uri": "file://INPUT_DIR/input2.h" - }, - "names": { - "subHeading": [ - { - "kind": "identifier", - "spelling": "add" - } - ], - "title": "add" - }, - "parameters": { + "functionSignature": { "parameters": [ { "declarationFragments": [ @@ -365,7 +350,34 @@ "spelling": "void" } ] - } + }, + "identifier": { + "interfaceLanguage": "c", + "precise": "c:@F@add" + }, + "kind": { + "displayName": "Function", + "identifier": "c.func" + }, + "location": { + "position": { + "character": 6, + "line": 7 + }, + "uri": "file://INPUT_DIR/input2.h" + }, + "names": { + "subHeading": [ + { + "kind": "identifier", + "spelling": "add" + } + ], + "title": "add" + }, + "pathComponents": [ + "add" + ] } ] } diff --git a/clang/test/ExtractAPI/language.c b/clang/test/ExtractAPI/language.c --- a/clang/test/ExtractAPI/language.c +++ b/clang/test/ExtractAPI/language.c @@ -53,9 +53,10 @@ "vendor": "apple" } }, - "relationhips": [], + "relationships": [], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -80,8 +81,10 @@ "identifier": "c.var" }, "location": { - "character": 6, - "line": 1, + "position": { + "character": 6, + "line": 1 + }, "uri": "file://INPUT_DIR/c.h" }, "names": { @@ -92,7 +95,10 @@ } ], "title": "c" - } + }, + "pathComponents": [ + "c" + ] } ] } @@ -121,9 +127,10 @@ "vendor": "apple" } }, - "relationhips": [], + "relationships": [], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -148,8 +155,10 @@ "identifier": "objective-c.var" }, "location": { - "character": 6, - "line": 1, + "position": { + "character": 6, + "line": 1 + }, "uri": "file://INPUT_DIR/objc.h" }, "names": { @@ -160,7 +169,10 @@ } ], "title": "objc" - } + }, + "pathComponents": [ + "objc" + ] } ] } diff --git a/clang/test/ExtractAPI/macro_undefined.c b/clang/test/ExtractAPI/macro_undefined.c --- a/clang/test/ExtractAPI/macro_undefined.c +++ b/clang/test/ExtractAPI/macro_undefined.c @@ -47,9 +47,10 @@ "vendor": "apple" } }, - "relationhips": [], + "relationships": [], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -69,6 +70,15 @@ "spelling": "()" } ], + "functionSignature": { + "returns": [ + { + "kind": "typeIdentifier", + "preciseIdentifier": "c:v", + "spelling": "void" + } + ] + }, "identifier": { "interfaceLanguage": "objective-c", "precise": "c:@F@foo" @@ -78,8 +88,10 @@ "identifier": "objective-c.func" }, "location": { - "character": 1, - "line": 3, + "position": { + "character": 1, + "line": 3 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -91,17 +103,12 @@ ], "title": "foo" }, - "parameters": { - "returns": [ - { - "kind": "typeIdentifier", - "preciseIdentifier": "c:v", - "spelling": "void" - } - ] - } + "pathComponents": [ + "foo" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -163,29 +170,7 @@ "spelling": ")" } ], - "identifier": { - "interfaceLanguage": "objective-c", - "precise": "c:@F@bar" - }, - "kind": { - "displayName": "Function", - "identifier": "objective-c.func" - }, - "location": { - "character": 1, - "line": 4, - "uri": "file://INPUT_DIR/input.h" - }, - "names": { - "subHeading": [ - { - "kind": "identifier", - "spelling": "bar" - } - ], - "title": "bar" - }, - "parameters": { + "functionSignature": { "parameters": [ { "declarationFragments": [ @@ -239,9 +224,37 @@ "spelling": "void" } ] - } + }, + "identifier": { + "interfaceLanguage": "objective-c", + "precise": "c:@F@bar" + }, + "kind": { + "displayName": "Function", + "identifier": "objective-c.func" + }, + "location": { + "position": { + "character": 1, + "line": 4 + }, + "uri": "file://INPUT_DIR/input.h" + }, + "names": { + "subHeading": [ + { + "kind": "identifier", + "spelling": "bar" + } + ], + "title": "bar" + }, + "pathComponents": [ + "bar" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -265,8 +278,10 @@ "identifier": "objective-c.macro" }, "location": { - "character": 9, - "line": 1, + "position": { + "character": 9, + "line": 1 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -277,7 +292,10 @@ } ], "title": "HELLO" - } + }, + "pathComponents": [ + "HELLO" + ] } ] } diff --git a/clang/test/ExtractAPI/macros.c b/clang/test/ExtractAPI/macros.c --- a/clang/test/ExtractAPI/macros.c +++ b/clang/test/ExtractAPI/macros.c @@ -46,9 +46,10 @@ "vendor": "apple" } }, - "relationhips": [], + "relationships": [], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -72,8 +73,10 @@ "identifier": "objective-c.macro" }, "location": { - "character": 9, - "line": 1, + "position": { + "character": 9, + "line": 1 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -84,9 +87,13 @@ } ], "title": "HELLO" - } + }, + "pathComponents": [ + "HELLO" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -110,8 +117,10 @@ "identifier": "objective-c.macro" }, "location": { - "character": 9, - "line": 2, + "position": { + "character": 9, + "line": 2 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -122,9 +131,13 @@ } ], "title": "WORLD" - } + }, + "pathComponents": [ + "WORLD" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -160,8 +173,10 @@ "identifier": "objective-c.macro" }, "location": { - "character": 9, - "line": 3, + "position": { + "character": 9, + "line": 3 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -172,9 +187,13 @@ } ], "title": "MACRO_FUN" - } + }, + "pathComponents": [ + "MACRO_FUN" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -226,8 +245,10 @@ "identifier": "objective-c.macro" }, "location": { - "character": 9, - "line": 4, + "position": { + "character": 9, + "line": 4 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -238,9 +259,13 @@ } ], "title": "FUN" - } + }, + "pathComponents": [ + "FUN" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -276,8 +301,10 @@ "identifier": "objective-c.macro" }, "location": { - "character": 9, - "line": 5, + "position": { + "character": 9, + "line": 5 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -288,9 +315,13 @@ } ], "title": "FUNC99" - } + }, + "pathComponents": [ + "FUNC99" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -326,8 +357,10 @@ "identifier": "objective-c.macro" }, "location": { - "character": 9, - "line": 6, + "position": { + "character": 9, + "line": 6 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -338,7 +371,10 @@ } ], "title": "FUNGNU" - } + }, + "pathComponents": [ + "FUNGNU" + ] } ] } diff --git a/clang/test/ExtractAPI/objc_interface.m b/clang/test/ExtractAPI/objc_interface.m --- a/clang/test/ExtractAPI/objc_interface.m +++ b/clang/test/ExtractAPI/objc_interface.m @@ -52,7 +52,7 @@ "vendor": "apple" } }, - "relationhips": [ + "relationships": [ { "kind": "memberOf", "source": "c:objc(cs)Super(cm)getWithProperty:", @@ -86,6 +86,7 @@ ], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -109,8 +110,10 @@ "identifier": "objective-c.class" }, "location": { - "character": 12, - "line": 3, + "position": { + "character": 12, + "line": 3 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -121,9 +124,13 @@ } ], "title": "Super" - } + }, + "pathComponents": [ + "Super" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "text", @@ -172,8 +179,10 @@ "identifier": "objective-c.type.method" }, "location": { - "character": 1, - "line": 5, + "position": { + "character": 1, + "line": 5 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -188,9 +197,14 @@ } ], "title": "getWithProperty:" - } + }, + "pathComponents": [ + "Super", + "getWithProperty:" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -251,8 +265,10 @@ "identifier": "objective-c.property" }, "location": { - "character": 50, - "line": 4, + "position": { + "character": 50, + "line": 4 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -263,9 +279,14 @@ } ], "title": "Property" - } + }, + "pathComponents": [ + "Super", + "Property" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -298,8 +319,10 @@ "identifier": "objective-c.class" }, "location": { - "character": 12, - "line": 8, + "position": { + "character": 12, + "line": 8 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -310,9 +333,13 @@ } ], "title": "Derived" - } + }, + "pathComponents": [ + "Derived" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -337,8 +364,10 @@ "identifier": "objective-c.ivar" }, "location": { - "character": 8, - "line": 9, + "position": { + "character": 8, + "line": 9 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -349,9 +378,14 @@ } ], "title": "Ivar" - } + }, + "pathComponents": [ + "Derived", + "Ivar" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "text", @@ -380,8 +414,10 @@ "identifier": "objective-c.method" }, "location": { - "character": 1, - "line": 11, + "position": { + "character": 1, + "line": 11 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -396,7 +432,11 @@ } ], "title": "getIvar" - } + }, + "pathComponents": [ + "Derived", + "getIvar" + ] } ] } diff --git a/clang/test/ExtractAPI/objc_protocol.m b/clang/test/ExtractAPI/objc_protocol.m --- a/clang/test/ExtractAPI/objc_protocol.m +++ b/clang/test/ExtractAPI/objc_protocol.m @@ -45,7 +45,7 @@ "vendor": "apple" } }, - "relationhips": [ + "relationships": [ { "kind": "conformsTo", "source": "c:objc(pl)AnotherProtocol", @@ -54,6 +54,7 @@ ], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -77,8 +78,10 @@ "identifier": "objective-c.protocol" }, "location": { - "character": 11, - "line": 1, + "position": { + "character": 11, + "line": 1 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -89,9 +92,13 @@ } ], "title": "Protocol" - } + }, + "pathComponents": [ + "Protocol" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -128,8 +135,10 @@ "identifier": "objective-c.protocol" }, "location": { - "character": 11, - "line": 4, + "position": { + "character": 11, + "line": 4 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -140,7 +149,10 @@ } ], "title": "AnotherProtocol" - } + }, + "pathComponents": [ + "AnotherProtocol" + ] } ] } diff --git a/clang/test/ExtractAPI/struct.c b/clang/test/ExtractAPI/struct.c --- a/clang/test/ExtractAPI/struct.c +++ b/clang/test/ExtractAPI/struct.c @@ -48,7 +48,7 @@ "vendor": "apple" } }, - "relationhips": [ + "relationships": [ { "kind": "memberOf", "source": "c:@S@Color@FI@Red", @@ -72,6 +72,7 @@ ], "symbols": [ { + "accessLevel": "public", "declarationFragments": [ { "kind": "keyword", @@ -112,8 +113,10 @@ "identifier": "c.struct" }, "location": { - "character": 8, - "line": 2, + "position": { + "character": 8, + "line": 2 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -124,9 +127,13 @@ } ], "title": "Color" - } + }, + "pathComponents": [ + "Color" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -151,8 +158,10 @@ "identifier": "c.property" }, "location": { - "character": 12, - "line": 3, + "position": { + "character": 12, + "line": 3 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -163,9 +172,14 @@ } ], "title": "Red" - } + }, + "pathComponents": [ + "Color", + "Red" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -190,8 +204,10 @@ "identifier": "c.property" }, "location": { - "character": 12, - "line": 4, + "position": { + "character": 12, + "line": 4 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -202,9 +218,14 @@ } ], "title": "Green" - } + }, + "pathComponents": [ + "Color", + "Green" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -229,8 +250,10 @@ "identifier": "c.property" }, "location": { - "character": 12, - "line": 5, + "position": { + "character": 12, + "line": 5 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -241,9 +264,14 @@ } ], "title": "Blue" - } + }, + "pathComponents": [ + "Color", + "Blue" + ] }, { + "accessLevel": "public", "declarationFragments": [ { "kind": "typeIdentifier", @@ -285,8 +313,10 @@ "identifier": "c.property" }, "location": { - "character": 12, - "line": 7, + "position": { + "character": 12, + "line": 7 + }, "uri": "file://INPUT_DIR/input.h" }, "names": { @@ -297,7 +327,11 @@ } ], "title": "Alpha" - } + }, + "pathComponents": [ + "Color", + "Alpha" + ] } ] }