Skip to content

Commit dcdf014

Browse files
jucrouzetmarijnh
authored andcommitted
[protobuf mode] Add protobuf3 / gRPC keywords
1 parent 44ab677 commit dcdf014

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

mode/protobuf/index.html

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,49 @@ <h2>ProtoBuf mode</h2>
5454
required bool deleted = 11 [default = false];
5555
}
5656

57-
</textarea></form>
57+
</textarea>
58+
<textarea id="code2" name="code2">
59+
syntax = "proto3";
60+
package tutorial;
61+
62+
import "google/protobuf/timestamp.proto";
63+
option java_package = "com.example.tutorial";
64+
option java_outer_classname = "AddressBookProtos";
65+
option csharp_namespace = "Google.Protobuf.Examples.AddressBook";
66+
67+
message Person {
68+
string name = 1;
69+
int32 id = 2; // Unique ID number for this person.
70+
string email = 3;
71+
72+
enum PhoneType {
73+
MOBILE = 0;
74+
HOME = 1;
75+
WORK = 2;
76+
}
77+
78+
message PhoneNumber {
79+
string number = 1;
80+
PhoneType type = 2;
81+
}
82+
83+
repeated PhoneNumber phones = 4;
84+
85+
google.protobuf.Timestamp last_updated = 5;
86+
}
87+
88+
// Our address book file is just one of these.
89+
message AddressBook {
90+
repeated Person people = 1;
91+
}
92+
service Test {
93+
rpc SayHello (HelloRequest) returns (HelloReply) {}
94+
rpc SayHelloAgain (HelloRequest) returns (HelloReply) {}
95+
}</textarea>
96+
</form>
5897
<script>
5998
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
99+
var editor = CodeMirror.fromTextArea(document.getElementById("code2"), {});
60100
</script>
61101

62102
<p><strong>MIME types defined:</strong> <code>text/x-protobuf</code>.</p>

mode/protobuf/protobuf.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919
"package", "message", "import", "syntax",
2020
"required", "optional", "repeated", "reserved", "default", "extensions", "packed",
2121
"bool", "bytes", "double", "enum", "float", "string",
22-
"int32", "int64", "uint32", "uint64", "sint32", "sint64", "fixed32", "fixed64", "sfixed32", "sfixed64"
22+
"int32", "int64", "uint32", "uint64", "sint32", "sint64", "fixed32", "fixed64", "sfixed32", "sfixed64",
23+
"option", "service", "rpc", "returns"
2324
];
2425
var keywords = wordRegexp(keywordArray);
2526

0 commit comments

Comments
 (0)