|
15 | 15 | */
|
16 | 16 |
|
17 | 17 | include "thrift/lib/thrift/schema.thrift"
|
| 18 | +include "thrift/lib/thrift/standard.thrift" |
| 19 | +include "thrift/lib/thrift/protocol.thrift" |
| 20 | +include "thrift/lib/thrift/id.thrift" |
18 | 21 |
|
19 | 22 | namespace py3 apache.thrift
|
20 | 23 | namespace rust thrift_ast
|
21 | 24 |
|
22 |
| -/** This file has been merged into schema.thrift. Please include it and use its types directly. */ |
23 |
| -typedef schema.SourceInfo SourceInfo |
24 |
| -typedef schema.IdentifierRef IdentifierRef |
25 |
| -typedef schema.IncludeRef IncludeRef |
26 |
| -typedef schema.Schema Ast |
| 25 | +/** |
| 26 | + * Information about a thrift source file. |
| 27 | + */ |
| 28 | +struct SourceInfo { |
| 29 | + // A source file name. It can include directory components and/or be a |
| 30 | + // virtual file name that doesn't have a correspondent entry in the system's |
| 31 | + // directory structure. |
| 32 | + // Preserves the legacy behavior of sometimes leaking resolved relative paths. |
| 33 | + // The unmodified path is available inside schema.Program. |
| 34 | + 1: string fileName; |
| 35 | + |
| 36 | + /** |
| 37 | + * Per-language include statements. |
| 38 | + */ |
| 39 | + 2: map<string, list<id.ValueId>> languageIncludes; |
| 40 | + |
| 41 | + /** |
| 42 | + * Per-language namespace. |
| 43 | + */ |
| 44 | + 3: map<string, id.ValueId> namespaces; |
| 45 | +} |
| 46 | + |
| 47 | +// An instance of an identifier in a source file. |
| 48 | +struct IdentifierRef { |
| 49 | + 1: schema.SourceRange range; |
| 50 | + 2: standard.TypeUri uri; |
| 51 | + // Because enum values don't have URIs, references to them have to point to their owning enum. |
| 52 | + // When that happens this field identifies the particular value being referenced. |
| 53 | + 3: string enumValue; |
| 54 | +} |
| 55 | + |
| 56 | +// An instance of an include in a source file. |
| 57 | +struct IncludeRef { |
| 58 | + 1: schema.SourceRange range; |
| 59 | + 2: id.ProgramId target; |
| 60 | +} |
| 61 | + |
| 62 | +// A thrift schema that corresponds to one or more thrift files. |
| 63 | +@cpp.UseOpEncode |
| 64 | +struct Ast { |
| 65 | + /** |
| 66 | + * The programs included in the schema, accessible by `ProgramId`. |
| 67 | + * The first program in the program list must be the main file, |
| 68 | + * with (recursively) included programs listed after it. |
| 69 | + */ |
| 70 | + 1: schema.ProgramList programs; |
| 71 | + |
| 72 | + /** The values, accessible by `ValueId`. */ |
| 73 | + 2: list<protocol.Value> values; |
| 74 | + |
| 75 | + /** The definitions, accessible by `DefinitionId`. */ |
| 76 | + 4: schema.DefinitionList definitions; |
| 77 | + |
| 78 | + /** |
| 79 | + * DEPRECATED! Get the information from the Program struct. |
| 80 | + * Information about the files holding the thrift definitions. |
| 81 | + */ |
| 82 | + 5: map<id.ProgramId, SourceInfo> sources; |
| 83 | + |
| 84 | + /** |
| 85 | + * The source ranges of all references to named entities in the main program. |
| 86 | + * The `source_ranges` option must be passed to thrift2ast to populate this map. |
| 87 | + */ |
| 88 | + 6: list<IdentifierRef> identifierSourceRanges; |
| 89 | + |
| 90 | + /** |
| 91 | + * The source ranges of paths included in the main program. |
| 92 | + * The `source_ranges` option must be passed to thrift2ast to populate this map. |
| 93 | + */ |
| 94 | + 7: list<IncludeRef> includeSourceRanges; |
| 95 | +} |
0 commit comments