protostar 0.1.0.beta1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +60 -0
  3. data/LICENSE.txt +21 -0
  4. data/README.md +647 -0
  5. data/THIRD_PARTY_NOTICES.md +61 -0
  6. data/exe/protoc-gen-protostar +7 -0
  7. data/exe/protostar +7 -0
  8. data/lib/protostar/builder/generator.rb +71 -0
  9. data/lib/protostar/builder/sink.rb +35 -0
  10. data/lib/protostar/builder.rb +965 -0
  11. data/lib/protostar/cli.rb +267 -0
  12. data/lib/protostar/codec/decode_generator.rb +199 -0
  13. data/lib/protostar/codec/decoder.rb +296 -0
  14. data/lib/protostar/codec/encode_generator.rb +224 -0
  15. data/lib/protostar/codec/encoder.rb +121 -0
  16. data/lib/protostar/codec/sizer.rb +91 -0
  17. data/lib/protostar/codec.rb +15 -0
  18. data/lib/protostar/compiler/ast.rb +193 -0
  19. data/lib/protostar/compiler/emitters/descriptor_set.rb +57 -0
  20. data/lib/protostar/compiler/emitters/google_ruby.rb +103 -0
  21. data/lib/protostar/compiler/emitters/grpc.rb +175 -0
  22. data/lib/protostar/compiler/emitters/protostar_rbs.rb +252 -0
  23. data/lib/protostar/compiler/emitters/rbs.rb +394 -0
  24. data/lib/protostar/compiler/emitters/ruby.rb +503 -0
  25. data/lib/protostar/compiler/emitters.rb +268 -0
  26. data/lib/protostar/compiler/include/LICENSE +32 -0
  27. data/lib/protostar/compiler/include/google/protobuf/any.proto +106 -0
  28. data/lib/protostar/compiler/include/google/protobuf/api.proto +229 -0
  29. data/lib/protostar/compiler/include/google/protobuf/compiler/plugin.proto +180 -0
  30. data/lib/protostar/compiler/include/google/protobuf/cpp_features.proto +87 -0
  31. data/lib/protostar/compiler/include/google/protobuf/descriptor.proto +1532 -0
  32. data/lib/protostar/compiler/include/google/protobuf/duration.proto +115 -0
  33. data/lib/protostar/compiler/include/google/protobuf/empty.proto +51 -0
  34. data/lib/protostar/compiler/include/google/protobuf/field_mask.proto +243 -0
  35. data/lib/protostar/compiler/include/google/protobuf/java_features.proto +132 -0
  36. data/lib/protostar/compiler/include/google/protobuf/source_context.proto +48 -0
  37. data/lib/protostar/compiler/include/google/protobuf/struct.proto +111 -0
  38. data/lib/protostar/compiler/include/google/protobuf/timestamp.proto +145 -0
  39. data/lib/protostar/compiler/include/google/protobuf/type.proto +217 -0
  40. data/lib/protostar/compiler/include/google/protobuf/wrappers.proto +157 -0
  41. data/lib/protostar/compiler/lexer.rb +659 -0
  42. data/lib/protostar/compiler/linker.rb +894 -0
  43. data/lib/protostar/compiler/option_interpreter.rb +363 -0
  44. data/lib/protostar/compiler/parser.rb +1696 -0
  45. data/lib/protostar/compiler/retention.rb +104 -0
  46. data/lib/protostar/compiler/run.rb +184 -0
  47. data/lib/protostar/compiler/source_info.rb +161 -0
  48. data/lib/protostar/compiler/symbol_table.rb +223 -0
  49. data/lib/protostar/compiler/text_format.rb +340 -0
  50. data/lib/protostar/compiler/validator.rb +944 -0
  51. data/lib/protostar/compiler.rb +304 -0
  52. data/lib/protostar/diagnostics/codes.rb +1307 -0
  53. data/lib/protostar/diagnostics/formats.rb +64 -0
  54. data/lib/protostar/diagnostics/renderer.rb +240 -0
  55. data/lib/protostar/diagnostics/source.rb +153 -0
  56. data/lib/protostar/diagnostics.rb +117 -0
  57. data/lib/protostar/dsl.rb +367 -0
  58. data/lib/protostar/enum.rb +70 -0
  59. data/lib/protostar/errors.rb +23 -0
  60. data/lib/protostar/google/protobuf/any_pb.rb +90 -0
  61. data/lib/protostar/google/protobuf/api_pb.rb +199 -0
  62. data/lib/protostar/google/protobuf/compiler/plugin_pb.rb +168 -0
  63. data/lib/protostar/google/protobuf/descriptor_pb.rb +1239 -0
  64. data/lib/protostar/google/protobuf/duration_pb.rb +99 -0
  65. data/lib/protostar/google/protobuf/empty_pb.rb +36 -0
  66. data/lib/protostar/google/protobuf/field_mask_pb.rb +228 -0
  67. data/lib/protostar/google/protobuf/source_context_pb.rb +33 -0
  68. data/lib/protostar/google/protobuf/struct_pb.rb +91 -0
  69. data/lib/protostar/google/protobuf/timestamp_pb.rb +129 -0
  70. data/lib/protostar/google/protobuf/type_pb.rb +202 -0
  71. data/lib/protostar/google/protobuf/wrappers_pb.rb +125 -0
  72. data/lib/protostar/google_protobuf_shim.rb +24 -0
  73. data/lib/protostar/json/encoder.rb +340 -0
  74. data/lib/protostar/json/errors.rb +34 -0
  75. data/lib/protostar/json/parser.rb +437 -0
  76. data/lib/protostar/json/path.rb +39 -0
  77. data/lib/protostar/json.rb +95 -0
  78. data/lib/protostar/lint/command.rb +197 -0
  79. data/lib/protostar/lint/config.rb +98 -0
  80. data/lib/protostar/lint/context.rb +126 -0
  81. data/lib/protostar/lint/directives.rb +56 -0
  82. data/lib/protostar/lint/fixer.rb +165 -0
  83. data/lib/protostar/lint/naming.rb +54 -0
  84. data/lib/protostar/lint/rule.rb +120 -0
  85. data/lib/protostar/lint/rules/comment_enum.rb +31 -0
  86. data/lib/protostar/lint/rules/comment_enum_value.rb +32 -0
  87. data/lib/protostar/lint/rules/comment_field.rb +33 -0
  88. data/lib/protostar/lint/rules/comment_message.rb +31 -0
  89. data/lib/protostar/lint/rules/comment_rpc.rb +31 -0
  90. data/lib/protostar/lint/rules/comment_service.rb +31 -0
  91. data/lib/protostar/lint/rules/edition_recommended.rb +31 -0
  92. data/lib/protostar/lint/rules/enum_first_value_zero.rb +34 -0
  93. data/lib/protostar/lint/rules/enum_pascal_case.rb +25 -0
  94. data/lib/protostar/lint/rules/enum_value_prefix.rb +38 -0
  95. data/lib/protostar/lint/rules/enum_value_upper_snake_case.rb +28 -0
  96. data/lib/protostar/lint/rules/enum_zero_value_suffix.rb +41 -0
  97. data/lib/protostar/lint/rules/field_lower_snake_case.rb +34 -0
  98. data/lib/protostar/lint/rules/field_not_required.rb +39 -0
  99. data/lib/protostar/lint/rules/field_number_reuse_risk.rb +45 -0
  100. data/lib/protostar/lint/rules/field_numbers_hot_range.rb +44 -0
  101. data/lib/protostar/lint/rules/file_lower_snake_case.rb +27 -0
  102. data/lib/protostar/lint/rules/import_no_public.rb +29 -0
  103. data/lib/protostar/lint/rules/import_no_weak.rb +28 -0
  104. data/lib/protostar/lint/rules/import_used.rb +33 -0
  105. data/lib/protostar/lint/rules/message_pascal_case.rb +27 -0
  106. data/lib/protostar/lint/rules/no_deprecated_features.rb +50 -0
  107. data/lib/protostar/lint/rules/no_groups.rb +34 -0
  108. data/lib/protostar/lint/rules/oneof_lower_snake_case.rb +27 -0
  109. data/lib/protostar/lint/rules/package_defined.rb +28 -0
  110. data/lib/protostar/lint/rules/package_directory_match.rb +33 -0
  111. data/lib/protostar/lint/rules/package_lower_snake_case.rb +28 -0
  112. data/lib/protostar/lint/rules/package_same_directory.rb +39 -0
  113. data/lib/protostar/lint/rules/package_version_suffix.rb +31 -0
  114. data/lib/protostar/lint/rules/reserved_names_with_numbers.rb +44 -0
  115. data/lib/protostar/lint/rules/rpc_pascal_case.rb +25 -0
  116. data/lib/protostar/lint/rules/rpc_request_response_unique.rb +40 -0
  117. data/lib/protostar/lint/rules/rpc_request_standard_name.rb +32 -0
  118. data/lib/protostar/lint/rules/rpc_response_standard_name.rb +31 -0
  119. data/lib/protostar/lint/rules/service_pascal_case.rb +25 -0
  120. data/lib/protostar/lint/rules/service_suffix.rb +28 -0
  121. data/lib/protostar/lint/rules/syntax_specified.rb +35 -0
  122. data/lib/protostar/lint/runner.rb +135 -0
  123. data/lib/protostar/lint.rb +122 -0
  124. data/lib/protostar/message/accessors.rb +86 -0
  125. data/lib/protostar/message/coercion.rb +171 -0
  126. data/lib/protostar/message/field_info.rb +145 -0
  127. data/lib/protostar/message/reflection.rb +149 -0
  128. data/lib/protostar/message.rb +572 -0
  129. data/lib/protostar/plugin.rb +94 -0
  130. data/lib/protostar/schema/default_value.rb +113 -0
  131. data/lib/protostar/schema/descriptor.rb +41 -0
  132. data/lib/protostar/schema/draft/copy.rb +88 -0
  133. data/lib/protostar/schema/draft/resolution.rb +177 -0
  134. data/lib/protostar/schema/draft.rb +779 -0
  135. data/lib/protostar/schema/enum.rb +106 -0
  136. data/lib/protostar/schema/extension_range.rb +37 -0
  137. data/lib/protostar/schema/features.rb +153 -0
  138. data/lib/protostar/schema/field.rb +201 -0
  139. data/lib/protostar/schema/file.rb +217 -0
  140. data/lib/protostar/schema/freezer.rb +61 -0
  141. data/lib/protostar/schema/message.rb +104 -0
  142. data/lib/protostar/schema/oneof.rb +38 -0
  143. data/lib/protostar/schema/options.rb +367 -0
  144. data/lib/protostar/schema/pool.rb +179 -0
  145. data/lib/protostar/schema/proto.rb +576 -0
  146. data/lib/protostar/schema/resolver.rb +118 -0
  147. data/lib/protostar/schema/service.rb +89 -0
  148. data/lib/protostar/schema/source_info.rb +53 -0
  149. data/lib/protostar/schema.rb +65 -0
  150. data/lib/protostar/short_names/any.rb +7 -0
  151. data/lib/protostar/short_names/duration.rb +7 -0
  152. data/lib/protostar/short_names/empty.rb +7 -0
  153. data/lib/protostar/short_names/field_mask.rb +7 -0
  154. data/lib/protostar/short_names/struct.rb +9 -0
  155. data/lib/protostar/short_names/timestamp.rb +7 -0
  156. data/lib/protostar/short_names/wrappers.rb +15 -0
  157. data/lib/protostar/text/extensions.rb +114 -0
  158. data/lib/protostar/text/parser.rb +439 -0
  159. data/lib/protostar/text/printer.rb +304 -0
  160. data/lib/protostar/text/tokenizer.rb +116 -0
  161. data/lib/protostar/text.rb +67 -0
  162. data/lib/protostar/types.rb +152 -0
  163. data/lib/protostar/unknown_field.rb +58 -0
  164. data/lib/protostar/version.rb +5 -0
  165. data/lib/protostar/view/generator.rb +298 -0
  166. data/lib/protostar/view/map.rb +194 -0
  167. data/lib/protostar/view/repeated.rb +143 -0
  168. data/lib/protostar/view/scan.rb +183 -0
  169. data/lib/protostar/view.rb +283 -0
  170. data/lib/protostar/well_known/any.rb +52 -0
  171. data/lib/protostar/well_known/duration.rb +53 -0
  172. data/lib/protostar/well_known/list_value.rb +63 -0
  173. data/lib/protostar/well_known/struct.rb +55 -0
  174. data/lib/protostar/well_known/timestamp.rb +64 -0
  175. data/lib/protostar/well_known/value.rb +60 -0
  176. data/lib/protostar/well_known.rb +38 -0
  177. data/lib/protostar/wire/io_source.rb +40 -0
  178. data/lib/protostar/wire/reader.rb +254 -0
  179. data/lib/protostar/wire/writer.rb +201 -0
  180. data/lib/protostar/wire.rb +96 -0
  181. data/lib/protostar.rb +95 -0
  182. data/shims/google-protobuf/lib/google/protobuf/any_pb.rb +17 -0
  183. data/shims/google-protobuf/lib/google/protobuf/api_pb.rb +22 -0
  184. data/shims/google-protobuf/lib/google/protobuf/compiler/plugin_pb.rb +25 -0
  185. data/shims/google-protobuf/lib/google/protobuf/descriptor_pb.rb +72 -0
  186. data/shims/google-protobuf/lib/google/protobuf/descriptor_pool.rb +164 -0
  187. data/shims/google-protobuf/lib/google/protobuf/descriptors.rb +553 -0
  188. data/shims/google-protobuf/lib/google/protobuf/duration_pb.rb +17 -0
  189. data/shims/google-protobuf/lib/google/protobuf/empty_pb.rb +17 -0
  190. data/shims/google-protobuf/lib/google/protobuf/field_mask_pb.rb +17 -0
  191. data/shims/google-protobuf/lib/google/protobuf/internal/convert.rb +180 -0
  192. data/shims/google-protobuf/lib/google/protobuf/internal/extensions.rb +154 -0
  193. data/shims/google-protobuf/lib/google/protobuf/internal/json.rb +104 -0
  194. data/shims/google-protobuf/lib/google/protobuf/internal/well_known.rb +140 -0
  195. data/shims/google-protobuf/lib/google/protobuf/map.rb +216 -0
  196. data/shims/google-protobuf/lib/google/protobuf/message.rb +544 -0
  197. data/shims/google-protobuf/lib/google/protobuf/message_exts.rb +41 -0
  198. data/shims/google-protobuf/lib/google/protobuf/plugin_pb.rb +4 -0
  199. data/shims/google-protobuf/lib/google/protobuf/repeated_field.rb +366 -0
  200. data/shims/google-protobuf/lib/google/protobuf/source_context_pb.rb +17 -0
  201. data/shims/google-protobuf/lib/google/protobuf/struct_pb.rb +20 -0
  202. data/shims/google-protobuf/lib/google/protobuf/timestamp_pb.rb +17 -0
  203. data/shims/google-protobuf/lib/google/protobuf/type_pb.rb +27 -0
  204. data/shims/google-protobuf/lib/google/protobuf/well_known_types.rb +37 -0
  205. data/shims/google-protobuf/lib/google/protobuf/wrappers_pb.rb +25 -0
  206. data/shims/google-protobuf/lib/google/protobuf.rb +107 -0
  207. data/shims/google-protobuf/lib/google/protobuf_ffi.rb +5 -0
  208. data/shims/google-protobuf/lib/google/protobuf_native.rb +5 -0
  209. data/sig/protostar/google/protobuf/any_pb.rbs +77 -0
  210. data/sig/protostar/google/protobuf/api_pb.rbs +242 -0
  211. data/sig/protostar/google/protobuf/compiler/plugin_pb.rbs +264 -0
  212. data/sig/protostar/google/protobuf/descriptor_pb.rbs +2220 -0
  213. data/sig/protostar/google/protobuf/duration_pb.rbs +82 -0
  214. data/sig/protostar/google/protobuf/empty_pb.rbs +18 -0
  215. data/sig/protostar/google/protobuf/field_mask_pb.rbs +170 -0
  216. data/sig/protostar/google/protobuf/source_context_pb.rbs +24 -0
  217. data/sig/protostar/google/protobuf/struct_pb.rbs +135 -0
  218. data/sig/protostar/google/protobuf/timestamp_pb.rbs +102 -0
  219. data/sig/protostar/google/protobuf/type_pb.rbs +304 -0
  220. data/sig/protostar/google/protobuf/wrappers_pb.rbs +169 -0
  221. data/sig/protostar/lint.rbs +216 -0
  222. data/sig/protostar.rbs +326 -0
  223. metadata +366 -0
