-
Notifications
You must be signed in to change notification settings - Fork 745
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add pbkit as a Protobuf parser (#592)
* Add protobuf parser * feat: add protocol buffers parser * doc: add pbkit to README * remove an unused babel plugin * remove verdored parser * chore: up pbkit (#1) it resolves some parse error cases Co-authored-by: JongChan Choi <disjukr@naver.com>
- Loading branch information
Showing
7 changed files
with
86 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
syntax = "proto3"; | ||
package tutorial; | ||
|
||
import "google/protobuf/timestamp.proto"; | ||
|
||
option go_package = "github.com/protocolbuffers/protobuf/examples/go/tutorialpb"; | ||
|
||
message Person { | ||
string name = 1; | ||
int32 id = 2; // Unique ID number for this person. | ||
string email = 3; | ||
|
||
enum PhoneType { | ||
MOBILE = 0; | ||
HOME = 1; | ||
WORK = 2; | ||
} | ||
|
||
message PhoneNumber { | ||
string number = 1; | ||
PhoneType type = 2; | ||
} | ||
|
||
repeated PhoneNumber phones = 4; | ||
|
||
google.protobuf.Timestamp last_updated = 5; | ||
} | ||
|
||
// Our address book file is just one of these. | ||
message AddressBook { | ||
repeated Person people = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import 'codemirror/mode/protobuf/protobuf'; | ||
|
||
export const id = 'protobuf'; | ||
export const displayName = 'Protocol Buffers'; | ||
export const mimeTypes = ['text/x-protobuf']; | ||
export const fileExtension = 'proto'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import defaultParserInterface from '../utils/defaultParserInterface'; | ||
import pkg from 'pbkit/package.json'; | ||
|
||
const ID = 'pbkit'; | ||
|
||
export default { | ||
...defaultParserInterface, | ||
id: ID, | ||
displayName: ID, | ||
version: pkg.version, | ||
homepage: 'https://github.com/riiid/pbkit', | ||
locationProps: new Set(['start', 'end']), | ||
typeProps: new Set(['type']), | ||
|
||
loadParser(callback) { | ||
require(['pbkit/core/parser/proto'], callback); | ||
}, | ||
|
||
parse(parser, code) { | ||
return parser.parse(code).ast; | ||
}, | ||
|
||
nodeToRange(node) { | ||
const { start, end } = node; | ||
return [start, end]; | ||
}, | ||
|
||
opensByDefault(node, key) { | ||
if (key === 'statements') { | ||
return true; | ||
} | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters