diff --git a/third-party/thrift/src/thrift/lib/thrift/ast.thrift b/third-party/thrift/src/thrift/lib/thrift/ast.thrift index c9db14a748a356..d4b9cc006edff9 100644 --- a/third-party/thrift/src/thrift/lib/thrift/ast.thrift +++ b/third-party/thrift/src/thrift/lib/thrift/ast.thrift @@ -15,12 +15,81 @@ */ include "thrift/lib/thrift/schema.thrift" +include "thrift/lib/thrift/standard.thrift" +include "thrift/lib/thrift/protocol.thrift" +include "thrift/lib/thrift/id.thrift" namespace py3 apache.thrift namespace rust thrift_ast -/** This file has been merged into schema.thrift. Please include it and use its types directly. */ -typedef schema.SourceInfo SourceInfo -typedef schema.IdentifierRef IdentifierRef -typedef schema.IncludeRef IncludeRef -typedef schema.Schema Ast +/** + * Information about a thrift source file. + */ +struct SourceInfo { + // A source file name. It can include directory components and/or be a + // virtual file name that doesn't have a correspondent entry in the system's + // directory structure. + // Preserves the legacy behavior of sometimes leaking resolved relative paths. + // The unmodified path is available inside schema.Program. + 1: string fileName; + + /** + * Per-language include statements. + */ + 2: map> languageIncludes; + + /** + * Per-language namespace. + */ + 3: map namespaces; +} + +// An instance of an identifier in a source file. +struct IdentifierRef { + 1: schema.SourceRange range; + 2: standard.TypeUri uri; + // Because enum values don't have URIs, references to them have to point to their owning enum. + // When that happens this field identifies the particular value being referenced. + 3: string enumValue; +} + +// An instance of an include in a source file. +struct IncludeRef { + 1: schema.SourceRange range; + 2: id.ProgramId target; +} + +// A thrift schema that corresponds to one or more thrift files. +@cpp.UseOpEncode +struct Ast { + /** + * The programs included in the schema, accessible by `ProgramId`. + * The first program in the program list must be the main file, + * with (recursively) included programs listed after it. + */ + 1: schema.ProgramList programs; + + /** The values, accessible by `ValueId`. */ + 2: list values; + + /** The definitions, accessible by `DefinitionId`. */ + 4: schema.DefinitionList definitions; + + /** + * DEPRECATED! Get the information from the Program struct. + * Information about the files holding the thrift definitions. + */ + 5: map sources; + + /** + * The source ranges of all references to named entities in the main program. + * The `source_ranges` option must be passed to thrift2ast to populate this map. + */ + 6: list identifierSourceRanges; + + /** + * The source ranges of paths included in the main program. + * The `source_ranges` option must be passed to thrift2ast to populate this map. + */ + 7: list includeSourceRanges; +} diff --git a/third-party/thrift/src/thrift/lib/thrift/schema.thrift b/third-party/thrift/src/thrift/lib/thrift/schema.thrift index 70de4196991c90..a4a5b2e06ec933 100644 --- a/third-party/thrift/src/thrift/lib/thrift/schema.thrift +++ b/third-party/thrift/src/thrift/lib/thrift/schema.thrift @@ -698,71 +698,12 @@ typedef list ProgramList @thrift.Experimental // TODO(afuller): Adapt! @cpp.UseOpEncode struct Schema { - /** - * The programs included in the schema, accessible by `ProgramId`. - * The first program in the program list must be the main file, - * with (recursively) included programs listed after it. - */ + /** The programs included in the schema, accessible by `ProgramId`. */ 1: ProgramList programs; /** The values, accessible by `ValueId`. */ - 2: list values; + 3: list values; /** The definitions, accessible by `DefinitionId`. */ - 3: DefinitionList definitions; - - /** - * DEPRECATED! Get the information from the Program struct. - * Information about the files holding the thrift definitions. - */ - 5: map sources; - - /** - * The source ranges of all references to named entities in the main program. - * The `source_ranges` option must be passed to thrift2ast to populate this map. - */ - 6: list identifierSourceRanges; - - /** - * The source ranges of paths included in the main program. - * The `source_ranges` option must be passed to thrift2ast to populate this map. - */ - 7: list includeSourceRanges; -} - -/** - * Information about a thrift source file. - */ -struct SourceInfo { - // A source file name. It can include directory components and/or be a - // virtual file name that doesn't have a correspondent entry in the system's - // directory structure. - // Preserves the legacy behavior of sometimes leaking resolved relative paths. - // The unmodified path is available inside schema.Program. - 1: string fileName; - - /** - * Per-language include statements. - */ - 2: map> languageIncludes; - - /** - * Per-language namespace. - */ - 3: map namespaces; -} - -// An instance of an identifier in a source file. -struct IdentifierRef { - 1: SourceRange range; - 2: standard.TypeUri uri; - // Because enum values don't have URIs, references to them have to point to their owning enum. - // When that happens this field identifies the particular value being referenced. - 3: string enumValue; -} - -// An instance of an include in a source file. -struct IncludeRef { - 1: SourceRange range; - 2: id.ProgramId target; + 5: DefinitionList definitions; }