@@ -0,0 +1,304 @@
1
+ # Generated by protostar from google/protobuf/type.proto. Do not edit.
2
+
3
+ module Protostar
4
+ module Google
5
+ module Protobuf
6
+ # A protocol buffer message type.
7
+ # New usages of this message as an alternative to DescriptorProto are strongly
8
+ # discouraged. This message does not reliability preserve all information
9
+ # necessary to model the schema and preserve semantics. Instead make use of
10
+ # FileDescriptorSet which preserves the necessary information.
11
+ class Type < ::Protostar::Message
12
+ type init_map = {
13
+ ?name: ::String?,
14
+ ?fields: (::Array[::Protostar::Google::Protobuf::Field | ::Protostar::Google::Protobuf::Field::init_map])?,
15
+ ?oneofs: ::Array[::String]?,
16
+ ?options: (::Array[::Protostar::Google::Protobuf::Option | ::Protostar::Google::Protobuf::Option::init_map])?,
17
+ ?source_context: (::Protostar::Google::Protobuf::SourceContext | ::Protostar::Google::Protobuf::SourceContext::init_map)?,
18
+ ?syntax: (::Protostar::Google::Protobuf::Syntax::names | ::Integer)?,
19
+ ?edition: ::String?
20
+ }
21
+ def initialize: (
22
+ ?init_map? fields,
23
+ ?name: ::String?,
24
+ ?fields: (::Array[::Protostar::Google::Protobuf::Field | ::Protostar::Google::Protobuf::Field::init_map])?,
25
+ ?oneofs: ::Array[::String]?,
26
+ ?options: (::Array[::Protostar::Google::Protobuf::Option | ::Protostar::Google::Protobuf::Option::init_map])?,
27
+ ?source_context: (::Protostar::Google::Protobuf::SourceContext | ::Protostar::Google::Protobuf::SourceContext::init_map)?,
28
+ ?syntax: (::Protostar::Google::Protobuf::Syntax::names | ::Integer)?,
29
+ ?edition: ::String?
30
+ ) -> void
31
+
32
+ # The fully qualified message name.
33
+ attr_reader name(): ::String
34
+ attr_writer name(): ::String?
35
+
36
+ # The list of fields.
37
+ attr_reader fields(): ::Array[::Protostar::Google::Protobuf::Field]
38
+ attr_writer fields(): (::Array[::Protostar::Google::Protobuf::Field | ::Protostar::Google::Protobuf::Field::init_map])?
39
+
40
+ # The list of types appearing in `oneof` definitions in this type.
41
+ attr_reader oneofs(): ::Array[::String]
42
+ attr_writer oneofs(): ::Array[::String]?
43
+
44
+ # The protocol buffer options.
45
+ attr_reader options(): ::Array[::Protostar::Google::Protobuf::Option]
46
+ attr_writer options(): (::Array[::Protostar::Google::Protobuf::Option | ::Protostar::Google::Protobuf::Option::init_map])?
47
+
48
+ # The source context.
49
+ attr_reader source_context(): ::Protostar::Google::Protobuf::SourceContext?
50
+ attr_writer source_context(): (::Protostar::Google::Protobuf::SourceContext | ::Protostar::Google::Protobuf::SourceContext::init_map)?
51
+ def has_source_context?: () -> bool
52
+ def clear_source_context: () -> void
53
+
54
+ # The source syntax.
55
+ attr_reader syntax(): ::Protostar::Google::Protobuf::Syntax::names | ::Integer
56
+ attr_writer syntax(): (::Protostar::Google::Protobuf::Syntax::names | ::Integer)?
57
+
58
+ # The source edition string, only valid when syntax is SYNTAX_EDITIONS.
59
+ attr_reader edition(): ::String
60
+ attr_writer edition(): ::String?
61
+ end
62
+
63
+ # A single field of a message type.
64
+ # New usages of this message as an alternative to FieldDescriptorProto are
65
+ # strongly discouraged. This message does not reliability preserve all
66
+ # information necessary to model the schema and preserve semantics. Instead
67
+ # make use of FileDescriptorSet which preserves the necessary information.
68
+ class Field < ::Protostar::Message
69
+ # Basic field types.
70
+ module Kind
71
+ extend ::Protostar::Enum
72
+
73
+ TYPE_UNKNOWN: 0
74
+ TYPE_DOUBLE: 1
75
+ TYPE_FLOAT: 2
76
+ TYPE_INT64: 3
77
+ TYPE_UINT64: 4
78
+ TYPE_INT32: 5
79
+ TYPE_FIXED64: 6
80
+ TYPE_FIXED32: 7
81
+ TYPE_BOOL: 8
82
+ TYPE_STRING: 9
83
+ TYPE_GROUP: 10
84
+ TYPE_MESSAGE: 11
85
+ TYPE_BYTES: 12
86
+ TYPE_UINT32: 13
87
+ TYPE_ENUM: 14
88
+ TYPE_SFIXED32: 15
89
+ TYPE_SFIXED64: 16
90
+ TYPE_SINT32: 17
91
+ TYPE_SINT64: 18
92
+
93
+ type names = :TYPE_UNKNOWN | :TYPE_DOUBLE | :TYPE_FLOAT | :TYPE_INT64 | :TYPE_UINT64 | :TYPE_INT32 | :TYPE_FIXED64 | :TYPE_FIXED32 | :TYPE_BOOL | :TYPE_STRING | :TYPE_GROUP | :TYPE_MESSAGE | :TYPE_BYTES | :TYPE_UINT32 | :TYPE_ENUM | :TYPE_SFIXED32 | :TYPE_SFIXED64 | :TYPE_SINT32 | :TYPE_SINT64
94
+ end
95
+
96
+ # Whether a field is optional, required, or repeated.
97
+ module Cardinality
98
+ extend ::Protostar::Enum
99
+
100
+ CARDINALITY_UNKNOWN: 0
101
+ CARDINALITY_OPTIONAL: 1
102
+ CARDINALITY_REQUIRED: 2
103
+ CARDINALITY_REPEATED: 3
104
+
105
+ type names = :CARDINALITY_UNKNOWN | :CARDINALITY_OPTIONAL | :CARDINALITY_REQUIRED | :CARDINALITY_REPEATED
106
+ end
107
+
108
+ type init_map = {
109
+ ?kind: (::Protostar::Google::Protobuf::Field::Kind::names | ::Integer)?,
110
+ ?cardinality: (::Protostar::Google::Protobuf::Field::Cardinality::names | ::Integer)?,
111
+ ?number: ::Integer?,
112
+ ?name: ::String?,
113
+ ?type_url: ::String?,
114
+ ?oneof_index: ::Integer?,
115
+ ?packed: bool?,
116
+ ?options: (::Array[::Protostar::Google::Protobuf::Option | ::Protostar::Google::Protobuf::Option::init_map])?,
117
+ ?json_name: ::String?,
118
+ ?default_value: ::String?
119
+ }
120
+ def initialize: (
121
+ ?init_map? fields,
122
+ ?kind: (::Protostar::Google::Protobuf::Field::Kind::names | ::Integer)?,
123
+ ?cardinality: (::Protostar::Google::Protobuf::Field::Cardinality::names | ::Integer)?,
124
+ ?number: ::Integer?,
125
+ ?name: ::String?,
126
+ ?type_url: ::String?,
127
+ ?oneof_index: ::Integer?,
128
+ ?packed: bool?,
129
+ ?options: (::Array[::Protostar::Google::Protobuf::Option | ::Protostar::Google::Protobuf::Option::init_map])?,
130
+ ?json_name: ::String?,
131
+ ?default_value: ::String?
132
+ ) -> void
133
+
134
+ # The field type.
135
+ attr_reader kind(): ::Protostar::Google::Protobuf::Field::Kind::names | ::Integer
136
+ attr_writer kind(): (::Protostar::Google::Protobuf::Field::Kind::names | ::Integer)?
137
+
138
+ # The field cardinality.
139
+ attr_reader cardinality(): ::Protostar::Google::Protobuf::Field::Cardinality::names | ::Integer
140
+ attr_writer cardinality(): (::Protostar::Google::Protobuf::Field::Cardinality::names | ::Integer)?
141
+
142
+ # The field number.
143
+ attr_reader number(): ::Integer
144
+ attr_writer number(): ::Integer?
145
+
146
+ # The field name.
147
+ attr_reader name(): ::String
148
+ attr_writer name(): ::String?
149
+
150
+ # The field type URL, without the scheme, for message or enumeration
151
+ # types. Example: `"type.googleapis.com/google.protobuf.Timestamp"`.
152
+ attr_reader type_url(): ::String
153
+ attr_writer type_url(): ::String?
154
+
155
+ # The index of the field type in `Type.oneofs`, for message or enumeration
156
+ # types. The first type has index 1; zero means the type is not in the list.
157
+ attr_reader oneof_index(): ::Integer
158
+ attr_writer oneof_index(): ::Integer?
159
+
160
+ # Whether to use alternative packed wire representation.
161
+ attr_reader packed(): bool
162
+ attr_writer packed(): bool?
163
+
164
+ # The protocol buffer options.
165
+ attr_reader options(): ::Array[::Protostar::Google::Protobuf::Option]
166
+ attr_writer options(): (::Array[::Protostar::Google::Protobuf::Option | ::Protostar::Google::Protobuf::Option::init_map])?
167
+
168
+ # The field JSON name.
169
+ attr_reader json_name(): ::String
170
+ attr_writer json_name(): ::String?
171
+
172
+ # The string value of the default value of this field. Proto2 syntax only.
173
+ attr_reader default_value(): ::String
174
+ attr_writer default_value(): ::String?
175
+ end
176
+
177
+ # Enum type definition.
178
+ # New usages of this message as an alternative to EnumDescriptorProto are
179
+ # strongly discouraged. This message does not reliability preserve all
180
+ # information necessary to model the schema and preserve semantics. Instead
181
+ # make use of FileDescriptorSet which preserves the necessary information.
182
+ class Enum < ::Protostar::Message
183
+ type init_map = {
184
+ ?name: ::String?,
185
+ ?enumvalue: (::Array[::Protostar::Google::Protobuf::EnumValue | ::Protostar::Google::Protobuf::EnumValue::init_map])?,
186
+ ?options: (::Array[::Protostar::Google::Protobuf::Option | ::Protostar::Google::Protobuf::Option::init_map])?,
187
+ ?source_context: (::Protostar::Google::Protobuf::SourceContext | ::Protostar::Google::Protobuf::SourceContext::init_map)?,
188
+ ?syntax: (::Protostar::Google::Protobuf::Syntax::names | ::Integer)?,
189
+ ?edition: ::String?
190
+ }
191
+ def initialize: (
192
+ ?init_map? fields,
193
+ ?name: ::String?,
194
+ ?enumvalue: (::Array[::Protostar::Google::Protobuf::EnumValue | ::Protostar::Google::Protobuf::EnumValue::init_map])?,
195
+ ?options: (::Array[::Protostar::Google::Protobuf::Option | ::Protostar::Google::Protobuf::Option::init_map])?,
196
+ ?source_context: (::Protostar::Google::Protobuf::SourceContext | ::Protostar::Google::Protobuf::SourceContext::init_map)?,
197
+ ?syntax: (::Protostar::Google::Protobuf::Syntax::names | ::Integer)?,
198
+ ?edition: ::String?
199
+ ) -> void
200
+
201
+ # Enum type name.
202
+ attr_reader name(): ::String
203
+ attr_writer name(): ::String?
204
+
205
+ # Enum value definitions.
206
+ attr_reader enumvalue(): ::Array[::Protostar::Google::Protobuf::EnumValue]
207
+ attr_writer enumvalue(): (::Array[::Protostar::Google::Protobuf::EnumValue | ::Protostar::Google::Protobuf::EnumValue::init_map])?
208
+
209
+ # Protocol buffer options.
210
+ attr_reader options(): ::Array[::Protostar::Google::Protobuf::Option]
211
+ attr_writer options(): (::Array[::Protostar::Google::Protobuf::Option | ::Protostar::Google::Protobuf::Option::init_map])?
212
+
213
+ # The source context.
214
+ attr_reader source_context(): ::Protostar::Google::Protobuf::SourceContext?
215
+ attr_writer source_context(): (::Protostar::Google::Protobuf::SourceContext | ::Protostar::Google::Protobuf::SourceContext::init_map)?
216
+ def has_source_context?: () -> bool
217
+ def clear_source_context: () -> void
218
+
219
+ # The source syntax.
220
+ attr_reader syntax(): ::Protostar::Google::Protobuf::Syntax::names | ::Integer
221
+ attr_writer syntax(): (::Protostar::Google::Protobuf::Syntax::names | ::Integer)?
222
+
223
+ # The source edition string, only valid when syntax is SYNTAX_EDITIONS.
224
+ attr_reader edition(): ::String
225
+ attr_writer edition(): ::String?
226
+ end
227
+
228
+ # Enum value definition.
229
+ # New usages of this message as an alternative to EnumValueDescriptorProto are
230
+ # strongly discouraged. This message does not reliability preserve all
231
+ # information necessary to model the schema and preserve semantics. Instead
232
+ # make use of FileDescriptorSet which preserves the necessary information.
233
+ class EnumValue < ::Protostar::Message
234
+ type init_map = {
235
+ ?name: ::String?,
236
+ ?number: ::Integer?,
237
+ ?options: (::Array[::Protostar::Google::Protobuf::Option | ::Protostar::Google::Protobuf::Option::init_map])?
238
+ }
239
+ def initialize: (
240
+ ?init_map? fields,
241
+ ?name: ::String?,
242
+ ?number: ::Integer?,
243
+ ?options: (::Array[::Protostar::Google::Protobuf::Option | ::Protostar::Google::Protobuf::Option::init_map])?
244
+ ) -> void
245
+
246
+ # Enum value name.
247
+ attr_reader name(): ::String
248
+ attr_writer name(): ::String?
249
+
250
+ # Enum value number.
251
+ attr_reader number(): ::Integer
252
+ attr_writer number(): ::Integer?
253
+
254
+ # Protocol buffer options.
255
+ attr_reader options(): ::Array[::Protostar::Google::Protobuf::Option]
256
+ attr_writer options(): (::Array[::Protostar::Google::Protobuf::Option | ::Protostar::Google::Protobuf::Option::init_map])?
257
+ end
258
+
259
+ # A protocol buffer option, which can be attached to a message, field,
260
+ # enumeration, etc.
261
+ # New usages of this message as an alternative to FileOptions, MessageOptions,
262
+ # FieldOptions, EnumOptions, EnumValueOptions, ServiceOptions, or MethodOptions
263
+ # are strongly discouraged.
264
+ class Option < ::Protostar::Message
265
+ type init_map = {
266
+ ?name: ::String?,
267
+ ?value: (::Protostar::Google::Protobuf::Any | ::Protostar::Google::Protobuf::Any::init_map)?
268
+ }
269
+ def initialize: (
270
+ ?init_map? fields,
271
+ ?name: ::String?,
272
+ ?value: (::Protostar::Google::Protobuf::Any | ::Protostar::Google::Protobuf::Any::init_map)?
273
+ ) -> void
274
+
275
+ # The option's name. For protobuf built-in options (options defined in
276
+ # descriptor.proto), this is the short name. For example, `"map_entry"`.
277
+ # For custom options, it should be the fully-qualified name. For example,
278
+ # `"google.api.http"`.
279
+ attr_reader name(): ::String
280
+ attr_writer name(): ::String?
281
+
282
+ # The option's value packed in an Any message. If the value is a primitive,
283
+ # the corresponding wrapper type defined in google/protobuf/wrappers.proto
284
+ # should be used. If the value is an enum, it should be stored as an int32
285
+ # value using the google.protobuf.Int32Value type.
286
+ attr_reader value(): ::Protostar::Google::Protobuf::Any?
287
+ attr_writer value(): (::Protostar::Google::Protobuf::Any | ::Protostar::Google::Protobuf::Any::init_map)?
288
+ def has_value?: () -> bool
289
+ def clear_value: () -> void
290
+ end
291
+
292
+ # The syntax in which a protocol buffer element is defined.
293
+ module Syntax
294
+ extend ::Protostar::Enum
295
+
296
+ SYNTAX_PROTO2: 0
297
+ SYNTAX_PROTO3: 1
298
+ SYNTAX_EDITIONS: 2
299
+
300
+ type names = :SYNTAX_PROTO2 | :SYNTAX_PROTO3 | :SYNTAX_EDITIONS
301
+ end
302
+ end
303
+ end
304
+ end
@@ -0,0 +1,169 @@
1
+ # Generated by protostar from google/protobuf/wrappers.proto. Do not edit.
2
+
3
+ module Protostar
4
+ module Google
5
+ module Protobuf
6
+ # Wrapper message for `double`.
7
+ # The JSON representation for `DoubleValue` is JSON number.
8
+ # Not recommended for use in new APIs, but still useful for legacy APIs and
9
+ # has no plan to be removed.
10
+ class DoubleValue < ::Protostar::Message
11
+ type init_map = {
12
+ ?value: (::Float | ::Integer)?
13
+ }
14
+ def initialize: (
15
+ ?init_map? fields,
16
+ ?value: (::Float | ::Integer)?
17
+ ) -> void
18
+
19
+ # The double value.
20
+ attr_reader value(): ::Float
21
+ attr_writer value(): (::Float | ::Integer)?
22
+ end
23
+
24
+ # Wrapper message for `float`.
25
+ # The JSON representation for `FloatValue` is JSON number.
26
+ # Not recommended for use in new APIs, but still useful for legacy APIs and
27
+ # has no plan to be removed.
28
+ class FloatValue < ::Protostar::Message
29
+ type init_map = {
30
+ ?value: (::Float | ::Integer)?
31
+ }
32
+ def initialize: (
33
+ ?init_map? fields,
34
+ ?value: (::Float | ::Integer)?
35
+ ) -> void
36
+
37
+ # The float value.
38
+ attr_reader value(): ::Float
39
+ attr_writer value(): (::Float | ::Integer)?
40
+ end
41
+
42
+ # Wrapper message for `int64`.
43
+ # The JSON representation for `Int64Value` is JSON string.
44
+ # Not recommended for use in new APIs, but still useful for legacy APIs and
45
+ # has no plan to be removed.
46
+ class Int64Value < ::Protostar::Message
47
+ type init_map = {
48
+ ?value: ::Integer?
49
+ }
50
+ def initialize: (
51
+ ?init_map? fields,
52
+ ?value: ::Integer?
53
+ ) -> void
54
+
55
+ # The int64 value.
56
+ attr_reader value(): ::Integer
57
+ attr_writer value(): ::Integer?
58
+ end
59
+
60
+ # Wrapper message for `uint64`.
61
+ # The JSON representation for `UInt64Value` is JSON string.
62
+ # Not recommended for use in new APIs, but still useful for legacy APIs and
63
+ # has no plan to be removed.
64
+ class UInt64Value < ::Protostar::Message
65
+ type init_map = {
66
+ ?value: ::Integer?
67
+ }
68
+ def initialize: (
69
+ ?init_map? fields,
70
+ ?value: ::Integer?
71
+ ) -> void
72
+
73
+ # The uint64 value.
74
+ attr_reader value(): ::Integer
75
+ attr_writer value(): ::Integer?
76
+ end
77
+
78
+ # Wrapper message for `int32`.
79
+ # The JSON representation for `Int32Value` is JSON number.
80
+ # Not recommended for use in new APIs, but still useful for legacy APIs and
81
+ # has no plan to be removed.
82
+ class Int32Value < ::Protostar::Message
83
+ type init_map = {
84
+ ?value: ::Integer?
85
+ }
86
+ def initialize: (
87
+ ?init_map? fields,
88
+ ?value: ::Integer?
89
+ ) -> void
90
+
91
+ # The int32 value.
92
+ attr_reader value(): ::Integer
93
+ attr_writer value(): ::Integer?
94
+ end
95
+
96
+ # Wrapper message for `uint32`.
97
+ # The JSON representation for `UInt32Value` is JSON number.
98
+ # Not recommended for use in new APIs, but still useful for legacy APIs and
99
+ # has no plan to be removed.
100
+ class UInt32Value < ::Protostar::Message
101
+ type init_map = {
102
+ ?value: ::Integer?
103
+ }
104
+ def initialize: (
105
+ ?init_map? fields,
106
+ ?value: ::Integer?
107
+ ) -> void
108
+
109
+ # The uint32 value.
110
+ attr_reader value(): ::Integer
111
+ attr_writer value(): ::Integer?
112
+ end
113
+
114
+ # Wrapper message for `bool`.
115
+ # The JSON representation for `BoolValue` is JSON `true` and `false`.
116
+ # Not recommended for use in new APIs, but still useful for legacy APIs and
117
+ # has no plan to be removed.
118
+ class BoolValue < ::Protostar::Message
119
+ type init_map = {
120
+ ?value: bool?
121
+ }
122
+ def initialize: (
123
+ ?init_map? fields,
124
+ ?value: bool?
125
+ ) -> void
126
+
127
+ # The bool value.
128
+ attr_reader value(): bool
129
+ attr_writer value(): bool?
130
+ end
131
+
132
+ # Wrapper message for `string`.
133
+ # The JSON representation for `StringValue` is JSON string.
134
+ # Not recommended for use in new APIs, but still useful for legacy APIs and
135
+ # has no plan to be removed.
136
+ class StringValue < ::Protostar::Message
137
+ type init_map = {
138
+ ?value: ::String?
139
+ }
140
+ def initialize: (
141
+ ?init_map? fields,
142
+ ?value: ::String?
143
+ ) -> void
144
+
145
+ # The string value.
146
+ attr_reader value(): ::String
147
+ attr_writer value(): ::String?
148
+ end
149
+
150
+ # Wrapper message for `bytes`.
151
+ # The JSON representation for `BytesValue` is JSON string.
152
+ # Not recommended for use in new APIs, but still useful for legacy APIs and
153
+ # has no plan to be removed.
154
+ class BytesValue < ::Protostar::Message
155
+ type init_map = {
156
+ ?value: ::String?
157
+ }
158
+ def initialize: (
159
+ ?init_map? fields,
160
+ ?value: ::String?
161
+ ) -> void
162
+
163
+ # The bytes value.
164
+ attr_reader value(): ::String
165
+ attr_writer value(): ::String?
166
+ end
167
+ end
168
+ end
169
+ end
@@ -0,0 +1,216 @@
1
+ # protostar lint and the rustc-style diagnostics it prints. The compiler
2
+ # itself has no signatures yet; its Diagnostic is described here because the
3
+ # renderer takes it.
4
+ module Protostar
5
+ class Compiler
6
+ class Diagnostic
7
+ attr_reader file: ::String
8
+ attr_reader line: ::Integer?
9
+ attr_reader column: ::Integer?
10
+ attr_reader message: ::String
11
+ attr_reader severity: :error | :warning
12
+ attr_reader path: ::String?
13
+ attr_reader spans: ::Array[Diagnostics::Span]
14
+ attr_reader help: ::Array[::String]
15
+ attr_reader notes: ::Array[::String]
16
+ attr_reader fix: Diagnostics::Fix?
17
+ attr_reader rule: ::String?
18
+
19
+ def initialize: (::String file, ::Integer? line, ::Integer? column, ::String message, ?(:error | :warning) severity,
20
+ ?path: ::String?, ?spans: ::Array[Diagnostics::Span], ?code: ::String?, ?title: ::String?,
21
+ ?help: ::Array[::String], ?notes: ::Array[::String], ?fix: Diagnostics::Fix?, ?rule: ::String?) -> void
22
+ def code: () -> ::String?
23
+ def title: () -> ::String
24
+ def annotated: () -> Diagnostic
25
+ def with: (**untyped changes) -> Diagnostic
26
+ def error?: () -> bool
27
+ def warning?: () -> bool
28
+ def to_s: () -> ::String
29
+ def format: (?(:gcc | :msvs) error_format) -> ::String
30
+ end
31
+ end
32
+
33
+ module Diagnostics
34
+ class Span
35
+ attr_reader line: ::Integer
36
+ attr_reader column: ::Integer
37
+ attr_reader end_line: ::Integer?
38
+ attr_reader end_column: ::Integer?
39
+ attr_reader label: ::String?
40
+
41
+ def initialize: (::Integer line, ::Integer column, ?::Integer? end_line, ?::Integer? end_column, ?label: ::String?, ?primary: bool) -> void
42
+ def primary?: () -> bool
43
+ def with_label: (::String? label) -> Span
44
+ def to_h: () -> ::Hash[::Symbol, untyped]
45
+ end
46
+
47
+ class Edit
48
+ attr_reader line: ::Integer
49
+ attr_reader column: ::Integer
50
+ attr_reader end_line: ::Integer
51
+ attr_reader end_column: ::Integer
52
+ attr_reader text: ::String
53
+
54
+ def initialize: (::Integer line, ::Integer column, ::Integer end_line, ::Integer end_column, ::String text) -> void
55
+ def to_h: () -> ::Hash[::Symbol, untyped]
56
+ end
57
+
58
+ class Fix
59
+ attr_reader description: ::String
60
+ attr_reader edits: ::Array[Edit]
61
+
62
+ def initialize: (::String description, ::Array[Edit] edits) -> void
63
+ def to_h: () -> ::Hash[::Symbol, untyped]
64
+ end
65
+
66
+ class Source
67
+ attr_reader lines: ::Array[::String]
68
+
69
+ def initialize: (::String text) -> void
70
+ def line: (::Integer number) -> ::String
71
+ def size: () -> ::Integer
72
+ def display: (::Integer number) -> ::String
73
+ def display_column: (::Integer number, ::Integer column) -> ::Integer
74
+ def token_end: (::Integer number, ::Integer column) -> ::Integer
75
+ def first_column: (::Integer number) -> ::Integer?
76
+ def end_column: (::Integer number) -> ::Integer
77
+ def resolve: (Span span) -> Span
78
+ def apply: (::String text, ::Array[Edit] edits) -> ::String
79
+ end
80
+
81
+ class Renderer
82
+ def initialize: (?color: bool, ?source: (^(Compiler::Diagnostic) -> ::String?)?) -> void
83
+ def render: (Compiler::Diagnostic diagnostic) -> ::String
84
+ def source_for: (Compiler::Diagnostic diagnostic) -> Source?
85
+ end
86
+
87
+ module Formats
88
+ def self.record: (Compiler::Diagnostic diagnostic, ?source: Source?) -> ::Hash[::Symbol, untyped]
89
+ def self.json: (Compiler::Diagnostic diagnostic, ?source: Source?) -> ::String
90
+ def self.github: (Compiler::Diagnostic diagnostic, ?source: Source?) -> ::String
91
+ end
92
+
93
+ module Codes
94
+ class Entry
95
+ attr_reader code: ::String
96
+ attr_reader summary: ::String
97
+ attr_reader templates: ::Array[::String]
98
+ attr_reader explanation: ::String
99
+ end
100
+
101
+ class Match
102
+ attr_reader entry: Entry
103
+ attr_reader captures: ::Hash[::Symbol, ::String]
104
+ def code: () -> ::String
105
+ end
106
+
107
+ ENTRIES: ::Array[Entry]
108
+
109
+ def self.lookup: (::String message) -> Match?
110
+ def self.[]: (::String code) -> Entry?
111
+ def self.annotate: (Compiler::Diagnostic diagnostic) -> Compiler::Diagnostic
112
+ def self.pattern: (::String template) -> ::Regexp
113
+ end
114
+ end
115
+
116
+ module Lint
117
+ class Error < Protostar::Error
118
+ end
119
+
120
+ TIERS: ::Array[::Symbol]
121
+ RULES: ::Hash[::String, [::String, ::Symbol, ::Symbol]]
122
+
123
+ def self.categories: () -> ::Array[::Symbol]
124
+ def self.rule_class: (::String id) -> singleton(Rule)
125
+ def self.rule_id: (::String id_or_code) -> ::String?
126
+ def self.select: (::Array[::String] names, ?except: ::Array[::String]) -> ::Array[::String]
127
+
128
+ class Rule
129
+ CLAIMS: ::Array[::String]
130
+
131
+ def self.id: () -> ::String
132
+ def self.code: () -> ::String
133
+ def self.tier: () -> ::Symbol
134
+ def self.category: () -> ::Symbol
135
+ def self.reason: () -> ::String
136
+ def self.explanation: () -> ::String
137
+
138
+ attr_reader context: Context
139
+ attr_reader diagnostics: ::Array[Compiler::Diagnostic]
140
+
141
+ def initialize: (Context context) -> void
142
+ def check: () -> void
143
+ end
144
+
145
+ class Context
146
+ attr_reader name: ::String
147
+ attr_reader path: ::String?
148
+ attr_reader disk_path: ::String?
149
+ attr_reader file: untyped
150
+ attr_reader ast: untyped
151
+ attr_reader text: ::String
152
+ attr_reader warnings: ::Array[Compiler::Diagnostic]
153
+ attr_reader all: ::Array[Context]
154
+
155
+ def source: () -> Diagnostics::Source
156
+ def each: (::Symbol kind) { (untyped node, untyped descriptor) -> void } -> void
157
+ def descriptor: (untyped node) -> untyped
158
+ def span: (untyped node, ::Symbol kind, ?label: ::String?, ?primary: bool) -> Diagnostics::Span?
159
+ def span_at: (::Array[::Integer] path, ?label: ::String?, ?primary: bool) -> Diagnostics::Span?
160
+ def comment: (untyped node) -> ::String?
161
+ def renamable?: (::String from, ::String to) -> bool
162
+ end
163
+
164
+ class Runner
165
+ class Result
166
+ attr_reader diagnostics: ::Array[Compiler::Diagnostic]
167
+ attr_reader contexts: ::Array[Context]
168
+ attr_reader names: ::Array[::String]
169
+ def errors?: () -> bool
170
+ def warnings?: () -> bool
171
+ end
172
+
173
+ attr_reader compiler: Compiler
174
+
175
+ def initialize: (include_paths: ::Array[::String], rules: ::Array[::String], ?except: ::Array[::String], ?directives: bool) -> void
176
+ def run: (::Array[::String] names, ?sources: ::Hash[::String, ::String]) -> Result
177
+ def text: (::String name) -> ::String?
178
+ end
179
+
180
+ class Config
181
+ attr_reader rules: ::Array[::String]
182
+ attr_reader except: ::Array[::String]
183
+ attr_reader ignore: ::Array[::String]
184
+ attr_reader root: ::String
185
+ attr_reader file: ::String?
186
+
187
+ def self.find: (::Array[::String] inputs, ?cwd: ::String) -> Config
188
+ def self.load: (::String path) -> Config
189
+ def allow_comment_directives?: () -> bool
190
+ def ignored?: (::String path) -> bool
191
+ end
192
+
193
+ class Directives
194
+ def initialize: (::String text) -> void
195
+ def suppressed?: (Compiler::Diagnostic diagnostic) -> bool
196
+ end
197
+
198
+ class Fixer
199
+ class Change
200
+ attr_reader name: ::String
201
+ attr_reader path: ::String?
202
+ attr_reader before: ::String
203
+ attr_reader after: ::String
204
+ attr_reader fixed: ::Array[Compiler::Diagnostic]
205
+ end
206
+
207
+ def self.plan: (::Array[Compiler::Diagnostic] diagnostics, text: ^(::String) -> ::String?, path: ^(::String) -> ::String?) -> ::Array[Change]
208
+ def self.diff: (Change change) -> ::String
209
+ end
210
+
211
+ class Command
212
+ def initialize: (untyped out, untyped err) -> void
213
+ def run: (::Array[::String] argv) -> ::Integer
214
+ end
215
+ end
216
+ end