blob: 2499917d46fb0055003e985aa0fec17042238b74 [file] [log] [blame]
Zack Williamse940c7a2019-08-21 14:25:39 -07001package protoparse
2
3import "fmt"
4
5// This file defines all of the nodes in the proto AST.
6
7// ErrorWithSourcePos is an error about a proto source file includes information
8// about the location in the file that caused the error.
9type ErrorWithSourcePos struct {
10 Underlying error
11 Pos *SourcePos
12}
13
14// Error implements the error interface
15func (e ErrorWithSourcePos) Error() string {
16 if e.Pos.Line <= 0 || e.Pos.Col <= 0 {
17 return fmt.Sprintf("%s: %v", e.Pos.Filename, e.Underlying)
18 }
19 return fmt.Sprintf("%s:%d:%d: %v", e.Pos.Filename, e.Pos.Line, e.Pos.Col, e.Underlying)
20}
21
22// SourcePos identifies a location in a proto source file.
23type SourcePos struct {
24 Filename string
25 Line, Col int
26 Offset int
27}
28
29func unknownPos(filename string) *SourcePos {
30 return &SourcePos{Filename: filename}
31}
32
33type node interface {
34 start() *SourcePos
35 end() *SourcePos
36 leadingComments() []*comment
37 trailingComments() []*comment
38}
39
40type terminalNode interface {
41 node
42 popLeadingComment() *comment
43 pushTrailingComment(*comment)
44}
45
46var _ terminalNode = (*basicNode)(nil)
47var _ terminalNode = (*stringLiteralNode)(nil)
48var _ terminalNode = (*intLiteralNode)(nil)
49var _ terminalNode = (*floatLiteralNode)(nil)
50var _ terminalNode = (*identNode)(nil)
51
52type fileDecl interface {
53 node
54 getSyntax() node
55}
56
57var _ fileDecl = (*fileNode)(nil)
58var _ fileDecl = (*noSourceNode)(nil)
59
60type optionDecl interface {
61 node
62 getName() node
63 getValue() valueNode
64}
65
66var _ optionDecl = (*optionNode)(nil)
67var _ optionDecl = (*noSourceNode)(nil)
68
69type fieldDecl interface {
70 node
71 fieldLabel() node
72 fieldName() node
73 fieldType() node
74 fieldTag() node
75 fieldExtendee() node
76 getGroupKeyword() node
77}
78
79var _ fieldDecl = (*fieldNode)(nil)
80var _ fieldDecl = (*groupNode)(nil)
81var _ fieldDecl = (*mapFieldNode)(nil)
82var _ fieldDecl = (*syntheticMapField)(nil)
83var _ fieldDecl = (*noSourceNode)(nil)
84
85type rangeDecl interface {
86 node
87 rangeStart() node
88 rangeEnd() node
89}
90
91var _ rangeDecl = (*rangeNode)(nil)
92var _ rangeDecl = (*noSourceNode)(nil)
93
94type enumValueDecl interface {
95 node
96 getName() node
97 getNumber() node
98}
99
100var _ enumValueDecl = (*enumValueNode)(nil)
101var _ enumValueDecl = (*noSourceNode)(nil)
102
103type msgDecl interface {
104 node
105 messageName() node
106 reservedNames() []*stringLiteralNode
107}
108
109var _ msgDecl = (*messageNode)(nil)
110var _ msgDecl = (*groupNode)(nil)
111var _ msgDecl = (*mapFieldNode)(nil)
112var _ msgDecl = (*noSourceNode)(nil)
113
114type methodDecl interface {
115 node
116 getInputType() node
117 getOutputType() node
118}
119
120var _ methodDecl = (*methodNode)(nil)
121var _ methodDecl = (*noSourceNode)(nil)
122
123type posRange struct {
124 start, end *SourcePos
125}
126
127type basicNode struct {
128 posRange
129 leading []*comment
130 trailing []*comment
131}
132
133func (n *basicNode) start() *SourcePos {
134 return n.posRange.start
135}
136
137func (n *basicNode) end() *SourcePos {
138 return n.posRange.end
139}
140
141func (n *basicNode) leadingComments() []*comment {
142 return n.leading
143}
144
145func (n *basicNode) trailingComments() []*comment {
146 return n.trailing
147}
148
149func (n *basicNode) popLeadingComment() *comment {
150 c := n.leading[0]
151 n.leading = n.leading[1:]
152 return c
153}
154
155func (n *basicNode) pushTrailingComment(c *comment) {
156 n.trailing = append(n.trailing, c)
157}
158
159type comment struct {
160 posRange
161 text string
162}
163
164type basicCompositeNode struct {
165 first node
166 last node
167}
168
169func (n *basicCompositeNode) start() *SourcePos {
170 return n.first.start()
171}
172
173func (n *basicCompositeNode) end() *SourcePos {
174 return n.last.end()
175}
176
177func (n *basicCompositeNode) leadingComments() []*comment {
178 return n.first.leadingComments()
179}
180
181func (n *basicCompositeNode) trailingComments() []*comment {
182 return n.last.trailingComments()
183}
184
185func (n *basicCompositeNode) setRange(first, last node) {
186 n.first = first
187 n.last = last
188}
189
190type fileNode struct {
191 basicCompositeNode
192 syntax *syntaxNode
193 decls []*fileElement
194
195 // These fields are populated after parsing, to make it easier to find them
196 // without searching decls. The parse result has a map of descriptors to
197 // nodes which makes the other declarations easily discoverable. But these
198 // elements do not map to descriptors -- they are just stored as strings in
199 // the file descriptor.
200 imports []*importNode
201 pkg *packageNode
202}
203
204func (n *fileNode) getSyntax() node {
205 return n.syntax
206}
207
208type fileElement struct {
209 // a discriminated union: only one field will be set
210 imp *importNode
211 pkg *packageNode
212 option *optionNode
213 message *messageNode
214 enum *enumNode
215 extend *extendNode
216 service *serviceNode
217 empty *basicNode
218}
219
220func (n *fileElement) start() *SourcePos {
221 return n.get().start()
222}
223
224func (n *fileElement) end() *SourcePos {
225 return n.get().end()
226}
227
228func (n *fileElement) leadingComments() []*comment {
229 return n.get().leadingComments()
230}
231
232func (n *fileElement) trailingComments() []*comment {
233 return n.get().trailingComments()
234}
235
236func (n *fileElement) get() node {
237 switch {
238 case n.imp != nil:
239 return n.imp
240 case n.pkg != nil:
241 return n.pkg
242 case n.option != nil:
243 return n.option
244 case n.message != nil:
245 return n.message
246 case n.enum != nil:
247 return n.enum
248 case n.extend != nil:
249 return n.extend
250 case n.service != nil:
251 return n.service
252 default:
253 return n.empty
254 }
255}
256
257type syntaxNode struct {
258 basicCompositeNode
259 syntax *stringLiteralNode
260}
261
262type importNode struct {
263 basicCompositeNode
264 name *stringLiteralNode
265 public bool
266 weak bool
267}
268
269type packageNode struct {
270 basicCompositeNode
271 name *identNode
272}
273
274type identifier string
275
276type identKind int
277
278const (
279 identSimpleName identKind = iota
280 identQualified
281 identTypeName
282)
283
284type identNode struct {
285 basicNode
286 val string
287 kind identKind
288}
289
290func (n *identNode) value() interface{} {
291 return identifier(n.val)
292}
293
294type optionNode struct {
295 basicCompositeNode
296 name *optionNameNode
297 val valueNode
298}
299
300func (n *optionNode) getName() node {
301 return n.name
302}
303
304func (n *optionNode) getValue() valueNode {
305 return n.val
306}
307
308type optionNameNode struct {
309 basicCompositeNode
310 parts []*optionNamePartNode
311}
312
313type optionNamePartNode struct {
314 basicCompositeNode
315 text *identNode
316 offset int
317 length int
318 isExtension bool
319 st, en *SourcePos
320}
321
322func (n *optionNamePartNode) start() *SourcePos {
323 if n.isExtension {
324 return n.basicCompositeNode.start()
325 }
326 return n.st
327}
328
329func (n *optionNamePartNode) end() *SourcePos {
330 if n.isExtension {
331 return n.basicCompositeNode.end()
332 }
333 return n.en
334}
335
336func (n *optionNamePartNode) setRange(first, last node) {
337 n.basicCompositeNode.setRange(first, last)
338 if !n.isExtension {
339 st := *first.start()
340 st.Col += n.offset
341 n.st = &st
342 en := st
343 en.Col += n.length
344 n.en = &en
345 }
346}
347
348type valueNode interface {
349 node
350 value() interface{}
351}
352
353var _ valueNode = (*stringLiteralNode)(nil)
354var _ valueNode = (*intLiteralNode)(nil)
355var _ valueNode = (*negativeIntLiteralNode)(nil)
356var _ valueNode = (*floatLiteralNode)(nil)
357var _ valueNode = (*boolLiteralNode)(nil)
358var _ valueNode = (*sliceLiteralNode)(nil)
359var _ valueNode = (*aggregateLiteralNode)(nil)
360var _ valueNode = (*noSourceNode)(nil)
361
362type stringLiteralNode struct {
363 basicCompositeNode
364 val string
365}
366
367func (n *stringLiteralNode) value() interface{} {
368 return n.val
369}
370
371func (n *stringLiteralNode) popLeadingComment() *comment {
372 return n.first.(terminalNode).popLeadingComment()
373}
374
375func (n *stringLiteralNode) pushTrailingComment(c *comment) {
376 n.last.(terminalNode).pushTrailingComment(c)
377}
378
379type intLiteralNode struct {
380 basicNode
381 val uint64
382}
383
384func (n *intLiteralNode) value() interface{} {
385 return n.val
386}
387
388type negativeIntLiteralNode struct {
389 basicCompositeNode
390 val int64
391}
392
393func (n *negativeIntLiteralNode) value() interface{} {
394 return n.val
395}
396
397type floatLiteralNode struct {
398 basicCompositeNode
399 val float64
400}
401
402func (n *floatLiteralNode) value() interface{} {
403 return n.val
404}
405
406func (n *floatLiteralNode) popLeadingComment() *comment {
407 return n.first.(terminalNode).popLeadingComment()
408}
409
410func (n *floatLiteralNode) pushTrailingComment(c *comment) {
411 n.last.(terminalNode).pushTrailingComment(c)
412}
413
414type boolLiteralNode struct {
415 basicNode
416 val bool
417}
418
419func (n *boolLiteralNode) value() interface{} {
420 return n.val
421}
422
423type sliceLiteralNode struct {
424 basicCompositeNode
425 elements []valueNode
426}
427
428func (n *sliceLiteralNode) value() interface{} {
429 return n.elements
430}
431
432type aggregateLiteralNode struct {
433 basicCompositeNode
434 elements []*aggregateEntryNode
435}
436
437func (n *aggregateLiteralNode) value() interface{} {
438 return n.elements
439}
440
441type aggregateEntryNode struct {
442 basicCompositeNode
443 name *aggregateNameNode
444 val valueNode
445}
446
447type aggregateNameNode struct {
448 basicCompositeNode
449 name *identNode
450 isExtension bool
451}
452
453func (a *aggregateNameNode) value() string {
454 if a.isExtension {
455 return "[" + a.name.val + "]"
456 } else {
457 return a.name.val
458 }
459}
460
461type fieldNode struct {
462 basicCompositeNode
463 label *labelNode
464 fldType *identNode
465 name *identNode
466 tag *intLiteralNode
467 options []*optionNode
468
469 // This field is populated after parsing, to allow lookup of extendee source
470 // locations when field extendees cannot be linked. (Otherwise, this is just
471 // stored as a string in the field descriptors defined inside the extend
472 // block).
473 extendee *extendNode
474}
475
476func (n *fieldNode) fieldLabel() node {
477 // proto3 fields and fields inside one-ofs will not have a label and we need
478 // this check in order to return a nil node -- otherwise we'd return a
479 // non-nil node that has a nil pointer value in it :/
480 if n.label == nil {
481 return nil
482 }
483 return n.label
484}
485
486func (n *fieldNode) fieldName() node {
487 return n.name
488}
489
490func (n *fieldNode) fieldType() node {
491 return n.fldType
492}
493
494func (n *fieldNode) fieldTag() node {
495 return n.tag
496}
497
498func (n *fieldNode) fieldExtendee() node {
499 if n.extendee != nil {
500 return n.extendee.extendee
501 }
502 return nil
503}
504
505func (n *fieldNode) getGroupKeyword() node {
506 return nil
507}
508
509type labelNode struct {
510 basicNode
511 repeated bool
512 required bool
513}
514
515type groupNode struct {
516 basicCompositeNode
517 groupKeyword *identNode
518 label *labelNode
519 name *identNode
520 tag *intLiteralNode
521 decls []*messageElement
522
523 // This field is populated after parsing, to make it easier to find them
524 // without searching decls. The parse result has a map of descriptors to
525 // nodes which makes the other declarations easily discoverable. But these
526 // elements do not map to descriptors -- they are just stored as strings in
527 // the message descriptor.
528 reserved []*stringLiteralNode
529 // This field is populated after parsing, to allow lookup of extendee source
530 // locations when field extendees cannot be linked. (Otherwise, this is just
531 // stored as a string in the field descriptors defined inside the extend
532 // block).
533 extendee *extendNode
534}
535
536func (n *groupNode) fieldLabel() node {
537 return n.label
538}
539
540func (n *groupNode) fieldName() node {
541 return n.name
542}
543
544func (n *groupNode) fieldType() node {
545 return n.name
546}
547
548func (n *groupNode) fieldTag() node {
549 return n.tag
550}
551
552func (n *groupNode) fieldExtendee() node {
553 if n.extendee != nil {
554 return n.extendee.extendee
555 }
556 return nil
557}
558
559func (n *groupNode) getGroupKeyword() node {
560 return n.groupKeyword
561}
562
563func (n *groupNode) messageName() node {
564 return n.name
565}
566
567func (n *groupNode) reservedNames() []*stringLiteralNode {
568 return n.reserved
569}
570
571type oneOfNode struct {
572 basicCompositeNode
573 name *identNode
574 decls []*oneOfElement
575}
576
577type oneOfElement struct {
578 // a discriminated union: only one field will be set
579 option *optionNode
580 field *fieldNode
581 empty *basicNode
582}
583
584func (n *oneOfElement) start() *SourcePos {
585 return n.get().start()
586}
587
588func (n *oneOfElement) end() *SourcePos {
589 return n.get().end()
590}
591
592func (n *oneOfElement) leadingComments() []*comment {
593 return n.get().leadingComments()
594}
595
596func (n *oneOfElement) trailingComments() []*comment {
597 return n.get().trailingComments()
598}
599
600func (n *oneOfElement) get() node {
601 switch {
602 case n.option != nil:
603 return n.option
604 case n.field != nil:
605 return n.field
606 default:
607 return n.empty
608 }
609}
610
611type mapFieldNode struct {
612 basicCompositeNode
613 mapKeyword *identNode
614 keyType *identNode
615 valueType *identNode
616 name *identNode
617 tag *intLiteralNode
618 options []*optionNode
619}
620
621func (n *mapFieldNode) fieldLabel() node {
622 return n.mapKeyword
623}
624
625func (n *mapFieldNode) fieldName() node {
626 return n.name
627}
628
629func (n *mapFieldNode) fieldType() node {
630 return n.mapKeyword
631}
632
633func (n *mapFieldNode) fieldTag() node {
634 return n.tag
635}
636
637func (n *mapFieldNode) fieldExtendee() node {
638 return nil
639}
640
641func (n *mapFieldNode) getGroupKeyword() node {
642 return nil
643}
644
645func (n *mapFieldNode) messageName() node {
646 return n.name
647}
648
649func (n *mapFieldNode) reservedNames() []*stringLiteralNode {
650 return nil
651}
652
653func (n *mapFieldNode) keyField() *syntheticMapField {
654 tag := &intLiteralNode{
655 basicNode: basicNode{
656 posRange: posRange{start: n.keyType.start(), end: n.keyType.end()},
657 },
658 val: 1,
659 }
660 return &syntheticMapField{ident: n.keyType, tag: tag}
661}
662
663func (n *mapFieldNode) valueField() *syntheticMapField {
664 tag := &intLiteralNode{
665 basicNode: basicNode{
666 posRange: posRange{start: n.valueType.start(), end: n.valueType.end()},
667 },
668 val: 2,
669 }
670 return &syntheticMapField{ident: n.valueType, tag: tag}
671}
672
673type syntheticMapField struct {
674 ident *identNode
675 tag *intLiteralNode
676}
677
678func (n *syntheticMapField) start() *SourcePos {
679 return n.ident.start()
680}
681
682func (n *syntheticMapField) end() *SourcePos {
683 return n.ident.end()
684}
685
686func (n *syntheticMapField) leadingComments() []*comment {
687 return nil
688}
689
690func (n *syntheticMapField) trailingComments() []*comment {
691 return nil
692}
693
694func (n *syntheticMapField) fieldLabel() node {
695 return n.ident
696}
697
698func (n *syntheticMapField) fieldName() node {
699 return n.ident
700}
701
702func (n *syntheticMapField) fieldType() node {
703 return n.ident
704}
705
706func (n *syntheticMapField) fieldTag() node {
707 return n.tag
708}
709
710func (n *syntheticMapField) fieldExtendee() node {
711 return nil
712}
713
714func (n *syntheticMapField) getGroupKeyword() node {
715 return nil
716}
717
718type extensionRangeNode struct {
719 basicCompositeNode
720 ranges []*rangeNode
721 options []*optionNode
722}
723
724type rangeNode struct {
725 basicCompositeNode
726 stNode, enNode node
727 st, en int32
728}
729
730func (n *rangeNode) rangeStart() node {
731 return n.stNode
732}
733
734func (n *rangeNode) rangeEnd() node {
735 return n.enNode
736}
737
738type reservedNode struct {
739 basicCompositeNode
740 ranges []*rangeNode
741 names []*stringLiteralNode
742}
743
744type enumNode struct {
745 basicCompositeNode
746 name *identNode
747 decls []*enumElement
748
749 // This field is populated after parsing, to make it easier to find them
750 // without searching decls. The parse result has a map of descriptors to
751 // nodes which makes the other declarations easily discoverable. But these
752 // elements do not map to descriptors -- they are just stored as strings in
753 // the message descriptor.
754 reserved []*stringLiteralNode
755}
756
757type enumElement struct {
758 // a discriminated union: only one field will be set
759 option *optionNode
760 value *enumValueNode
761 reserved *reservedNode
762 empty *basicNode
763}
764
765func (n *enumElement) start() *SourcePos {
766 return n.get().start()
767}
768
769func (n *enumElement) end() *SourcePos {
770 return n.get().end()
771}
772
773func (n *enumElement) leadingComments() []*comment {
774 return n.get().leadingComments()
775}
776
777func (n *enumElement) trailingComments() []*comment {
778 return n.get().trailingComments()
779}
780
781func (n *enumElement) get() node {
782 switch {
783 case n.option != nil:
784 return n.option
785 case n.value != nil:
786 return n.value
787 default:
788 return n.empty
789 }
790}
791
792type enumValueNode struct {
793 basicCompositeNode
794 name *identNode
795 options []*optionNode
796
797 // only one of these two will be set:
798
799 numberP *intLiteralNode // positive numeric value
800 numberN *negativeIntLiteralNode // negative numeric value
801}
802
803func (n *enumValueNode) getName() node {
804 return n.name
805}
806
807func (n *enumValueNode) getNumber() node {
808 if n.numberP != nil {
809 return n.numberP
810 }
811 return n.numberN
812}
813
814type messageNode struct {
815 basicCompositeNode
816 name *identNode
817 decls []*messageElement
818
819 // This field is populated after parsing, to make it easier to find them
820 // without searching decls. The parse result has a map of descriptors to
821 // nodes which makes the other declarations easily discoverable. But these
822 // elements do not map to descriptors -- they are just stored as strings in
823 // the message descriptor.
824 reserved []*stringLiteralNode
825}
826
827func (n *messageNode) messageName() node {
828 return n.name
829}
830
831func (n *messageNode) reservedNames() []*stringLiteralNode {
832 return n.reserved
833}
834
835type messageElement struct {
836 // a discriminated union: only one field will be set
837 option *optionNode
838 field *fieldNode
839 mapField *mapFieldNode
840 oneOf *oneOfNode
841 group *groupNode
842 nested *messageNode
843 enum *enumNode
844 extend *extendNode
845 extensionRange *extensionRangeNode
846 reserved *reservedNode
847 empty *basicNode
848}
849
850func (n *messageElement) start() *SourcePos {
851 return n.get().start()
852}
853
854func (n *messageElement) end() *SourcePos {
855 return n.get().end()
856}
857
858func (n *messageElement) leadingComments() []*comment {
859 return n.get().leadingComments()
860}
861
862func (n *messageElement) trailingComments() []*comment {
863 return n.get().trailingComments()
864}
865
866func (n *messageElement) get() node {
867 switch {
868 case n.option != nil:
869 return n.option
870 case n.field != nil:
871 return n.field
872 case n.mapField != nil:
873 return n.mapField
874 case n.oneOf != nil:
875 return n.oneOf
876 case n.group != nil:
877 return n.group
878 case n.nested != nil:
879 return n.nested
880 case n.enum != nil:
881 return n.enum
882 case n.extend != nil:
883 return n.extend
884 case n.extensionRange != nil:
885 return n.extensionRange
886 case n.reserved != nil:
887 return n.reserved
888 default:
889 return n.empty
890 }
891}
892
893type extendNode struct {
894 basicCompositeNode
895 extendee *identNode
896 decls []*extendElement
897}
898
899type extendElement struct {
900 // a discriminated union: only one field will be set
901 field *fieldNode
902 group *groupNode
903 empty *basicNode
904}
905
906func (n *extendElement) start() *SourcePos {
907 return n.get().start()
908}
909
910func (n *extendElement) end() *SourcePos {
911 return n.get().end()
912}
913
914func (n *extendElement) leadingComments() []*comment {
915 return n.get().leadingComments()
916}
917
918func (n *extendElement) trailingComments() []*comment {
919 return n.get().trailingComments()
920}
921
922func (n *extendElement) get() node {
923 switch {
924 case n.field != nil:
925 return n.field
926 case n.group != nil:
927 return n.group
928 default:
929 return n.empty
930 }
931}
932
933type serviceNode struct {
934 basicCompositeNode
935 name *identNode
936 decls []*serviceElement
937}
938
939type serviceElement struct {
940 // a discriminated union: only one field will be set
941 option *optionNode
942 rpc *methodNode
943 empty *basicNode
944}
945
946func (n *serviceElement) start() *SourcePos {
947 return n.get().start()
948}
949
950func (n *serviceElement) end() *SourcePos {
951 return n.get().end()
952}
953
954func (n *serviceElement) leadingComments() []*comment {
955 return n.get().leadingComments()
956}
957
958func (n *serviceElement) trailingComments() []*comment {
959 return n.get().trailingComments()
960}
961
962func (n *serviceElement) get() node {
963 switch {
964 case n.option != nil:
965 return n.option
966 case n.rpc != nil:
967 return n.rpc
968 default:
969 return n.empty
970 }
971}
972
973type methodNode struct {
974 basicCompositeNode
975 name *identNode
976 input *rpcTypeNode
977 output *rpcTypeNode
978 options []*optionNode
979}
980
981func (n *methodNode) getInputType() node {
982 return n.input.msgType
983}
984
985func (n *methodNode) getOutputType() node {
986 return n.output.msgType
987}
988
989type rpcTypeNode struct {
990 basicCompositeNode
991 msgType *identNode
992 streamKeyword node
993}
994
995type noSourceNode struct {
996 pos *SourcePos
997}
998
999func (n noSourceNode) start() *SourcePos {
1000 return n.pos
1001}
1002
1003func (n noSourceNode) end() *SourcePos {
1004 return n.pos
1005}
1006
1007func (n noSourceNode) leadingComments() []*comment {
1008 return nil
1009}
1010
1011func (n noSourceNode) trailingComments() []*comment {
1012 return nil
1013}
1014
1015func (n noSourceNode) getSyntax() node {
1016 return n
1017}
1018
1019func (n noSourceNode) getName() node {
1020 return n
1021}
1022
1023func (n noSourceNode) getValue() valueNode {
1024 return n
1025}
1026
1027func (n noSourceNode) fieldLabel() node {
1028 return n
1029}
1030
1031func (n noSourceNode) fieldName() node {
1032 return n
1033}
1034
1035func (n noSourceNode) fieldType() node {
1036 return n
1037}
1038
1039func (n noSourceNode) fieldTag() node {
1040 return n
1041}
1042
1043func (n noSourceNode) fieldExtendee() node {
1044 return n
1045}
1046
1047func (n noSourceNode) getGroupKeyword() node {
1048 return n
1049}
1050
1051func (n noSourceNode) rangeStart() node {
1052 return n
1053}
1054
1055func (n noSourceNode) rangeEnd() node {
1056 return n
1057}
1058
1059func (n noSourceNode) getNumber() node {
1060 return n
1061}
1062
1063func (n noSourceNode) messageName() node {
1064 return n
1065}
1066
1067func (n noSourceNode) reservedNames() []*stringLiteralNode {
1068 return nil
1069}
1070
1071func (n noSourceNode) getInputType() node {
1072 return n
1073}
1074
1075func (n noSourceNode) getOutputType() node {
1076 return n
1077}
1078
1079func (n noSourceNode) value() interface{} {
1080 return nil
1081}