├── .bazelignore ├── .bazelrc ├── .bazelversion ├── .deepsource.toml ├── .editorconfig ├── .errcheckignore ├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug-report.md │ └── enhancement.md ├── PULL_REQUEST_TEMPLATE.md ├── stale.yml └── workflows │ └── test.yml ├── .gitignore ├── .golangci.yml ├── BUILD.bazel ├── CONTRIBUTING.md ├── LICENSE ├── Makefile ├── NOTICE ├── README.md ├── WORKSPACE ├── build └── bazel │ ├── BUILD.bazel │ ├── deps.bzl │ └── gomock.bzl ├── cmd └── protocol-buffers-language-server │ ├── BUILD.bazel │ └── main.go ├── docs ├── assets │ └── logo.png └── development.md ├── go.mod ├── go.sum ├── hack ├── expose-generated-go.sh └── tools.go └── pkg ├── config ├── BUILD.bazel ├── config.go ├── config_test.go └── doc.go ├── logging ├── BUILD.bazel ├── context.go ├── doc.go └── logging.go ├── lsp ├── BUILD.bazel ├── doc.go ├── server │ ├── BUILD.bazel │ ├── completion.go │ ├── completion_test.go │ ├── definition.go │ ├── definition_test.go │ ├── general.go │ ├── general_test.go │ ├── server.go │ ├── server_test.go │ ├── text_synchronization.go │ ├── text_synchronization_test.go │ ├── workspace.go │ └── workspace_test.go └── source │ ├── BUILD.bazel │ ├── doc.go │ ├── file.go │ ├── session.go │ ├── session_test.go │ ├── sourcetest │ ├── BUILD.bazel │ └── mock.go │ ├── view.go │ └── view_test.go └── proto ├── parser ├── BUILD.bazel ├── parser.go └── parser_test.go ├── registry ├── BUILD.bazel ├── doc.go ├── enum.go ├── enum_test.go ├── map.go ├── map_test.go ├── message.go ├── message_test.go ├── oneof.go ├── oneof_test.go ├── package.go ├── package_test.go ├── proto.go ├── proto_test.go ├── registrytest │ ├── BUILD.bazel │ └── mock.go ├── service.go └── service_test.go └── types ├── BUILD.bazel └── types.go /.bazelignore: -------------------------------------------------------------------------------- 1 | .git -------------------------------------------------------------------------------- /.bazelrc: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | build --verbose_failures 16 | test --test_output=errors 17 | 18 | build:unit --features=race 19 | test:unit --features=race 20 | 21 | build --show_timestamps --verbose_failures 22 | test --test_output=errors --test_verbose_timeout_warnings 23 | 24 | # https://github.com/bazelbuild/rules_docker/issues/842 25 | build --host_force_python=PY2 26 | test --host_force_python=PY2 27 | run --host_force_python=PY2 28 | -------------------------------------------------------------------------------- /.bazelversion: -------------------------------------------------------------------------------- 1 | 2.0.0 2 | -------------------------------------------------------------------------------- /.deepsource.toml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | version = 1 16 | 17 | test_patterns = [ 18 | '**/*_test.go' 19 | ] 20 | 21 | [[analyzers]] 22 | name = 'go' 23 | enabled = true 24 | 25 | [analyzers.meta] 26 | import_path = 'github.com/micnncim/protocol-buffers-language-server' 27 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | root = true 16 | 17 | [*] 18 | indent_style = space 19 | indent_size = 4 20 | end_of_line = lf 21 | charset = utf-8 22 | trim_trailing_whitespace = true 23 | insert_final_newline = true 24 | 25 | [*.go] 26 | indent_style = tab 27 | 28 | [Makefile] 29 | indent_style = tab 30 | 31 | [*.md] 32 | trim_trailing_whitespace = false 33 | 34 | [*.yml] 35 | indent_size = 2 36 | -------------------------------------------------------------------------------- /.errcheckignore: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | go.uber.org/multierr.Append 16 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # https://github.com/github/linguist#using-gitattributes 2 | **/doc.go linguist-documentation 3 | WORKSPACE linguist-detectable=false 4 | **/*.bazel linguist-detectable=false 5 | **/*.bzl linguist-detectable=false 6 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug-report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug Report 3 | about: Report a bug encountered 4 | labels: bug 5 | 6 | --- 7 | 8 | 9 | 10 | ## What happened 11 | 12 | ## What you expected to happen 13 | 14 | ## How to reproduce it 15 | 16 | ## Environment 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/enhancement.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Enhancement Request 3 | about: Suggest an enhancement to the this project 4 | labels: enhancement 5 | --- 6 | 7 | 8 | 9 | ## What you want to add 10 | 11 | ## Why this is needed 12 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## What this PR does / Why we need it 2 | 3 | ## Which issue(s) this PR fixes 4 | 5 | Fixes # 6 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # https://probot.github.io/apps/stale 2 | 3 | # Number of days of inactivity before an issue becomes stale 4 | daysUntilStale: 60 5 | # Number of days of inactivity before a stale issue is closed 6 | daysUntilClose: 7 7 | # Issues with these labels will never be considered stale 8 | exemptLabels: 9 | - bug 10 | - help wanted 11 | # Label to use when marking an issue as stale 12 | staleLabel: stale 13 | # Comment to post when marking an issue as stale. Set to `false` to disable 14 | markComment: > 15 | This issue has been automatically marked as stale because it has not had 16 | recent activity. It will be closed if no further activity occurs. Thank you 17 | for your contributions. 18 | # Comment to post when closing a stale issue. Set to `false` to disable 19 | closeComment: false 20 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | on: [push] 3 | jobs: 4 | 5 | test: 6 | name: Test 7 | runs-on: ubuntu-latest 8 | steps: 9 | 10 | - name: Check out code into the Go modules directory 11 | uses: actions/checkout@v2 12 | 13 | - name: Cache Bazel binary from Bazelisk 14 | uses: actions/cache@v1 15 | with: 16 | path: ~/.cache/bazelisk/bin 17 | key: ${{ runner.os }}-${{ hashFiles('.bazelversion') }} 18 | 19 | - name: Test 20 | run: make test 21 | 22 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /bazel-bin 2 | /bazel-genfiles 3 | /bazel-out 4 | /bazel-protocol-buffers-language-server 5 | /bazel-testlogs 6 | 7 | /bin 8 | 9 | *.pb.go 10 | *.pb.validate.go 11 | *.mock.go 12 | -------------------------------------------------------------------------------- /.golangci.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | service: 16 | golangci-lint-version: 1.17.x 17 | run: 18 | deadline: 5m 19 | 20 | skip-dirs: 21 | - vendor$ 22 | 23 | skip-files: 24 | - ".*\\.pb\\.go" 25 | - ".*\\.mock\\.go" 26 | - ".*(.|_)gen\\.go" 27 | 28 | linters: 29 | enable-all: true 30 | disable: 31 | - depguard 32 | - dupl 33 | - gochecknoglobals 34 | - gochecknoinits 35 | - goconst 36 | - gocyclo 37 | - gosec 38 | - nakedret 39 | - prealloc 40 | - scopelint 41 | fast: false 42 | 43 | linters-settings: 44 | errcheck: 45 | check-type-assertions: false 46 | check-blank: true 47 | exclude: .errcheckignore 48 | govet: 49 | check-shadowing: false 50 | golint: 51 | min-confidence: 0.8 52 | gofmt: 53 | simplify: true 54 | goimports: 55 | local-prefixes: github.com/micnncim/protocol-buffers-language-server 56 | maligned: 57 | suggest-new: true 58 | misspell: 59 | locale: US 60 | lll: 61 | line-length: 160 62 | tab-width: 1 63 | unused: 64 | check-exported: false 65 | unparam: 66 | algo: cha 67 | check-exported: false 68 | gocritic: 69 | disabled-checks: 70 | - regexpMust 71 | enabled-tags: 72 | - performance 73 | settings: 74 | captLocal: 75 | paramsOnly: true 76 | hugeParam: 77 | sizeThreshold: 80 78 | rangeExprCopy: 79 | sizeThreshold: 512 80 | rangeValCopy: 81 | sizeThreshold: 128 82 | issues: 83 | exclude-rules: 84 | - path: _test\.go$ 85 | linters: 86 | - errcheck 87 | - maligned 88 | -------------------------------------------------------------------------------- /BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@bazel_gazelle//:def.bzl", "gazelle") 16 | 17 | # gazelle:prefix github.com/micnncim/protocol-buffers-language-server 18 | gazelle(name = "gazelle") 19 | 20 | load("@com_github_bazelbuild_buildtools//buildifier:def.bzl", "buildifier") 21 | 22 | buildifier( 23 | name = "buildifier", 24 | exclude_patterns = [ 25 | "./docs/*", 26 | ], 27 | ) 28 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contribution Guide 2 | 3 | ## Pull Requests 4 | 5 | We have some rules for pull requests. 6 | 7 | - Use [the pull request template](/.github/PULL_REQUEST_TEMPLATE.md). 8 | - Commit messages start with a verb with capital letter. 9 | - e.g) `Add enviroment variable of log level to config for debugging` 10 | - Commits are merged with squash. 11 | For more information, see [Squash your commits by GitHub](https://github.blog/2016-04-01-squash-your-commits/). 12 | 13 | See [Writing Good Pull Requests by Istio](https://github.com/istio/istio/wiki/Writing-Good-Pull-Requests) for guidance on creating pull requests 14 | 15 | ### GitHub Workflow 16 | 17 | This project adopts GitHub Workflow. For more information, see [the GitHub Workflow Guide by Kubernetes](https://github.com/kubernetes/community/blob/master/contributors/guide/github-workflow.md). 18 | 19 | ## Issues 20 | 21 | GitHub issues can be used to report bugs or submit feature requests. 22 | Use [the issue templates](./.github/ISSUE_TEMPLATE). 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright 2019 The Protocol Buffers Language Server Authors. 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | .PHONY: dep 16 | dep: bin/bazelisk 17 | go mod tidy 18 | bin/bazelisk run //:gazelle 19 | bin/bazelisk run //:gazelle -- update-repos -from_file=go.mod -to_macro=build/bazel/deps.bzl%go_repositories 20 | 21 | .PHONY: run 22 | run: bin/bazelisk 23 | bin/bazelisk run //cmd/protocol-buffers-language-server 24 | 25 | .PHONY: build 26 | build: bin/bazelisk 27 | bin/bazelisk build //... 28 | 29 | .PHONY: test 30 | test: bin/bazelisk 31 | bin/bazelisk test //... 32 | 33 | .PHONY: buildifier 34 | buildifier: bin/bazelisk 35 | bin/bazelisk run //:buildifier 36 | 37 | .PHONY: clean 38 | clean: bin/bazelisk 39 | bin/bazelisk clean 40 | 41 | .PHONY: coverage 42 | coverage: 43 | go test -v -race -covermode=atomic -coverpkg=./... -coverprofile=coverage.txt ./... 44 | 45 | .PHONY: expose-generated-go 46 | expose-generated-go: 47 | ./hack/expose-generated-go.sh micnncim protocol-buffers-language-server 48 | 49 | bin/bazelisk: 50 | @mkdir -p bin 51 | go build -o bin/bazelisk github.com/bazelbuild/bazelisk 52 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | Protocol Buffers Language Server 2 | 3 | =============== 4 | 5 | This product contains a modified part of gopls, distributed by The Go Authors: 6 | 7 | - License: https://github.com/golang/tools/blob/master/LICENSE 8 | - Homepage: https://github.com/golang/tools 9 | 10 | 11 | This product contains a modified part of bazel_gomock, distributed by Jeff Hodges: 12 | 13 | - License: https://github.com/jmhodges/bazel_gomock/blob/master/LICENSE (MIT) 14 | - Homepage: https://github.com/jmhodges/bazel_gomock 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![](docs/assets/logo.png) 2 | 3 | [![actions-workflow-test][actions-workflow-test-badge]][actions-workflow-test] 4 | [![pkg.go.dev][pkg.go.dev-badge]][pkg.go.dev] 5 | [![codefactor][codefactor-badge]][codefactor] 6 | [![dependabot][dependabot-badge]][dependabot] 7 | [![license][license-badge]][license] 8 | 9 | **WARNING**: 10 | This repository is in active development. 11 | There are no guarantees about stability. 12 | Breaking changes will occur until a stable release is made and announced. 13 | 14 | [Language Server](https://langserver.org/) for [Protocol Buffers](https://developers.google.com/protocol-buffers/). 15 | 16 | ## Development 17 | 18 | See [Development Guide](./docs/development.md). 19 | 20 | ## Contribution 21 | 22 | See [Contribution Guide](./CONTRIBUTING.md). 23 | 24 | ## Reference 25 | 26 | - [Langserver.org](https://langserver.org/) 27 | - [Official page for Language Server Protocol](https://microsoft.github.io/language-server-protocol/) 28 | - [Protocol Buffers  |  Google Developers](https://developers.google.com/protocol-buffers/) 29 | 30 | ## Author 31 | 32 | [@micnncim](https://github.com/micnncim) 33 | 34 | ## License 35 | 36 | Copyright 2019 The Protocol Buffers Language Server Authors. 37 | 38 | Protocol Buffers Language Server is released under the [Apache License 2.0](./LICENSE). 39 | 40 | 41 | 42 | [actions-workflow-test]: https://github.com/micnncim/protocol-buffers-language-server/actions?query=workflow%3ATest 43 | [actions-workflow-test-badge]: https://img.shields.io/github/workflow/status/micnncim/protocol-buffers-language-server/Test?label=Test&style=for-the-badge&logo=github 44 | 45 | [pkg.go.dev]: https://pkg.go.dev/github.com/micnncim/protocol-buffers-language-server?tab=overview 46 | [pkg.go.dev-badge]: https://img.shields.io/badge/pkg.go.dev-reference-02ABD7?style=for-the-badge&logoWidth=25&logo=data%3Aimage%2Fsvg%2Bxml%3Bbase64%2CPHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9Ijg1IDU1IDEyMCAxMjAiPjxwYXRoIGZpbGw9IiMwMEFERDgiIGQ9Ik00MC4yIDEwMS4xYy0uNCAwLS41LS4yLS4zLS41bDIuMS0yLjdjLjItLjMuNy0uNSAxLjEtLjVoMzUuN2MuNCAwIC41LjMuMy42bC0xLjcgMi42Yy0uMi4zLS43LjYtMSAuNmwtMzYuMi0uMXptLTE1LjEgOS4yYy0uNCAwLS41LS4yLS4zLS41bDIuMS0yLjdjLjItLjMuNy0uNSAxLjEtLjVoNDUuNmMuNCAwIC42LjMuNS42bC0uOCAyLjRjLS4xLjQtLjUuNi0uOS42bC00Ny4zLjF6bTI0LjIgOS4yYy0uNCAwLS41LS4zLS4zLS42bDEuNC0yLjVjLjItLjMuNi0uNiAxLS42aDIwYy40IDAgLjYuMy42LjdsLS4yIDIuNGMwIC40LS40LjctLjcuN2wtMjEuOC0uMXptMTAzLjgtMjAuMmMtNi4zIDEuNi0xMC42IDIuOC0xNi44IDQuNC0xLjUuNC0xLjYuNS0yLjktMS0xLjUtMS43LTIuNi0yLjgtNC43LTMuOC02LjMtMy4xLTEyLjQtMi4yLTE4LjEgMS41LTYuOCA0LjQtMTAuMyAxMC45LTEwLjIgMTkgLjEgOCA1LjYgMTQuNiAxMy41IDE1LjcgNi44LjkgMTIuNS0xLjUgMTctNi42LjktMS4xIDEuNy0yLjMgMi43LTMuN2gtMTkuM2MtMi4xIDAtMi42LTEuMy0xLjktMyAxLjMtMy4xIDMuNy04LjMgNS4xLTEwLjkuMy0uNiAxLTEuNiAyLjUtMS42aDM2LjRjLS4yIDIuNy0uMiA1LjQtLjYgOC4xLTEuMSA3LjItMy44IDEzLjgtOC4yIDE5LjYtNy4yIDkuNS0xNi42IDE1LjQtMjguNSAxNy05LjggMS4zLTE4LjktLjYtMjYuOS02LjYtNy40LTUuNi0xMS42LTEzLTEyLjctMjIuMi0xLjMtMTAuOSAxLjktMjAuNyA4LjUtMjkuMyA3LjEtOS4zIDE2LjUtMTUuMiAyOC0xNy4zIDkuNC0xLjcgMTguNC0uNiAyNi41IDQuOSA1LjMgMy41IDkuMSA4LjMgMTEuNiAxNC4xLjYuOS4yIDEuNC0xIDEuN3oiLz48cGF0aCBmaWxsPSIjMDBBREQ4IiBkPSJNMTg2LjIgMTU0LjZjLTkuMS0uMi0xNy40LTIuOC0yNC40LTguOC01LjktNS4xLTkuNi0xMS42LTEwLjgtMTkuMy0xLjgtMTEuMyAxLjMtMjEuMyA4LjEtMzAuMiA3LjMtOS42IDE2LjEtMTQuNiAyOC0xNi43IDEwLjItMS44IDE5LjgtLjggMjguNSA1LjEgNy45IDUuNCAxMi44IDEyLjcgMTQuMSAyMi4zIDEuNyAxMy41LTIuMiAyNC41LTExLjUgMzMuOS02LjYgNi43LTE0LjcgMTAuOS0yNCAxMi44LTIuNy41LTUuNC42LTggLjl6bTIzLjgtNDAuNGMtLjEtMS4zLS4xLTIuMy0uMy0zLjMtMS44LTkuOS0xMC45LTE1LjUtMjAuNC0xMy4zLTkuMyAyLjEtMTUuMyA4LTE3LjUgMTcuNC0xLjggNy44IDIgMTUuNyA5LjIgMTguOSA1LjUgMi40IDExIDIuMSAxNi4zLS42IDcuOS00LjEgMTIuMi0xMC41IDEyLjctMTkuMXoiLz48L3N2Zz4= 47 | 48 | [codefactor]: https://www.codefactor.io/repository/github/micnncim/protocol-buffers-language-server 49 | [codefactor-badge]: https://img.shields.io/codefactor/grade/github/micnncim/protocol-buffers-language-server?logo=codefactor&style=for-the-badge 50 | 51 | [dependabot]: https://github.com/micnncim/protocol-buffers-language-server/pulls?q=is:pr%20author:app/dependabot-preview 52 | [dependabot-badge]: https://img.shields.io/badge/dependabot-enabled-blue?style=for-the-badge&logo=dependabot 53 | 54 | [license]: LICENSE 55 | [license-badge]: https://img.shields.io/github/license/micnncim/protocol-buffers-language-server?style=for-the-badge 56 | 57 | -------------------------------------------------------------------------------- /WORKSPACE: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | workspace( 16 | name = "protocol_buffers_language_server", 17 | ) 18 | 19 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 20 | 21 | ## Go 22 | 23 | http_archive( 24 | name = "io_bazel_rules_go", 25 | sha256 = "ae8c36ff6e565f674c7a3692d6a9ea1096e4c1ade497272c2108a810fb39acd2", 26 | urls = [ 27 | "https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/rules_go/releases/download/0.19.4/rules_go-0.19.4.tar.gz", 28 | "https://github.com/bazelbuild/rules_go/releases/download/0.19.4/rules_go-0.19.4.tar.gz", 29 | ], 30 | ) 31 | 32 | load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies") 33 | 34 | go_rules_dependencies() 35 | 36 | go_register_toolchains( 37 | go_version = "1.13", 38 | ) 39 | 40 | ## gazelle 41 | 42 | http_archive( 43 | name = "bazel_gazelle", 44 | sha256 = "7fc87f4170011201b1690326e8c16c5d802836e3a0d617d8f75c3af2b23180c4", 45 | urls = [ 46 | "https://storage.googleapis.com/bazel-mirror/github.com/bazelbuild/bazel-gazelle/releases/download/0.18.2/bazel-gazelle-0.18.2.tar.gz", 47 | "https://github.com/bazelbuild/bazel-gazelle/releases/download/0.18.2/bazel-gazelle-0.18.2.tar.gz", 48 | ], 49 | ) 50 | 51 | load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies", "go_repository") 52 | 53 | gazelle_dependencies() 54 | 55 | ## buildtools 56 | 57 | http_archive( 58 | name = "com_github_bazelbuild_buildtools", 59 | strip_prefix = "buildtools-0.28.0", 60 | url = "https://github.com/bazelbuild/buildtools/archive/0.28.0.zip", 61 | ) 62 | 63 | load( 64 | "@com_github_bazelbuild_buildtools//buildifier:deps.bzl", 65 | "buildifier_dependencies", 66 | ) 67 | 68 | buildifier_dependencies() 69 | 70 | ## protobuf 71 | 72 | http_archive( 73 | name = "com_google_protobuf", 74 | sha256 = "2ee9dcec820352671eb83e081295ba43f7a4157181dad549024d7070d079cf65", 75 | strip_prefix = "protobuf-3.9.0", 76 | urls = ["https://github.com/protocolbuffers/protobuf/archive/v3.9.0.tar.gz"], 77 | ) 78 | 79 | load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps") 80 | 81 | protobuf_deps() 82 | 83 | # gazelle:repository_macro build/bazel/deps.bzl%go_repositories 84 | 85 | ## Load dependencies 86 | 87 | load("//build/bazel:deps.bzl", "go_repositories") 88 | 89 | go_repositories() 90 | -------------------------------------------------------------------------------- /build/bazel/BUILD.bazel: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micnncim/protocol-buffers-language-server/6c789bde03b5bfdf3854a7eee725108d430f7134/build/bazel/BUILD.bazel -------------------------------------------------------------------------------- /build/bazel/deps.bzl: -------------------------------------------------------------------------------- 1 | load("@bazel_gazelle//:deps.bzl", "go_repository") 2 | 3 | def go_repositories(): 4 | go_repository( 5 | name = "com_github_golang_lint", 6 | importpath = "github.com/golang/lint", 7 | sum = "h1:2hRPrmiwPrp3fQX967rNJIhQPtiGXdlQWAxKbKw3VHA=", 8 | version = "v0.0.0-20180702182130-06c8688daad7", 9 | ) 10 | go_repository( 11 | name = "com_github_kisielk_gotool", 12 | importpath = "github.com/kisielk/gotool", 13 | sum = "h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg=", 14 | version = "v1.0.0", 15 | ) 16 | go_repository( 17 | name = "co_honnef_go_tools", 18 | importpath = "honnef.co/go/tools", 19 | sum = "h1:/8zB6iBfHCl1qAnEAWwGPNrUvapuy6CPla1VM0k8hQw=", 20 | version = "v0.0.0-20190106161140-3f1c8253044a", 21 | ) 22 | go_repository( 23 | name = "com_github_anmitsu_go_shlex", 24 | importpath = "github.com/anmitsu/go-shlex", 25 | sum = "h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=", 26 | version = "v0.0.0-20161002113705-648efa622239", 27 | ) 28 | go_repository( 29 | name = "com_github_beorn7_perks", 30 | importpath = "github.com/beorn7/perks", 31 | sum = "h1:xJ4a3vCFaGF/jqvzLMYoU8P317H5OQ+Via4RmuPwCS0=", 32 | version = "v0.0.0-20180321164747-3a771d992973", 33 | ) 34 | go_repository( 35 | name = "com_github_bradfitz_go_smtpd", 36 | importpath = "github.com/bradfitz/go-smtpd", 37 | sum = "h1:ckJgFhFWywOx+YLEMIJsTb+NV6NexWICk5+AMSuz3ss=", 38 | version = "v0.0.0-20170404230938-deb6d6237625", 39 | ) 40 | go_repository( 41 | name = "com_github_buger_jsonparser", 42 | importpath = "github.com/buger/jsonparser", 43 | sum = "h1:D21IyuvjDCshj1/qq+pCNd3VZOAEI9jy6Bi131YlXgI=", 44 | version = "v0.0.0-20181115193947-bf1c66bbce23", 45 | ) 46 | go_repository( 47 | name = "com_github_burntsushi_toml", 48 | importpath = "github.com/BurntSushi/toml", 49 | sum = "h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=", 50 | version = "v0.3.1", 51 | ) 52 | go_repository( 53 | name = "com_github_client9_misspell", 54 | importpath = "github.com/client9/misspell", 55 | sum = "h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI=", 56 | version = "v0.3.4", 57 | ) 58 | go_repository( 59 | name = "com_github_coreos_go_systemd", 60 | importpath = "github.com/coreos/go-systemd", 61 | sum = "h1:t5Wuyh53qYyg9eqn4BbnlIT+vmhyww0TatL+zT3uWgI=", 62 | version = "v0.0.0-20181012123002-c6f51f82210d", 63 | ) 64 | go_repository( 65 | name = "com_github_davecgh_go_spew", 66 | importpath = "github.com/davecgh/go-spew", 67 | sum = "h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=", 68 | version = "v1.1.1", 69 | ) 70 | go_repository( 71 | name = "com_github_dustin_go_humanize", 72 | importpath = "github.com/dustin/go-humanize", 73 | sum = "h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=", 74 | version = "v1.0.0", 75 | ) 76 | go_repository( 77 | name = "com_github_emicklei_proto", 78 | importpath = "github.com/emicklei/proto", 79 | sum = "h1:XbpwxmuOPrdES97FrSfpyy67SSCV/wBIKXqgJzh6hNw=", 80 | version = "v1.6.15", 81 | ) 82 | go_repository( 83 | name = "com_github_flynn_go_shlex", 84 | importpath = "github.com/flynn/go-shlex", 85 | sum = "h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=", 86 | version = "v0.0.0-20150515145356-3f9db97f8568", 87 | ) 88 | go_repository( 89 | name = "com_github_francoispqt_gojay", 90 | importpath = "github.com/francoispqt/gojay", 91 | sum = "h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk=", 92 | version = "v1.2.13", 93 | ) 94 | go_repository( 95 | name = "com_github_fsnotify_fsnotify", 96 | importpath = "github.com/fsnotify/fsnotify", 97 | sum = "h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=", 98 | version = "v1.4.7", 99 | ) 100 | go_repository( 101 | name = "com_github_ghodss_yaml", 102 | importpath = "github.com/ghodss/yaml", 103 | sum = "h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk=", 104 | version = "v1.0.0", 105 | ) 106 | go_repository( 107 | name = "com_github_gliderlabs_ssh", 108 | importpath = "github.com/gliderlabs/ssh", 109 | sum = "h1:j3L6gSLQalDETeEg/Jg0mGY0/y/N6zI2xX1978P0Uqw=", 110 | version = "v0.1.1", 111 | ) 112 | go_repository( 113 | name = "com_github_go_errors_errors", 114 | importpath = "github.com/go-errors/errors", 115 | sum = "h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=", 116 | version = "v1.0.1", 117 | ) 118 | go_repository( 119 | name = "com_github_go_language_server_jsonrpc2", 120 | importpath = "github.com/go-language-server/jsonrpc2", 121 | sum = "h1:lWefg5lZbYnrSQHqKEyHEGZ2himQXtDkfmA13ZR/XFM=", 122 | version = "v0.3.0", 123 | ) 124 | go_repository( 125 | name = "com_github_go_language_server_protocol", 126 | importpath = "github.com/go-language-server/protocol", 127 | sum = "h1:nDdo0E1txdMyYqY0GnXTki/xcy5jMbXJj+NWPrmb/PM=", 128 | version = "v0.5.0", 129 | ) 130 | go_repository( 131 | name = "com_github_go_language_server_uri", 132 | importpath = "github.com/go-language-server/uri", 133 | sum = "h1:zkFlKR0EYmCg3076hwVbM9/+/Ugr8vMQvQQgoS2JpTo=", 134 | version = "v0.2.0", 135 | ) 136 | go_repository( 137 | name = "com_github_gogo_protobuf", 138 | importpath = "github.com/gogo/protobuf", 139 | sum = "h1:72R+M5VuhED/KujmZVcIquuo8mBgX4oVda//DQb3PXo=", 140 | version = "v1.1.1", 141 | ) 142 | go_repository( 143 | name = "com_github_golang_glog", 144 | importpath = "github.com/golang/glog", 145 | sum = "h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=", 146 | version = "v0.0.0-20160126235308-23def4e6c14b", 147 | ) 148 | go_repository( 149 | name = "com_github_golang_mock", 150 | importpath = "github.com/golang/mock", 151 | sum = "h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s=", 152 | version = "v1.3.1", 153 | ) 154 | go_repository( 155 | name = "com_github_golang_protobuf", 156 | importpath = "github.com/golang/protobuf", 157 | sum = "h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg=", 158 | version = "v1.3.1", 159 | ) 160 | go_repository( 161 | name = "com_github_google_btree", 162 | importpath = "github.com/google/btree", 163 | sum = "h1:964Od4U6p2jUkFxvCydnIczKteheJEzHRToSGK3Bnlw=", 164 | version = "v0.0.0-20180813153112-4030bb1f1f0c", 165 | ) 166 | go_repository( 167 | name = "com_github_google_go_cmp", 168 | importpath = "github.com/google/go-cmp", 169 | sum = "h1:B3yqxlLHBEoav+FDQM8ph7IIRA6AhQ70w119k3hoT2Y=", 170 | version = "v0.3.2-0.20190829225427-b1c9c4891a65", 171 | ) 172 | go_repository( 173 | name = "com_github_google_go_github", 174 | importpath = "github.com/google/go-github", 175 | sum = "h1:N0LgJ1j65A7kfXrZnUDaYCs/Sf4rEjNlfyDHW9dolSY=", 176 | version = "v17.0.0+incompatible", 177 | ) 178 | go_repository( 179 | name = "com_github_google_go_querystring", 180 | importpath = "github.com/google/go-querystring", 181 | sum = "h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=", 182 | version = "v1.0.0", 183 | ) 184 | go_repository( 185 | name = "com_github_google_martian", 186 | importpath = "github.com/google/martian", 187 | sum = "h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=", 188 | version = "v2.1.0+incompatible", 189 | ) 190 | go_repository( 191 | name = "com_github_google_pprof", 192 | importpath = "github.com/google/pprof", 193 | sum = "h1:eqyIo2HjKhKe/mJzTG8n4VqvLXIOEG+SLdDqX7xGtkY=", 194 | version = "v0.0.0-20181206194817-3ea8567a2e57", 195 | ) 196 | go_repository( 197 | name = "com_github_googleapis_gax_go", 198 | importpath = "github.com/googleapis/gax-go", 199 | sum = "h1:j0GKcs05QVmm7yesiZq2+9cxHkNK9YM6zKx4D2qucQU=", 200 | version = "v2.0.0+incompatible", 201 | ) 202 | go_repository( 203 | name = "com_github_googleapis_gax_go_v2", 204 | importpath = "github.com/googleapis/gax-go/v2", 205 | sum = "h1:siORttZ36U2R/WjiJuDz8znElWBiAlO9rVt+mqJt0Cc=", 206 | version = "v2.0.3", 207 | ) 208 | go_repository( 209 | name = "com_github_gopherjs_gopherjs", 210 | importpath = "github.com/gopherjs/gopherjs", 211 | sum = "h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=", 212 | version = "v0.0.0-20181017120253-0766667cb4d1", 213 | ) 214 | go_repository( 215 | name = "com_github_gregjones_httpcache", 216 | importpath = "github.com/gregjones/httpcache", 217 | sum = "h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM=", 218 | version = "v0.0.0-20180305231024-9cad4c3443a7", 219 | ) 220 | go_repository( 221 | name = "com_github_grpc_ecosystem_grpc_gateway", 222 | importpath = "github.com/grpc-ecosystem/grpc-gateway", 223 | sum = "h1:WcmKMm43DR7RdtlkEXQJyo5ws8iTp98CyhCCbOHMvNI=", 224 | version = "v1.5.0", 225 | ) 226 | go_repository( 227 | name = "com_github_jellevandenhooff_dkim", 228 | importpath = "github.com/jellevandenhooff/dkim", 229 | sum = "h1:ujPKutqRlJtcfWk6toYVYagwra7HQHbXOaS171b4Tg8=", 230 | version = "v0.0.0-20150330215556-f50fe3d243e1", 231 | ) 232 | go_repository( 233 | name = "com_github_json_iterator_go", 234 | importpath = "github.com/json-iterator/go", 235 | sum = "h1:MrUvLMLTMxbqFJ9kzlvat/rYZqZnW3u4wkLzWTaFwKs=", 236 | version = "v1.1.6", 237 | ) 238 | go_repository( 239 | name = "com_github_jstemmer_go_junit_report", 240 | importpath = "github.com/jstemmer/go-junit-report", 241 | sum = "h1:rBMNdlhTLzJjJSDIjNEXX1Pz3Hmwmz91v+zycvx9PJc=", 242 | version = "v0.0.0-20190106144839-af01ea7f8024", 243 | ) 244 | go_repository( 245 | name = "com_github_kr_pretty", 246 | importpath = "github.com/kr/pretty", 247 | sum = "h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=", 248 | version = "v0.1.0", 249 | ) 250 | go_repository( 251 | name = "com_github_kr_pty", 252 | importpath = "github.com/kr/pty", 253 | sum = "h1:/Um6a/ZmD5tF7peoOJ5oN5KMQ0DrGVQSXLNwyckutPk=", 254 | version = "v1.1.3", 255 | ) 256 | go_repository( 257 | name = "com_github_kr_text", 258 | importpath = "github.com/kr/text", 259 | sum = "h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=", 260 | version = "v0.1.0", 261 | ) 262 | go_repository( 263 | name = "com_github_lunixbochs_vtclean", 264 | importpath = "github.com/lunixbochs/vtclean", 265 | sum = "h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+LVb8=", 266 | version = "v1.0.0", 267 | ) 268 | go_repository( 269 | name = "com_github_mailru_easyjson", 270 | importpath = "github.com/mailru/easyjson", 271 | sum = "h1:W/GaMY0y69G4cFlmsC6B9sbuo2fP8OFP1ABjt4kPz+w=", 272 | version = "v0.0.0-20190312143242-1de009706dbe", 273 | ) 274 | go_repository( 275 | name = "com_github_matttproud_golang_protobuf_extensions", 276 | importpath = "github.com/matttproud/golang_protobuf_extensions", 277 | sum = "h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU=", 278 | version = "v1.0.1", 279 | ) 280 | go_repository( 281 | name = "com_github_microcosm_cc_bluemonday", 282 | importpath = "github.com/microcosm-cc/bluemonday", 283 | sum = "h1:SIYunPjnlXcW+gVfvm0IlSeR5U3WZUOLfVmqg85Go44=", 284 | version = "v1.0.1", 285 | ) 286 | go_repository( 287 | name = "com_github_modern_go_concurrent", 288 | importpath = "github.com/modern-go/concurrent", 289 | sum = "h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=", 290 | version = "v0.0.0-20180306012644-bacd9c7ef1dd", 291 | ) 292 | go_repository( 293 | name = "com_github_modern_go_reflect2", 294 | importpath = "github.com/modern-go/reflect2", 295 | sum = "h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9AWI=", 296 | version = "v1.0.1", 297 | ) 298 | go_repository( 299 | name = "com_github_neelance_astrewrite", 300 | importpath = "github.com/neelance/astrewrite", 301 | sum = "h1:D6paGObi5Wud7xg83MaEFyjxQB1W5bz5d0IFppr+ymk=", 302 | version = "v0.0.0-20160511093645-99348263ae86", 303 | ) 304 | go_repository( 305 | name = "com_github_neelance_sourcemap", 306 | importpath = "github.com/neelance/sourcemap", 307 | sum = "h1:eFXv9Nu1lGbrNbj619aWwZfVF5HBrm9Plte8aNptuTI=", 308 | version = "v0.0.0-20151028013722-8c68805598ab", 309 | ) 310 | go_repository( 311 | name = "com_github_openzipkin_zipkin_go", 312 | importpath = "github.com/openzipkin/zipkin-go", 313 | sum = "h1:A/ADD6HaPnAKj3yS7HjGHRK77qi41Hi0DirOOIQAeIw=", 314 | version = "v0.1.1", 315 | ) 316 | go_repository( 317 | name = "com_github_pkg_errors", 318 | importpath = "github.com/pkg/errors", 319 | sum = "h1:PCj9X21C4pet4sEcElTfAi6LSl5ShkjE8doieLc+cbU=", 320 | version = "v0.8.2-0.20190227000051-27936f6d90f9", 321 | ) 322 | go_repository( 323 | name = "com_github_pmezard_go_difflib", 324 | importpath = "github.com/pmezard/go-difflib", 325 | sum = "h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=", 326 | version = "v1.0.0", 327 | ) 328 | go_repository( 329 | name = "com_github_prometheus_client_golang", 330 | importpath = "github.com/prometheus/client_golang", 331 | sum = "h1:1921Yw9Gc3iSc4VQh3PIoOqgPCZS7G/4xQNVUp8Mda8=", 332 | version = "v0.8.0", 333 | ) 334 | go_repository( 335 | name = "com_github_prometheus_client_model", 336 | importpath = "github.com/prometheus/client_model", 337 | sum = "h1:idejC8f05m9MGOsuEi1ATq9shN03HrxNkD/luQvxCv8=", 338 | version = "v0.0.0-20180712105110-5c3871d89910", 339 | ) 340 | go_repository( 341 | name = "com_github_prometheus_common", 342 | importpath = "github.com/prometheus/common", 343 | sum = "h1:n/3MEhJQjQxrOUCzh1Y3Re6aJUUWRp2M9+Oc3eVn/54=", 344 | version = "v0.0.0-20180801064454-c7de2306084e", 345 | ) 346 | go_repository( 347 | name = "com_github_prometheus_procfs", 348 | importpath = "github.com/prometheus/procfs", 349 | sum = "h1:agujYaXJSxSo18YNX3jzl+4G6Bstwt+kqv47GS12uL0=", 350 | version = "v0.0.0-20180725123919-05ee40e3a273", 351 | ) 352 | go_repository( 353 | name = "com_github_russross_blackfriday", 354 | importpath = "github.com/russross/blackfriday", 355 | sum = "h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNueLj0oo=", 356 | version = "v1.5.2", 357 | ) 358 | go_repository( 359 | name = "com_github_sergi_go_diff", 360 | importpath = "github.com/sergi/go-diff", 361 | sum = "h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=", 362 | version = "v1.0.0", 363 | ) 364 | go_repository( 365 | name = "com_github_shurcool_component", 366 | importpath = "github.com/shurcooL/component", 367 | sum = "h1:Fth6mevc5rX7glNLpbAMJnqKlfIkcTjZCSHEeqvKbcI=", 368 | version = "v0.0.0-20170202220835-f88ec8f54cc4", 369 | ) 370 | go_repository( 371 | name = "com_github_shurcool_events", 372 | importpath = "github.com/shurcooL/events", 373 | sum = "h1:vabduItPAIz9px5iryD5peyx7O3Ya8TBThapgXim98o=", 374 | version = "v0.0.0-20181021180414-410e4ca65f48", 375 | ) 376 | go_repository( 377 | name = "com_github_shurcool_github_flavored_markdown", 378 | importpath = "github.com/shurcooL/github_flavored_markdown", 379 | sum = "h1:qb9IthCFBmROJ6YBS31BEMeSYjOscSiG+EO+JVNTz64=", 380 | version = "v0.0.0-20181002035957-2122de532470", 381 | ) 382 | go_repository( 383 | name = "com_github_shurcool_go", 384 | importpath = "github.com/shurcooL/go", 385 | sum = "h1:MZM7FHLqUHYI0Y/mQAt3d2aYa0SiNms/hFqC9qJYolM=", 386 | version = "v0.0.0-20180423040247-9e1955d9fb6e", 387 | ) 388 | go_repository( 389 | name = "com_github_shurcool_go_goon", 390 | importpath = "github.com/shurcooL/go-goon", 391 | sum = "h1:llrF3Fs4018ePo4+G/HV/uQUqEI1HMDjCeOf2V6puPc=", 392 | version = "v0.0.0-20170922171312-37c2f522c041", 393 | ) 394 | go_repository( 395 | name = "com_github_shurcool_gofontwoff", 396 | importpath = "github.com/shurcooL/gofontwoff", 397 | sum = "h1:Yoy/IzG4lULT6qZg62sVC+qyBL8DQkmD2zv6i7OImrc=", 398 | version = "v0.0.0-20180329035133-29b52fc0a18d", 399 | ) 400 | go_repository( 401 | name = "com_github_shurcool_gopherjslib", 402 | importpath = "github.com/shurcooL/gopherjslib", 403 | sum = "h1:UOk+nlt1BJtTcH15CT7iNO7YVWTfTv/DNwEAQHLIaDQ=", 404 | version = "v0.0.0-20160914041154-feb6d3990c2c", 405 | ) 406 | go_repository( 407 | name = "com_github_shurcool_highlight_diff", 408 | importpath = "github.com/shurcooL/highlight_diff", 409 | sum = "h1:vYEG87HxbU6dXj5npkeulCS96Dtz5xg3jcfCgpcvbIw=", 410 | version = "v0.0.0-20170515013008-09bb4053de1b", 411 | ) 412 | go_repository( 413 | name = "com_github_shurcool_highlight_go", 414 | importpath = "github.com/shurcooL/highlight_go", 415 | sum = "h1:7pDq9pAMCQgRohFmd25X8hIH8VxmT3TaDm+r9LHxgBk=", 416 | version = "v0.0.0-20181028180052-98c3abbbae20", 417 | ) 418 | go_repository( 419 | name = "com_github_shurcool_home", 420 | importpath = "github.com/shurcooL/home", 421 | sum = "h1:MPblCbqA5+z6XARjScMfz1TqtJC7TuTRj0U9VqIBs6k=", 422 | version = "v0.0.0-20181020052607-80b7ffcb30f9", 423 | ) 424 | go_repository( 425 | name = "com_github_shurcool_htmlg", 426 | importpath = "github.com/shurcooL/htmlg", 427 | sum = "h1:crYRwvwjdVh1biHzzciFHe8DrZcYrVcZFlJtykhRctg=", 428 | version = "v0.0.0-20170918183704-d01228ac9e50", 429 | ) 430 | go_repository( 431 | name = "com_github_shurcool_httperror", 432 | importpath = "github.com/shurcooL/httperror", 433 | sum = "h1:eHRtZoIi6n9Wo1uR+RU44C247msLWwyA89hVKwRLkMk=", 434 | version = "v0.0.0-20170206035902-86b7830d14cc", 435 | ) 436 | go_repository( 437 | name = "com_github_shurcool_httpfs", 438 | importpath = "github.com/shurcooL/httpfs", 439 | sum = "h1:SWV2fHctRpRrp49VXJ6UZja7gU9QLHwRpIPBN89SKEo=", 440 | version = "v0.0.0-20171119174359-809beceb2371", 441 | ) 442 | go_repository( 443 | name = "com_github_shurcool_httpgzip", 444 | importpath = "github.com/shurcooL/httpgzip", 445 | sum = "h1:fxoFD0in0/CBzXoyNhMTjvBZYW6ilSnTw7N7y/8vkmM=", 446 | version = "v0.0.0-20180522190206-b1c53ac65af9", 447 | ) 448 | go_repository( 449 | name = "com_github_shurcool_issues", 450 | importpath = "github.com/shurcooL/issues", 451 | sum = "h1:T4wuULTrzCKMFlg3HmKHgXAF8oStFb/+lOIupLV2v+o=", 452 | version = "v0.0.0-20181008053335-6292fdc1e191", 453 | ) 454 | go_repository( 455 | name = "com_github_shurcool_issuesapp", 456 | importpath = "github.com/shurcooL/issuesapp", 457 | sum = "h1:Y+TeIabU8sJD10Qwd/zMty2/LEaT9GNDaA6nyZf+jgo=", 458 | version = "v0.0.0-20180602232740-048589ce2241", 459 | ) 460 | go_repository( 461 | name = "com_github_shurcool_notifications", 462 | importpath = "github.com/shurcooL/notifications", 463 | sum = "h1:TQVQrsyNaimGwF7bIhzoVC9QkKm4KsWd8cECGzFx8gI=", 464 | version = "v0.0.0-20181007000457-627ab5aea122", 465 | ) 466 | go_repository( 467 | name = "com_github_shurcool_octicon", 468 | importpath = "github.com/shurcooL/octicon", 469 | sum = "h1:bu666BQci+y4S0tVRVjsHUeRon6vUXmsGBwdowgMrg4=", 470 | version = "v0.0.0-20181028054416-fa4f57f9efb2", 471 | ) 472 | go_repository( 473 | name = "com_github_shurcool_reactions", 474 | importpath = "github.com/shurcooL/reactions", 475 | sum = "h1:LneqU9PHDsg/AkPDU3AkqMxnMYL+imaqkpflHu73us8=", 476 | version = "v0.0.0-20181006231557-f2e0b4ca5b82", 477 | ) 478 | go_repository( 479 | name = "com_github_shurcool_sanitized_anchor_name", 480 | importpath = "github.com/shurcooL/sanitized_anchor_name", 481 | sum = "h1:/vdW8Cb7EXrkqWGufVMES1OH2sU9gKVb2n9/1y5NMBY=", 482 | version = "v0.0.0-20170918181015-86672fcb3f95", 483 | ) 484 | go_repository( 485 | name = "com_github_shurcool_users", 486 | importpath = "github.com/shurcooL/users", 487 | sum = "h1:YGaxtkYjb8mnTvtufv2LKLwCQu2/C7qFB7UtrOlTWOY=", 488 | version = "v0.0.0-20180125191416-49c67e49c537", 489 | ) 490 | go_repository( 491 | name = "com_github_shurcool_webdavfs", 492 | importpath = "github.com/shurcooL/webdavfs", 493 | sum = "h1:JtcyT0rk/9PKOdnKQzuDR+FSjh7SGtJwpgVpfZBRKlQ=", 494 | version = "v0.0.0-20170829043945-18c3829fa133", 495 | ) 496 | go_repository( 497 | name = "com_github_sourcegraph_annotate", 498 | importpath = "github.com/sourcegraph/annotate", 499 | sum = "h1:yKm7XZV6j9Ev6lojP2XaIshpT4ymkqhMeSghO5Ps00E=", 500 | version = "v0.0.0-20160123013949-f4cad6c6324d", 501 | ) 502 | go_repository( 503 | name = "com_github_sourcegraph_syntaxhighlight", 504 | importpath = "github.com/sourcegraph/syntaxhighlight", 505 | sum = "h1:qpG93cPwA5f7s/ZPBJnGOYQNK/vKsaDaseuKT5Asee8=", 506 | version = "v0.0.0-20170531221838-bd320f5d308e", 507 | ) 508 | go_repository( 509 | name = "com_github_stretchr_objx", 510 | importpath = "github.com/stretchr/objx", 511 | sum = "h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=", 512 | version = "v0.1.0", 513 | ) 514 | go_repository( 515 | name = "com_github_stretchr_testify", 516 | importpath = "github.com/stretchr/testify", 517 | sum = "h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=", 518 | version = "v1.4.0", 519 | ) 520 | go_repository( 521 | name = "com_github_tarm_serial", 522 | importpath = "github.com/tarm/serial", 523 | sum = "h1:UyzmZLoiDWMRywV4DUYb9Fbt8uiOSooupjTq10vpvnU=", 524 | version = "v0.0.0-20180830185346-98f6abe2eb07", 525 | ) 526 | go_repository( 527 | name = "com_github_viant_assertly", 528 | importpath = "github.com/viant/assertly", 529 | sum = "h1:5x1GzBaRteIwTr5RAGFVG14uNeRFxVNbXPWrK2qAgpc=", 530 | version = "v0.4.8", 531 | ) 532 | go_repository( 533 | name = "com_github_viant_toolbox", 534 | importpath = "github.com/viant/toolbox", 535 | sum = "h1:6TteTDQ68CjgcCe8wH3D3ZhUQQOJXMTbj/D9rkk2a1k=", 536 | version = "v0.24.0", 537 | ) 538 | go_repository( 539 | name = "com_google_cloud_go", 540 | importpath = "cloud.google.com/go", 541 | sum = "h1:69FNAINiZfsEuwH3fKq8QrAAnHz+2m4XL4kVYi5BX0Q=", 542 | version = "v0.37.0", 543 | ) 544 | go_repository( 545 | name = "com_shuralyov_dmitri_app_changes", 546 | importpath = "dmitri.shuralyov.com/app/changes", 547 | sum = "h1:hJiie5Bf3QucGRa4ymsAUOxyhYwGEz1xrsVk0P8erlw=", 548 | version = "v0.0.0-20180602232624-0a106ad413e3", 549 | ) 550 | go_repository( 551 | name = "com_shuralyov_dmitri_html_belt", 552 | importpath = "dmitri.shuralyov.com/html/belt", 553 | sum = "h1:SPOUaucgtVls75mg+X7CXigS71EnsfVUK/2CgVrwqgw=", 554 | version = "v0.0.0-20180602232347-f7d459c86be0", 555 | ) 556 | go_repository( 557 | name = "com_shuralyov_dmitri_service_change", 558 | importpath = "dmitri.shuralyov.com/service/change", 559 | sum = "h1:GvWw74lx5noHocd+f6HBMXK6DuggBB1dhVkuGZbv7qM=", 560 | version = "v0.0.0-20181023043359-a85b471d5412", 561 | ) 562 | go_repository( 563 | name = "com_shuralyov_dmitri_state", 564 | importpath = "dmitri.shuralyov.com/state", 565 | sum = "h1:ivON6cwHK1OH26MZyWDCnbTRZZf0IhNsENoNAKFS1g4=", 566 | version = "v0.0.0-20180228185332-28bcc343414c", 567 | ) 568 | go_repository( 569 | name = "com_sourcegraph_sourcegraph_go_diff", 570 | importpath = "sourcegraph.com/sourcegraph/go-diff", 571 | sum = "h1:eTiIR0CoWjGzJcnQ3OkhIl/b9GJovq4lSAVRt0ZFEG8=", 572 | version = "v0.5.0", 573 | ) 574 | go_repository( 575 | name = "com_sourcegraph_sqs_pbtypes", 576 | importpath = "sourcegraph.com/sqs/pbtypes", 577 | sum = "h1:JPJh2pk3+X4lXAkZIk2RuE/7/FoK9maXw+TNPJhVS/c=", 578 | version = "v0.0.0-20180604144634-d3ebe8f20ae4", 579 | ) 580 | go_repository( 581 | name = "in_gopkg_check_v1", 582 | importpath = "gopkg.in/check.v1", 583 | sum = "h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=", 584 | version = "v0.0.0-20161208181325-20d25e280405", 585 | ) 586 | go_repository( 587 | name = "in_gopkg_inf_v0", 588 | importpath = "gopkg.in/inf.v0", 589 | sum = "h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=", 590 | version = "v0.9.1", 591 | ) 592 | go_repository( 593 | name = "in_gopkg_yaml_v2", 594 | importpath = "gopkg.in/yaml.v2", 595 | sum = "h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=", 596 | version = "v2.2.2", 597 | ) 598 | go_repository( 599 | name = "io_opencensus_go", 600 | importpath = "go.opencensus.io", 601 | sum = "h1:Mk5rgZcggtbvtAun5aJzAtjKKN/t0R3jJPlWILlv938=", 602 | version = "v0.18.0", 603 | ) 604 | go_repository( 605 | name = "org_apache_git_thrift_git", 606 | importpath = "git.apache.org/thrift.git", 607 | replace = "github.com/apache/thrift", 608 | sum = "h1:btlJ8oUpVIaJj+kl2yh/ACoII+MltLj1vukud/FwOvw=", 609 | version = "v0.0.0-20180902110319-2566ecd5d999", 610 | ) 611 | go_repository( 612 | name = "org_go4", 613 | importpath = "go4.org", 614 | sum = "h1:+hE86LblG4AyDgwMCLTE6FOlM9+qjHSYS+rKqxUVdsM=", 615 | version = "v0.0.0-20180809161055-417644f6feb5", 616 | ) 617 | go_repository( 618 | name = "org_go4_grpc", 619 | importpath = "grpc.go4.org", 620 | sum = "h1:tmXTu+dfa+d9Evp8NpJdgOy6+rt8/x4yG7qPBrtNfLY=", 621 | version = "v0.0.0-20170609214715-11d0a25b4919", 622 | ) 623 | go_repository( 624 | name = "org_golang_google_api", 625 | importpath = "google.golang.org/api", 626 | sum = "h1:K6z2u68e86TPdSdefXdzvXgR1zEMa+459vBSfWYAZkI=", 627 | version = "v0.1.0", 628 | ) 629 | go_repository( 630 | name = "org_golang_google_appengine", 631 | importpath = "google.golang.org/appengine", 632 | sum = "h1:/wp5JvzpHIxhs/dumFmF7BXTf3Z+dd4uXta4kVyO508=", 633 | version = "v1.4.0", 634 | ) 635 | go_repository( 636 | name = "org_golang_google_genproto", 637 | importpath = "google.golang.org/genproto", 638 | sum = "h1:VOR2wHHZJgoALLvnlCN4JUaWACO1lOLXiSN2F3g/GXU=", 639 | version = "v0.0.0-20190306203927-b5d61aea6440", 640 | ) 641 | go_repository( 642 | name = "org_golang_google_grpc", 643 | importpath = "google.golang.org/grpc", 644 | sum = "h1:cfg4PD8YEdSFnm7qLV4++93WcmhH2nIUhMjhdCvl3j8=", 645 | version = "v1.19.0", 646 | ) 647 | go_repository( 648 | name = "org_golang_x_build", 649 | importpath = "golang.org/x/build", 650 | sum = "h1:E2M5QgjZ/Jg+ObCQAudsXxuTsLj7Nl5RV/lZcQZmKSo=", 651 | version = "v0.0.0-20190111050920-041ab4dc3f9d", 652 | ) 653 | go_repository( 654 | name = "org_golang_x_crypto", 655 | importpath = "golang.org/x/crypto", 656 | sum = "h1:YX8ljsm6wXlHZO+aRz9Exqr0evNhKRNe5K/gi+zKh4U=", 657 | version = "v0.0.0-20190313024323-a1f597ede03a", 658 | ) 659 | go_repository( 660 | name = "org_golang_x_exp", 661 | importpath = "golang.org/x/exp", 662 | sum = "h1:c2HOrn5iMezYjSlGPncknSEr/8x5LELb/ilJbXi9DEA=", 663 | version = "v0.0.0-20190121172915-509febef88a4", 664 | ) 665 | go_repository( 666 | name = "org_golang_x_lint", 667 | importpath = "golang.org/x/lint", 668 | sum = "h1:GmgasJE571dBGXS7E282h2rIZj+KvCLV8z5I6QXbKNI=", 669 | version = "v0.0.0-20190227174305-5b3e6a55c961", 670 | ) 671 | go_repository( 672 | name = "org_golang_x_net", 673 | importpath = "golang.org/x/net", 674 | sum = "h1:actzWV6iWn3GLqN8dZjzsB+CLt+gaV2+wsxroxiQI8I=", 675 | version = "v0.0.0-20190313220215-9f648a60d977", 676 | ) 677 | go_repository( 678 | name = "org_golang_x_oauth2", 679 | importpath = "golang.org/x/oauth2", 680 | sum = "h1:Wo7BWFiOk0QRFMLYMqJGFMd9CgUAcGx7V+qEg/h5IBI=", 681 | version = "v0.0.0-20190226205417-e64efc72b421", 682 | ) 683 | go_repository( 684 | name = "org_golang_x_perf", 685 | importpath = "golang.org/x/perf", 686 | sum = "h1:xYq6+9AtI+xP3M4r0N1hCkHrInHDBohhquRgx9Kk6gI=", 687 | version = "v0.0.0-20180704124530-6e6d33e29852", 688 | ) 689 | go_repository( 690 | name = "org_golang_x_sync", 691 | importpath = "golang.org/x/sync", 692 | sum = "h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU=", 693 | version = "v0.0.0-20190423024810-112230192c58", 694 | ) 695 | go_repository( 696 | name = "org_golang_x_sys", 697 | importpath = "golang.org/x/sys", 698 | sum = "h1:yCrMx/EeIue0+Qca57bWZS7VX6ymEoypmhWyPhz0NHM=", 699 | version = "v0.0.0-20190316082340-a2f829d7f35f", 700 | ) 701 | go_repository( 702 | name = "org_golang_x_text", 703 | importpath = "golang.org/x/text", 704 | sum = "h1:z99zHgr7hKfrUcX/KsoJk5FJfjTceCKIp96+biqP4To=", 705 | version = "v0.3.1-0.20180807135948-17ff2d5776d2", 706 | ) 707 | go_repository( 708 | name = "org_golang_x_time", 709 | importpath = "golang.org/x/time", 710 | sum = "h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg=", 711 | version = "v0.0.0-20181108054448-85acf8d2951c", 712 | ) 713 | go_repository( 714 | name = "org_golang_x_tools", 715 | importpath = "golang.org/x/tools", 716 | sum = "h1:qsl9y/CJx34tuA7QCPNp86JNJe4spst6Ff8MjvPUdPg=", 717 | version = "v0.0.0-20190425150028-36563e24a262", 718 | ) 719 | go_repository( 720 | name = "org_golang_x_xerrors", 721 | importpath = "golang.org/x/xerrors", 722 | sum = "h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc=", 723 | version = "v0.0.0-20190717185122-a985d3407aa7", 724 | ) 725 | go_repository( 726 | name = "org_uber_go_atomic", 727 | importpath = "go.uber.org/atomic", 728 | sum = "h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU=", 729 | version = "v1.4.0", 730 | ) 731 | go_repository( 732 | name = "org_uber_go_multierr", 733 | importpath = "go.uber.org/multierr", 734 | sum = "h1:Q0q3m6foxW9fUIiNtElisPPzFNmxZ6jxL00xve0A348=", 735 | version = "v1.1.1-0.20190429210458-bd075f90b08f", 736 | ) 737 | go_repository( 738 | name = "org_uber_go_zap", 739 | importpath = "go.uber.org/zap", 740 | sum = "h1:2/OCbaWT0ZStdlrAU9heVF2FAVUoP+Mky/bPxP2Mqhs=", 741 | version = "v1.10.1-0.20190430155229-8a2ee5670ced", 742 | ) 743 | go_repository( 744 | name = "com_github_alecthomas_kingpin", 745 | importpath = "github.com/alecthomas/kingpin", 746 | sum = "h1:5svnBTFgJjZvGKyYBtMB0+m5wvrbUHiqye8wRJMlnYI=", 747 | version = "v2.2.6+incompatible", 748 | ) 749 | go_repository( 750 | name = "com_github_alecthomas_template", 751 | importpath = "github.com/alecthomas/template", 752 | sum = "h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM=", 753 | version = "v0.0.0-20190718012654-fb15b899a751", 754 | ) 755 | go_repository( 756 | name = "com_github_alecthomas_units", 757 | importpath = "github.com/alecthomas/units", 758 | sum = "h1:Hs82Z41s6SdL1CELW+XaDYmOH4hkBN4/N9og/AsOv7E=", 759 | version = "v0.0.0-20190717042225-c3de453c63f4", 760 | ) 761 | go_repository( 762 | name = "com_github_kelseyhightower_envconfig", 763 | importpath = "github.com/kelseyhightower/envconfig", 764 | sum = "h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8=", 765 | version = "v1.4.0", 766 | ) 767 | go_repository( 768 | name = "com_github_bazelbuild_bazelisk", 769 | importpath = "github.com/bazelbuild/bazelisk", 770 | sum = "h1:YRIIdISvlGj8UoPji/8hkwxOrbQPE84i4Wb8u3frGMM=", 771 | version = "v0.0.8", 772 | ) 773 | go_repository( 774 | name = "com_github_hashicorp_go_version", 775 | importpath = "github.com/hashicorp/go-version", 776 | sum = "h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0=", 777 | version = "v1.1.0", 778 | ) 779 | -------------------------------------------------------------------------------- /build/bazel/gomock.bzl: -------------------------------------------------------------------------------- 1 | # The MIT License (MIT) 2 | # Copyright © 2018 Jeff Hodges 3 | 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the “Software”), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | 14 | # THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | # THE SOFTWARE. 21 | 22 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_context", "go_rule") 23 | load("@io_bazel_rules_go//go/private:providers.bzl", "GoLibrary") 24 | 25 | _MOCKGEN_TOOL = "@com_github_golang_mock//mockgen" 26 | _MOCKGEN_MODEL_LIB = "@com_github_golang_mock//mockgen/model:go_default_library" 27 | 28 | def _gomock_source_impl(ctx): 29 | args = ["-source", ctx.file.source.path] 30 | if ctx.attr.package != "": 31 | args += ["-package", ctx.attr.package] 32 | args += [",".join(ctx.attr.interfaces)] 33 | 34 | out = ctx.outputs.out 35 | cmd = ctx.file.mockgen_tool 36 | go_ctx = go_context(ctx) 37 | inputs = go_ctx.sdk.headers + go_ctx.sdk.srcs + go_ctx.sdk.tools + [ctx.file.source] 38 | 39 | # We can use the go binary from the stdlib for most of the environment 40 | # variables, but our GOPATH is specific to the library target we were given. 41 | ctx.actions.run_shell( 42 | outputs = [out], 43 | inputs = inputs, 44 | tools = [ 45 | cmd, 46 | go_ctx.go, 47 | ], 48 | command = """ 49 | source <($PWD/{godir}/go env) && 50 | export PATH=$GOROOT/bin:$PWD/{godir}:$PATH && 51 | {cmd} {args} > {out} 52 | """.format( 53 | godir = go_ctx.go.path[:-1 - len(go_ctx.go.basename)], 54 | cmd = "$(pwd)/" + cmd.path, 55 | args = " ".join(args), 56 | out = out.path, 57 | ), 58 | ) 59 | 60 | _gomock_source = go_rule( 61 | _gomock_source_impl, 62 | attrs = { 63 | "library": attr.label( 64 | doc = "The target the Go library is at to look for the interfaces in. When this is set and source is not set, mockgen will use its reflect code to generate the mocks. If source is set, its dependencies will be included in the GOPATH that mockgen will be run in.", 65 | providers = [GoLibrary], 66 | mandatory = True, 67 | ), 68 | "source": attr.label( 69 | doc = "A Go source file to find all the interfaces to generate mocks for. See also the docs for library.", 70 | mandatory = False, 71 | allow_single_file = True, 72 | ), 73 | "out": attr.output( 74 | doc = "The new Go file to emit the generated mocks into", 75 | mandatory = True, 76 | ), 77 | "interfaces": attr.string_list( 78 | allow_empty = False, 79 | doc = "The names of the Go interfaces to generate mocks for. If not set, all of the interfaces in the library or source file will have mocks generated for them.", 80 | mandatory = True, 81 | ), 82 | "package": attr.string( 83 | doc = "The name of the package the generated mocks should be in. If not specified, uses mockgen's default.", 84 | ), 85 | "self_package": attr.string( 86 | doc = "The full package import path for the generated code. The purpose of this flag is to prevent import cycles in the generated code by trying to include its own package. This can happen if the mock's package is set to one of its inputs (usually the main one) and the output is stdio so mockgen cannot detect the final output package. Setting this flag will then tell mockgen which import to exclude.", 87 | ), 88 | "mockgen_tool": attr.label( 89 | doc = "The mockgen tool to run", 90 | default = Label(_MOCKGEN_TOOL), 91 | allow_single_file = True, 92 | executable = True, 93 | cfg = "host", 94 | mandatory = False, 95 | ), 96 | }, 97 | ) 98 | 99 | def gomock(name, library, out, **kwargs): 100 | mockgen_tool = _MOCKGEN_TOOL 101 | if kwargs.get("mockgen_tool", None): 102 | mockgen_tool = kwargs["mockgen_tool"] 103 | 104 | if kwargs.get("source", None): 105 | _gomock_source( 106 | name = name, 107 | library = library, 108 | out = out, 109 | **kwargs 110 | ) 111 | else: 112 | _gomock_reflect( 113 | name = name, 114 | library = library, 115 | out = out, 116 | mockgen_tool = mockgen_tool, 117 | **kwargs 118 | ) 119 | 120 | def _gomock_reflect(name, library, out, mockgen_tool, **kwargs): 121 | interfaces = kwargs.get("interfaces", None) 122 | mockgen_model_lib = _MOCKGEN_MODEL_LIB 123 | if kwargs.get("mockgen_model_library", None): 124 | mockgen_model_lib = kwargs["mockgen_model_library"] 125 | 126 | prog_src = name + "_gomock_prog" 127 | prog_src_out = prog_src + ".go" 128 | _gomock_prog_gen( 129 | name = prog_src, 130 | interfaces = interfaces, 131 | library = library, 132 | package = kwargs.get("package", None), 133 | out = prog_src_out, 134 | mockgen_tool = mockgen_tool, 135 | ) 136 | prog_bin = name + "_gomock_prog_bin" 137 | go_binary( 138 | name = prog_bin, 139 | srcs = [prog_src_out], 140 | deps = [library, mockgen_model_lib], 141 | ) 142 | _gomock_prog_exec( 143 | name = name, 144 | interfaces = interfaces, 145 | library = library, 146 | package = kwargs.get("package", None), 147 | out = out, 148 | prog_bin = prog_bin, 149 | mockgen_tool = mockgen_tool, 150 | self_package = kwargs.get("self_package", None), 151 | ) 152 | 153 | def _gomock_prog_gen_impl(ctx): 154 | args = ["-prog_only"] 155 | if ctx.attr.package != "": 156 | args += ["-package", ctx.attr.package] 157 | args += [ctx.attr.library[GoLibrary].importpath] 158 | args += [",".join(ctx.attr.interfaces)] 159 | 160 | cmd = ctx.file.mockgen_tool 161 | out = ctx.outputs.out 162 | ctx.actions.run_shell( 163 | outputs = [out], 164 | tools = [cmd], 165 | command = """ 166 | {cmd} {args} > {out} 167 | """.format( 168 | cmd = "$(pwd)/" + cmd.path, 169 | args = " ".join(args), 170 | out = out.path, 171 | ), 172 | ) 173 | 174 | _gomock_prog_gen = go_rule( 175 | _gomock_prog_gen_impl, 176 | attrs = { 177 | "library": attr.label( 178 | doc = "The target the Go library is at to look for the interfaces in. When this is set and source is not set, mockgen will use its reflect code to generate the mocks.", 179 | providers = [GoLibrary], 180 | mandatory = True, 181 | ), 182 | "out": attr.output( 183 | doc = "The new Go source file put the mock generator code", 184 | mandatory = True, 185 | ), 186 | "interfaces": attr.string_list( 187 | allow_empty = False, 188 | doc = "The names of the Go interfaces to generate mocks for. If not set, all of the interfaces in the library or source file will have mocks generated for them.", 189 | mandatory = True, 190 | ), 191 | "package": attr.string( 192 | doc = "The name of the package the generated mocks should be in. If not specified, uses mockgen's default.", 193 | ), 194 | "mockgen_tool": attr.label( 195 | doc = "The mockgen tool to run", 196 | default = Label(_MOCKGEN_TOOL), 197 | allow_single_file = True, 198 | executable = True, 199 | cfg = "host", 200 | mandatory = False, 201 | ), 202 | }, 203 | ) 204 | 205 | def _gomock_prog_exec_impl(ctx): 206 | args = ["-exec_only", ctx.file.prog_bin.path] 207 | if ctx.attr.package != "": 208 | args += ["-package", ctx.attr.package] 209 | 210 | if ctx.attr.self_package != "": 211 | args += ["-self_package", ctx.attr.self_package] 212 | 213 | args += [ctx.attr.library[GoLibrary].importpath] 214 | args += [",".join(ctx.attr.interfaces)] 215 | 216 | ctx.actions.run_shell( 217 | outputs = [ctx.outputs.out], 218 | inputs = [ctx.file.prog_bin], 219 | tools = [ctx.file.mockgen_tool], 220 | command = """{cmd} {args} > {out}""".format( 221 | cmd = "$(pwd)/" + ctx.file.mockgen_tool.path, 222 | args = " ".join(args), 223 | out = ctx.outputs.out.path, 224 | ), 225 | env = { 226 | # GOCACHE is required starting in Go 1.12 227 | "GOCACHE": "./.gocache", 228 | }, 229 | ) 230 | 231 | _gomock_prog_exec = go_rule( 232 | _gomock_prog_exec_impl, 233 | attrs = { 234 | "library": attr.label( 235 | doc = "The target the Go library is at to look for the interfaces in. When this is set and source is not set, mockgen will use its reflect code to generate the mocks. If source is set, its dependencies will be included in the GOPATH that mockgen will be run in.", 236 | providers = [GoLibrary], 237 | mandatory = True, 238 | ), 239 | "out": attr.output( 240 | doc = "The new Go source file to put the generated mock code", 241 | mandatory = True, 242 | ), 243 | "interfaces": attr.string_list( 244 | allow_empty = False, 245 | doc = "The names of the Go interfaces to generate mocks for. If not set, all of the interfaces in the library or source file will have mocks generated for them.", 246 | mandatory = True, 247 | ), 248 | "package": attr.string( 249 | doc = "The name of the package the generated mocks should be in. If not specified, uses mockgen's default.", 250 | ), 251 | "self_package": attr.string( 252 | doc = "The full package import path for the generated code. The purpose of this flag is to prevent import cycles in the generated code by trying to include its own package. This can happen if the mock's package is set to one of its inputs (usually the main one) and the output is stdio so mockgen cannot detect the final output package. Setting this flag will then tell mockgen which import to exclude.", 253 | ), 254 | "prog_bin": attr.label( 255 | doc = "The program binary generated by mockgen's -prog_only and compiled by bazel.", 256 | allow_single_file = True, 257 | executable = True, 258 | cfg = "host", 259 | mandatory = True, 260 | ), 261 | "mockgen_tool": attr.label( 262 | doc = "The mockgen tool to run", 263 | default = Label(_MOCKGEN_TOOL), 264 | allow_single_file = True, 265 | executable = True, 266 | cfg = "host", 267 | mandatory = False, 268 | ), 269 | }, 270 | ) 271 | -------------------------------------------------------------------------------- /cmd/protocol-buffers-language-server/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library") 16 | 17 | go_library( 18 | name = "go_default_library", 19 | srcs = ["main.go"], 20 | importpath = "github.com/micnncim/protocol-buffers-language-server/cmd/protocol-buffers-language-server", 21 | visibility = ["//visibility:private"], 22 | deps = [ 23 | "//pkg/config:go_default_library", 24 | "//pkg/logging:go_default_library", 25 | "//pkg/lsp/server:go_default_library", 26 | "//pkg/lsp/source:go_default_library", 27 | "@com_github_alecthomas_kingpin//:go_default_library", 28 | "@com_github_go_language_server_jsonrpc2//:go_default_library", 29 | "@org_uber_go_zap//:go_default_library", 30 | ], 31 | ) 32 | 33 | go_binary( 34 | name = "protocol-buffers-language-server", 35 | embed = [":go_default_library"], 36 | visibility = ["//visibility:public"], 37 | ) 38 | -------------------------------------------------------------------------------- /cmd/protocol-buffers-language-server/main.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package main 16 | 17 | import ( 18 | "context" 19 | "fmt" 20 | "os" 21 | 22 | "github.com/alecthomas/kingpin" 23 | "github.com/go-language-server/jsonrpc2" 24 | "go.uber.org/zap" 25 | 26 | "github.com/micnncim/protocol-buffers-language-server/pkg/config" 27 | "github.com/micnncim/protocol-buffers-language-server/pkg/logging" 28 | "github.com/micnncim/protocol-buffers-language-server/pkg/lsp/server" 29 | "github.com/micnncim/protocol-buffers-language-server/pkg/lsp/source" 30 | ) 31 | 32 | var cfg config.Config 33 | 34 | func init() { 35 | kingpin.Flag("logfile", "Filename to log.").StringVar(&cfg.Log.File) 36 | kingpin.Flag("loglevel", "Level of logging.").Default("info").StringVar(&cfg.Log.Level) 37 | kingpin.Flag("address", "Address on run server. Use for debugging purposes.").StringVar(&cfg.Server.Address) 38 | kingpin.Flag("port", "Port on run server. Use for debugging purposes.").IntVar(&cfg.Server.Port) 39 | } 40 | 41 | func main() { 42 | kingpin.Parse() 43 | 44 | logger, err := logging.NewLogger(cfg.Log) 45 | if err != nil { 46 | fmt.Fprint(os.Stderr, err) 47 | os.Exit(1) 48 | } 49 | ctx := context.Background() 50 | ctx = logging.WithContext(ctx, logger) 51 | 52 | ctx, cancel := context.WithCancel(ctx) 53 | defer cancel() 54 | session := source.NewSession() 55 | 56 | if err := runServer(ctx, session, server.WithLogger(logger)); err != nil { 57 | logger.Error("failed to run server", zap.Error(err)) 58 | os.Exit(1) 59 | } 60 | } 61 | 62 | func runServer(ctx context.Context, session source.Session, opts ...server.Option) error { 63 | run := func(ctx context.Context, srv *server.Server) { 64 | go srv.Run(ctx) 65 | } 66 | 67 | if address := cfg.Server.Address; address != "" { 68 | return server.RunServerOnAddress(ctx, session, address, run, opts...) 69 | } 70 | 71 | if port := cfg.Server.Port; port != 0 { 72 | return server.RunServerOnPort(ctx, session, port, run, opts...) 73 | } 74 | 75 | stream := jsonrpc2.NewStream(os.Stdin, os.Stdout) 76 | ctx, srv := server.NewServer(ctx, session, stream, opts...) 77 | 78 | return srv.Run(ctx) 79 | } 80 | -------------------------------------------------------------------------------- /docs/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/micnncim/protocol-buffers-language-server/6c789bde03b5bfdf3854a7eee725108d430f7134/docs/assets/logo.png -------------------------------------------------------------------------------- /docs/development.md: -------------------------------------------------------------------------------- 1 | # Development Guide 2 | 3 | This document contains notes about development and testing of Protocol Buffers Language Server. 4 | 5 | ## Prerequisites 6 | 7 | - [Go 1.13](https://golang.org/dl) (for development) 8 | 9 | ## Build and Test 10 | 11 | This project uses [Bazel](https://bazel.build) and also Bazelisk for build and test. 12 | Bazelisk installs Bazel versioned by `.bazelversion`. 13 | 14 | And Bazel controls the versions of Go, Protocol Buffers and something like that. 15 | Thus, you don't need to care about their versions and install them to build or test. 16 | To develop you need to use Go 1.13. 17 | 18 | To build this project, run the following command. 19 | This builds it with Bazel. 20 | 21 | ``` 22 | $ make build 23 | ``` 24 | 25 | To test this project, run the following command. 26 | This tests it with Bazel. 27 | 28 | ``` 29 | $ make test 30 | ``` 31 | 32 | To update Go Modules, run the following command. 33 | This updates `go.mod` and `go.sum` and then updates the related Bazel files. 34 | 35 | ``` 36 | $ make dep 37 | ``` 38 | 39 | The generated files, like `.mock.go`, are not controlled by Git. 40 | And Bazel generates the files but the stuff is put into Bazel's sandbox. 41 | As a result, the files don't appear in your editor or IDE. 42 | 43 | To link generated files to your workspace and then make them appear in your editor or IDE, run the following command. 44 | 45 | ``` 46 | $ make expose-generated-go 47 | ``` 48 | 49 | ## Debug 50 | 51 | This project provides some flags for debugging. 52 | To know the way to debug, run it with `--help`. 53 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/micnncim/protocol-buffers-language-server 2 | 3 | go 1.13 4 | 5 | require ( 6 | github.com/alecthomas/kingpin v2.2.6+incompatible 7 | github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect 8 | github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 // indirect 9 | github.com/bazelbuild/bazelisk v0.0.8 10 | github.com/emicklei/proto v1.6.15 11 | github.com/go-language-server/jsonrpc2 v0.3.0 12 | github.com/go-language-server/protocol v0.5.0 13 | github.com/go-language-server/uri v0.2.0 14 | github.com/golang/mock v1.3.1 15 | github.com/kelseyhightower/envconfig v1.4.0 16 | go.uber.org/atomic v1.4.0 17 | go.uber.org/zap v1.10.1-0.20190430155229-8a2ee5670ced 18 | ) 19 | 20 | // https://thrift.apache.org/lib/go suggests using github 21 | replace git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999 22 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 2 | cloud.google.com/go v0.31.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 3 | cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 4 | cloud.google.com/go v0.37.0/go.mod h1:TS1dMSSfndXH133OKGwekG838Om/cQT0BUHV3HcBgoo= 5 | dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU= 6 | dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU= 7 | dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4= 8 | dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU= 9 | github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 10 | github.com/alecthomas/kingpin v2.2.6+incompatible h1:5svnBTFgJjZvGKyYBtMB0+m5wvrbUHiqye8wRJMlnYI= 11 | github.com/alecthomas/kingpin v2.2.6+incompatible/go.mod h1:59OFYbFVLKQKq+mqrL6Rw5bR0c3ACQaawgXx0QYndlE= 12 | github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= 13 | github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= 14 | github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 h1:Hs82Z41s6SdL1CELW+XaDYmOH4hkBN4/N9og/AsOv7E= 15 | github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= 16 | github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= 17 | github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= 18 | github.com/bazelbuild/bazelisk v0.0.8 h1:YRIIdISvlGj8UoPji/8hkwxOrbQPE84i4Wb8u3frGMM= 19 | github.com/bazelbuild/bazelisk v0.0.8/go.mod h1:0sUXNcOkMOudP6UartDysZ44w2Oy1BCJnJnhMn+y6Ls= 20 | github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= 21 | github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g= 22 | github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s= 23 | github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 24 | github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 25 | github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 26 | github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= 27 | github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 28 | github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= 29 | github.com/emicklei/proto v1.6.15 h1:XbpwxmuOPrdES97FrSfpyy67SSCV/wBIKXqgJzh6hNw= 30 | github.com/emicklei/proto v1.6.15/go.mod h1:rn1FgRS/FANiZdD2djyH7TMA9jdRDcYQ9IEN9yvjX0A= 31 | github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= 32 | github.com/francoispqt/gojay v1.2.13 h1:d2m3sFjloqoIUQU3TsHBgj6qg/BVGlTBeHDUmyJnXKk= 33 | github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY= 34 | github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= 35 | github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= 36 | github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= 37 | github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q= 38 | github.com/go-language-server/jsonrpc2 v0.3.0 h1:lWefg5lZbYnrSQHqKEyHEGZ2himQXtDkfmA13ZR/XFM= 39 | github.com/go-language-server/jsonrpc2 v0.3.0/go.mod h1:fHr6RX9DZFhGEFBcjBWfJXH5+o9QiXwH3vHGLqgd9zI= 40 | github.com/go-language-server/protocol v0.5.0 h1:nDdo0E1txdMyYqY0GnXTki/xcy5jMbXJj+NWPrmb/PM= 41 | github.com/go-language-server/protocol v0.5.0/go.mod h1:mAVIsoEmoVHhKelBvj11euYXPZwUxNMUoksl/ymPcz8= 42 | github.com/go-language-server/uri v0.2.0 h1:zkFlKR0EYmCg3076hwVbM9/+/Ugr8vMQvQQgoS2JpTo= 43 | github.com/go-language-server/uri v0.2.0/go.mod h1:1wEq7lT5PmX5uljJuQJeRxdW06jr5VfA1aR1FKe2/gc= 44 | github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 45 | github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 46 | github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E= 47 | github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 48 | github.com/golang/mock v1.2.0 h1:28o5sBqPkBsMGnC6b4MvE2TzSr5/AT4c/1fLqVGIwlk= 49 | github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 50 | github.com/golang/mock v1.3.1 h1:qGJ6qTW+x6xX/my+8YUVl4WNpX9B7+/l2tRsHGZ7f2s= 51 | github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= 52 | github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 53 | github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 54 | github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= 55 | github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= 56 | github.com/google/go-cmp v0.3.2-0.20190829225427-b1c9c4891a65 h1:B3yqxlLHBEoav+FDQM8ph7IIRA6AhQ70w119k3hoT2Y= 57 | github.com/google/go-cmp v0.3.2-0.20190829225427-b1c9c4891a65/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= 58 | github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ= 59 | github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= 60 | github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= 61 | github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= 62 | github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= 63 | github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg= 64 | github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 65 | github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= 66 | github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= 67 | github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0= 68 | github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= 69 | github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU= 70 | github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= 71 | github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= 72 | github.com/kelseyhightower/envconfig v1.4.0 h1:Im6hONhd3pLkfDFsbRgu68RDNkGF1r3dvMUtDTo2cv8= 73 | github.com/kelseyhightower/envconfig v1.4.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= 74 | github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 75 | github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 76 | github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 77 | github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 78 | github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= 79 | github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= 80 | github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= 81 | github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 82 | github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4= 83 | github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= 84 | github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= 85 | github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo= 86 | github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM= 87 | github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8= 88 | github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 89 | github.com/pkg/errors v0.8.2-0.20190227000051-27936f6d90f9 h1:PCj9X21C4pet4sEcElTfAi6LSl5ShkjE8doieLc+cbU= 90 | github.com/pkg/errors v0.8.2-0.20190227000051-27936f6d90f9/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 91 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 92 | github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 93 | github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 94 | github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 95 | github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= 96 | github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 97 | github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= 98 | github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= 99 | github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= 100 | github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= 101 | github.com/shurcooL/github_flavored_markdown v0.0.0-20181002035957-2122de532470/go.mod h1:2dOwnU2uBioM+SGy2aZoq1f/Sd1l9OkAeAUvjSyvgU0= 102 | github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk= 103 | github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ= 104 | github.com/shurcooL/gofontwoff v0.0.0-20180329035133-29b52fc0a18d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw= 105 | github.com/shurcooL/gopherjslib v0.0.0-20160914041154-feb6d3990c2c/go.mod h1:8d3azKNyqcHP1GaQE/c6dDgjkgSx2BZ4IoEi4F1reUI= 106 | github.com/shurcooL/highlight_diff v0.0.0-20170515013008-09bb4053de1b/go.mod h1:ZpfEhSmds4ytuByIcDnOLkTHGUI6KNqRNPDLHDk+mUU= 107 | github.com/shurcooL/highlight_go v0.0.0-20181028180052-98c3abbbae20/go.mod h1:UDKB5a1T23gOMUJrI+uSuH0VRDStOiUVSjBTRDVBVag= 108 | github.com/shurcooL/home v0.0.0-20181020052607-80b7ffcb30f9/go.mod h1:+rgNQw2P9ARFAs37qieuu7ohDNQ3gds9msbT2yn85sg= 109 | github.com/shurcooL/htmlg v0.0.0-20170918183704-d01228ac9e50/go.mod h1:zPn1wHpTIePGnXSHpsVPWEktKXHr6+SS6x/IKRb7cpw= 110 | github.com/shurcooL/httperror v0.0.0-20170206035902-86b7830d14cc/go.mod h1:aYMfkZ6DWSJPJ6c4Wwz3QtW22G7mf/PEgaB9k/ik5+Y= 111 | github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg= 112 | github.com/shurcooL/httpgzip v0.0.0-20180522190206-b1c53ac65af9/go.mod h1:919LwcH0M7/W4fcZ0/jy0qGght1GIhqyS/EgWGH2j5Q= 113 | github.com/shurcooL/issues v0.0.0-20181008053335-6292fdc1e191/go.mod h1:e2qWDig5bLteJ4fwvDAc2NHzqFEthkqn7aOZAOpj+PQ= 114 | github.com/shurcooL/issuesapp v0.0.0-20180602232740-048589ce2241/go.mod h1:NPpHK2TI7iSaM0buivtFUc9offApnI0Alt/K8hcHy0I= 115 | github.com/shurcooL/notifications v0.0.0-20181007000457-627ab5aea122/go.mod h1:b5uSkrEVM1jQUspwbixRBhaIjIzL2xazXp6kntxYle0= 116 | github.com/shurcooL/octicon v0.0.0-20181028054416-fa4f57f9efb2/go.mod h1:eWdoE5JD4R5UVWDucdOPg1g2fqQRq78IQa9zlOV1vpQ= 117 | github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1lToEk4d2s07G3XGfz2QrgHXg4RJBvjrOozvoWfk= 118 | github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= 119 | github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4= 120 | github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw= 121 | github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE= 122 | github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA= 123 | github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 124 | github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 125 | github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= 126 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 127 | github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA= 128 | github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU= 129 | github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM= 130 | go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA= 131 | go.uber.org/atomic v1.4.0 h1:cxzIVoETapQEqDhQu3QfnvXAV4AlzcvUCxkVUFw3+EU= 132 | go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= 133 | go.uber.org/multierr v1.1.1-0.20190429210458-bd075f90b08f h1:Q0q3m6foxW9fUIiNtElisPPzFNmxZ6jxL00xve0A348= 134 | go.uber.org/multierr v1.1.1-0.20190429210458-bd075f90b08f/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= 135 | go.uber.org/zap v1.10.1-0.20190430155229-8a2ee5670ced h1:2/OCbaWT0ZStdlrAU9heVF2FAVUoP+Mky/bPxP2Mqhs= 136 | go.uber.org/zap v1.10.1-0.20190430155229-8a2ee5670ced/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= 137 | go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE= 138 | golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw= 139 | golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= 140 | golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 141 | golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= 142 | golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 143 | golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 144 | golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 145 | golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 146 | golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 147 | golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 148 | golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 149 | golang.org/x/net v0.0.0-20181029044818-c44066c5c816/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 150 | golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 151 | golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 152 | golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 153 | golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 154 | golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 155 | golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 156 | golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 157 | golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 158 | golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= 159 | golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw= 160 | golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 161 | golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 162 | golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 163 | golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 164 | golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= 165 | golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 166 | golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 167 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 168 | golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 169 | golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 170 | golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 171 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 172 | golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 173 | golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 174 | golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= 175 | golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 176 | golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 177 | golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 178 | golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 179 | golang.org/x/tools v0.0.0-20190425150028-36563e24a262 h1:qsl9y/CJx34tuA7QCPNp86JNJe4spst6Ff8MjvPUdPg= 180 | golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 181 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7 h1:9zdDQZ7Thm29KFXgAX/+yaf3eVbP7djjWp/dXAppNCc= 182 | golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 183 | google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= 184 | google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0= 185 | google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y= 186 | google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 187 | google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 188 | google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 189 | google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 190 | google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 191 | google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 192 | google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 193 | google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg= 194 | google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= 195 | google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= 196 | google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio= 197 | google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs= 198 | google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 199 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= 200 | gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= 201 | gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= 202 | gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 203 | gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= 204 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 205 | grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o= 206 | honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 207 | honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 208 | honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 209 | sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck= 210 | sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0= 211 | -------------------------------------------------------------------------------- /hack/expose-generated-go.sh: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env bash 2 | 3 | # Copyright 2019 The Protocol Buffers Language Server Authors. 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -o errexit 18 | set -o nounset 19 | set -o pipefail 20 | 21 | if [[ "$#" -ne 2 ]]; then 22 | echo "usage: $0 " 23 | exit 1 24 | fi 25 | 26 | ORGANIZATION=$1 27 | REPOSITORY=$2 28 | 29 | OS="$(go env GOHOSTOS)" 30 | ARCH="$(go env GOARCH)" 31 | 32 | printf "\e[32;1m>>> Exposing Go generated files\n\e[m" 33 | 34 | expose_package () { 35 | local out_path=$1 36 | local package=$2 37 | local old_links=$(eval echo \$"$3") 38 | local generated_files=$(eval echo \$"$4") 39 | 40 | # Delete all old links 41 | for f in ${old_links}; do 42 | if [[ -f "${f}" ]]; then 43 | # shellcheck disable=SC2059 44 | printf "\e[32;1m>>> Deleting old link: ${f}\n\e[m" 45 | rm "${f}" 46 | fi 47 | done 48 | 49 | # Compute the relative_path from this package to the bazel-bin 50 | local count_paths="$(echo -n "${package}" | tr '/' '\n' | wc -l)" 51 | local relative_path="" 52 | for i in $(seq 0 "${count_paths}"); do 53 | relative_path="../${relative_path}" 54 | done 55 | 56 | local found=0 57 | for f in ${generated_files}; do 58 | if [[ -f "${f}" ]]; then 59 | found=1 60 | local base=${f##*/} 61 | printf "\e[32;1m>>> Adding a new link: ${package}/${base}\n\e[m" 62 | ln -nsf "${relative_path}${f}" "${package}/" 63 | fi 64 | done 65 | if [[ "${found}" == "0" ]]; then 66 | printf "\e[32;1m>>> Error: No generated file was found inside ${out_path} for the package ${package}\n\e[m" 67 | exit 1 68 | fi 69 | } 70 | 71 | # For proto go files 72 | 73 | for label in $(bazel query 'kind(go_proto_library, //...)'); do 74 | bazel build "${label}" 75 | done 76 | 77 | for label in $(bazel query 'kind(go_proto_library, //...)'); do 78 | package="${label%%:*}" 79 | package="${package##//}" 80 | target="${label##*:}" 81 | [[ -d "${package}" ]] || continue 82 | 83 | # Compute the path where bazel put the files 84 | out_path="bazel-bin/${package}/${OS}_${ARCH}_stripped/${target}%/github.com/${ORGANIZATION}/${REPOSITORY}/${package}" 85 | 86 | old_links=$(eval echo "${package}"/*.pb.go) 87 | generated_files=$(eval echo "${out_path}"/*.pb.go) 88 | expose_package "${out_path}" "${package}" old_links generated_files 89 | done 90 | 91 | # For mock go files 92 | 93 | # Build mock go files 94 | for label in $(bazel query 'kind(gomock, //...)'); do 95 | bazel build "${label}" 96 | done 97 | 98 | # Link to the generated files and add them to excluding list in the root BUILD file. 99 | for package in $(bazel query 'kind(gomock, //...)' --output package); do 100 | # Compute the path where Bazel puts the files. 101 | out_path="bazel-bin/${package}" 102 | 103 | # shellcheck disable=SC2125 104 | old_links=${package}/*.mock.go 105 | # shellcheck disable=SC2125 106 | generated_files=${out_path}/*.mock.go 107 | expose_package "${out_path}" "${package}" old_links generated_files 108 | done 109 | 110 | # Reset the root BUILD file 111 | cat "${GENERATED_BUILD_FILE}" > "${BUILD_FILE}" 112 | rm "${GENERATED_BUILD_FILE}" -------------------------------------------------------------------------------- /hack/tools.go: -------------------------------------------------------------------------------- 1 | // +build tools 2 | 3 | // Copyright 2019 The Protocol Buffers Language Server Authors. 4 | // 5 | // Licensed under the Apache License, Version 2.0 (the "License"); 6 | // you may not use this file except in compliance with the License. 7 | // You may obtain a copy of the License at 8 | // 9 | // http://www.apache.org/licenses/LICENSE-2.0 10 | // 11 | // Unless required by applicable law or agreed to in writing, software 12 | // distributed under the License is distributed on an "AS IS" BASIS, 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | // See the License for the specific language governing permissions and 15 | // limitations under the License. 16 | 17 | package tools 18 | 19 | import ( 20 | _ "github.com/bazelbuild/bazelisk" 21 | ) 22 | -------------------------------------------------------------------------------- /pkg/config/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 16 | 17 | go_library( 18 | name = "go_default_library", 19 | srcs = [ 20 | "config.go", 21 | "doc.go", 22 | ], 23 | importpath = "github.com/micnncim/protocol-buffers-language-server/pkg/config", 24 | visibility = ["//visibility:public"], 25 | deps = [ 26 | "@com_github_go_language_server_protocol//:go_default_library", 27 | "@com_github_kelseyhightower_envconfig//:go_default_library", 28 | ], 29 | ) 30 | 31 | go_test( 32 | name = "go_default_test", 33 | size = "small", 34 | srcs = ["config_test.go"], 35 | embed = [":go_default_library"], 36 | ) 37 | -------------------------------------------------------------------------------- /pkg/config/config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | 17 | import ( 18 | "github.com/go-language-server/protocol" 19 | "github.com/kelseyhightower/envconfig" 20 | ) 21 | 22 | const envPrefix = "PROTOBUF_LSP" 23 | 24 | var ( 25 | DefaultLSPConfig = LSP{ 26 | TextDocumentSyncKind: protocol.Full, 27 | } 28 | ) 29 | 30 | // Config represents a configuration for server. 31 | type Config struct { 32 | Env Env 33 | Server Server 34 | Log Log 35 | } 36 | 37 | // Env represents a environment variables for server. 38 | type Env struct { 39 | } 40 | 41 | // Server represents a configuration for server. 42 | type Server struct { 43 | LSP LSP 44 | Address string 45 | Port int 46 | } 47 | 48 | // LSP represents a configuration for LSP. 49 | type LSP struct { 50 | TextDocumentSyncKind protocol.TextDocumentSyncKind 51 | } 52 | 53 | // Log represents a configuration for zap.Logger. 54 | type Log struct { 55 | File string 56 | Level string 57 | } 58 | 59 | func newEnv() (Env, error) { 60 | env := Env{} 61 | if err := envconfig.Process(envPrefix, env); err != nil { 62 | return Env{}, err 63 | } 64 | return env, nil 65 | } 66 | -------------------------------------------------------------------------------- /pkg/config/config_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package config 16 | -------------------------------------------------------------------------------- /pkg/config/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package config provides configuration for server. 16 | package config 17 | -------------------------------------------------------------------------------- /pkg/logging/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 16 | 17 | go_library( 18 | name = "go_default_library", 19 | srcs = [ 20 | "context.go", 21 | "doc.go", 22 | "logging.go", 23 | ], 24 | importpath = "github.com/micnncim/protocol-buffers-language-server/pkg/logging", 25 | visibility = ["//visibility:public"], 26 | deps = [ 27 | "//pkg/config:go_default_library", 28 | "@org_uber_go_zap//:go_default_library", 29 | "@org_uber_go_zap//zapcore:go_default_library", 30 | ], 31 | ) 32 | -------------------------------------------------------------------------------- /pkg/logging/context.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package logging 16 | 17 | import ( 18 | "context" 19 | 20 | "go.uber.org/zap" 21 | ) 22 | 23 | type ctxKey struct{} 24 | 25 | // WithContext returns a context.Context with *zap.Logger as a context value. 26 | func WithContext(ctx context.Context, logger *zap.Logger) context.Context { 27 | return context.WithValue(ctx, ctxKey{}, logger) 28 | } 29 | 30 | // FromContext extracts *zap.Logger from a given context.Context and returns it. 31 | func FromContext(ctx context.Context) *zap.Logger { 32 | logger, ok := ctx.Value(ctxKey{}).(*zap.Logger) 33 | if !ok { 34 | return zap.NewNop() 35 | } 36 | return logger 37 | } 38 | -------------------------------------------------------------------------------- /pkg/logging/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package logging provides logging. 16 | package logging 17 | -------------------------------------------------------------------------------- /pkg/logging/logging.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package logging 16 | 17 | import ( 18 | "fmt" 19 | "strings" 20 | "time" 21 | 22 | "go.uber.org/zap" 23 | "go.uber.org/zap/zapcore" 24 | 25 | "github.com/micnncim/protocol-buffers-language-server/pkg/config" 26 | ) 27 | 28 | // NewLogger returns *zap.Logger initialized by provided log level and []zap.Option. 29 | func NewLogger(cfg config.Log, opts ...zap.Option) (*zap.Logger, error) { 30 | c, err := newConfig(cfg) 31 | if err != nil { 32 | return nil, err 33 | } 34 | return c.Build(opts...) 35 | } 36 | 37 | func newConfig(cfg config.Log) (zap.Config, error) { 38 | c := zap.Config{ 39 | Development: false, 40 | DisableCaller: false, 41 | DisableStacktrace: false, 42 | Sampling: &zap.SamplingConfig{ 43 | Initial: 100, 44 | Thereafter: 100, 45 | }, 46 | Encoding: "json", 47 | EncoderConfig: zapcore.EncoderConfig{ 48 | MessageKey: "message", 49 | LevelKey: "level", 50 | TimeKey: "time", 51 | NameKey: "logger", 52 | CallerKey: "caller", 53 | StacktraceKey: "stacktrace", 54 | LineEnding: zapcore.DefaultLineEnding, 55 | EncodeLevel: zapcore.LowercaseLevelEncoder, 56 | EncodeTime: logTimeEncoder, 57 | EncodeDuration: zapcore.SecondsDurationEncoder, 58 | EncodeCaller: zapcore.ShortCallerEncoder, 59 | }, 60 | OutputPaths: []string{"stdout"}, 61 | ErrorOutputPaths: []string{"stderr"}, 62 | } 63 | 64 | l, err := parseLogLevel(cfg.Level) 65 | if err != nil { 66 | return zap.Config{}, err 67 | } 68 | c.Level = zap.NewAtomicLevelAt(l) 69 | 70 | if f := cfg.File; f != "" { 71 | c.OutputPaths = []string{f} 72 | c.ErrorOutputPaths = []string{f} 73 | } 74 | 75 | return c, nil 76 | } 77 | 78 | func logTimeEncoder(t time.Time, enc zapcore.PrimitiveArrayEncoder) { 79 | enc.AppendString(t.Format("2006-01-02T15:04:05")) 80 | } 81 | 82 | func parseLogLevel(levelStr string) (zapcore.Level, error) { 83 | switch strings.ToUpper(levelStr) { 84 | case zapcore.DebugLevel.CapitalString(): 85 | return zapcore.DebugLevel, nil 86 | case zapcore.InfoLevel.CapitalString(): 87 | return zapcore.InfoLevel, nil 88 | case zapcore.WarnLevel.CapitalString(): 89 | return zapcore.WarnLevel, nil 90 | case zapcore.ErrorLevel.CapitalString(): 91 | return zapcore.ErrorLevel, nil 92 | default: 93 | return zapcore.InfoLevel, fmt.Errorf("undefined log level: %v", levelStr) 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /pkg/lsp/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 16 | 17 | go_library( 18 | name = "go_default_library", 19 | srcs = ["doc.go"], 20 | importpath = "github.com/micnncim/protocol-buffers-language-server/pkg/lsp", 21 | visibility = ["//visibility:public"], 22 | ) 23 | -------------------------------------------------------------------------------- /pkg/lsp/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package lsp provides Language Server Protocol for Protocol Buffers. 16 | package lsp 17 | -------------------------------------------------------------------------------- /pkg/lsp/server/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 16 | 17 | go_library( 18 | name = "go_default_library", 19 | srcs = [ 20 | "completion.go", 21 | "definition.go", 22 | "general.go", 23 | "server.go", 24 | "text_synchronization.go", 25 | "workspace.go", 26 | ], 27 | importpath = "github.com/micnncim/protocol-buffers-language-server/pkg/lsp/server", 28 | visibility = ["//visibility:public"], 29 | deps = [ 30 | "//pkg/config:go_default_library", 31 | "//pkg/logging:go_default_library", 32 | "//pkg/lsp/source:go_default_library", 33 | "//pkg/proto/types:go_default_library", 34 | "@com_github_go_language_server_jsonrpc2//:go_default_library", 35 | "@com_github_go_language_server_protocol//:go_default_library", 36 | "@com_github_go_language_server_uri//:go_default_library", 37 | "@org_uber_go_zap//:go_default_library", 38 | ], 39 | ) 40 | 41 | go_test( 42 | name = "go_default_test", 43 | size = "small", 44 | srcs = [ 45 | "completion_test.go", 46 | "definition_test.go", 47 | "general_test.go", 48 | "server_test.go", 49 | "text_synchronization_test.go", 50 | "workspace_test.go", 51 | ], 52 | embed = [":go_default_library"], 53 | ) 54 | -------------------------------------------------------------------------------- /pkg/lsp/server/completion.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package server 16 | 17 | import ( 18 | "context" 19 | "strings" 20 | 21 | "github.com/go-language-server/protocol" 22 | "go.uber.org/zap" 23 | 24 | "github.com/micnncim/protocol-buffers-language-server/pkg/logging" 25 | "github.com/micnncim/protocol-buffers-language-server/pkg/lsp/source" 26 | "github.com/micnncim/protocol-buffers-language-server/pkg/proto/types" 27 | ) 28 | 29 | func (s *Server) completion(ctx context.Context, params *protocol.CompletionParams) (result *protocol.CompletionList, err error) { 30 | logger := logging.FromContext(ctx) 31 | logger = logger.With(zap.Any("params", params)) 32 | 33 | uri := params.TextDocument.URI 34 | filename := uri.Filename() 35 | 36 | v := s.session.ViewOf(uri) 37 | 38 | f, err := v.GetFile(uri) 39 | if err != nil { 40 | logger.Error("file not found", zap.String("filename", filename)) 41 | return 42 | } 43 | 44 | protoFile, ok := f.(source.ProtoFile) 45 | if !ok { 46 | return 47 | } 48 | 49 | proto := protoFile.Proto() 50 | var items []protocol.CompletionItem 51 | 52 | // Get completions for field within messages. 53 | 54 | // TODO: Check whether the params.TextDocumentPositionParams.Position is valid. 55 | // TODO: Sort the items. 56 | 57 | // TODO: Remove this and judge whether target is rpc with better performance. 58 | buf, _, err := f.Read(ctx) 59 | if err != nil { 60 | logger.Error("failed to read file", zap.String("filename", filename)) 61 | return 62 | } 63 | line := int(params.Position.Line) + 1 64 | targetLine := readLine(string(buf), line) 65 | // If target is not rpc, add build-in types to completion items. 66 | isRPC := strings.HasPrefix(strings.TrimSpace(targetLine), "rpc") 67 | 68 | if !isRPC { 69 | for _, t := range types.BuildInProtoTypes { 70 | items = append(items, protocol.CompletionItem{ 71 | Label: string(t), 72 | Detail: "type", 73 | }) 74 | } 75 | } 76 | 77 | for _, m := range proto.Messages() { 78 | items = append(items, protocol.CompletionItem{ 79 | Label: m.Protobuf().Name, 80 | Detail: "message", 81 | }) 82 | } 83 | 84 | if !isRPC { 85 | for _, e := range proto.Enums() { 86 | items = append(items, protocol.CompletionItem{ 87 | Label: e.Protobuf().Name, 88 | Detail: "enum", 89 | }) 90 | } 91 | } 92 | 93 | result = &protocol.CompletionList{ 94 | IsIncomplete: false, 95 | Items: items, 96 | } 97 | return 98 | } 99 | 100 | func readLine(text string, line int) string { 101 | if line < 1 { 102 | return "" 103 | } 104 | slugs := strings.Split(text, "\n") 105 | return slugs[line-1] 106 | } 107 | -------------------------------------------------------------------------------- /pkg/lsp/server/completion_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package server 16 | -------------------------------------------------------------------------------- /pkg/lsp/server/definition.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package server 16 | 17 | import ( 18 | "context" 19 | 20 | "github.com/go-language-server/protocol" 21 | "go.uber.org/zap" 22 | 23 | "github.com/micnncim/protocol-buffers-language-server/pkg/logging" 24 | "github.com/micnncim/protocol-buffers-language-server/pkg/lsp/source" 25 | ) 26 | 27 | // TODO: Match position with line and column. 28 | // Currently matches with only line. 29 | func (s *Server) definition(ctx context.Context, params *protocol.TextDocumentPositionParams) (result []protocol.Location, err error) { 30 | logger := logging.FromContext(ctx) 31 | logger = logger.With(zap.Any("params", params)) 32 | 33 | uri := params.TextDocument.URI 34 | filename := uri.Filename() 35 | 36 | v := s.session.ViewOf(uri) 37 | 38 | f, err := v.GetFile(uri) 39 | if err != nil { 40 | logger.Error("file not found", zap.String("filename", filename)) 41 | return 42 | } 43 | 44 | protoFile, ok := f.(source.ProtoFile) 45 | if !ok { 46 | return 47 | } 48 | 49 | proto := protoFile.Proto() 50 | 51 | line := int(params.Position.Line) + 1 52 | field, ok := proto.GetMessageFieldByLine(line) 53 | if !ok { 54 | logger.Warn("field not found", zap.Int("line", line)) 55 | return 56 | } 57 | 58 | typ := field.ProtoField.Type 59 | // TODO: Search the requested proto file and imported proto files. 60 | m, ok := proto.GetMessageByName(typ) 61 | if !ok { 62 | logger.Warn("message not found", zap.String("name", typ)) 63 | return 64 | } 65 | 66 | line, column := m.Protobuf().Position.Line, m.Protobuf().Position.Column 67 | 68 | result = []protocol.Location{ 69 | { 70 | URI: uri, 71 | Range: protocol.Range{ 72 | Start: protocol.Position{ 73 | Line: float64(line) - 1, 74 | Character: float64(column) - 1, 75 | }, 76 | }, 77 | }, 78 | } 79 | 80 | return 81 | } 82 | -------------------------------------------------------------------------------- /pkg/lsp/server/definition_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package server 16 | -------------------------------------------------------------------------------- /pkg/lsp/server/general.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Copyright 2019 The Go Authors. All rights reserved. 16 | // Use of this source code is governed by a BSD-style 17 | // license that can be found in the LICENSE file. 18 | 19 | package server 20 | 21 | import ( 22 | "context" 23 | "errors" 24 | "os" 25 | "path/filepath" 26 | 27 | "github.com/go-language-server/jsonrpc2" 28 | "github.com/go-language-server/protocol" 29 | "github.com/go-language-server/uri" 30 | "go.uber.org/zap" 31 | 32 | "github.com/micnncim/protocol-buffers-language-server/pkg/config" 33 | "github.com/micnncim/protocol-buffers-language-server/pkg/logging" 34 | ) 35 | 36 | func (s *Server) initialize(ctx context.Context, params *protocol.InitializeParams) (result *protocol.InitializeResult, err error) { 37 | logger := logging.FromContext(ctx) 38 | logger = logger.With(zap.Any("params", params)) 39 | 40 | s.stateMu.RLock() 41 | state := s.state 42 | s.stateMu.RUnlock() 43 | if state > stateInitializing { 44 | err = jsonrpc2.NewError(jsonrpc2.InvalidRequest, "server already initialized") 45 | return 46 | } 47 | s.stateMu.Lock() 48 | s.state = stateInitializing 49 | s.stateMu.Unlock() 50 | 51 | folders := params.WorkspaceFolders 52 | if len(folders) == 0 { 53 | rootURI := params.RootURI 54 | if rootURI == "" { 55 | err = errors.New("single file mode not supported yet") 56 | return 57 | } 58 | folders = []protocol.WorkspaceFolder{ 59 | { 60 | URI: rootURI.Filename(), 61 | Name: filepath.Base(rootURI.Filename()), 62 | }, 63 | } 64 | } 65 | 66 | for _, folder := range folders { 67 | s.addView(ctx, folder.Name, uri.File(folder.URI)) 68 | } 69 | 70 | cfg := config.DefaultLSPConfig 71 | 72 | result = &protocol.InitializeResult{ 73 | Capabilities: protocol.ServerCapabilities{ 74 | TextDocumentSync: protocol.TextDocumentSyncOptions{ 75 | OpenClose: true, 76 | Change: float64(cfg.TextDocumentSyncKind), 77 | }, 78 | HoverProvider: false, 79 | CompletionProvider: &protocol.CompletionOptions{ 80 | TriggerCharacters: []string{"."}, 81 | }, 82 | SignatureHelpProvider: &protocol.SignatureHelpOptions{ 83 | TriggerCharacters: nil, 84 | }, 85 | DefinitionProvider: true, 86 | WorkspaceSymbolProvider: false, 87 | DocumentFormattingProvider: false, 88 | DocumentRangeFormattingProvider: false, 89 | RenameProvider: nil, 90 | FoldingRangeProvider: nil, 91 | Workspace: &protocol.ServerCapabilitiesWorkspace{ 92 | WorkspaceFolders: &protocol.ServerCapabilitiesWorkspaceFolders{ 93 | Supported: false, 94 | ChangeNotifications: nil, 95 | }, 96 | }, 97 | }, 98 | } 99 | 100 | return 101 | } 102 | 103 | func (s *Server) initialized(ctx context.Context, params *protocol.InitializedParams) (err error) { 104 | s.stateMu.Lock() 105 | s.state = stateInitialized 106 | s.stateMu.Unlock() 107 | return 108 | } 109 | 110 | func (s *Server) shutdown(ctx context.Context) (err error) { 111 | s.stateMu.RLock() 112 | state := s.state 113 | s.stateMu.RUnlock() 114 | if state < stateInitialized { 115 | err = jsonrpc2.NewError(jsonrpc2.InvalidRequest, "server not initialized") 116 | return 117 | } 118 | s.session.Shutdown(ctx) 119 | s.stateMu.Lock() 120 | s.state = stateShutdown 121 | s.stateMu.Unlock() 122 | return 123 | } 124 | 125 | func (s *Server) exit(ctx context.Context) (err error) { 126 | s.stateMu.RLock() 127 | defer s.stateMu.RUnlock() 128 | if s.state != stateShutdown { 129 | os.Exit(1) 130 | } 131 | os.Exit(0) 132 | return 133 | } 134 | -------------------------------------------------------------------------------- /pkg/lsp/server/general_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package server 16 | -------------------------------------------------------------------------------- /pkg/lsp/server/server.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Copyright 2018 The Go Authors. All rights reserved. 16 | // Use of this source code is governed by a BSD-style 17 | // license that can be found in the LICENSE file. 18 | 19 | package server 20 | 21 | import ( 22 | "context" 23 | "fmt" 24 | "net" 25 | "sync" 26 | 27 | "github.com/go-language-server/jsonrpc2" 28 | "github.com/go-language-server/protocol" 29 | "go.uber.org/zap" 30 | 31 | "github.com/micnncim/protocol-buffers-language-server/pkg/config" 32 | "github.com/micnncim/protocol-buffers-language-server/pkg/logging" 33 | "github.com/micnncim/protocol-buffers-language-server/pkg/lsp/source" 34 | ) 35 | 36 | type state int 37 | 38 | const ( 39 | stateCreated = state(iota) 40 | stateInitializing 41 | stateInitialized // Set once the server has received Initialize Request 42 | stateShutdown // Set once the server has received Initialized Request 43 | ) 44 | 45 | type Server struct { 46 | Conn *jsonrpc2.Conn 47 | Client protocol.ClientInterface 48 | 49 | state state 50 | stateMu *sync.RWMutex 51 | 52 | session source.Session 53 | 54 | config config.LSP 55 | 56 | logger *zap.Logger 57 | } 58 | 59 | var _ protocol.ServerInterface = (*Server)(nil) 60 | 61 | type Option func(*Server) 62 | 63 | func WithLogger(logger *zap.Logger) Option { 64 | return func(s *Server) { 65 | s.logger = logger 66 | } 67 | } 68 | 69 | func NewServer(ctx context.Context, session source.Session, stream jsonrpc2.Stream, opts ...Option) (context.Context, *Server) { 70 | s := &Server{ 71 | state: stateCreated, 72 | stateMu: &sync.RWMutex{}, 73 | session: session, 74 | logger: zap.NewNop(), 75 | } 76 | for _, opt := range opts { 77 | opt(s) 78 | } 79 | 80 | jsonrpcOpts := []jsonrpc2.Options{ 81 | jsonrpc2.WithCanceler(protocol.Canceller), 82 | jsonrpc2.WithCapacity(protocol.DefaultBufferSize), 83 | jsonrpc2.WithLogger(s.logger.Named("jsonrpc2")), 84 | } 85 | s.Conn, s.Client = protocol.NewServer(ctx, s, stream, zap.NewNop(), jsonrpcOpts...) 86 | 87 | logger := s.logger.Named("server") 88 | logging.WithContext(ctx, logger) 89 | 90 | return ctx, s 91 | } 92 | 93 | // RunServerOnPort starts a server on the given port and does not exit. 94 | // This function exists for debugging purposes. 95 | func RunServerOnPort(ctx context.Context, session source.Session, port int, handler func(ctx context.Context, s *Server), opts ...Option) error { 96 | return RunServerOnAddress(ctx, session, fmt.Sprintf(":%v", port), handler, opts...) 97 | } 98 | 99 | // RunServerOnPort starts a server on the given port and does not exit. 100 | // This function exists for debugging purposes. 101 | func RunServerOnAddress(ctx context.Context, session source.Session, addr string, handler func(ctx context.Context, s *Server), opts ...Option) error { 102 | ln, err := net.Listen("tcp", addr) 103 | if err != nil { 104 | return err 105 | } 106 | for { 107 | conn, err := ln.Accept() 108 | if err != nil { 109 | return err 110 | } 111 | handler(NewServer(ctx, session, jsonrpc2.NewStream(conn, conn), opts...)) 112 | } 113 | } 114 | 115 | func (s *Server) Run(ctx context.Context) (err error) { 116 | return s.Conn.Run(ctx) 117 | } 118 | 119 | // Initialize implements initialize method. 120 | // https://microsoft.github.io/language-server-protocol/specification#initialize 121 | func (s *Server) Initialize(ctx context.Context, params *protocol.InitializeParams) (result *protocol.InitializeResult, err error) { 122 | return s.initialize(ctx, params) 123 | } 124 | 125 | // Initialized implements initialized method. 126 | // https://microsoft.github.io/language-server-protocol/specification#initialized 127 | func (s *Server) Initialized(ctx context.Context, params *protocol.InitializedParams) (err error) { 128 | return s.initialized(ctx, params) 129 | } 130 | 131 | // Shutdown implements shutdown method. 132 | // https://microsoft.github.io/language-server-protocol/specification#shutdown 133 | func (s *Server) Shutdown(ctx context.Context) (err error) { 134 | return s.shutdown(ctx) 135 | } 136 | 137 | // Exit implements exit method. 138 | // https://microsoft.github.io/language-server-protocol/specification#exit 139 | func (s *Server) Exit(ctx context.Context) (err error) { 140 | return s.exit(ctx) 141 | } 142 | 143 | func (s *Server) CodeAction(ctx context.Context, params *protocol.CodeActionParams) (result []protocol.CodeAction, err error) { 144 | err = notImplemented("CodeAction") 145 | return 146 | } 147 | 148 | func (s *Server) CodeLens(ctx context.Context, params *protocol.CodeLensParams) (result []protocol.CodeLens, err error) { 149 | err = notImplemented("CodeLens") 150 | return 151 | } 152 | 153 | func (s *Server) CodeLensResolve(ctx context.Context, params *protocol.CodeLens) (result *protocol.CodeLens, err error) { 154 | err = notImplemented("CodeLensResolve") 155 | return 156 | } 157 | 158 | func (s *Server) ColorPresentation(ctx context.Context, params *protocol.ColorPresentationParams) (result []protocol.ColorPresentation, err error) { 159 | err = notImplemented("ColorPresentation") 160 | return 161 | } 162 | 163 | // Completion implements textDocument/completion method. 164 | // https://microsoft.github.io/language-server-protocol/specification#textDocument_completion 165 | func (s *Server) Completion(ctx context.Context, params *protocol.CompletionParams) (result *protocol.CompletionList, err error) { 166 | return s.completion(ctx, params) 167 | } 168 | 169 | func (s *Server) CompletionResolve(ctx context.Context, params *protocol.CompletionItem) (result *protocol.CompletionItem, err error) { 170 | err = notImplemented("CompletionResolve") 171 | return 172 | } 173 | 174 | func (s *Server) Declaration(ctx context.Context, params *protocol.TextDocumentPositionParams) (result []protocol.Location, err error) { 175 | err = notImplemented("Declaration") 176 | return 177 | } 178 | 179 | // Definition implements textDocument/definition method. 180 | // https://microsoft.github.io/language-server-protocol/specification#textDocument_definition 181 | func (s *Server) Definition(ctx context.Context, params *protocol.TextDocumentPositionParams) (result []protocol.Location, err error) { 182 | return s.definition(ctx, params) 183 | } 184 | 185 | // DidChange implements textDocument/didChange method. 186 | // https://microsoft.github.io/language-server-protocol/specification#textDocument_didChange 187 | func (s *Server) DidChange(ctx context.Context, params *protocol.DidChangeTextDocumentParams) (err error) { 188 | return s.didChange(ctx, params) 189 | } 190 | 191 | func (s *Server) DidChangeConfiguration(ctx context.Context, params *protocol.DidChangeConfigurationParams) (err error) { 192 | err = notImplemented("DidChangeConfiguration") 193 | return 194 | } 195 | 196 | func (s *Server) DidChangeWatchedFiles(ctx context.Context, params *protocol.DidChangeWatchedFilesParams) (err error) { 197 | err = notImplemented("DidChangeWatchedFiles") 198 | return 199 | } 200 | 201 | // DidChangeWorkspaceFolders implements workspace/didChangeWorkspaceFolders method. 202 | // https://microsoft.github.io/language-server-protocol/specification#workspace_didChangeWorkspaceFolders 203 | func (s *Server) DidChangeWorkspaceFolders(ctx context.Context, params *protocol.DidChangeWorkspaceFoldersParams) (err error) { 204 | return s.changeWorkspace(ctx, params.Event) 205 | } 206 | 207 | // DidClose implements textDocument/didClose method. 208 | // https://microsoft.github.io/language-server-protocol/specification#textDocument_didClose 209 | func (s *Server) DidClose(ctx context.Context, params *protocol.DidCloseTextDocumentParams) (err error) { 210 | return s.didClose(ctx, params) 211 | } 212 | 213 | // DidOpen implements textDocument/didOpen method. 214 | // https://microsoft.github.io/language-server-protocol/specification#textDocument_didOpen 215 | func (s *Server) DidOpen(ctx context.Context, params *protocol.DidOpenTextDocumentParams) (err error) { 216 | return s.didOpen(ctx, params) 217 | } 218 | 219 | // DidSave implements textDocument/didSave method. 220 | // https://microsoft.github.io/language-server-protocol/specification#textDocument_didSave 221 | func (s *Server) DidSave(ctx context.Context, params *protocol.DidSaveTextDocumentParams) (err error) { 222 | return s.didSave(ctx, params) 223 | } 224 | 225 | func (s *Server) DocumentColor(ctx context.Context, params *protocol.DocumentColorParams) (result []protocol.ColorInformation, err error) { 226 | err = notImplemented("DocumentColor") 227 | return 228 | } 229 | 230 | func (s *Server) DocumentHighlight(ctx context.Context, params *protocol.TextDocumentPositionParams) (result []protocol.DocumentHighlight, err error) { 231 | err = notImplemented("DocumentHighlight") 232 | return 233 | } 234 | 235 | func (s *Server) DocumentLink(ctx context.Context, params *protocol.DocumentLinkParams) (result []protocol.DocumentLink, err error) { 236 | err = notImplemented("DocumentLink") 237 | return 238 | } 239 | 240 | func (s *Server) DocumentLinkResolve(ctx context.Context, params *protocol.DocumentLink) (result *protocol.DocumentLink, err error) { 241 | err = notImplemented("DocumentLinkResolve") 242 | return 243 | } 244 | 245 | func (s *Server) DocumentSymbol(ctx context.Context, params *protocol.DocumentSymbolParams) (result []protocol.DocumentSymbol, err error) { 246 | err = notImplemented("DocumentSymbol") 247 | return 248 | } 249 | 250 | func (s *Server) ExecuteCommand(ctx context.Context, params *protocol.ExecuteCommandParams) (result interface{}, err error) { 251 | err = notImplemented("ExecuteCommand") 252 | return 253 | } 254 | 255 | func (s *Server) FoldingRanges(ctx context.Context, params *protocol.FoldingRangeParams) (result []protocol.FoldingRange, err error) { 256 | err = notImplemented("FoldingRanges") 257 | return 258 | } 259 | 260 | func (s *Server) Formatting(ctx context.Context, params *protocol.DocumentFormattingParams) (result []protocol.TextEdit, err error) { 261 | err = notImplemented("Formatting") 262 | return 263 | } 264 | 265 | func (s *Server) Hover(ctx context.Context, params *protocol.TextDocumentPositionParams) (result *protocol.Hover, err error) { 266 | err = notImplemented("Hover") 267 | return 268 | } 269 | 270 | func (s *Server) Implementation(ctx context.Context, params *protocol.TextDocumentPositionParams) (result []protocol.Location, err error) { 271 | err = notImplemented("Implementation") 272 | return 273 | } 274 | 275 | func (s *Server) OnTypeFormatting(ctx context.Context, params *protocol.DocumentOnTypeFormattingParams) (result []protocol.TextEdit, err error) { 276 | err = notImplemented("OnTypeFormatting") 277 | return 278 | } 279 | 280 | func (s *Server) PrepareRename(ctx context.Context, params *protocol.TextDocumentPositionParams) (result *protocol.Range, err error) { 281 | err = notImplemented("PrepareRename") 282 | return 283 | } 284 | 285 | func (s *Server) RangeFormatting(ctx context.Context, params *protocol.DocumentRangeFormattingParams) (result []protocol.TextEdit, err error) { 286 | err = notImplemented("RangeFormatting") 287 | return 288 | } 289 | 290 | func (s *Server) References(ctx context.Context, params *protocol.ReferenceParams) (result []protocol.Location, err error) { 291 | err = notImplemented("References") 292 | return 293 | } 294 | 295 | func (s *Server) Rename(ctx context.Context, params *protocol.RenameParams) (result *protocol.WorkspaceEdit, err error) { 296 | err = notImplemented("Rename") 297 | return 298 | } 299 | 300 | func (s *Server) SignatureHelp(ctx context.Context, params *protocol.TextDocumentPositionParams) (result *protocol.SignatureHelp, err error) { 301 | err = notImplemented("SignatureHelp") 302 | return 303 | } 304 | 305 | func (s *Server) Symbols(ctx context.Context, params *protocol.WorkspaceSymbolParams) (result []protocol.SymbolInformation, err error) { 306 | err = notImplemented("Symbols") 307 | return 308 | } 309 | 310 | func (s *Server) TypeDefinition(ctx context.Context, params *protocol.TextDocumentPositionParams) (result []protocol.Location, err error) { 311 | err = notImplemented("TypeDefinition") 312 | return 313 | } 314 | 315 | func (s *Server) WillSave(ctx context.Context, params *protocol.WillSaveTextDocumentParams) (err error) { 316 | err = notImplemented("WillSave") 317 | return 318 | } 319 | 320 | func (s *Server) WillSaveWaitUntil(ctx context.Context, params *protocol.WillSaveTextDocumentParams) (result []protocol.TextEdit, err error) { 321 | err = notImplemented("WillSaveWaitUntil") 322 | return 323 | } 324 | 325 | func notImplemented(method string) error { 326 | return jsonrpc2.Errorf(jsonrpc2.MethodNotFound, "method %q not implemented", method) 327 | } 328 | -------------------------------------------------------------------------------- /pkg/lsp/server/server_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package server 16 | -------------------------------------------------------------------------------- /pkg/lsp/server/text_synchronization.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Copyright 2019 The Go Authors. All rights reserved. 16 | // Use of this source code is governed by a BSD-style 17 | // license that can be found in the LICENSE file. 18 | 19 | package server 20 | 21 | import ( 22 | "context" 23 | "fmt" 24 | 25 | "github.com/go-language-server/jsonrpc2" 26 | "github.com/go-language-server/protocol" 27 | "go.uber.org/zap" 28 | 29 | "github.com/micnncim/protocol-buffers-language-server/pkg/logging" 30 | ) 31 | 32 | func (s *Server) didOpen(ctx context.Context, params *protocol.DidOpenTextDocumentParams) error { 33 | logger := logging.FromContext(ctx) 34 | logger = logger.With(zap.Any("params", params)) 35 | 36 | uri := params.TextDocument.URI 37 | text := []byte(params.TextDocument.Text) 38 | 39 | v := s.session.ViewOf(uri) 40 | v.DidOpen(uri, text) 41 | 42 | return nil 43 | } 44 | 45 | func (s *Server) didChange(ctx context.Context, params *protocol.DidChangeTextDocumentParams) error { 46 | if len(params.ContentChanges) < 1 { 47 | return jsonrpc2.NewError(jsonrpc2.InternalError, "no content changes provided") 48 | } 49 | 50 | uri := params.TextDocument.URI 51 | // TODO: Support incremental change. Currently support only full change. 52 | text := params.ContentChanges[0].Text 53 | 54 | switch s.config.TextDocumentSyncKind { 55 | case protocol.None: 56 | return nil 57 | case protocol.Full: 58 | case protocol.Incremental: 59 | return fmt.Errorf("incremental change is not supported yet") 60 | } 61 | 62 | v := s.session.ViewOf(uri) 63 | v.SetContent(ctx, uri, []byte(text)) 64 | 65 | return nil 66 | } 67 | 68 | func (s *Server) didClose(ctx context.Context, params *protocol.DidCloseTextDocumentParams) error { 69 | uri := params.TextDocument.URI 70 | 71 | v := s.session.ViewOf(uri) 72 | v.DidClose(uri) 73 | v.SetContent(ctx, uri, nil) 74 | 75 | return nil 76 | } 77 | 78 | func (s *Server) didSave(_ context.Context, params *protocol.DidSaveTextDocumentParams) error { 79 | uri := params.TextDocument.URI 80 | 81 | v := s.session.ViewOf(uri) 82 | v.DidSave(uri) 83 | 84 | return nil 85 | } 86 | -------------------------------------------------------------------------------- /pkg/lsp/server/text_synchronization_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package server 16 | -------------------------------------------------------------------------------- /pkg/lsp/server/workspace.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Copyright 2019 The Go Authors. All rights reserved. 16 | // Use of this source code is governed by a BSD-style 17 | // license that can be found in the LICENSE file. 18 | 19 | package server 20 | 21 | import ( 22 | "context" 23 | 24 | "github.com/go-language-server/protocol" 25 | "github.com/go-language-server/uri" 26 | 27 | "github.com/micnncim/protocol-buffers-language-server/pkg/lsp/source" 28 | ) 29 | 30 | func (s *Server) changeWorkspace(ctx context.Context, event protocol.WorkspaceFoldersChangeEvent) error { 31 | for _, folder := range event.Removed { 32 | view, ok := s.session.View(folder.Name) 33 | if !ok { 34 | continue 35 | } 36 | if err := view.Shutdown(ctx); err != nil { 37 | return err 38 | } 39 | } 40 | 41 | for _, folder := range event.Added { 42 | s.addView(ctx, folder.Name, uri.File(folder.URI)) 43 | } 44 | return nil 45 | } 46 | 47 | func (s *Server) addView(ctx context.Context, name string, uri uri.URI) { 48 | view := source.NewView(s.session, name, uri) 49 | s.session.AddView(ctx, view) 50 | } 51 | -------------------------------------------------------------------------------- /pkg/lsp/server/workspace_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package server 16 | -------------------------------------------------------------------------------- /pkg/lsp/source/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 16 | 17 | go_library( 18 | name = "go_default_library", 19 | srcs = [ 20 | "doc.go", 21 | "file.go", 22 | "session.go", 23 | "view.go", 24 | ], 25 | importpath = "github.com/micnncim/protocol-buffers-language-server/pkg/lsp/source", 26 | visibility = ["//visibility:public"], 27 | deps = [ 28 | "//pkg/proto/parser:go_default_library", 29 | "//pkg/proto/registry:go_default_library", 30 | "@com_github_go_language_server_uri//:go_default_library", 31 | "@org_uber_go_atomic//:go_default_library", 32 | ], 33 | ) 34 | 35 | go_test( 36 | name = "go_default_test", 37 | size = "small", 38 | srcs = [ 39 | "session_test.go", 40 | "view_test.go", 41 | ], 42 | embed = [":go_default_library"], 43 | ) 44 | -------------------------------------------------------------------------------- /pkg/lsp/source/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package source provides source info for client. 16 | package source 17 | -------------------------------------------------------------------------------- /pkg/lsp/source/file.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Copyright 2018 The Go Authors. All rights reserved. 16 | // Use of this source code is governed by a BSD-style 17 | // license that can be found in the LICENSE file. 18 | 19 | package source 20 | 21 | import ( 22 | "context" 23 | 24 | "github.com/go-language-server/uri" 25 | 26 | "github.com/micnncim/protocol-buffers-language-server/pkg/proto/registry" 27 | ) 28 | 29 | // File represents a source file of any type. 30 | type File interface { 31 | URI() uri.URI 32 | View() View 33 | FileSystem() FileSystem 34 | Read(ctx context.Context) ([]byte, string, error) 35 | 36 | Saved() bool 37 | // TODO: Fix appropriate function name. 38 | SetSaved(saved bool) 39 | } 40 | 41 | type ProtoFile interface { 42 | File 43 | Proto() registry.Proto 44 | SetProto(proto registry.Proto) 45 | } 46 | 47 | // FileSystem is the interface to something that provides file contents. 48 | type FileSystem interface { 49 | // GetFile returns a file whose the given uri. 50 | GetFile(uri uri.URI) (File, error) 51 | } 52 | 53 | // file is a file for changed files. 54 | type file struct { 55 | session Session 56 | view View 57 | 58 | uri uri.URI 59 | data []byte 60 | hash string 61 | 62 | // saved is true if a file has been saved on disk. 63 | saved bool 64 | } 65 | 66 | var _ File = (*file)(nil) 67 | 68 | type protoFile struct { 69 | File 70 | proto registry.Proto 71 | } 72 | 73 | var _ ProtoFile = (*protoFile)(nil) 74 | 75 | func (f *file) URI() uri.URI { 76 | return f.uri 77 | } 78 | 79 | func (f *file) View() View { 80 | return f.view 81 | } 82 | 83 | func (f *file) FileSystem() FileSystem { 84 | return f.view 85 | } 86 | 87 | func (f *file) Read(context.Context) ([]byte, string, error) { 88 | return f.data, f.hash, nil 89 | } 90 | 91 | func (f *file) Saved() bool { 92 | return f.saved 93 | } 94 | 95 | func (f *file) SetSaved(saved bool) { 96 | f.saved = saved 97 | } 98 | 99 | func (p *protoFile) Proto() registry.Proto { 100 | return p.proto 101 | } 102 | 103 | func (p *protoFile) SetProto(proto registry.Proto) { 104 | p.proto = proto 105 | } 106 | -------------------------------------------------------------------------------- /pkg/lsp/source/session.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Copyright 2018 The Go Authors. All rights reserved. 16 | // Use of this source code is governed by a BSD-style 17 | // license that can be found in the LICENSE file. 18 | 19 | package source 20 | 21 | import ( 22 | "context" 23 | "crypto/sha1" 24 | "fmt" 25 | "strings" 26 | "sync" 27 | 28 | "github.com/go-language-server/uri" 29 | "go.uber.org/atomic" 30 | ) 31 | 32 | var ( 33 | sessionIndex = &atomic.Int64{} 34 | viewIndex = &atomic.Int64{} 35 | ) 36 | 37 | // Session represents a single connection from a client. 38 | // A session just manages views and does not access files directly. 39 | type Session interface { 40 | // View returns a view with a matching name, if the session has one. 41 | View(name string) (View, bool) 42 | 43 | // ViewOf returns a view corresponding to the given URI. 44 | ViewOf(uri uri.URI) View 45 | 46 | // Views returns the set of active views built by this session. 47 | Views() []View 48 | 49 | // AddView creates a new View, adds it to the Session and returns it. 50 | AddView(ctx context.Context, view View) 51 | 52 | // RemoveView removes a View with a matching name. 53 | RemoveView(ctx context.Context, view View) error 54 | 55 | // Shutdown the session and all views it has created. 56 | Shutdown(ctx context.Context) 57 | } 58 | 59 | type session struct { 60 | id int64 61 | 62 | views []View 63 | viewMap map[uri.URI]View 64 | viewMu *sync.RWMutex 65 | } 66 | 67 | var _ Session = (*session)(nil) 68 | 69 | // NewSession returns Session. 70 | func NewSession() Session { 71 | return &session{ 72 | id: sessionIndex.Add(1), 73 | viewMap: make(map[uri.URI]View), 74 | viewMu: &sync.RWMutex{}, 75 | } 76 | } 77 | 78 | func (s *session) View(name string) (View, bool) { 79 | s.viewMu.RLock() 80 | defer s.viewMu.RUnlock() 81 | 82 | for _, view := range s.views { 83 | if view.Name() == name { 84 | return view, true 85 | } 86 | } 87 | 88 | return nil, false 89 | } 90 | 91 | func (s *session) ViewOf(uri uri.URI) View { 92 | s.viewMu.Lock() 93 | defer s.viewMu.Unlock() 94 | 95 | // uri is folder and matches one of viewMap. 96 | v, ok := s.viewMap[uri] 97 | if ok { 98 | return v 99 | } 100 | 101 | v = s.bestView(uri) 102 | s.viewMap[uri] = v 103 | 104 | return v 105 | } 106 | 107 | func (s *session) Views() (views []View) { 108 | s.viewMu.RLock() 109 | views = s.views 110 | s.viewMu.RUnlock() 111 | return 112 | } 113 | 114 | func (s *session) AddView(ctx context.Context, view View) { 115 | s.viewMu.Lock() 116 | 117 | s.views = append(s.views, view) 118 | // we always need to drop the view map 119 | s.viewMap = make(map[uri.URI]View) 120 | 121 | s.viewMu.Unlock() 122 | } 123 | 124 | func (s *session) RemoveView(ctx context.Context, view View) error { 125 | s.viewMu.Lock() 126 | defer s.viewMu.Unlock() 127 | // we always need to drop the view map 128 | s.viewMap = make(map[uri.URI]View) 129 | for i, v := range s.views { 130 | if v == view { 131 | s.views[i] = s.views[len(s.views)-1] 132 | s.views[len(s.views)-1] = nil 133 | s.views = s.views[:len(s.views)-1] 134 | return nil 135 | } 136 | } 137 | return fmt.Errorf("view %s for %v not found", view.Name(), view.Folder()) 138 | } 139 | 140 | func (s *session) Shutdown(context.Context) { 141 | s.viewMu.Lock() 142 | defer s.viewMu.Unlock() 143 | 144 | s.views = nil 145 | s.viewMap = nil 146 | } 147 | 148 | // bestView finds the best view to associate a given URI with. 149 | // viewMu must be held when calling this method. 150 | func (s *session) bestView(uri uri.URI) View { 151 | // we need to find the best view for this file 152 | var longest View 153 | for _, view := range s.views { 154 | if longest != nil && len(longest.Folder()) > len(view.Folder()) { 155 | continue 156 | } 157 | if strings.HasPrefix(string(uri), string(view.Folder())) { 158 | longest = view 159 | } 160 | } 161 | if longest != nil { 162 | return longest 163 | } 164 | // TODO: are there any more heuristics we can use? 165 | return s.views[0] 166 | } 167 | 168 | func hashContent(content []byte) string { 169 | return fmt.Sprintf("%x", sha1.Sum(content)) 170 | } 171 | -------------------------------------------------------------------------------- /pkg/lsp/source/session_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package source 16 | -------------------------------------------------------------------------------- /pkg/lsp/source/sourcetest/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 16 | 17 | go_library( 18 | name = "go_default_library", 19 | srcs = [ 20 | "mock.go", 21 | "source.mock.go", 22 | ], 23 | importpath = "github.com/micnncim/protocol-buffers-language-server/pkg/lsp/source/sourcetest", 24 | visibility = ["//visibility:public"], 25 | deps = [ 26 | "//pkg/lsp/source:go_default_library", 27 | "//pkg/proto/registry:go_default_library", 28 | "@com_github_go_language_server_uri//:go_default_library", 29 | "@com_github_golang_mock//gomock:go_default_library", 30 | ], 31 | ) 32 | 33 | load("//build/bazel:gomock.bzl", "gomock") 34 | 35 | gomock( 36 | name = "mock_source", 37 | out = "source.mock.go", 38 | interfaces = [ 39 | "File", 40 | "ProtoFile", 41 | "FileSystem", 42 | "Session", 43 | "View", 44 | ], 45 | library = "//pkg/lsp/source:go_default_library", 46 | package = "sourcetest", 47 | ) 48 | -------------------------------------------------------------------------------- /pkg/lsp/source/sourcetest/mock.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package sourcetest 16 | 17 | import ( 18 | _ "github.com/golang/mock/gomock" //nolint:golint 19 | 20 | _ "github.com/micnncim/protocol-buffers-language-server/pkg/lsp/source" //nolint:golint 21 | ) 22 | -------------------------------------------------------------------------------- /pkg/lsp/source/view.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Copyright 2018 The Go Authors. All rights reserved. 16 | // Use of this source code is governed by a BSD-style 17 | // license that can be found in the LICENSE file. 18 | 19 | package source 20 | 21 | import ( 22 | "bytes" 23 | "context" 24 | "os" 25 | "path/filepath" 26 | "sync" 27 | 28 | "github.com/go-language-server/uri" 29 | 30 | "github.com/micnncim/protocol-buffers-language-server/pkg/proto/parser" 31 | "github.com/micnncim/protocol-buffers-language-server/pkg/proto/registry" 32 | ) 33 | 34 | // View represents a single workspace. 35 | // Views are managed by a session. A view accesses files. 36 | type View interface { 37 | FileSystem 38 | 39 | // Session returns the session that created this view. 40 | Session() Session 41 | 42 | // Name returns the name this view was constructed with. 43 | Name() string 44 | 45 | // Folder returns the root folder for this view. 46 | Folder() uri.URI 47 | 48 | // Called to set the effective contents of a file from this view. 49 | SetContent(ctx context.Context, uri uri.URI, content []byte) 50 | 51 | // Ignore returns true if this file should be ignored by this view. 52 | Ignore(uri.URI) bool 53 | 54 | // Shutdown closes this view, and detaches it from it's session. 55 | Shutdown(ctx context.Context) error 56 | 57 | // DidOpen is invoked each time a file is opened in the editor. 58 | DidOpen(uri uri.URI, text []byte) 59 | 60 | // DidSave is invoked each time an open file is saved in the editor. 61 | DidSave(uri uri.URI) 62 | 63 | // DidClose is invoked each time an open file is closed in the editor. 64 | DidClose(uri uri.URI) 65 | 66 | // IsOpen can be called to check if the editor has a file currently open. 67 | IsOpen(uri uri.URI) bool 68 | } 69 | 70 | type view struct { 71 | id int64 72 | session Session 73 | 74 | // name is the user visible name of this view. 75 | name string 76 | 77 | // folder is the root of this view. 78 | folder uri.URI 79 | 80 | // keep track of files by uri and by basename, a single file may be mapped 81 | // to multiple uris, and the same basename may map to multiple files 82 | filesByURI map[uri.URI]File 83 | filesByBase map[string][]File 84 | fileMu *sync.RWMutex 85 | 86 | openFiles map[uri.URI]bool 87 | openFileMu *sync.RWMutex 88 | 89 | // ignoredURIs is the set of URIs of files that we ignore. 90 | ignoredURIs map[uri.URI]struct{} 91 | ignoredURIMu *sync.RWMutex 92 | } 93 | 94 | var _ View = (*view)(nil) 95 | 96 | func NewView(session Session, name string, folder uri.URI) View { 97 | return &view{ 98 | id: viewIndex.Add(1), 99 | session: session, 100 | name: name, 101 | folder: folder, 102 | filesByURI: make(map[uri.URI]File), 103 | filesByBase: make(map[string][]File), 104 | fileMu: &sync.RWMutex{}, 105 | openFiles: make(map[uri.URI]bool), 106 | openFileMu: &sync.RWMutex{}, 107 | ignoredURIs: make(map[uri.URI]struct{}), 108 | ignoredURIMu: &sync.RWMutex{}, 109 | } 110 | } 111 | 112 | func (v *view) Session() Session { 113 | return v.session 114 | } 115 | 116 | func (v *view) Name() string { 117 | return v.name 118 | } 119 | 120 | func (v *view) Folder() uri.URI { 121 | return v.folder 122 | } 123 | 124 | func (v *view) GetFile(uri uri.URI) (File, error) { 125 | f, err := v.findFile(uri) 126 | if err != nil { 127 | return nil, err 128 | } 129 | if f != nil { 130 | return f, nil 131 | } 132 | 133 | file := &protoFile{ 134 | File: &file{ 135 | session: v.Session(), 136 | view: v, 137 | uri: uri, 138 | }, 139 | } 140 | v.mapFile(uri, file) 141 | 142 | return file, nil 143 | } 144 | 145 | // SetContent sets the file contents for a file. 146 | func (v *view) SetContent(ctx context.Context, uri uri.URI, data []byte) { 147 | if !v.Ignore(uri) { 148 | return 149 | } 150 | 151 | v.fileMu.Lock() 152 | defer v.fileMu.Unlock() 153 | 154 | if data == nil { 155 | delete(v.filesByURI, uri) 156 | return 157 | } 158 | 159 | pf := &protoFile{ 160 | File: &file{ 161 | session: v.Session(), 162 | uri: uri, 163 | data: data, 164 | hash: hashContent(data), 165 | }, 166 | } 167 | 168 | // TODO: 169 | // Control times of parse of proto. 170 | // Currently it parses every time of file change. 171 | pf.proto = parseProto(data) 172 | 173 | v.filesByURI[uri] = pf 174 | } 175 | 176 | func (v *view) Ignore(uri uri.URI) (ok bool) { 177 | v.ignoredURIMu.Lock() 178 | _, ok = v.ignoredURIs[uri] 179 | v.ignoredURIMu.Unlock() 180 | return 181 | } 182 | 183 | func (v *view) Shutdown(ctx context.Context) error { 184 | return v.session.RemoveView(ctx, v) 185 | } 186 | 187 | func (v *view) DidOpen(uri uri.URI, text []byte) { 188 | v.openFileMu.Lock() 189 | v.openFiles[uri] = true 190 | v.openFileMu.Unlock() 191 | v.openFile(uri, text) 192 | } 193 | 194 | func (v *view) DidSave(uri uri.URI) { 195 | v.fileMu.Lock() 196 | if file, ok := v.filesByURI[uri]; ok { 197 | file.SetSaved(true) 198 | } 199 | v.fileMu.Unlock() 200 | } 201 | 202 | func (v *view) DidClose(uri uri.URI) { 203 | v.openFileMu.Lock() 204 | delete(v.openFiles, uri) 205 | v.openFileMu.Unlock() 206 | } 207 | 208 | func (v *view) IsOpen(uri uri.URI) bool { 209 | v.openFileMu.RLock() 210 | defer v.openFileMu.RUnlock() 211 | 212 | open, ok := v.openFiles[uri] 213 | if !ok { 214 | return false 215 | } 216 | return open 217 | } 218 | 219 | func (v *view) openFile(uri uri.URI, data []byte) { 220 | v.fileMu.Lock() 221 | 222 | pf := &protoFile{ 223 | File: &file{ 224 | view: v, 225 | uri: uri, 226 | data: data, 227 | hash: hashContent(data), 228 | }, 229 | } 230 | 231 | pf.proto = parseProto(data) 232 | v.filesByURI[uri] = pf 233 | 234 | v.fileMu.Unlock() 235 | } 236 | 237 | func (v *view) findFile(uri uri.URI) (File, error) { 238 | v.fileMu.Lock() 239 | defer v.fileMu.Unlock() 240 | 241 | if f, ok := v.filesByURI[uri]; ok { 242 | return f, nil 243 | } 244 | 245 | filename := uri.Filename() 246 | basename := filepath.Base(filename) 247 | targetStat, err := os.Stat(filename) 248 | if os.IsNotExist(err) { 249 | return nil, err 250 | } 251 | if err != nil { 252 | return nil, nil // the file may exist, return without an error 253 | } 254 | for _, f := range v.filesByBase[basename] { 255 | stat, err := os.Stat(f.URI().Filename()) 256 | if err != nil { 257 | continue 258 | } 259 | if os.SameFile(targetStat, stat) { 260 | v.mapFile(uri, f) 261 | return f, nil 262 | } 263 | } 264 | return nil, nil 265 | } 266 | 267 | func (v *view) mapFile(uri uri.URI, f File) { 268 | v.fileMu.Lock() 269 | 270 | v.filesByURI[uri] = f 271 | basename := filepath.Base(uri.Filename()) 272 | v.filesByBase[basename] = append(v.filesByBase[basename], f) 273 | 274 | v.fileMu.Unlock() 275 | } 276 | 277 | func parseProto(data []byte) registry.Proto { 278 | buf := bytes.NewBuffer(data) 279 | proto, err := parser.ParseProto(buf) 280 | if err != nil { 281 | return nil 282 | } 283 | return proto 284 | } 285 | -------------------------------------------------------------------------------- /pkg/lsp/source/view_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package source 16 | -------------------------------------------------------------------------------- /pkg/proto/parser/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 16 | 17 | go_library( 18 | name = "go_default_library", 19 | srcs = ["parser.go"], 20 | importpath = "github.com/micnncim/protocol-buffers-language-server/pkg/proto/parser", 21 | visibility = ["//visibility:public"], 22 | deps = [ 23 | "//pkg/proto/registry:go_default_library", 24 | "@com_github_emicklei_proto//:go_default_library", 25 | ], 26 | ) 27 | 28 | go_test( 29 | name = "go_default_test", 30 | size = "small", 31 | srcs = ["parser_test.go"], 32 | embed = [":go_default_library"], 33 | ) 34 | -------------------------------------------------------------------------------- /pkg/proto/parser/parser.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package parser 16 | 17 | import ( 18 | "io" 19 | 20 | protobuf "github.com/emicklei/proto" 21 | 22 | "github.com/micnncim/protocol-buffers-language-server/pkg/proto/registry" 23 | ) 24 | 25 | // ParseProtos parses protobuf files from filenames and return registry.ProtoSet. 26 | func ParseProto(r io.Reader) (registry.Proto, error) { 27 | parser := protobuf.NewParser(r) 28 | p, err := parser.Parse() 29 | if err != nil { 30 | return nil, err 31 | } 32 | return registry.NewProto(p), nil 33 | } 34 | -------------------------------------------------------------------------------- /pkg/proto/parser/parser_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package parser 16 | -------------------------------------------------------------------------------- /pkg/proto/registry/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") 16 | 17 | go_library( 18 | name = "go_default_library", 19 | srcs = [ 20 | "doc.go", 21 | "enum.go", 22 | "map.go", 23 | "message.go", 24 | "oneof.go", 25 | "package.go", 26 | "proto.go", 27 | "service.go", 28 | ], 29 | importpath = "github.com/micnncim/protocol-buffers-language-server/pkg/proto/registry", 30 | visibility = ["//visibility:public"], 31 | deps = ["@com_github_emicklei_proto//:go_default_library"], 32 | ) 33 | 34 | go_test( 35 | name = "go_default_test", 36 | size = "small", 37 | srcs = [ 38 | "enum_test.go", 39 | "map_test.go", 40 | "message_test.go", 41 | "oneof_test.go", 42 | "package_test.go", 43 | "proto_test.go", 44 | "service_test.go", 45 | ], 46 | embed = [":go_default_library"], 47 | ) 48 | -------------------------------------------------------------------------------- /pkg/proto/registry/doc.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // Package registry provides registries for Protocol Buffers descriptors. 16 | package registry 17 | -------------------------------------------------------------------------------- /pkg/proto/registry/enum.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | 17 | import ( 18 | "sync" 19 | 20 | protobuf "github.com/emicklei/proto" 21 | ) 22 | 23 | // Enum is a registry for protobuf enum. 24 | type Enum interface { 25 | Protobuf() *protobuf.Enum 26 | 27 | GetFieldByName(name string) (*EnumField, bool) 28 | 29 | GetFieldByLine(line int) (*EnumField, bool) 30 | } 31 | 32 | type enum struct { 33 | protoEnum *protobuf.Enum 34 | 35 | fullyQualifiedName string 36 | 37 | fieldNameToValue map[string]*EnumField 38 | 39 | lineToEnumField map[int]*EnumField 40 | 41 | mu *sync.RWMutex 42 | } 43 | 44 | var _ Enum = (*enum)(nil) 45 | 46 | // NewEnum returns Enum initialized by provided *protobuf.Enum. 47 | func NewEnum(protoEnum *protobuf.Enum) Enum { 48 | enum := &enum{ 49 | protoEnum: protoEnum, 50 | 51 | fullyQualifiedName: "", 52 | 53 | fieldNameToValue: make(map[string]*EnumField), 54 | 55 | lineToEnumField: make(map[int]*EnumField), 56 | } 57 | 58 | for _, e := range protoEnum.Elements { 59 | v, ok := e.(*protobuf.EnumField) 60 | if !ok { 61 | continue 62 | } 63 | f := NewEnumField(v) 64 | enum.fieldNameToValue[v.Name] = f 65 | enum.lineToEnumField[v.Position.Line] = f 66 | } 67 | 68 | return enum 69 | } 70 | 71 | // Protobuf returns *protobuf.Enum. 72 | func (e *enum) Protobuf() *protobuf.Enum { 73 | return e.protoEnum 74 | } 75 | 76 | // GetFieldByName gets EnumField by provided name. 77 | // This ensures thread safety. 78 | func (e *enum) GetFieldByName(name string) (f *EnumField, ok bool) { 79 | e.mu.RLock() 80 | f, ok = e.fieldNameToValue[name] 81 | e.mu.RUnlock() 82 | return 83 | } 84 | 85 | // GetMapFieldByLine gets MapField by provided line. 86 | // This ensures thread safety. 87 | func (e *enum) GetFieldByLine(line int) (f *EnumField, ok bool) { 88 | e.mu.RLock() 89 | f, ok = e.lineToEnumField[line] 90 | e.mu.RUnlock() 91 | return 92 | } 93 | 94 | // EnumField is a registry for protobuf enum field. 95 | type EnumField struct { 96 | ProtoEnumField *protobuf.EnumField 97 | } 98 | 99 | // NewEnumField returns EnumField initialized by provided *protobuf.EnumField. 100 | func NewEnumField(protoMessage *protobuf.EnumField) *EnumField { 101 | return &EnumField{ 102 | ProtoEnumField: protoMessage, 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /pkg/proto/registry/enum_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | -------------------------------------------------------------------------------- /pkg/proto/registry/map.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | 17 | import protobuf "github.com/emicklei/proto" 18 | 19 | // MapField is a registry for protobuf enum field. 20 | type MapField struct { 21 | ProtoMapField *protobuf.MapField 22 | } 23 | 24 | // NewMapField returns MapField initialized by provided *protobuf.MapField. 25 | func NewMapField(protoMapField *protobuf.MapField) *MapField { 26 | return &MapField{ 27 | ProtoMapField: protoMapField, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /pkg/proto/registry/map_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | -------------------------------------------------------------------------------- /pkg/proto/registry/message.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | 17 | import ( 18 | "sync" 19 | 20 | protobuf "github.com/emicklei/proto" 21 | ) 22 | 23 | // Message is a registry for protobuf message. 24 | type Message interface { 25 | Protobuf() *protobuf.Message 26 | 27 | NestedMessages() []Message 28 | NestedEnums() []Enum 29 | Fields() []*MessageField 30 | Oneofs() []Oneof 31 | MapFields() []*MapField 32 | 33 | GetNestedMessageByName(name string) (Message, bool) 34 | GetNestedEnumByName(name string) (Enum, bool) 35 | 36 | GetFieldByName(name string) (*MessageField, bool) 37 | GetOneofFieldByName(name string) (Oneof, bool) 38 | GetMapFieldByName(name string) (*MapField, bool) 39 | 40 | GetFieldByLine(line int) (*MessageField, bool) 41 | GetOneofFieldByLine(line int) (Oneof, bool) 42 | GetMapFieldByLine(line int) (*MapField, bool) 43 | } 44 | 45 | type message struct { 46 | protoMessage *protobuf.Message 47 | 48 | fullyQualifiedName string 49 | 50 | nestedMessages []Message 51 | nestedEnums []Enum 52 | fields []*MessageField 53 | oneofs []Oneof 54 | mapFields []*MapField 55 | 56 | nestedEnumNameToEnum map[string]Enum 57 | nestedMessageNameToMessage map[string]Message 58 | 59 | fieldNameToField map[string]*MessageField 60 | oneofFieldNameToOneofField map[string]Oneof 61 | mapFieldNameToMapField map[string]*MapField 62 | 63 | lineToField map[int]*MessageField 64 | lineToOneofField map[int]Oneof 65 | lineToMapField map[int]*MapField 66 | 67 | mu *sync.RWMutex 68 | } 69 | 70 | var _ Message = (*message)(nil) 71 | 72 | // NewMessage returns Message initialized by provided *protobuf.Message. 73 | func NewMessage(protoMessage *protobuf.Message) Message { 74 | m := &message{ 75 | protoMessage: protoMessage, 76 | 77 | fullyQualifiedName: "", 78 | 79 | nestedEnumNameToEnum: make(map[string]Enum), 80 | nestedMessageNameToMessage: make(map[string]Message), 81 | 82 | fieldNameToField: make(map[string]*MessageField), 83 | oneofFieldNameToOneofField: make(map[string]Oneof), 84 | mapFieldNameToMapField: make(map[string]*MapField), 85 | 86 | lineToField: make(map[int]*MessageField), 87 | lineToOneofField: make(map[int]Oneof), 88 | lineToMapField: make(map[int]*MapField), 89 | 90 | mu: &sync.RWMutex{}, 91 | } 92 | 93 | for _, e := range protoMessage.Elements { 94 | switch v := e.(type) { 95 | 96 | case *protobuf.NormalField: 97 | f := NewMessageField(v) 98 | m.fields = append(m.fields, f) 99 | 100 | case *protobuf.Oneof: 101 | f := NewOneof(v) 102 | m.oneofs = append(m.oneofs, f) 103 | 104 | case *protobuf.MapField: 105 | f := NewMapField(v) 106 | m.mapFields = append(m.mapFields, f) 107 | 108 | default: 109 | } 110 | } 111 | 112 | for _, f := range m.fields { 113 | m.fieldNameToField[f.ProtoField.Name] = f 114 | m.lineToField[f.ProtoField.Position.Line] = f 115 | } 116 | 117 | for _, f := range m.oneofs { 118 | m.oneofFieldNameToOneofField[f.Protobuf().Name] = f 119 | m.lineToOneofField[f.Protobuf().Position.Line] = f 120 | } 121 | 122 | for _, f := range m.mapFields { 123 | m.mapFieldNameToMapField[f.ProtoMapField.Name] = f 124 | m.lineToMapField[f.ProtoMapField.Position.Line] = f 125 | } 126 | 127 | return m 128 | } 129 | 130 | // Protobuf returns *protobuf.Proto. 131 | func (m *message) Protobuf() *protobuf.Message { 132 | return m.protoMessage 133 | } 134 | 135 | // NestedMessages returns slice of nested Message. 136 | func (m *message) NestedMessages() (msgs []Message) { 137 | m.mu.RLock() 138 | msgs = m.nestedMessages 139 | m.mu.RUnlock() 140 | return 141 | } 142 | 143 | // NestedEnums returns slice of nested Enum. 144 | func (m *message) NestedEnums() (enums []Enum) { 145 | m.mu.RLock() 146 | enums = m.nestedEnums 147 | m.mu.RUnlock() 148 | return 149 | } 150 | 151 | // Fields returns slice of MessageField. 152 | func (m *message) Fields() (fs []*MessageField) { 153 | m.mu.RLock() 154 | fs = m.fields 155 | m.mu.RUnlock() 156 | return 157 | } 158 | 159 | // Oneofs returns slice of Oneof. 160 | func (m *message) Oneofs() (fs []Oneof) { 161 | m.mu.RLock() 162 | fs = m.oneofs 163 | m.mu.RUnlock() 164 | return 165 | } 166 | 167 | // MapFields returns slice of MapField. 168 | func (m *message) MapFields() (fs []*MapField) { 169 | m.mu.RLock() 170 | fs = m.mapFields 171 | m.mu.RUnlock() 172 | return 173 | } 174 | 175 | // GetNestedMessageByName gets Message by provided name. 176 | // This ensures thread safety. 177 | func (m *message) GetNestedMessageByName(name string) (msg Message, ok bool) { 178 | m.mu.RLock() 179 | msg, ok = m.nestedMessageNameToMessage[name] 180 | m.mu.RUnlock() 181 | return 182 | } 183 | 184 | // GetNestedEnumByName gets enum by provided name. 185 | // This ensures thread safety. 186 | func (m *message) GetNestedEnumByName(name string) (e Enum, ok bool) { 187 | m.mu.RLock() 188 | e, ok = m.nestedEnumNameToEnum[name] 189 | m.mu.RUnlock() 190 | return 191 | } 192 | 193 | // GetFieldByName gets MessageField by provided name. 194 | // This ensures thread safety. 195 | func (m *message) GetFieldByName(name string) (f *MessageField, ok bool) { 196 | m.mu.RLock() 197 | f, ok = m.fieldNameToField[name] 198 | m.mu.RUnlock() 199 | return 200 | } 201 | 202 | // GetFieldByName gets oneof by provided name. 203 | // This ensures thread safety. 204 | func (m *message) GetOneofFieldByName(name string) (f Oneof, ok bool) { 205 | m.mu.RLock() 206 | f, ok = m.oneofFieldNameToOneofField[name] 207 | m.mu.RUnlock() 208 | return f, ok 209 | } 210 | 211 | // GetMapFieldByName gets MapField by provided name. 212 | // This ensures thread safety. 213 | func (m *message) GetMapFieldByName(name string) (f *MapField, ok bool) { 214 | m.mu.RLock() 215 | f, ok = m.mapFieldNameToMapField[name] 216 | m.mu.RUnlock() 217 | return 218 | } 219 | 220 | // GetFieldByLine gets MessageField by provided line. 221 | // This ensures thread safety. 222 | func (m *message) GetFieldByLine(line int) (f *MessageField, ok bool) { 223 | m.mu.RLock() 224 | f, ok = m.lineToField[line] 225 | m.mu.RUnlock() 226 | return 227 | } 228 | 229 | // GetFieldByLine gets oneof by provided line. 230 | // This ensures thread safety. 231 | func (m *message) GetOneofFieldByLine(line int) (f Oneof, ok bool) { 232 | m.mu.RLock() 233 | f, ok = m.lineToOneofField[line] 234 | m.mu.RUnlock() 235 | return 236 | } 237 | 238 | // GetMapFieldByLine gets MapField by provided line. 239 | // This ensures thread safety. 240 | func (m *message) GetMapFieldByLine(line int) (f *MapField, ok bool) { 241 | m.mu.RLock() 242 | f, ok = m.lineToMapField[line] 243 | m.mu.RUnlock() 244 | return 245 | } 246 | 247 | // MessageField is a registry for protobuf message field. 248 | type MessageField struct { 249 | ProtoField *protobuf.NormalField 250 | } 251 | 252 | // NewMessageField returns MessageField initialized by provided *protobuf.MessageField. 253 | func NewMessageField(protoMessage *protobuf.NormalField) *MessageField { 254 | return &MessageField{ 255 | ProtoField: protoMessage, 256 | } 257 | } 258 | -------------------------------------------------------------------------------- /pkg/proto/registry/message_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | -------------------------------------------------------------------------------- /pkg/proto/registry/oneof.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | 17 | import ( 18 | "sync" 19 | 20 | protobuf "github.com/emicklei/proto" 21 | ) 22 | 23 | // Oneof is a registry for protobuf oneof. 24 | type Oneof interface { 25 | Protobuf() *protobuf.Oneof 26 | 27 | GetFieldByName(name string) (*OneofField, bool) 28 | 29 | GetFieldByLine(line int) (*OneofField, bool) 30 | } 31 | 32 | type oneof struct { 33 | protoOneofField *protobuf.Oneof 34 | 35 | fieldNameToField map[string]*OneofField 36 | 37 | lineToField map[int]*OneofField 38 | 39 | mu *sync.RWMutex 40 | } 41 | 42 | var _ Oneof = (*oneof)(nil) 43 | 44 | // NewOneof returns Oneof initialized by provided *protobuf.Oneof. 45 | func NewOneof(protoOneofField *protobuf.Oneof) Oneof { 46 | oneof := &oneof{ 47 | protoOneofField: protoOneofField, 48 | 49 | fieldNameToField: make(map[string]*OneofField), 50 | 51 | lineToField: make(map[int]*OneofField), 52 | } 53 | 54 | for _, e := range protoOneofField.Elements { 55 | v, ok := e.(*protobuf.OneOfField) 56 | if !ok { 57 | continue 58 | } 59 | f := NewOneofField(v) 60 | oneof.fieldNameToField[v.Name] = f 61 | oneof.lineToField[v.Position.Line] = f 62 | } 63 | 64 | return oneof 65 | } 66 | 67 | // Protobuf returns *protobuf.Oneof. 68 | func (o *oneof) Protobuf() *protobuf.Oneof { 69 | return o.protoOneofField 70 | } 71 | 72 | // GetFieldByName gets EnumField by provided name. 73 | // This ensures thread safety. 74 | func (o *oneof) GetFieldByName(name string) (f *OneofField, ok bool) { 75 | o.mu.RLock() 76 | f, ok = o.fieldNameToField[name] 77 | o.mu.RUnlock() 78 | return 79 | } 80 | 81 | // GetFieldByName gets MapField by provided line. 82 | // This ensures thread safety. 83 | func (o *oneof) GetFieldByLine(line int) (f *OneofField, ok bool) { 84 | o.mu.RLock() 85 | f, ok = o.lineToField[line] 86 | o.mu.RUnlock() 87 | return 88 | } 89 | 90 | // OneofField is a registry for protobuf oneof field. 91 | type OneofField struct { 92 | ProtoOneOfField *protobuf.OneOfField 93 | } 94 | 95 | // NewOneofField returns OneofField initialized by provided *protobuf.OneofField. 96 | func NewOneofField(protoOneOfField *protobuf.OneOfField) *OneofField { 97 | return &OneofField{ 98 | ProtoOneOfField: protoOneOfField, 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /pkg/proto/registry/oneof_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | -------------------------------------------------------------------------------- /pkg/proto/registry/package.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | 17 | import protobuf "github.com/emicklei/proto" 18 | 19 | // Package is a registry for protobuf package. 20 | type Package struct { 21 | ProtoPackage *protobuf.Package 22 | } 23 | 24 | // NewPackage returns Package initialized by provided *protobuf.Package. 25 | func NewPackage(protoPackage *protobuf.Package) *Package { 26 | return &Package{ 27 | ProtoPackage: protoPackage, 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /pkg/proto/registry/package_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | -------------------------------------------------------------------------------- /pkg/proto/registry/proto.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | 17 | import ( 18 | "sync" 19 | 20 | protobuf "github.com/emicklei/proto" 21 | ) 22 | 23 | // ProtoSet is a registry for Proto. 24 | type ProtoSet interface { 25 | Protos() []Proto 26 | Append(proto *protobuf.Proto) 27 | 28 | GetProtoByFilename(filename string) (Proto, bool) 29 | } 30 | 31 | type protoSet struct { 32 | protos map[string]Proto 33 | 34 | mu *sync.RWMutex 35 | } 36 | 37 | var _ ProtoSet = (*protoSet)(nil) 38 | 39 | // NewProtoSet returns protoSet initialized by provided []*protobuf.Proto. 40 | func NewProtoSet(protos ...*protobuf.Proto) ProtoSet { 41 | protoSet := &protoSet{ 42 | protos: make(map[string]Proto), 43 | } 44 | for _, p := range protos { 45 | protoSet.protos[p.Filename] = NewProto(p) 46 | } 47 | return protoSet 48 | } 49 | 50 | func (p *protoSet) Protos() []Proto { 51 | p.mu.Lock() 52 | defer p.mu.Unlock() 53 | 54 | protos := make([]Proto, 0, len(p.protos)) 55 | for _, proto := range p.protos { 56 | protos = append(protos, proto) 57 | } 58 | return protos 59 | } 60 | 61 | // Append appends Proto to protoSet. 62 | // This ensures thread safety. 63 | func (p *protoSet) Append(proto *protobuf.Proto) { 64 | p.mu.Lock() 65 | p.protos[proto.Filename] = NewProto(proto) 66 | p.mu.Unlock() 67 | } 68 | 69 | // GetProtoByFilename gets Proto by provided Filename. 70 | // This ensures thread safety. 71 | func (p *protoSet) GetProtoByFilename(filename string) (pr Proto, ok bool) { 72 | p.mu.RLock() 73 | pr, ok = p.protos[filename] 74 | p.mu.RUnlock() 75 | return 76 | } 77 | 78 | // Proto is a registry for protobuf proto. 79 | type Proto interface { 80 | Protobuf() *protobuf.Proto 81 | 82 | Packages() []*Package 83 | Messages() []Message 84 | Enums() []Enum 85 | Services() []Service 86 | 87 | GetPackageByName(name string) (*Package, bool) 88 | GetMessageByName(name string) (Message, bool) 89 | GetEnumByName(name string) (Enum, bool) 90 | GetServiceByName(name string) (Service, bool) 91 | 92 | GetPackageByLine(line int) (*Package, bool) 93 | GetMessageByLine(line int) (Message, bool) 94 | GetEnumByLine(line int) (Enum, bool) 95 | GetServiceByLine(line int) (Service, bool) 96 | 97 | GetMessageFieldByLine(line int) (*MessageField, bool) 98 | GetEnumFieldByLine(line int) (*EnumField, bool) 99 | } 100 | 101 | type proto struct { 102 | protoProto *protobuf.Proto 103 | 104 | packages []*Package 105 | messages []Message 106 | enums []Enum 107 | services []Service 108 | 109 | packageNameToPackage map[string]*Package 110 | messageNameToMessage map[string]Message 111 | enumNameToEnum map[string]Enum 112 | serviceNameToService map[string]Service 113 | 114 | lineToPackage map[int]*Package 115 | lineToMessage map[int]Message 116 | lineToEnum map[int]Enum 117 | lineToService map[int]Service 118 | 119 | mu *sync.RWMutex 120 | } 121 | 122 | var _ Proto = (*proto)(nil) 123 | 124 | // NewProto returns Proto initialized by provided *protobuf.Proto. 125 | func NewProto(protoProto *protobuf.Proto) Proto { 126 | proto := &proto{ 127 | protoProto: protoProto, 128 | 129 | packageNameToPackage: make(map[string]*Package), 130 | messageNameToMessage: make(map[string]Message), 131 | enumNameToEnum: make(map[string]Enum), 132 | serviceNameToService: make(map[string]Service), 133 | 134 | lineToPackage: make(map[int]*Package), 135 | lineToMessage: make(map[int]Message), 136 | lineToEnum: make(map[int]Enum), 137 | lineToService: make(map[int]Service), 138 | 139 | mu: &sync.RWMutex{}, 140 | } 141 | 142 | for _, el := range protoProto.Elements { 143 | switch v := el.(type) { 144 | 145 | case *protobuf.Package: 146 | p := NewPackage(v) 147 | proto.packages = append(proto.packages, p) 148 | 149 | case *protobuf.Message: 150 | m := NewMessage(v) 151 | proto.messages = append(proto.messages, m) 152 | 153 | case *protobuf.Enum: 154 | e := NewEnum(v) 155 | proto.enums = append(proto.enums, e) 156 | 157 | case *protobuf.Service: 158 | s := NewService(v) 159 | proto.services = append(proto.services, s) 160 | 161 | default: 162 | } 163 | } 164 | 165 | for _, p := range proto.packages { 166 | proto.packageNameToPackage[p.ProtoPackage.Name] = p 167 | proto.lineToPackage[p.ProtoPackage.Position.Line] = p 168 | } 169 | 170 | for _, m := range proto.messages { 171 | proto.messageNameToMessage[m.Protobuf().Name] = m 172 | proto.lineToMessage[m.Protobuf().Position.Line] = m 173 | } 174 | 175 | for _, e := range proto.enums { 176 | proto.enumNameToEnum[e.Protobuf().Name] = e 177 | proto.lineToEnum[e.Protobuf().Position.Line] = e 178 | } 179 | 180 | for _, s := range proto.services { 181 | proto.serviceNameToService[s.Protobuf().Name] = s 182 | proto.lineToService[s.Protobuf().Position.Line] = s 183 | } 184 | 185 | return proto 186 | } 187 | 188 | // Protobuf returns *protobuf.Proto. 189 | func (p *proto) Protobuf() *protobuf.Proto { 190 | return p.protoProto 191 | } 192 | 193 | func (p *proto) Packages() (pkgs []*Package) { 194 | p.mu.RLock() 195 | pkgs = p.packages 196 | p.mu.RUnlock() 197 | return 198 | } 199 | 200 | func (p *proto) Messages() (msgs []Message) { 201 | p.mu.RLock() 202 | msgs = p.messages 203 | p.mu.RUnlock() 204 | return 205 | } 206 | 207 | func (p *proto) Enums() (enums []Enum) { 208 | p.mu.RLock() 209 | enums = p.enums 210 | p.mu.RUnlock() 211 | return 212 | } 213 | 214 | func (p *proto) Services() (svcs []Service) { 215 | p.mu.RLock() 216 | svcs = p.services 217 | p.mu.RUnlock() 218 | return 219 | } 220 | 221 | // GetPackageByName gets Package by provided name. 222 | // This ensures thread safety. 223 | func (p *proto) GetPackageByName(name string) (pkg *Package, ok bool) { 224 | p.mu.RLock() 225 | pkg, ok = p.packageNameToPackage[name] 226 | p.mu.RUnlock() 227 | return 228 | } 229 | 230 | // GetMessageByName gets message by provided name. 231 | // This ensures thread safety. 232 | func (p *proto) GetMessageByName(name string) (m Message, ok bool) { 233 | p.mu.RLock() 234 | m, ok = p.messageNameToMessage[name] 235 | p.mu.RUnlock() 236 | return 237 | } 238 | 239 | // GetEnumByName gets enum by provided name. 240 | // This ensures thread safety. 241 | func (p *proto) GetEnumByName(name string) (e Enum, ok bool) { 242 | p.mu.RLock() 243 | e, ok = p.enumNameToEnum[name] 244 | p.mu.RUnlock() 245 | return 246 | } 247 | 248 | // GetServiceByName gets service by provided name. 249 | // This ensures thread safety. 250 | func (p *proto) GetServiceByName(name string) (s Service, ok bool) { 251 | p.mu.RLock() 252 | s, ok = p.serviceNameToService[name] 253 | p.mu.RUnlock() 254 | return 255 | } 256 | 257 | // GetPackageByLine gets Package by provided line. 258 | // This ensures thread safety. 259 | func (p *proto) GetPackageByLine(line int) (pkg *Package, ok bool) { 260 | p.mu.RLock() 261 | pkg, ok = p.lineToPackage[line] 262 | p.mu.RUnlock() 263 | return 264 | } 265 | 266 | // GetMessageByLine gets message by provided line. 267 | // This ensures thread safety. 268 | func (p *proto) GetMessageByLine(line int) (m Message, ok bool) { 269 | p.mu.RLock() 270 | m, ok = p.lineToMessage[line] 271 | p.mu.RUnlock() 272 | return 273 | } 274 | 275 | // GetEnumByLine gets enum by provided line. 276 | // This ensures thread safety. 277 | func (p *proto) GetEnumByLine(line int) (e Enum, ok bool) { 278 | p.mu.RLock() 279 | e, ok = p.lineToEnum[line] 280 | p.mu.RUnlock() 281 | return 282 | } 283 | 284 | // GetServiceByLine gets service by provided line. 285 | // This ensures thread safety. 286 | func (p *proto) GetServiceByLine(line int) (s Service, ok bool) { 287 | p.mu.RLock() 288 | s, ok = p.lineToService[line] 289 | p.mu.RUnlock() 290 | return 291 | } 292 | 293 | // GetMessageFieldByLine gets message field by provided line. 294 | // This ensures thread safety. 295 | func (p *proto) GetMessageFieldByLine(line int) (f *MessageField, ok bool) { 296 | p.mu.RLock() 297 | defer p.mu.RUnlock() 298 | 299 | for _, message := range p.messages { 300 | f, ok = message.GetFieldByLine(line) 301 | if ok { 302 | return 303 | } 304 | } 305 | return 306 | } 307 | 308 | // GetEnumFieldByLine gets enum field by provided line. 309 | // This ensures thread safety. 310 | func (p *proto) GetEnumFieldByLine(line int) (f *EnumField, ok bool) { 311 | p.mu.RLock() 312 | defer p.mu.RUnlock() 313 | 314 | for _, enum := range p.enums { 315 | f, ok = enum.GetFieldByLine(line) 316 | if ok { 317 | return 318 | } 319 | } 320 | return 321 | } 322 | -------------------------------------------------------------------------------- /pkg/proto/registry/proto_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | -------------------------------------------------------------------------------- /pkg/proto/registry/registrytest/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 16 | 17 | go_library( 18 | name = "go_default_library", 19 | srcs = [ 20 | "mock.go", 21 | "registry.mock.go", 22 | ], 23 | importpath = "github.com/micnncim/protocol-buffers-language-server/pkg/proto/registry/registrytest", 24 | visibility = ["//visibility:public"], 25 | deps = [ 26 | "//pkg/proto/registry:go_default_library", 27 | "@com_github_emicklei_proto//:go_default_library", 28 | "@com_github_golang_mock//gomock:go_default_library", 29 | ], 30 | ) 31 | 32 | load("//build/bazel:gomock.bzl", "gomock") 33 | 34 | gomock( 35 | name = "mock_registry", 36 | out = "registry.mock.go", 37 | interfaces = [ 38 | "ProtoSet", 39 | "Proto", 40 | "Message", 41 | "Enum", 42 | "Service", 43 | "Oneof", 44 | ], 45 | library = "//pkg/proto/registry:go_default_library", 46 | package = "registrytest", 47 | ) 48 | -------------------------------------------------------------------------------- /pkg/proto/registry/registrytest/mock.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registrytest 16 | 17 | import ( 18 | _ "github.com/golang/mock/gomock" //nolint:golint 19 | 20 | _ "github.com/micnncim/protocol-buffers-language-server/pkg/proto/registry" //nolint:golint 21 | ) 22 | -------------------------------------------------------------------------------- /pkg/proto/registry/service.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | 17 | import ( 18 | "sync" 19 | 20 | protobuf "github.com/emicklei/proto" 21 | ) 22 | 23 | // Service is a registry for protobuf service. 24 | type Service interface { 25 | Protobuf() *protobuf.Service 26 | 27 | RPCs() []*RPC 28 | 29 | GetRPCByName(bool string) (*RPC, bool) 30 | 31 | GetRPCByLine(line int) (*RPC, bool) 32 | } 33 | 34 | type service struct { 35 | protoService *protobuf.Service 36 | 37 | rpcs []*RPC 38 | 39 | rpcNameToRPC map[string]*RPC 40 | 41 | lineToRPC map[int]*RPC 42 | 43 | mu *sync.RWMutex 44 | } 45 | 46 | var _ Service = (*service)(nil) 47 | 48 | // NewService returns Service initialized by provided *protobuf.Service. 49 | func NewService(protoService *protobuf.Service) Service { 50 | s := &service{ 51 | protoService: protoService, 52 | 53 | rpcNameToRPC: make(map[string]*RPC), 54 | 55 | lineToRPC: make(map[int]*RPC), 56 | 57 | mu: &sync.RWMutex{}, 58 | } 59 | 60 | for _, e := range protoService.Elements { 61 | v, ok := e.(*protobuf.RPC) 62 | if !ok { 63 | continue 64 | } 65 | r := NewRPC(v) 66 | s.rpcs = append(s.rpcs, r) 67 | } 68 | 69 | for _, r := range s.rpcs { 70 | s.rpcNameToRPC[r.ProtoRPC.Name] = r 71 | s.lineToRPC[r.ProtoRPC.Position.Line] = r 72 | } 73 | 74 | return s 75 | } 76 | 77 | // Protobuf returns *protobuf.Service. 78 | func (s *service) Protobuf() *protobuf.Service { 79 | return s.protoService 80 | } 81 | 82 | // RPCs returns slice of RPC. 83 | func (s *service) RPCs() (rpcs []*RPC) { 84 | s.mu.RLock() 85 | rpcs = s.rpcs 86 | s.mu.RUnlock() 87 | return 88 | } 89 | 90 | // GetRPCByName gets RPC by provided name. 91 | // This ensures thread safety. 92 | func (s *service) GetRPCByName(name string) (r *RPC, ok bool) { 93 | s.mu.RLock() 94 | r, ok = s.rpcNameToRPC[name] 95 | s.mu.RUnlock() 96 | return 97 | } 98 | 99 | // GetRPCByLine gets RPC by provided line. 100 | // This ensures thread safety. 101 | func (s *service) GetRPCByLine(line int) (r *RPC, ok bool) { 102 | s.mu.RLock() 103 | r, ok = s.lineToRPC[line] 104 | s.mu.RUnlock() 105 | return 106 | } 107 | 108 | // RPC is a registry for protobuf rpc. 109 | type RPC struct { 110 | ProtoRPC *protobuf.RPC 111 | } 112 | 113 | // NewRPC returns RPC initialized by provided *protobuf.RPC. 114 | func NewRPC(protoRPC *protobuf.RPC) *RPC { 115 | return &RPC{ 116 | ProtoRPC: protoRPC, 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /pkg/proto/registry/service_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package registry 16 | -------------------------------------------------------------------------------- /pkg/proto/types/BUILD.bazel: -------------------------------------------------------------------------------- 1 | # Copyright 2019 The Protocol Buffers Language Server Authors. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | load("@io_bazel_rules_go//go:def.bzl", "go_library") 16 | 17 | go_library( 18 | name = "go_default_library", 19 | srcs = ["types.go"], 20 | importpath = "github.com/micnncim/protocol-buffers-language-server/pkg/proto/types", 21 | visibility = ["//visibility:public"], 22 | ) 23 | -------------------------------------------------------------------------------- /pkg/proto/types/types.go: -------------------------------------------------------------------------------- 1 | // Copyright 2019 The Protocol Buffers Language Server Authors. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | package types 16 | 17 | type ProtoType string 18 | 19 | // https://developers.google.com/protocol-buffers/docs/proto3 20 | const ( 21 | Double ProtoType = "double" 22 | Float ProtoType = "float" 23 | Int32 ProtoType = "int32" 24 | Int64 ProtoType = "int64" 25 | Uint32 ProtoType = "uint32" 26 | Uint64 ProtoType = "uint64" 27 | Sint32 ProtoType = "sint32" 28 | Sint64 ProtoType = "sint64" 29 | Fixed32 ProtoType = "fixed32" 30 | Fixed64 ProtoType = "fixed64" 31 | Sfixed32 ProtoType = "sfixed32" 32 | Sfixed64 ProtoType = "sfixed64" 33 | Bool ProtoType = "bool" 34 | String ProtoType = "string" 35 | Bytes ProtoType = "bytes" 36 | ) 37 | 38 | var BuildInProtoTypes = []ProtoType{ 39 | Double, 40 | Float, 41 | Int32, 42 | Int64, 43 | Uint32, 44 | Uint64, 45 | Sint32, 46 | Sint64, 47 | Fixed32, 48 | Fixed64, 49 | Sfixed32, 50 | Sfixed64, 51 | Bool, 52 | String, 53 | Bytes, 54 | } 55 | --------------------------------------------------------------------------------