From 9d60fb1700adb6ce4592c59ac2b6bc6cf3ee399d Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Fri, 6 Jul 2018 07:30:52 +0200 Subject: [PATCH 01/15] First sketch of a client for language server protocol. --- libs.lsp/build.xml | 25 +++ libs.lsp/external/binaries-list | 25 +++ libs.lsp/external/gson-2.7-license.txt | 207 ++++++++++++++++++ libs.lsp/external/guava-21.0-license.txt | 207 ++++++++++++++++++ libs.lsp/external/lsp4j-0.4.1-license.txt | 73 ++++++ libs.lsp/external/xtend-2.14.0-license.txt | 73 ++++++ libs.lsp/manifest.mf | 6 + libs.lsp/nbproject/project.properties | 27 +++ libs.lsp/nbproject/project.xml | 87 ++++++++ .../modules/libs/lsp/Bundle.properties | 18 ++ lsp.client/build.xml | 25 +++ lsp.client/manifest.mf | 6 + lsp.client/nbproject/project.properties | 19 ++ lsp.client/nbproject/project.xml | 170 ++++++++++++++ .../modules/lsp/client/Bundle.properties | 18 ++ .../lsp/client/ProjectLSPBindings.java | 99 +++++++++ .../bindings/CompletionProviderImpl.java | 163 ++++++++++++++ .../bindings/HyperlinkProviderImpl.java | 136 ++++++++++++ .../modules/lsp/client/bindings/Icons.java | 58 +++++ .../client/bindings/LanguageClientImpl.java | 105 +++++++++ ...xtDocumentSyncServerCapabilityHandler.java | 152 +++++++++++++ .../modules/lsp/client/bindings/Utils.java | 41 ++++ .../lsp/client/bindings/icons/attribute.png | Bin 0 -> 543 bytes .../lsp/client/bindings/icons/class.png | Bin 0 -> 785 bytes .../lsp/client/bindings/icons/color.gif | Bin 0 -> 848 bytes .../lsp/client/bindings/icons/constant.png | Bin 0 -> 400 bytes .../lsp/client/bindings/icons/constructor.png | Bin 0 -> 492 bytes .../lsp/client/bindings/icons/enum.png | Bin 0 -> 830 bytes .../lsp/client/bindings/icons/enummember.png | Bin 0 -> 342 bytes .../lsp/client/bindings/icons/event.png | Bin 0 -> 3234 bytes .../lsp/client/bindings/icons/field.png | Bin 0 -> 342 bytes .../lsp/client/bindings/icons/file.png | Bin 0 -> 399 bytes .../lsp/client/bindings/icons/folder.gif | Bin 0 -> 339 bytes .../lsp/client/bindings/icons/function.png | Bin 0 -> 556 bytes .../lsp/client/bindings/icons/interface.png | Bin 0 -> 541 bytes .../lsp/client/bindings/icons/keyword.png | Bin 0 -> 804 bytes .../lsp/client/bindings/icons/method.png | Bin 0 -> 556 bytes .../lsp/client/bindings/icons/module.png | Bin 0 -> 1474 bytes .../lsp/client/bindings/icons/operator.png | Bin 0 -> 556 bytes .../lsp/client/bindings/icons/property.png | Bin 0 -> 342 bytes .../lsp/client/bindings/icons/reference.png | Bin 0 -> 1447 bytes .../lsp/client/bindings/icons/snippet.png | Bin 0 -> 613 bytes .../lsp/client/bindings/icons/struct.png | Bin 0 -> 785 bytes .../lsp/client/bindings/icons/text.png | Bin 0 -> 613 bytes .../client/bindings/icons/typeparameter.gif | Bin 0 -> 310 bytes .../lsp/client/bindings/icons/unit.png | Bin 0 -> 1474 bytes .../lsp/client/bindings/icons/value.png | Bin 0 -> 516 bytes .../lsp/client/bindings/icons/variable.gif | Bin 0 -> 310 bytes .../client/spi/LanguageServerProvider.java | 31 +++ nbbuild/cluster.properties | 2 + 50 files changed, 1773 insertions(+) create mode 100644 libs.lsp/build.xml create mode 100644 libs.lsp/external/binaries-list create mode 100644 libs.lsp/external/gson-2.7-license.txt create mode 100644 libs.lsp/external/guava-21.0-license.txt create mode 100644 libs.lsp/external/lsp4j-0.4.1-license.txt create mode 100644 libs.lsp/external/xtend-2.14.0-license.txt create mode 100644 libs.lsp/manifest.mf create mode 100644 libs.lsp/nbproject/project.properties create mode 100644 libs.lsp/nbproject/project.xml create mode 100644 libs.lsp/src/org/netbeans/modules/libs/lsp/Bundle.properties create mode 100644 lsp.client/build.xml create mode 100644 lsp.client/manifest.mf create mode 100644 lsp.client/nbproject/project.properties create mode 100644 lsp.client/nbproject/project.xml create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/Bundle.properties create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/ProjectLSPBindings.java create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/HyperlinkProviderImpl.java create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/Icons.java create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/TextDocumentSyncServerCapabilityHandler.java create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/Utils.java create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/attribute.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/class.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/color.gif create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/constant.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/constructor.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/enum.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/enummember.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/event.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/field.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/file.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/folder.gif create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/function.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/interface.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/keyword.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/method.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/module.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/operator.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/property.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/reference.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/snippet.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/struct.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/text.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/typeparameter.gif create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/unit.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/value.png create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/variable.gif create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/spi/LanguageServerProvider.java diff --git a/libs.lsp/build.xml b/libs.lsp/build.xml new file mode 100644 index 000000000000..7b8cdc1347c4 --- /dev/null +++ b/libs.lsp/build.xml @@ -0,0 +1,25 @@ + + + + Builds, tests, and runs the project org.netbeans.modules.libs.lsp + + diff --git a/libs.lsp/external/binaries-list b/libs.lsp/external/binaries-list new file mode 100644 index 000000000000..d910a1107d41 --- /dev/null +++ b/libs.lsp/external/binaries-list @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +751F548C85FA49F330CECBB1875893F971B33C4E com.google.code.gson:gson:2.7 +3A3D111BE1BE1B745EDFA7D91678A12D7ED38709 com.google.guava:guava:21.0 +90E34B7C7E0257E3993CA5A939AE94F889D31340 org.eclipse.lsp4j:org.eclipse.lsp4j:0.4.1 +467F27E91FD694C05EB663532F2EDE0404025AFE org.eclipse.lsp4j:org.eclipse.lsp4j.generator:0.4.1 +F3F93F50BBEB7D58B50E6FFCA615CBFC76491846 org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.4.1 +56459301B64C92BBBB6E13988B91CDBE1FC6264E org.eclipse.xtend:org.eclipse.xtend.lib:2.14.0 +F2FCA7A70C8A29374E79487417CEFB5F51A84867 org.eclipse.xtend:org.eclipse.xtend.lib.macro:2.14.0 +C40FFE7E5E6244DD094AE95009AA45072C629254 org.eclipse.xtext:org.eclipse.xtext.xbase.lib:2.14.0 diff --git a/libs.lsp/external/gson-2.7-license.txt b/libs.lsp/external/gson-2.7-license.txt new file mode 100644 index 000000000000..d8c388518b46 --- /dev/null +++ b/libs.lsp/external/gson-2.7-license.txt @@ -0,0 +1,207 @@ +Name: GSon +Description: JSon serialization/deserialization library +Origin: GitHub +Version: 2.7 +License: Apache-2.0 + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/libs.lsp/external/guava-21.0-license.txt b/libs.lsp/external/guava-21.0-license.txt new file mode 100644 index 000000000000..a6b8f3b15227 --- /dev/null +++ b/libs.lsp/external/guava-21.0-license.txt @@ -0,0 +1,207 @@ +Name: Guava +Description: Google Core Libraries for Java +Origin: GitHub +Version: 21.0 +License: Apache-2.0 + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/libs.lsp/external/lsp4j-0.4.1-license.txt b/libs.lsp/external/lsp4j-0.4.1-license.txt new file mode 100644 index 000000000000..8129cb7f4e7a --- /dev/null +++ b/libs.lsp/external/lsp4j-0.4.1-license.txt @@ -0,0 +1,73 @@ +Name: Eclipse Language Server Protocol Library +Origin: Eclipse +Version: 0.4.1 +License: EPL-v10 +URL: http://www.eclipse.org/ +Description: Eclipse Language Server Protocol Library +Files: org.eclipse.lsp4j-0.4.1.jar org.eclipse.lsp4j.generator-0.4.1.jar org.eclipse.lsp4j.jsonrpc-0.4.1.jar + +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and +b) in the case of each subsequent Contributor: + +i) changes to the Program, and +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. +"Contributor" means any person or entity that distributes the Program. +"Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. +"Program" means the Contributions distributed in accordance with this Agreement. +"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. +b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. +c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. +d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: +a) it complies with the terms and conditions of this Agreement; and +b) its license agreement: +i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; +ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; +iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and +iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: +a) it must be made available under this Agreement; and +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the Program. +Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. +If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. +All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. +Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. +This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. diff --git a/libs.lsp/external/xtend-2.14.0-license.txt b/libs.lsp/external/xtend-2.14.0-license.txt new file mode 100644 index 000000000000..21580782981a --- /dev/null +++ b/libs.lsp/external/xtend-2.14.0-license.txt @@ -0,0 +1,73 @@ +Name: Eclipse Xtend library +Origin: Eclipse +Version: 2.14.0 +License: EPL-v10 +URL: http://www.eclipse.org/ +Description: Eclipse Xtend library +Files: org.eclipse.xtend.lib-2.14.0.jar org.eclipse.xtend.lib.macro-2.14.0.jar org.eclipse.xtext.xbase.lib-2.14.0.jar + +Eclipse Public License - v 1.0 + +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and documentation distributed under this Agreement, and +b) in the case of each subsequent Contributor: + +i) changes to the Program, and +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are distributed by that particular Contributor. A Contribution 'originates' from a Contributor if it was added to the Program by such Contributor itself or anyone acting on such Contributor's behalf. Contributions do not include additions to the Program which: (i) are separate modules of software distributed in conjunction with the Program under their own license agreement, and (ii) are not derivative works of the Program. +"Contributor" means any person or entity that distributes the Program. +"Licensed Patents" mean patent claims licensable by a Contributor which are necessarily infringed by the use or sale of its Contribution alone or when combined with the Program. +"Program" means the Contributions distributed in accordance with this Agreement. +"Recipient" means anyone who receives the Program under this Agreement, including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free copyright license to reproduce, prepare derivative works of, publicly display, publicly perform, distribute and sublicense the Contribution of such Contributor, if any, and such derivative works, in source code and object code form. +b) Subject to the terms of this Agreement, each Contributor hereby grants Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed Patents to make, use, sell, offer to sell, import and otherwise transfer the Contribution of such Contributor, if any, in source code and object code form. This patent license shall apply to the combination of the Contribution and the Program if, at the time the Contribution is added by the Contributor, such addition of the Contribution causes such combination to be covered by the Licensed Patents. The patent license shall not apply to any other combinations which include the Contribution. No hardware per se is licensed hereunder. +c) Recipient understands that although each Contributor grants the licenses to its Contributions set forth herein, no assurances are provided by any Contributor that the Program does not infringe the patent or other intellectual property rights of any other entity. Each Contributor disclaims any liability to Recipient for claims brought by any other entity based on infringement of intellectual property rights or otherwise. As a condition to exercising the rights and licenses granted hereunder, each Recipient hereby assumes sole responsibility to secure any other intellectual property rights needed, if any. For example, if a third party patent license is required to allow Recipient to distribute the Program, it is Recipient's responsibility to acquire that license before distributing the Program. +d) Each Contributor represents that to its knowledge it has sufficient copyright rights in its Contribution, if any, to grant the copyright license set forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its own license agreement, provided that: +a) it complies with the terms and conditions of this Agreement; and +b) its license agreement: +i) effectively disclaims on behalf of all Contributors all warranties and conditions, express and implied, including warranties or conditions of title and non-infringement, and implied warranties or conditions of merchantability and fitness for a particular purpose; +ii) effectively excludes on behalf of all Contributors all liability for damages, including direct, indirect, special, incidental and consequential damages, such as lost profits; +iii) states that any provisions which differ from this Agreement are offered by that Contributor alone and not by any other party; and +iv) states that source code for the Program is available from such Contributor, and informs licensees how to obtain it in a reasonable manner on or through a medium customarily used for software exchange. + +When the Program is made available in source code form: +a) it must be made available under this Agreement; and +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the Program. +Each Contributor must identify itself as the originator of its Contribution, if any, in a manner that reasonably allows subsequent Recipients to identify the originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with respect to end users, business partners and the like. While this license is intended to facilitate the commercial use of the Program, the Contributor who includes the Program in a commercial product offering should do so in a manner which does not create potential liability for other Contributors. Therefore, if a Contributor includes the Program in a commercial product offering, such Contributor ("Commercial Contributor") hereby agrees to defend and indemnify every other Contributor ("Indemnified Contributor") against any losses, damages and costs (collectively "Losses") arising from claims, lawsuits and other legal actions brought by a third party against the Indemnified Contributor to the extent caused by the acts or omissions of such Commercial Contributor in connection with its distribution of the Program in a commercial product offering. The obligations in this section do not apply to any claims or Losses relating to any actual or alleged intellectual property infringement. In order to qualify, an Indemnified Contributor must: a) promptly notify the Commercial Contributor in writing of such claim, and b) allow the Commercial Contributor to control, and cooperate with the Commercial Contributor in, the defense and any related settlement negotiations. The Indemnified Contributor may participate in any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product offering, Product X. That Contributor is then a Commercial Contributor. If that Commercial Contributor then makes performance claims, or offers warranties related to Product X, those performance claims and warranties are such Commercial Contributor's responsibility alone. Under this section, the Commercial Contributor would have to defend claims against the other Contributors related to those performance claims and warranties, and if a court requires any other Contributor to pay any damages as a result, the Commercial Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is solely responsible for determining the appropriateness of using and distributing the Program and assumes all risks associated with its exercise of rights under this Agreement , including but not limited to the risks and costs of program errors, compliance with applicable laws, damage to or loss of data, programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this Agreement, and without further action by the parties hereto, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable. +If Recipient institutes patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Program itself (excluding combinations of the Program with other software or hardware) infringes such Recipient's patent(s), then such Recipient's rights granted under Section 2(b) shall terminate as of the date such litigation is filed. +All Recipient's rights under this Agreement shall terminate if it fails to comply with any of the material terms or conditions of this Agreement and does not cure such failure in a reasonable period of time after becoming aware of such noncompliance. If all Recipient's rights under this Agreement terminate, Recipient agrees to cease use and distribution of the Program as soon as reasonably practicable. However, Recipient's obligations under this Agreement and any licenses granted by Recipient relating to the Program shall continue and survive. +Everyone is permitted to copy and distribute copies of this Agreement, but in order to avoid inconsistency the Agreement is copyrighted and may only be modified in the following manner. The Agreement Steward reserves the right to publish new versions (including revisions) of this Agreement from time to time. No one other than the Agreement Steward has the right to modify this Agreement. The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation may assign the responsibility to serve as the Agreement Steward to a suitable separate entity. Each new version of the Agreement will be given a distinguishing version number. The Program (including Contributions) may always be distributed subject to the version of the Agreement under which it was received. In addition, after a new version of the Agreement is published, Contributor may elect to distribute the Program (including its Contributions) under the new version. Except as expressly stated in Sections 2(a) and 2(b) above, Recipient receives no rights or licenses to the intellectual property of any Contributor under this Agreement, whether expressly, by implication, estoppel or otherwise. All rights in the Program not expressly granted under this Agreement are reserved. +This Agreement is governed by the laws of the State of New York and the intellectual property laws of the United States of America. No party to this Agreement will bring a legal action under this Agreement more than one year after the cause of action arose. Each party waives its rights to a jury trial in any resulting litigation. diff --git a/libs.lsp/manifest.mf b/libs.lsp/manifest.mf new file mode 100644 index 000000000000..2aaca82e5451 --- /dev/null +++ b/libs.lsp/manifest.mf @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +AutoUpdate-Show-In-Client: true +OpenIDE-Module: org.netbeans.modules.libs.lsp +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/libs/lsp/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff --git a/libs.lsp/nbproject/project.properties b/libs.lsp/nbproject/project.properties new file mode 100644 index 000000000000..b9b1c6c11fc7 --- /dev/null +++ b/libs.lsp/nbproject/project.properties @@ -0,0 +1,27 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +javac.source=1.7 +javac.compilerargs=-Xlint -Xlint:-serial +release.external/gson-2.7.jar=modules/ext/gson-2.7.jar +release.external/guava-21.0.jar=modules/ext/guava-21.0.jar +release.external/org.eclipse.lsp4j-0.4.1.jar=modules/ext/org.eclipse.lsp4j-0.4.1.jar +release.external/org.eclipse.lsp4j.generator-0.4.1.jar=modules/ext/org.eclipse.lsp4j.generator-0.4.1.jar +release.external/org.eclipse.lsp4j.jsonrpc-0.4.1.jar=modules/ext/org.eclipse.lsp4j.jsonrpc-0.4.1.jar +release.external/org.eclipse.xtend.lib-2.14.0.jar=modules/ext/org.eclipse.xtend.lib-2.14.0.jar +release.external/org.eclipse.xtend.lib.macro-2.14.0.jar=modules/ext/org.eclipse.xtend.lib.macro-2.14.0.jar +release.external/org.eclipse.xtext.xbase.lib-2.14.0.jar=modules/ext/org.eclipse.xtext.xbase.lib-2.14.0.jar diff --git a/libs.lsp/nbproject/project.xml b/libs.lsp/nbproject/project.xml new file mode 100644 index 000000000000..64b201636b3a --- /dev/null +++ b/libs.lsp/nbproject/project.xml @@ -0,0 +1,87 @@ + + + + org.netbeans.modules.apisupport.project + + + org.netbeans.modules.libs.lsp + + + org.netbeans.modules.kotlin.support + org.netbeans.modules.lsp.client + com.google.common.annotations + com.google.common.base + com.google.common.cache + com.google.common.collect + com.google.common.escape + com.google.common.eventbus + com.google.common.graph + com.google.common.hash + com.google.common.html + com.google.common.io + com.google.common.math + com.google.common.net + com.google.common.primitives + com.google.common.reflect + com.google.common.util.concurrent + com.google.common.xml + org.eclipse.lsp4j + org.eclipse.lsp4j.jsonrpc + org.eclipse.lsp4j.jsonrpc.messages + org.eclipse.lsp4j.launch + org.eclipse.lsp4j.services + + + ext/org.eclipse.lsp4j-0.4.1.jar + external/org.eclipse.lsp4j-0.4.1.jar + + + ext/org.eclipse.xtend.lib.macro-2.14.0.jar + external/org.eclipse.xtend.lib.macro-2.14.0.jar + + + ext/gson-2.7.jar + external/gson-2.7.jar + + + ext/guava-21.0.jar + external/guava-21.0.jar + + + ext/org.eclipse.lsp4j.generator-0.4.1.jar + external/org.eclipse.lsp4j.generator-0.4.1.jar + + + ext/org.eclipse.xtend.lib-2.14.0.jar + external/org.eclipse.xtend.lib-2.14.0.jar + + + ext/org.eclipse.xtext.xbase.lib-2.14.0.jar + external/org.eclipse.xtext.xbase.lib-2.14.0.jar + + + ext/org.eclipse.lsp4j.jsonrpc-0.4.1.jar + external/org.eclipse.lsp4j.jsonrpc-0.4.1.jar + + + + diff --git a/libs.lsp/src/org/netbeans/modules/libs/lsp/Bundle.properties b/libs.lsp/src/org/netbeans/modules/libs/lsp/Bundle.properties new file mode 100644 index 000000000000..0f425aacdece --- /dev/null +++ b/libs.lsp/src/org/netbeans/modules/libs/lsp/Bundle.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +OpenIDE-Module-Name=Language Server Protocol Libraries diff --git a/lsp.client/build.xml b/lsp.client/build.xml new file mode 100644 index 000000000000..b87c9060b3a9 --- /dev/null +++ b/lsp.client/build.xml @@ -0,0 +1,25 @@ + + + + Builds, tests, and runs the project org.netbeans.modules.lsp.client + + diff --git a/lsp.client/manifest.mf b/lsp.client/manifest.mf new file mode 100644 index 000000000000..6850bbae8cf9 --- /dev/null +++ b/lsp.client/manifest.mf @@ -0,0 +1,6 @@ +Manifest-Version: 1.0 +AutoUpdate-Show-In-Client: true +OpenIDE-Module: org.netbeans.modules.lsp.client +OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/lsp/client/Bundle.properties +OpenIDE-Module-Specification-Version: 1.0 + diff --git a/lsp.client/nbproject/project.properties b/lsp.client/nbproject/project.properties new file mode 100644 index 000000000000..5137752915a4 --- /dev/null +++ b/lsp.client/nbproject/project.properties @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +javac.source=1.8 +javac.compilerargs=-Xlint -Xlint:-serial diff --git a/lsp.client/nbproject/project.xml b/lsp.client/nbproject/project.xml new file mode 100644 index 000000000000..26a55d64bd34 --- /dev/null +++ b/lsp.client/nbproject/project.xml @@ -0,0 +1,170 @@ + + + + org.netbeans.modules.apisupport.project + + + org.netbeans.modules.lsp.client + + + org.netbeans.modules.editor + + + + 3 + 1.90 + + + + org.netbeans.modules.editor.completion + + + + 1 + 1.47 + + + + org.netbeans.modules.editor.document + + + + 1.12 + + + + org.netbeans.modules.editor.lib + + + + 3 + 4.10 + + + + org.netbeans.modules.editor.lib2 + + + + 1 + 2.20 + + + + org.netbeans.modules.editor.mimelookup + + + + 1 + 1.43 + + + + org.netbeans.modules.libs.lsp + + + + 1.0 + + + + org.netbeans.modules.projectapi + + + + 1 + 1.70 + + + + org.netbeans.spi.editor.hints + + + + 0 + 1.45 + + + + org.openide.filesystems + + + + 9.13 + + + + org.openide.modules + + + + 7.51 + + + + org.openide.nodes + + + + 7.48 + + + + org.openide.text + + + + 6.70 + + + + org.openide.util + + + + 9.10 + + + + org.openide.util.lookup + + + + 8.36 + + + + org.openide.util.ui + + + + 9.10 + + + + + org.netbeans.modules.kotlin.support + org.netbeans.modules.lsp.client.spi + + + + diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/Bundle.properties b/lsp.client/src/org/netbeans/modules/lsp/client/Bundle.properties new file mode 100644 index 000000000000..0afbddb386ea --- /dev/null +++ b/lsp.client/src/org/netbeans/modules/lsp/client/Bundle.properties @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +OpenIDE-Module-Name=LSP Client diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/ProjectLSPBindings.java b/lsp.client/src/org/netbeans/modules/lsp/client/ProjectLSPBindings.java new file mode 100644 index 000000000000..f61a706345d2 --- /dev/null +++ b/lsp.client/src/org/netbeans/modules/lsp/client/ProjectLSPBindings.java @@ -0,0 +1,99 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.lsp.client; + +import java.util.HashMap; +import java.util.Map; +import java.util.WeakHashMap; +import java.util.concurrent.ExecutionException; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.eclipse.lsp4j.InitializeParams; +import org.eclipse.lsp4j.InitializeResult; +import org.eclipse.lsp4j.services.LanguageServer; +import org.eclipse.lsp4j.services.TextDocumentService; +import org.netbeans.api.editor.mimelookup.MimeLookup; +import org.netbeans.api.project.FileOwnerQuery; +import org.netbeans.api.project.Project; +import org.netbeans.modules.lsp.client.bindings.LanguageClientImpl; +import org.netbeans.modules.lsp.client.bindings.TextDocumentSyncServerCapabilityHandler; +import org.netbeans.modules.lsp.client.spi.LanguageServerProvider; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; + +/** + * + * @author lahvac + */ +public class ProjectLSPBindings { + + private static final Map> project2MimeType2Server = new WeakHashMap<>(); + + public static ProjectLSPBindings getBindings(FileObject file) { + Project prj = FileOwnerQuery.getOwner(file); + + if (prj == null) + return null; + + String mimeType = FileUtil.getMIMEType(file); + + ProjectLSPBindings bindings = + project2MimeType2Server.computeIfAbsent(prj, p -> new HashMap<>()) + .computeIfAbsent(mimeType, mt -> { + LanguageClientImpl lci = new LanguageClientImpl(); + for (LanguageServerProvider provider : MimeLookup.getLookup(mimeType).lookupAll(LanguageServerProvider.class)) { + LanguageServer server = provider.startServer(prj, lci); + + if (server != null) { + try { + InitializeParams initParams = new InitializeParams(); + initParams.setRootUri(prj.getProjectDirectory().toURI().toString()); //XXX: what if a different root is expected???? + initParams.setProcessId(0); + InitializeResult result = server.initialize(initParams).get(); + return new ProjectLSPBindings(server, result); + } catch (InterruptedException | ExecutionException ex) { + LOG.log(Level.FINE, null, ex); + } + } + } + return new ProjectLSPBindings(null, null); + }); + + return bindings.server != null ? bindings : null; + } + private static final Logger LOG = Logger.getLogger(ProjectLSPBindings.class.getName()); + + private final LanguageServer server; + private final InitializeResult initResult; + + private ProjectLSPBindings(LanguageServer server, InitializeResult initResult) { + this.server = server; + this.initResult = initResult; + } + + public TextDocumentService getTextDocumentService() { + return server.getTextDocumentService(); + } + + public InitializeResult getInitResult() { + //XXX: defenzive copy? + return initResult; + } + +} diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java new file mode 100644 index 000000000000..3e9d19753c50 --- /dev/null +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java @@ -0,0 +1,163 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.lsp.client.bindings; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.event.KeyEvent; +import java.net.URI; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutionException; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.JTextComponent; +import org.eclipse.lsp4j.CompletionItem; +import org.eclipse.lsp4j.CompletionItemKind; +import org.eclipse.lsp4j.CompletionList; +import org.eclipse.lsp4j.CompletionParams; +import org.eclipse.lsp4j.TextDocumentIdentifier; +import org.eclipse.lsp4j.jsonrpc.messages.Either; +import org.netbeans.api.editor.mimelookup.MimeRegistration; +import org.netbeans.modules.editor.NbEditorUtilities; +import org.netbeans.modules.lsp.client.ProjectLSPBindings; +import org.netbeans.spi.editor.completion.CompletionProvider; +import org.netbeans.spi.editor.completion.CompletionResultSet; +import org.netbeans.spi.editor.completion.CompletionTask; +import org.netbeans.spi.editor.completion.support.AsyncCompletionQuery; +import org.netbeans.spi.editor.completion.support.AsyncCompletionTask; +import org.netbeans.spi.editor.completion.support.CompletionUtilities; +import org.openide.filesystems.FileObject; +import org.openide.util.Exceptions; +import org.openide.util.ImageUtilities; + +/** + * + * @author lahvac + */ +@MimeRegistration(mimeType="", service=CompletionProvider.class) +public class CompletionProviderImpl implements CompletionProvider { + + @Override + public CompletionTask createTask(int queryType, JTextComponent component) { + return new AsyncCompletionTask(new AsyncCompletionQuery() { + @Override + protected void query(CompletionResultSet resultSet, Document doc, int caretOffset) { + try { + FileObject file = NbEditorUtilities.getFileObject(doc); + if (file == null) { + //TODO: beep + return ; + } + ProjectLSPBindings server = ProjectLSPBindings.getBindings(file); + if (server == null) { + return ; + } + URI uri = file.toURI(); + CompletionParams params; + params = new CompletionParams(new TextDocumentIdentifier(uri.toString()), + Utils.createPosition(doc, caretOffset)); + CountDownLatch l = new CountDownLatch(1); + //TODO: Location or Location[] + Either, CompletionList> completionResult = server.getTextDocumentService().completion(params).get(); + List items; + boolean incomplete; + if (completionResult.isLeft()) { + items = completionResult.getLeft(); + incomplete = true; + } else { + items = completionResult.getRight().getItems(); + incomplete = completionResult.getRight().isIncomplete(); + } + for (CompletionItem i : items) { + String insert = i.getInsertText() != null ? i.getInsertText() : i.getLabel(); + CompletionItemKind kind = i.getKind(); + Icon ic = Icons.getCompletionIcon(kind); + ImageIcon icon = new ImageIcon(ImageUtilities.icon2Image(ic)); + resultSet.addItem(new org.netbeans.spi.editor.completion.CompletionItem() { + @Override + public void defaultAction(JTextComponent jtc) { + throw new UnsupportedOperationException("TODO."); + } + + @Override + public void processKeyEvent(KeyEvent ke) { + } + + @Override + public int getPreferredWidth(Graphics grphcs, Font font) { + return CompletionUtilities.getPreferredWidth(insert, null, grphcs, font); + } + + @Override + public void render(Graphics grphcs, Font font, Color color, Color color1, int i, int i1, boolean bln) { + CompletionUtilities.renderHtml(icon, insert, null, grphcs, font, color, i, i1, bln); + } + + @Override + public CompletionTask createDocumentationTask() { + return null; + } + + @Override + public CompletionTask createToolTipTask() { + return null; + } + + @Override + public boolean instantSubstitution(JTextComponent jtc) { + return false; + } + + @Override + public int getSortPriority() { + return 100; + } + + @Override + public CharSequence getSortText() { + return i.getSortText(); + } + + @Override + public CharSequence getInsertPrefix() { + return insert; + } + }); + } + } catch (BadLocationException | InterruptedException ex) { + Exceptions.printStackTrace(ex); + } catch (ExecutionException ex) { + Exceptions.printStackTrace(ex); + } finally { + resultSet.finish(); + } + } + }, component); + } + + @Override + public int getAutoQueryTypes(JTextComponent component, String typedText) { + return 0; //TODO: implement trigger characters, if any? + } + +} diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/HyperlinkProviderImpl.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/HyperlinkProviderImpl.java new file mode 100644 index 000000000000..df70752feda4 --- /dev/null +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/HyperlinkProviderImpl.java @@ -0,0 +1,136 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.lsp.client.bindings; + +import java.net.MalformedURLException; +import java.net.URI; +import java.util.EnumSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; +import javax.swing.SwingUtilities; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import org.eclipse.lsp4j.Location; +import org.eclipse.lsp4j.TextDocumentIdentifier; +import org.eclipse.lsp4j.TextDocumentPositionParams; +import org.netbeans.api.editor.mimelookup.MimeRegistration; +import org.netbeans.editor.BaseDocument; +import org.netbeans.editor.Utilities; +import org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt; +import org.netbeans.lib.editor.hyperlink.spi.HyperlinkType; +import org.netbeans.modules.editor.NbEditorUtilities; +import org.netbeans.modules.lsp.client.ProjectLSPBindings; +import org.openide.cookies.LineCookie; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.URLMapper; +import org.openide.text.Line; +import org.openide.text.Line.ShowOpenType; +import org.openide.text.Line.ShowVisibilityType; +import org.openide.util.Exceptions; + +/** + * + * @author lahvac + */ +@MimeRegistration(mimeType="", service=HyperlinkProviderExt.class) +public class HyperlinkProviderImpl implements HyperlinkProviderExt { + + @Override + public Set getSupportedHyperlinkTypes() { + return EnumSet.of(HyperlinkType.GO_TO_DECLARATION); + } + + @Override + public boolean isHyperlinkPoint(Document doc, int offset, HyperlinkType type) { + return getHyperlinkSpan(doc, offset, type) != null; + } + + @Override + public int[] getHyperlinkSpan(Document doc, int offset, HyperlinkType type) { + try { + //XXX: not really using the server, are we? + return Utilities.getIdentifierBlock((BaseDocument) doc, offset); + } catch (BadLocationException ex) { + return null; + } + } + + @Override + public void performClickAction(Document doc, int offset, HyperlinkType type) { + FileObject file = NbEditorUtilities.getFileObject(doc); + if (file == null) { + //TODO: beep + return ; + } + ProjectLSPBindings server = ProjectLSPBindings.getBindings(file); + if (server == null) { + return ; + } + URI uri = file.toURI(); + try { + TextDocumentPositionParams params; + params = new TextDocumentPositionParams(new TextDocumentIdentifier(uri.toString()), + Utils.createPosition(doc, offset)); + //TODO: Location or Location[] + CompletableFuture> def = server.getTextDocumentService().definition(params); + def.handleAsync((locations, exception) -> { + if (exception != null) { + exception.printStackTrace(); + } + if (locations != null && locations.size() == 1) { //TODO: what to do when there are multiple locations? + try { + URI target = URI.create(locations.get(0).getUri()); + FileObject targetFile = URLMapper.findFileObject(target.toURL()); + + if (targetFile != null) { + LineCookie lc = targetFile.getLookup().lookup(LineCookie.class); + + //TODO: expecting lc != null! + + Line line = lc.getLineSet().getCurrent(locations.get(0).getRange().getStart().getLine()); + + SwingUtilities.invokeLater(() -> + line.show(ShowOpenType.OPEN, ShowVisibilityType.FOCUS, locations.get(0).getRange().getStart().getCharacter()) + ); + } else { + //TODO: beep + } + } catch (MalformedURLException ex) { + Exceptions.printStackTrace(ex); + } + } + return null; + }).get(); + } catch (BadLocationException ex) { + Exceptions.printStackTrace(ex); + } catch (InterruptedException ex) { + Exceptions.printStackTrace(ex); + } catch (ExecutionException ex) { + Exceptions.printStackTrace(ex); + } + } + + @Override + public String getTooltipText(Document doc, int offset, HyperlinkType type) { + return null; + } + +} diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Icons.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Icons.java new file mode 100644 index 000000000000..9c71e17c710a --- /dev/null +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Icons.java @@ -0,0 +1,58 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.netbeans.modules.lsp.client.bindings; + +import java.awt.Image; +import java.util.Locale; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import org.eclipse.lsp4j.CompletionItemKind; +import org.openide.util.ImageUtilities; + +/** + * Based on: + * java.source/src/org/netbeans/modules/java/ui/Icons.java + * @author Petr Hrebejk + */ +public final class Icons { + + private static final String ICON_BASE = "org/netbeans/modules/lsp/client/bindings/icons/"; + private static final String GIF_EXTENSION = ".gif"; + private static final String PNG_EXTENSION = ".png"; + + private Icons() { + } + + public static Icon getCompletionIcon(CompletionItemKind completionKind) { + Image img = ImageUtilities.loadImage(ICON_BASE + completionKind.name().toLowerCase(Locale.US) + PNG_EXTENSION); + + if (img == null) { + img = ImageUtilities.loadImage(ICON_BASE + completionKind.name().toLowerCase(Locale.US) + GIF_EXTENSION); + } + + if (img == null) { + img = ImageUtilities.loadImage(ICON_BASE + "variable" + GIF_EXTENSION); + } + + return img == null ? null : new ImageIcon (img); + + } + +} diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java new file mode 100644 index 000000000000..453b2230cafa --- /dev/null +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java @@ -0,0 +1,105 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.lsp.client.bindings; + +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.EnumMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.stream.Collectors; +import javax.swing.text.Document; +import org.eclipse.lsp4j.Diagnostic; +import org.eclipse.lsp4j.DiagnosticSeverity; +import org.eclipse.lsp4j.MessageActionItem; +import org.eclipse.lsp4j.MessageParams; +import org.eclipse.lsp4j.PublishDiagnosticsParams; +import org.eclipse.lsp4j.ShowMessageRequestParams; +import org.eclipse.lsp4j.services.LanguageClient; +import org.netbeans.spi.editor.hints.ErrorDescription; +import org.netbeans.spi.editor.hints.ErrorDescriptionFactory; +import org.netbeans.spi.editor.hints.HintsController; +import org.netbeans.spi.editor.hints.Severity; +import org.openide.cookies.EditorCookie; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.URLMapper; +import org.openide.util.Exceptions; + +/** + * + * @author lahvac + */ +public class LanguageClientImpl implements LanguageClient { + + private static final Logger LOG = Logger.getLogger(LanguageClientImpl.class.getName()); + + @Override + public void telemetryEvent(Object arg0) { + System.err.println("telemetry: " + arg0); + } + + @Override + public void publishDiagnostics(PublishDiagnosticsParams arg0) { + try { + FileObject file = URLMapper.findFileObject(new URI(arg0.getUri()).toURL()); + EditorCookie ec = file.getLookup().lookup(EditorCookie.class); + Document doc = ec != null ? ec.getDocument() : null; + if (doc == null) + return ; //ignore... + List diags = arg0.getDiagnostics().stream().map(d -> + ErrorDescriptionFactory.createErrorDescription(severityMap.get(d.getSeverity()), d.getMessage(), file, Utils.getOffset(doc, d.getRange().getStart()), Utils.getOffset(doc, d.getRange().getEnd())) + ).collect(Collectors.toList()); + HintsController.setErrors(doc, LanguageClientImpl.class.getName(), diags); + } catch (URISyntaxException | MalformedURLException ex) { + LOG.log(Level.FINE, null, ex); + } + System.err.println("arg0: " + arg0.getDiagnostics().size()); + System.err.println("publishDiagnostics: " + arg0); + } + + private static final Map severityMap = new EnumMap<>(DiagnosticSeverity.class); + + static { + severityMap.put(DiagnosticSeverity.Error, Severity.ERROR); + severityMap.put(DiagnosticSeverity.Hint, Severity.HINT); + severityMap.put(DiagnosticSeverity.Information, Severity.HINT); + severityMap.put(DiagnosticSeverity.Warning, Severity.HINT); + } + + @Override + public void showMessage(MessageParams arg0) { + System.err.println("showMessage: " + arg0); + } + + @Override + public CompletableFuture showMessageRequest(ShowMessageRequestParams arg0) { + System.err.println("showMessageRequest"); + return null; //??? + } + + @Override + public void logMessage(MessageParams arg0) { + System.err.println("logMessage: " + arg0); + } + +} diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/TextDocumentSyncServerCapabilityHandler.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/TextDocumentSyncServerCapabilityHandler.java new file mode 100644 index 000000000000..b8c9e1f6314f --- /dev/null +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/TextDocumentSyncServerCapabilityHandler.java @@ -0,0 +1,152 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.lsp.client.bindings; + +import java.util.Arrays; +import java.util.Collections; +import java.util.IdentityHashMap; +import java.util.Set; +import javax.swing.SwingUtilities; +import javax.swing.event.DocumentEvent; +import javax.swing.event.DocumentListener; +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import javax.swing.text.JTextComponent; +import org.eclipse.lsp4j.DidChangeTextDocumentParams; +import org.eclipse.lsp4j.DidOpenTextDocumentParams; +import org.eclipse.lsp4j.Position; +import org.eclipse.lsp4j.Range; +import org.eclipse.lsp4j.TextDocumentContentChangeEvent; +import org.eclipse.lsp4j.TextDocumentItem; +import org.eclipse.lsp4j.VersionedTextDocumentIdentifier; +import org.netbeans.api.editor.EditorRegistry; +import org.netbeans.editor.BaseDocumentEvent; +import org.netbeans.modules.editor.*; +import org.netbeans.modules.lsp.client.ProjectLSPBindings; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.modules.OnStart; +import org.openide.util.Exceptions; + +/** TODO: asynchronous + * TODO: follow the synchronization options + * + * @author lahvac + */ +public class TextDocumentSyncServerCapabilityHandler { + + private final Set lastOpened = Collections.newSetFromMap(new IdentityHashMap<>()); + + private void handleChange() { + assert SwingUtilities.isEventDispatchThread(); + Set currentOpened = Collections.newSetFromMap(new IdentityHashMap<>()); + currentOpened.addAll(EditorRegistry.componentList()); + Set newOpened = Collections.newSetFromMap(new IdentityHashMap<>()); + newOpened.addAll(currentOpened); + newOpened.removeAll(lastOpened); + Set newClosed = Collections.newSetFromMap(new IdentityHashMap<>()); + newClosed.addAll(lastOpened); + newClosed.removeAll(newOpened); + lastOpened.removeAll(newClosed); + lastOpened.addAll(newOpened); + + for (JTextComponent opened : newOpened) { + FileObject file = NbEditorUtilities.getFileObject(opened.getDocument()); + + if (file == null) + continue; //ignore + + ProjectLSPBindings server = ProjectLSPBindings.getBindings(file); + + if (server == null) + continue; //ignore + + try { + //XXX: should construct events outside of AWT + TextDocumentItem textDocumentItem = new TextDocumentItem(file.toURI().toString(), + FileUtil.getMIMEType(file), + 0, + opened.getDocument().getText(0, opened.getDocument().getLength())); //XXX: should do in render! + + server.getTextDocumentService().didOpen(new DidOpenTextDocumentParams(textDocumentItem)); + } catch (BadLocationException ex) { + Exceptions.printStackTrace(ex); + } + + Document doc = opened.getDocument(); + + doc.addDocumentListener(new DocumentListener() { //XXX: listener + int version; //XXX: proper versioning! + @Override + public void insertUpdate(DocumentEvent e) { + try { + fireEvent(e.getOffset(), e.getDocument().getText(e.getOffset(), e.getLength()), ""); + } catch (BadLocationException ex) { + Exceptions.printStackTrace(ex); + } + } + @Override + public void removeUpdate(DocumentEvent e) { + fireEvent(e.getOffset(), "", ((BaseDocumentEvent) e).getText()); + } + private void fireEvent(int start, String newText, String oldText) { + try { + Position startPos = Utils.createPosition(doc, start); + int additionalLines = 0; + int additionalChars = 0; + for (char c : oldText.toCharArray()) { + if (c == '\n') { + additionalLines++; + additionalChars = 0; + } else { + additionalChars++; + } + } + Position endPos = new Position(startPos.getLine() + additionalLines, + startPos.getCharacter() + additionalChars); + TextDocumentContentChangeEvent event; + event = new TextDocumentContentChangeEvent(new Range(startPos, + endPos), + oldText.length(), + newText); + VersionedTextDocumentIdentifier di = new VersionedTextDocumentIdentifier(++version); + di.setUri(file.toURI().toString()); + server.getTextDocumentService().didChange(new DidChangeTextDocumentParams(di, Arrays.asList(event))); + } catch (BadLocationException ex) { + Exceptions.printStackTrace(ex); + } + } + @Override + public void changedUpdate(DocumentEvent e) {} + }); + } + } + + @OnStart + public static class Init implements Runnable { + + @Override + public void run() { + TextDocumentSyncServerCapabilityHandler h = new TextDocumentSyncServerCapabilityHandler(); + EditorRegistry.addPropertyChangeListener(evt -> h.handleChange()); + SwingUtilities.invokeLater(() -> h.handleChange()); + } + + } +} diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Utils.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Utils.java new file mode 100644 index 000000000000..ca0c7d9ff325 --- /dev/null +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Utils.java @@ -0,0 +1,41 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.lsp.client.bindings; + +import javax.swing.text.BadLocationException; +import javax.swing.text.Document; +import org.eclipse.lsp4j.Position; +import org.netbeans.api.editor.document.LineDocument; +import org.netbeans.api.editor.document.LineDocumentUtils; + +/** + * + * @author lahvac + */ +public class Utils { + + public static Position createPosition(Document doc, int offset) throws BadLocationException { + return new Position(LineDocumentUtils.getLineIndex((LineDocument) doc, offset), + offset - LineDocumentUtils.getLineStart((LineDocument) doc, offset)); + } + + public static int getOffset(Document doc, Position pos) { + return LineDocumentUtils.getLineStartFromIndex((LineDocument) doc, pos.getLine()) + pos.getCharacter(); + } +} diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/attribute.png b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/attribute.png new file mode 100644 index 0000000000000000000000000000000000000000..610dbab206e323136b36b592186598d6f1b430b5 GIT binary patch literal 543 zcmV+)0^t3LP)p;8@h}Zp}X?z4(EkFPC^wJjnDoI7GAgmQU}um5J2c&2&(m#lvfmCXL$VnH-lXK ze7Hn;ge8NnsvJY8iIDQFgRel|1A7G^fY1$a669uKxb^BM!|%Tg496$NGO#c+F#G|s zE%O&MtZ9;GP!!={fQAhi00a=a0h%vA|7Boh{>yOx!6SyEImb{WnSpU8!UNW#2@?Yd zAanz+-+ld4Usa5qp<=;F3>W){+zl`Z)sZY>>?$&DWlPV*twE1*wB+00b(E} literal 0 HcmV?d00001 diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/class.png b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/class.png new file mode 100644 index 0000000000000000000000000000000000000000..220e6f385e0aef0c0aa7ab28d6623b2a2b7d0374 GIT binary patch literal 785 zcmV+s1Md8ZP)FfD0{{dNhKZ}H zL;^MyGyMPg^7Q|&w^o8_5FaFt%>@7f#0Vl_U`d&9Am`6_>%2>LGyHyY87|H$qRX(g z$CcqbyHHR}*W2~T4gd%sxB+tugu*#~zF!ekx}M?J%hMPxWfM1LSl1oM@Pl12B6-5Q zl`wID0D^}B)7SSa0*h8L{Cs+t;s2i>7#JiDk_V|nHW(m)7~|?^fSthdY!8F+k2MU@ zX~ifu|M~Tw;l-_=46pD1V)*gpAH%PIzuvJiu}uO>P4t*L=L0|hF~-zP{a>Av!0_qg z2ZrlMmN2~AQ_hf@UjfzpkKy{Ej|`lGnhc7j<_!FjQVbuTKV!Im`Xs~SOBXgXGBCse z1Q65Tzke8>efq`lg^`OvP(Pf3$*PrMN_PhX13NpzgX=#SSh*A#3>+L8__?_l7(RUf z(;&X2x`yxf-+u}K0*K|$@81mHfHr}{frFPp!X%R6!JmH&z4f&Wx^l4$4vv-#3~ydx z1ges}Jj0Fi=i>na2xtJ%_Md-|f}4jy)G&hK@sFPjpDy2E5Ml;~^ZR!g27tu>{Qau{ z5I{^I1AYK)M8-^*cjeFf6l=0<2wchiGTU|^D#gGfem10X2HOG0>TWx z6!jP`-@VJgz{!DuLE`2F`UgQ1oNgOG>_ z!@DzI=5FAb>zt8#CYspw#*Vh=qZe9f*Gd@mnB%1+?HVK!5=N6-#svo^p^a P00000NkvXXu0mjf*;Qhm literal 0 HcmV?d00001 diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/color.gif b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/color.gif new file mode 100644 index 0000000000000000000000000000000000000000..670335626375c4a3a2197be059f86a13464ee66e GIT binary patch literal 848 zcmV-W1F!svP)k7RCwBA z{Qv)d0|OGceEXr`y1mB@uH1g4_2KhZk&J)$7}$CF-iWBGT~l#!zaXNf@g7+{Kmai! z8!&bGR-HJEFg*YP z!~$bXUb@Nf@VT45@ljz6QZjN3KmYt^c>M7KwtxwZrW|2qo>coDlEhB_WNIk&%ge`F~j?}C|HV}l|e;P zg5&hYbp{~4009Ix;Pl0-TFP1m3}1f!WBC2|KMH2}@)-kbi;FSby?9;=q!%E7z+v#} z^&1ghQE7%>APwl?_b&_~F)j{7u(&mR~Y1g0-ulLn%ib@O&pFS{vXb>NpI)DJeX~4Hn@B8(|gc%rKyW;Y z^Kb(F{t*L%#6j}N>Hz`>!+>vJKJ?o%{bgYIhlxSrAbDi<00D$zz{K#-0!>af1_pNA z7$gr;2h#%(Kqv-$|N61tMT8G;$^*%R)WP@w0fdqg|NQ;O&~o!JNl6(XfEbZ86C)#| uF|itf`p$xAfB<5oG&ceS5XHF>Aiw|y>vvE?0v z(btiIVPjv-@4(4GzCyA`kS_y6l_~>6Lo)-z&;LOBB?CjL0RzLU1O^7H84L{K`IF+0 zx-l>?CV9FzhE&{2`t$$4J+mr! zwe(Trn)`9<3N&^fWmx1`lTz8hki>A5NpH_8FO`H~!^8jQ>-+!zUzM#ogYBc^BLhitQq!k!vKRfU*?w+!iuvL9=F=ZOTBEd!C%QUDa^Gfd)}tkRWBCOfB6w#+D~O!? z`1xCF?1>M}u?9>E4IA1RFJJ$z&D0%c_@}07#>4;fF5quGsBWV W))gX#GQb#OVDNPHb6Mw<&;$TO53P)E2M8c07-L`->Q!ywPQd=ip^v z`1uo#<^KL+IP&p}<5MQqCV&89RuAnu`urz9!?VM47))*K8JL)v!Fcw>Zibr-t_-$} zLJS(Bf(#7oY$*84&tD8TFJ1l*5I`&}tn3WAWfK@KA2MQ?&{4rqP+!k5p|O!c%DaO> zc*S;xE3E$*uH1agfCJP41Q5&Lzke7$GjcMB7)CIB`1+fnv!<3o(6t%N|NQt5gV2|k z3|bae7&@<=IL2_{{KYu{0mSm>_iu)8zy2{W0sSd$9?ifcWz8Tds{rPUzJJc(;b6lc zBqD-gfTA@p%wE580|+3X0l$F$`3sFZ9tH_z9R^U^1d086`;tM38JJYwzr!#9B>v~` zUj={w0vqt-&p)gl{L0SF@c#L820=jq47vC3KL9QH`4}L8m_PdRM`00IbPwJ`&J0LpMrfLIua*?}0C92wpM@hhMOe*ppv04#GT(S1NSRR91007*qo IM6N<$f?0v z(btiIVPjv-@4(4GzCyA`kS_y6l_~>6Lo)-z&;LOBB?CjL0RzLU1O^7H84L{K`IF+0 zx&hUm@pN$vskoK&=l_3uW>p4-h8YqXEDVe;8yTU*ktSb*eTixp8JPtfB6xp%e=qM` zT4v*Tc5Se@5d(`r8S}q?i4`AznmaN(ykcPDSj|}f|4-tNkH6)i0=pUOJ53l?@F_HG zkoxfadw$#ddJbuZAa(%sLXKz8?l@_B4S2o5u*dc!yZ;K zF}6iXj0z1B8=tzhuh?_@%o&{`2Q_I$XRuv8Jv~tlUCc*RQWzW>7#T7T1wM(g?&t;ucLK6VZBx$bz literal 0 HcmV?d00001 diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/event.png b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/event.png new file mode 100644 index 0000000000000000000000000000000000000000..cf556834a88469b1c317693bf964345b37498275 GIT binary patch literal 3234 zcmV;T3|;eyP)KLZ*U+IBfRsybQWXdwQbLP>6pAqfylh#{fb6;Z(vMMVS~$e@S=j*ftg6;Uhf59&ghTmgWD0l;*T zI709Y^p6lP1rIRMx#05C~cW=H_Aw*bJ-5DT&Z2n+x)QHX^p z00esgV8|mQcmRZ%02D^@S3L16t`O%c004NIvOKvYIYoh62rY33S640`D9%Y2D-rV&neh&#Q1i z007~1e$oCcFS8neI|hJl{-P!B1ZZ9hpmq0)X0i`JwE&>$+E?>%_LC6RbVIkUx0b+_+BaR3cnT7Zv!AJxW zizFb)h!jyGOOZ85F;a?DAXP{m@;!0_IfqH8(HlgRxt7s3}k3K`kFu>>-2Q$QMFfPW!La{h336o>X zu_CMttHv6zR;&ZNiS=X8v3CR#fknUxHUxJ0uoBa_M6WNWeqIg~6QE69c9o#eyhGvpiOA@W-aonk<7r1(?fC{oI5N*U!4 zfg=2N-7=cNnjjOr{yriy6mMFgG#l znCF=fnQv8CDz++o6_Lscl}eQ+l^ZHARH>?_s@|##Rr6KLRFA1%Q+=*RRWnoLsR`7U zt5vFIcfW3@?wFpwUVxrVZ>QdQz32KIeJ}k~{cZZE^+ya? z2D1z#2HOnI7(B%_ac?{wFUQ;QQA1tBKtrWrm0_3Rgps+?Jfqb{jYbcQX~taRB;#$y zZN{S}1|}gUOHJxc?wV3fxuz+mJ4`!F$IZ;mqRrNsHJd##*D~ju=bP7?-?v~|cv>vB zsJ6IeNwVZxrdjT`yl#bBIa#GxRa#xMMy;K#CDyyGyQdMSxlWT#tDe?p!?5wT$+oGt z8L;Kp2HUQ-ZMJ=3XJQv;x5ci*?vuTfeY$;({XGW_huIFR9a(?@3)XSs8O^N5RyOM=TTmp(3=8^+zpz2r)C z^>JO{deZfso3oq3?Wo(Y?l$ge?uXo;%ru`Vo>?<<(8I_>;8Eq#KMS9gFl*neeosSB zfoHYnBQIkwkyowPu(zdms`p{<7e4kra-ZWq<2*OsGTvEV%s0Td$hXT+!*8Bnh2KMe zBmZRodjHV?r+_5^X9J0WL4jKW`}lf%A-|44I@@LTvf1rHjG(ze6+w@Jt%Bvjts!X0 z?2xS?_ve_-kiKB_KiJlZ$9G`c^=E@oNG)mWWaNo-3TIW8)$Hg0Ub-~8?KhvJ>$ z3*&nim@mj(aCxE5!t{lw7O5^0EIO7zOo&c6l<+|iDySBWCGrz@C5{St!X3hAA}`T4 z(TLbXTq+(;@<=L8dXnssyft|w#WSTW<++3>sgS%(4NTpeI-VAqb|7ssJvzNHgOZVu zaYCvgO_R1~>SyL=cFU|~g|hy|Zi}}s9+d~lYqOB71z9Z$wnC=pR9Yz4DhIM>Wmjgu z&56o6maCpC&F##y%G;1PobR9i?GnNg;gYtchD%p19a!eQtZF&3JaKv33gZ<8D~47E ztUS1iwkmDaPpj=$m#%)jCVEY4fnLGNg2A-`YwHVD3gv};>)hAvT~AmqS>Lr``i7kw zJ{5_It`yrBmlc25DBO7E8;5VoznR>Ww5hAaxn$2~(q`%A-YuS64wkBy=9dm`4cXeX z4c}I@?e+FW+b@^RDBHV(wnMq2zdX3SWv9u`%{xC-q*U}&`cyXV(%rRT*Z6MH?i+i& z_B8C(+grT%{XWUQ+f@NoP1R=AW&26{v-dx)iK^-Nmiuj8txj!m?Z*Ss1N{dh4z}01 z)YTo*JycSU)+_5r4#yw9{+;i4Ee$peRgIj+;v;ZGdF1K$3E%e~4LaI(jC-u%2h$&R z9cLXcYC@Xwnns&bn)_Q~Te?roKGD|d-g^8;+aC{{G(1^(O7m37Y1-+6)01cN&y1aw zoqc{T`P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z0005aNkl-9kJ194dl}E{fm~#6`5E>X1Z&sr71(CcVqucXywIRm5j|-{E;*!8-Zz znSS61kOO*w67Uk3e>6V)20#ED8k;_$l)8L!U*C@2Ej{#f>nyF9l)f%;??v&m5aP;{ z$&p#H_u|cd6$E$2h7V^`sT6B&fagOv1o4Q5VHix#JpLjy?Nr!aTN^xfU{5xP>U=UB zu3o?O=NXqq&(amu$q($#&OLiQ7{bVPbT7eJQ_jojMFfdSzP$Q!@1dtYkt4ocsu_?0v z(btiIVPjv-@4(4GzCyA`kS_y6l_~>6Lo)-z&;LOBB?CjL0RzLU1O^7H84L{K`IF+0 zx&hUm@pN$vskoK&=l_3uW>p4-h8YqXEDVe;8yTU*ktSb*eTixp8JPtfB6xp%e=qM` zT4v*Tc5Se@5d(`r8S}q?i4`AznmaN(ykcPDSj|}f|4-tNkH6)i0=pUOJ53l?@F_HG zkoxfadw$#ddJbuZAa(%sLXKz8?l@_B4S2o5u*dc!yZ;K zF}6iXj0z1B8=tzhuh?_@%o&{`2Q_I$XRuv8Jv~tlUCc*RQWzW>7#T7T1wM(g?&t;ucLK6VZBx$bz literal 0 HcmV?d00001 diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/file.png b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/file.png new file mode 100644 index 0000000000000000000000000000000000000000..712725a5749af733a805c885bc3bb2f9c4f1b479 GIT binary patch literal 399 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggaMmauNGe2&tD?n5DJzX3_EKZ-j zxX}M_fWYyO?`=2LBtUrPgx;XCcc0_+zA|goJSNK zr=0Oww|@O;#baV#*Vj3I44!`a>E!b7Ekc&ocXG3Z*!TZ_6xz4f=zzwywSSw1U(L4G zsbXum_nNz0eEHh>4bK=Sdaw8*|Ko*y(!Of8jybpe_BxnmcW_MXT{+8wJ38HKt-wt| zZtvAM>!wWLuDKU?Sm6kJ&YKU@t{WL&Q}w87{>YW@*#7DlSKV623Q2)I_6xN*7HD)d zXeng|s7rp^b@|uMo#t!1`Q|dIy_7R8EvWx&o*>aC6*qTz)n`dKXc}_9XtN--u-{>+-rOG{NKO-|AGbA7B0MY zC-^H*Up^zzk2nxHEXV|TX${!`fD3DT-&_)+LkTX zwr;()Z5z<2Yl{|NTLDyj=Kt1h*MLp}JB=`*_>+Z^fx(DD2c#6_CkD0xhnWQ)I#T@} zkCIR7FwMKrV)BuLhp};u*sm>I8`lQD{(O;b!}SJ>C9f86=(GQl&Nvvx=EAC?aV9lF z*^pgLTuDHZt3E2k8 KY;|^Ium%824V|q3 literal 0 HcmV?d00001 diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/function.png b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/function.png new file mode 100644 index 0000000000000000000000000000000000000000..7be8a378a3747d5a82416effd17e4b7fab5af00a GIT binary patch literal 556 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP>?0v z(btiIVPjv-@4(4GzCyA`kS_y6l_~>6Lo)-z&;LOBB?CjL0RzLU1O^7H84L{K`IF+0 zx-l>?F7kA745_%4^ymM7duCMzg@zdt8Y~QqE*lx4#E~ZdBKNW`vk9k|A7v;!V|%pT zVUI|MdZo|YV$mgR3Jns4tdFjpSrVYfcrZ2S)-Ii-RjYXZ2u@Yyb5G^E}~_dGPl4_k>cQD@=LfYJYC} z`|-0l56>AN3qudNC434E8>9-}9$hUd{@(sa_5YW~Y;0v^JUl||C!4P@vIvCfud%8B z$sw+tef52P{q3H6`_scFOidLK6HKf4{Y>|8^YMPkb9ZE|4Wt@rK!{@MBW&gAFX-|p_*&VHhvU%;W~$0lPB;R!;_Ns1Z! mezG5V?{JXChzA(J2N*Js?XY=Uzpw!qvkacDelF{r5}E+&8r}5( literal 0 HcmV?d00001 diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/interface.png b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/interface.png new file mode 100644 index 0000000000000000000000000000000000000000..ae582f77a865f782849599afd143a6326f5799cf GIT binary patch literal 541 zcmV+&0^k-9M6m$?0mMSA!i?NPdmxnw#Nj}^5{ReInB0F5Ab=Rt za|(EYoJOeRbRez=N_W(w z1Q0_|Smckd-@gC<{O#v|5FHd6@&Ch@?ex6pTAMWKzxumKmaid3X5p``1w~) zK}nTi$)2B{E0R#{uP@WlxrGQuzh+hNoGoTHBkquyEWaL#)Qi3 literal 0 HcmV?d00001 diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/keyword.png b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/keyword.png new file mode 100644 index 0000000000000000000000000000000000000000..beca697f9279712027c5a3b69e0e5754339f813f GIT binary patch literal 804 zcmV+<1Ka$GP)`l^pc+Pi0Ad0O=9g4*{{H>j_20k$ zAAqzk5HISUGG`i06Hxv?5Z?l^fpW`%SgN<9*#yJ~2p~p~3o>$xn1O5oAbx{vo1&`5 z^zyv4tfchp3v6uc`bbj$fEa8!Kmakqyub(q@hO@A(4DNNr8B*{D0?DM?gqNtx36C} z0|XEYvcQiYKNyzxHZlC_C}jA1d>2EKN-)EpKYueDyCyMQyL28|>A#gr=9>ZOw*Ude zgl@oBKXrza_qH=+=|nNaM20aWMFjy3`JD-p`}XbIi`B~(ngVTp>K_uh2I%?+00G2U zTv4k7)Vl|W#jjqy3i1krk)b|AaX~JF06#xa^B;ycZ{9FeH+3*PdGsK2*Vc_QlvUN; z)iiasZQrz(86bcdatg~HNJ>dtI=XpPPMJCH|EEu%{)51$&!7KKnl=;6{{H>@|2_K; z{x7O(*ai(Vc4lT~6A&99fLOkM{VMP3>C4Y6AfzfICBeYT%F3`{@iK;Q-+wR!2l#=# z#?H>ppsS_9uw~~yPY@rd@h6Zv17ZUN5X<$eS8`?L6}EHn{kd!orXc8-)_u zAa4O}WcdB(H#oNb!=erd00M|fNJMnO(V%`GQ0F)@Jy4d`c3iUWIxlamungHz!jOalM{hz01Hvmj^v1#0~G@gpdz7;0O) z;0ih#su_fZg~4o)8gu{?0v z(btiIVPjv-@4(4GzCyA`kS_y6l_~>6Lo)-z&;LOBB?CjL0RzLU1O^7H84L{K`IF+0 zx-l>?F7kA745_%4^ymM7duCMzg@zdt8Y~QqE*lx4#E~ZdBKNW`vk9k|A7v;!V|%pT zVUI|MdZo|YV$mgR3Jns4tdFjpSrVYfcrZ2S)-Ii-RjYXZ2u@Yyb5G^E}~_dGPl4_k>cQD@=LfYJYC} z`|-0l56>AN3qudNC434E8>9-}9$hUd{@(sa_5YW~Y;0v^JUl||C!4P@vIvCfud%8B z$sw+tef52P{q3H6`_scFOidLK6HKf4{Y>|8^YMPkb9ZE|4Wt@rK!{@MBW&gAFX-|p_*&VHhvU%;W~$0lPB;R!;_Ns1Z! mezG5V?{JXChzA(J2N*Js?XY=Uzpw!qvkacDelF{r5}E+&8r}5( literal 0 HcmV?d00001 diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/module.png b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/module.png new file mode 100644 index 0000000000000000000000000000000000000000..505f4b7f812319106884ce66b111bde60c9422c5 GIT binary patch literal 1474 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`k|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+mc-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxR5#hc$WX!DQqR!T z#M01EN5ROz&{*HlK;Otx*U-?)#N5izOaTg%fVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD#PU%0_}#n6BP2AO_EVu8M)o`HUDF34YC)x{-2sR(CaRb3oXS&*t9 zlvJ zOih!`jdW8}%u{tu(@e~DEi8-@bxjk^4Gc`pOwEnW%wgtW({EtxV(DVwXkqMP=wfK- zYUXHeZ0=%Y?rLFVYT@i`W&qRcnO9trn3tRivpW-LH&m}VUcFY%MX8A;`9&f5`8lvu z5Rj2yl3$#WU!dUZte_E|nU|7ZUaSd{2l&r$vI-3+A}#NeO%QvHfE(IMv7*vHFRMOwsNQkIz)+ zUpyV_c*r~LdFuV&b!X1#85-wpn)TID`KM)w)@B8!sHg`2$05bp6}}-M9df5{#+;p5 zc;WjT?xi#CdpyJOx38Mdl_209LA7fZ(*yzqS z=l7|I+KC?n^;jjMQbVu(y;O9qev`7e&HBEEEiAisA8PyiMnj@@#z*x$VZEmxf(%xz zd0?RS=IK4=`g6e<*}9LmOqx`e6Vmr|f^OG;jx+O4KIzDfd9gd@USHrf{psAd`Y&i^xr8Si z>*tp~@Lu@NED2|ggpFTT+$^m+AShC}N4#UzdQ*3%RYi-u%D9-gx@AAl`uO&$@$-i6 zRXvY`E?Cd~xVF^n)I@E?By(0q&o^8d(Q~7jK5f`B;n-!_Zy+-5 zno}8{&YW1qWW=ylF8cOF>7{1Aty2HEfBaOPamwtcSBhSx-j-)6>tC@)J3i*`T;cxh n?)4u(zo~kavY1EKvq~`Ztr7XuzQGSvN;7!6`njxgN@xNA?ExFr literal 0 HcmV?d00001 diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/operator.png b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/operator.png new file mode 100644 index 0000000000000000000000000000000000000000..7be8a378a3747d5a82416effd17e4b7fab5af00a GIT binary patch literal 556 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP>?0v z(btiIVPjv-@4(4GzCyA`kS_y6l_~>6Lo)-z&;LOBB?CjL0RzLU1O^7H84L{K`IF+0 zx-l>?F7kA745_%4^ymM7duCMzg@zdt8Y~QqE*lx4#E~ZdBKNW`vk9k|A7v;!V|%pT zVUI|MdZo|YV$mgR3Jns4tdFjpSrVYfcrZ2S)-Ii-RjYXZ2u@Yyb5G^E}~_dGPl4_k>cQD@=LfYJYC} z`|-0l56>AN3qudNC434E8>9-}9$hUd{@(sa_5YW~Y;0v^JUl||C!4P@vIvCfud%8B z$sw+tef52P{q3H6`_scFOidLK6HKf4{Y>|8^YMPkb9ZE|4Wt@rK!{@MBW&gAFX-|p_*&VHhvU%;W~$0lPB;R!;_Ns1Z! mezG5V?{JXChzA(J2N*Js?XY=Uzpw!qvkacDelF{r5}E+&8r}5( literal 0 HcmV?d00001 diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/property.png b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/property.png new file mode 100644 index 0000000000000000000000000000000000000000..06a86fb1d9c2eb820ac2002e89a1de3ffbf954ad GIT binary patch literal 342 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP>?0v z(btiIVPjv-@4(4GzCyA`kS_y6l_~>6Lo)-z&;LOBB?CjL0RzLU1O^7H84L{K`IF+0 zx&hUm@pN$vskoK&=l_3uW>p4-h8YqXEDVe;8yTU*ktSb*eTixp8JPtfB6xp%e=qM` zT4v*Tc5Se@5d(`r8S}q?i4`AznmaN(ykcPDSj|}f|4-tNkH6)i0=pUOJ53l?@F_HG zkoxfadw$#ddJbuZAa(%sLXKz8?l@_B4S2o5u*dc!yZ;K zF}6iXj0z1B8=tzhuh?_@%o&{`2Q_I$XRuv8Jv~tlUCc*RQWzW>7#T7T1wM(g?&t;ucLK6VZBx$bz literal 0 HcmV?d00001 diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/reference.png b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/reference.png new file mode 100644 index 0000000000000000000000000000000000000000..290ae366617d7b454aaef9954260a9af2c622d33 GIT binary patch literal 1447 zcmbVMZA=?w9KX^4N`?a2kb%<6fr`fKy|mZ%8p`X@(YOKw0%Tc`>)ivKw0Grt(83TJ z5@kf9#;HrD(Z#9zpfO=)(``hCiqmWchnXUxn2xB4B5!V>%+@PV^aI%kFS&c3|MUEQ z|M&k5R#ogvPRdMzASl^U&Qz;wO7y)WLH+7hBCNXXRmvKa8mU?Fvoe5+dC3J}hlgze z)qv%@+CK;R5TxxCY8#XW=YA_EdGu@)qYrqzDjS0G3jQ zkb26AJH4f#RVeS4K}~l>E!W+~(L7RE0Otp+ssayCSUBKui#}_>hHU7ys{80MhQJ#T zrOk$HI@RE;f=eYCz?9yEayVgx&9t7NOlI2r2u!LnhFdTaM{(Lp8LT)7Z#{@=P3D`e z)r@`1mMYnhRz>kzG0gAx>-`43B)4D$P16`oVkC*G2-MdlDr^81eK|1=4DfNX;8g@k zgrgc+m(-!y5Y^Mo5IkO|b6c_K+e(z0GAzJ)F+z`H9#1r`4YW_G2LHOTBidKn`;Iy^vB9E=T7Z}hytTLDj*SsXW^6ib^> z(qN=f7eN7(aG5w9kTgykEipYi@r`t`88=wW2F7k6h%%GKXt$KmC1n=6jHHakRE+Bo zeF`gbAZA-oZEtZ+x8+((Wxy(uTq{ZLSQk{aN{ZxbmAr6i=|3pb)9LE&gKZnU5-i;F->oMSCUBSji09@*ma|2Kb_ z>J%1jmj5(Q>`3j%=yrP)RAGCVfT&K8td7bbb-$m4Ak8HQQ(POEb~T+y!P8FW*-k;s z7aCU|oURF(i$+q9)HKLRk5&hVlHj_y(BYyP;?2>PyH0CH`y#J$5_jMA>+?(XWZnfk0e``h5rQi<%Rx| zj}GC(s|&Nek-u*IsI zG&22lVrAj}^8Q}f^g{UV-8m26PmUP}yY_ezhKr3?@Yj=r!c!Whpx|O0(iDD@&N>!p s&kQCUxmh>^HSHc->wTlSB?xJu>!O+57f@4x>j z`1hZG|9?R-h<)|hkN;LV3;*}5I1x2()ph}pK7asXV!#8Km>3zDp%}zoa^Mcb{Mtx{ zbw_S4WfzcD1*riDAiM^kg9K+ah6Q_Xf!XKoJof_800Bgj0V<-bU_PgAb_yCpl4YDgG2(<&A=Ffs|5%ktSr0faLQSpWQF z;9{H3@a@SrhEs0?8TgqufyMsr)mnh#d)HVEq1#;fus( z20^CX44elX7z!e%G5q-RABFfD0{{dNhKZ}H zL;^MyGyMPg^7Q|&w^o8_5FaFt%>@7f#0Vl_U`d&9Am`6_>%2>LGyHyY87|H$qRX(g z$CcqbyHHR}*W2~T4gd%sxB+tugu*#~zF!ekx}M?J%hMPxWfM1LSl1oM@Pl12B6-5Q zl`wID0D^}B)7SSa0*h8L{Cs+t;s2i>7#JiDk_V|nHW(m)7~|?^fSthdY!8F+k2MU@ zX~ifu|M~Tw;l-_=46pD1V)*gpAH%PIzuvJiu}uO>P4t*L=L0|hF~-zP{a>Av!0_qg z2ZrlMmN2~AQ_hf@UjfzpkKy{Ej|`lGnhc7j<_!FjQVbuTKV!Im`Xs~SOBXgXGBCse z1Q65Tzke8>efq`lg^`OvP(Pf3$*PrMN_PhX13NpzgX=#SSh*A#3>+L8__?_l7(RUf z(;&X2x`yxf-+u}K0*K|$@81mHfHr}{frFPp!X%R6!JmH&z4f&Wx^l4$4vv-#3~ydx z1ges}Jj0Fi=i>na2xtJ%_Md-|f}4jy)G&hK@sFPjpDy2E5Ml;~^ZR!g27tu>{Qau{ z5I{^I1AYK)M8-^*cjeFf6l=0<2wchiGTU|^D#gGfem10X2HOG0>TWx z6!jP`-@VJgz{!DuLE`2F`UgQ1oNgOG>_ z!@DzI=5FAb>zt8#CYspw#*Vh=qZe9f*Gd@mnB%1+?HVK!5=N6-#svo^p^a P00000NkvXXu0mjf*;Qhm literal 0 HcmV?d00001 diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/text.png b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/text.png new file mode 100644 index 0000000000000000000000000000000000000000..b56c19cee5d575480a31f2a3d433a240d9de649e GIT binary patch literal 613 zcmV-r0-F7aP)>!O+57f@4x>j z`1hZG|9?R-h<)|hkN;LV3;*}5I1x2()ph}pK7asXV!#8Km>3zDp%}zoa^Mcb{Mtx{ zbw_S4WfzcD1*riDAiM^kg9K+ah6Q_Xf!XKoJof_800Bgj0V<-bU_PgAb_yCpl4YDgG2(<&A=Ffs|5%ktSr0faLQSpWQF z;9{H3@a@SrhEs0?8TgqufyMsr)mnh#d)HVEq1#;fus( z20^CX44elX7z!e%G5q-RABp4-h8YqX zEDVfCn$DbD|5ojmrSNQTNkL;56}cHL7bqHD- zGycu@S>v`~-)03Vg$4=Dv%L(AE`@n490m;Y?gu1s-JHA!=qCnGS3j3^P6c-mj#PnPRIHZt82`Ti~3Uk?B!Ylp0*+7m{3+ootz+WN)WnQ(*-(AUCxn zQK2F?C$HG5!d3}vt`(3C64qBz04piUwpD^SD#ABF!8yMuRl!uxR5#hc$WX!DQqR!T z#M01EN5ROz&{*HlK;Otx*U-?)#N5izOaTg%fVLH-q*(>IxIyg#@@$ndN=gc>^!3Zj z%k|2Q_413-^$jg8E%gnI^o@*kfhu&1EAvVcD|GXUm0>2hq!uR^WfqiV=I1GZOiWD5 zFD#PU%0_}#n6BP2AO_EVu8M)o`HUDF34YC)x{-2sR(CaRb3oXS&*t9 zlvJ zOih!`jdW8}%u{tu(@e~DEi8-@bxjk^4Gc`pOwEnW%wgtW({EtxV(DVwXkqMP=wfK- zYUXHeZ0=%Y?rLFVYT@i`W&qRcnO9trn3tRivpW-LH&m}VUcFY%MX8A;`9&f5`8lvu z5Rj2yl3$#WU!dUZte_E|nU|7ZUaSd{2l&r$vI-3+A}#NeO%QvHfE(IMv7*vHFRMOwsNQkIz)+ zUpyV_c*r~LdFuV&b!X1#85-wpn)TID`KM)w)@B8!sHg`2$05bp6}}-M9df5{#+;p5 zc;WjT?xi#CdpyJOx38Mdl_209LA7fZ(*yzqS z=l7|I+KC?n^;jjMQbVu(y;O9qev`7e&HBEEEiAisA8PyiMnj@@#z*x$VZEmxf(%xz zd0?RS=IK4=`g6e<*}9LmOqx`e6Vmr|f^OG;jx+O4KIzDfd9gd@USHrf{psAd`Y&i^xr8Si z>*tp~@Lu@NED2|ggpFTT+$^m+AShC}N4#UzdQ*3%RYi-u%D9-gx@AAl`uO&$@$-i6 zRXvY`E?Cd~xVF^n)I@E?By(0q&o^8d(Q~7jK5f`B;n-!_Zy+-5 zno}8{&YW1qWW=ylF8cOF>7{1Aty2HEfBaOPamwtcSBhSx-j-)6>tC@)J3i*`T;cxh n?)4u(zo~kavY1EKvq~`Ztr7XuzQGSvN;7!6`njxgN@xNA?ExFr literal 0 HcmV?d00001 diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/value.png b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/icons/value.png new file mode 100644 index 0000000000000000000000000000000000000000..8c18e6b4a8cf6bff57c40698dc37ba839cd307e0 GIT binary patch literal 516 zcmV+f0{i`mP)^c)wlov0g*{W zK~y-)#gjctBT*EFpV1M6+C-+Y*$}Ku8&d>Q*$NhdFh%Ov2x29!2qO9qY_yGFktOQ> z0NKKBM+gcDh%pAmusTe{k6|=39*Y@;gxNw;c;GhoJ?DY@p7$yuLO0bzm!*bXDznEK zU>cYJ#()ZN2oz;2dDPY{B5jA9kxgz?F853Ka@~9t*Apo>9NGMHCqI@>FUT3$w*HRc zOmd@gS-P@CMC8Hoq;9>+-?}ZoPafpw!Hq;0O6TN^%*RZp2h%H)BeA&Fk21AQ)AqQ1 zbOD%J-X$?Iz|8pYXz;vH6DOjBDrdJZ0NmXB!>;Fxkv@gE79sE^6fpMh(eGZ=)1>F~ z0Ho*hEb3``dq5jf35*Q|RH}C`)U6h&M669nC1QAQU_QA7TL}dm)=USd<%jFnnoepi z&)&L@(-NGPP%|BZm4*U}1;eVA8}=t;Z(YZG^Tl$*reIiAp!k`Y&L}Ih$Jywhx;isH zJQ~*`XhSOIlS|EXC>U0?`RuOBR&wXRfUhP|`S#D$HQ*g%UE4Z%^ngVG0000p4-h8YqX zEDVfCn$DbD|5ojmrSNQTNkL;56}cHL7bqHD- zGycu@S>v`~-)03Vg$4=Dv%L(AE`@n490m;Y?gu1s-JHA!=qCnGS3j3^P6 Date: Sat, 7 Jul 2018 06:34:09 +0200 Subject: [PATCH 02/15] Fixing default action for LSP completion item. --- .../bindings/CompletionProviderImpl.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java index 3e9d19753c50..41a1ac6782a5 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java @@ -31,13 +31,17 @@ import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.JTextComponent; +import javax.swing.text.StyledDocument; import org.eclipse.lsp4j.CompletionItem; import org.eclipse.lsp4j.CompletionItemKind; import org.eclipse.lsp4j.CompletionList; import org.eclipse.lsp4j.CompletionParams; import org.eclipse.lsp4j.TextDocumentIdentifier; +import org.eclipse.lsp4j.TextEdit; import org.eclipse.lsp4j.jsonrpc.messages.Either; import org.netbeans.api.editor.mimelookup.MimeRegistration; +import org.netbeans.editor.BaseDocument; +import org.netbeans.editor.Utilities; import org.netbeans.modules.editor.NbEditorUtilities; import org.netbeans.modules.lsp.client.ProjectLSPBindings; import org.netbeans.spi.editor.completion.CompletionProvider; @@ -47,6 +51,7 @@ import org.netbeans.spi.editor.completion.support.AsyncCompletionTask; import org.netbeans.spi.editor.completion.support.CompletionUtilities; import org.openide.filesystems.FileObject; +import org.openide.text.NbDocument; import org.openide.util.Exceptions; import org.openide.util.ImageUtilities; @@ -96,7 +101,32 @@ protected void query(CompletionResultSet resultSet, Document doc, int caretOffse resultSet.addItem(new org.netbeans.spi.editor.completion.CompletionItem() { @Override public void defaultAction(JTextComponent jtc) { - throw new UnsupportedOperationException("TODO."); + Document doc = jtc.getDocument(); + TextEdit te = i.getTextEdit(); + if (te != null) { + int start = Utils.getOffset(doc, te.getRange().getStart()); + int end = Utils.getOffset(doc, te.getRange().getEnd()); + NbDocument.runAtomic((StyledDocument) doc, () -> { + try { + doc.remove(start, end - start); + doc.insertString(start, te.getNewText(), null); + } catch (BadLocationException ex) { + Exceptions.printStackTrace(ex); + } + }); + } else { + String toAdd = i.getInsertText(); + if (toAdd == null) { + toAdd = i.getLabel(); + } + try { + int offset = jtc.getCaretPosition(); + String ident = Utilities.getIdentifier((BaseDocument) doc, offset); + doc.insertString(offset, toAdd.substring(ident != null ? ident.length() : 0), null); + } catch (BadLocationException ex) { + Exceptions.printStackTrace(ex); + } + } } @Override From 1eb8fc3aa728e5ec266c3b74bf182d7372646a9d Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Sun, 8 Jul 2018 06:55:50 +0200 Subject: [PATCH 03/15] Adding ability to connect toan already running server. --- lsp.client/nbproject/project.xml | 25 ++++ .../modules/lsp/client/Bundle.properties | 6 + .../lsp/client/ConnectToLanguageServer.java | 70 +++++++++ .../ConnectToLanguageServerParameters.form | 125 ++++++++++++++++ .../ConnectToLanguageServerParameters.java | 137 ++++++++++++++++++ ...ojectLSPBindings.java => LSPBindings.java} | 82 +++++++++-- .../bindings/CompletionProviderImpl.java | 4 +- .../bindings/HyperlinkProviderImpl.java | 4 +- ...xtDocumentSyncServerCapabilityHandler.java | 4 +- 9 files changed, 438 insertions(+), 19 deletions(-) create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/ConnectToLanguageServer.java create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/ConnectToLanguageServerParameters.form create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/ConnectToLanguageServerParameters.java rename lsp.client/src/org/netbeans/modules/lsp/client/{ProjectLSPBindings.java => LSPBindings.java} (55%) diff --git a/lsp.client/nbproject/project.xml b/lsp.client/nbproject/project.xml index 26a55d64bd34..40d3b6fafd2c 100644 --- a/lsp.client/nbproject/project.xml +++ b/lsp.client/nbproject/project.xml @@ -25,6 +25,15 @@ org.netbeans.modules.lsp.client + + org.netbeans.api.progress + + + + 1 + 1.50 + + org.netbeans.modules.editor @@ -104,6 +113,22 @@ 1.45 + + org.openide.awt + + + + 7.70 + + + + org.openide.dialogs + + + + 7.45 + + org.openide.filesystems diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/Bundle.properties b/lsp.client/src/org/netbeans/modules/lsp/client/Bundle.properties index 0afbddb386ea..f30f87ad1c91 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/Bundle.properties +++ b/lsp.client/src/org/netbeans/modules/lsp/client/Bundle.properties @@ -16,3 +16,9 @@ # under the License. OpenIDE-Module-Name=LSP Client +ConnectToLanguageServerParameters.jLabel1.text=Root: +ConnectToLanguageServerParameters.jLabel2.text=Port: +ConnectToLanguageServerParameters.jLabel3.text=Extensions: +ConnectToLanguageServerParameters.port.text= +ConnectToLanguageServerParameters.extensions.text= +ConnectToLanguageServerParameters.root.text= diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/ConnectToLanguageServer.java b/lsp.client/src/org/netbeans/modules/lsp/client/ConnectToLanguageServer.java new file mode 100644 index 000000000000..a32d0fab3f58 --- /dev/null +++ b/lsp.client/src/org/netbeans/modules/lsp/client/ConnectToLanguageServer.java @@ -0,0 +1,70 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.lsp.client; + +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.File; +import org.openide.*; +import org.openide.awt.ActionID; +import org.openide.awt.ActionRegistration; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; +import org.openide.util.NbBundle.Messages; + +@ActionID( + category = "Tools", + id = "org.netbeans.modules.lsp.client.ConnectToLanguageServer" +) +@ActionRegistration( + displayName = "#CTL_ConnectToLanguageServer" +) +@Messages("CTL_ConnectToLanguageServer=Connect to Language Server") +public final class ConnectToLanguageServer implements ActionListener { + + @Override + @Messages({"ERR_CanFindRoot=Can't find the specified root directory", + "ERR_InvalidPort=The specified port is invalid" + }) + public void actionPerformed(ActionEvent e) { + ConnectToLanguageServerParameters params = new ConnectToLanguageServerParameters(); + DialogDescriptor dd = new DialogDescriptor(params, "Connect to Language Server", true, DialogDescriptor.OK_CANCEL_OPTION, DialogDescriptor.OK_OPTION, null); + + if (DialogDisplayer.getDefault().notify(dd) == DialogDescriptor.OK_OPTION) { + params.confirm(); + FileObject root = FileUtil.toFileObject(new File(params.getRoot())); + + if (root == null) { + DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(Bundle.ERR_CanFindRoot(), NotifyDescriptor.ERROR_MESSAGE)); + return ; + } + + int port; + + try { + port = Integer.parseInt(params.getPort()); + } catch (NumberFormatException ex) { + DialogDisplayer.getDefault().notifyLater(new NotifyDescriptor.Message(Bundle.ERR_InvalidPort(), NotifyDescriptor.ERROR_MESSAGE)); + return ; + } + + LSPBindings.addBindings(root, port, params.getExtensions().split(",")); + } + } +} diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/ConnectToLanguageServerParameters.form b/lsp.client/src/org/netbeans/modules/lsp/client/ConnectToLanguageServerParameters.form new file mode 100644 index 000000000000..e127e2dea316 --- /dev/null +++ b/lsp.client/src/org/netbeans/modules/lsp/client/ConnectToLanguageServerParameters.form @@ -0,0 +1,125 @@ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/ConnectToLanguageServerParameters.java b/lsp.client/src/org/netbeans/modules/lsp/client/ConnectToLanguageServerParameters.java new file mode 100644 index 000000000000..ff0a410fda87 --- /dev/null +++ b/lsp.client/src/org/netbeans/modules/lsp/client/ConnectToLanguageServerParameters.java @@ -0,0 +1,137 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.lsp.client; + +import java.util.prefs.Preferences; +import javax.swing.JTextField; +import org.openide.util.NbPreferences; + +/** + * + * @author lahvac + */ +public class ConnectToLanguageServerParameters extends javax.swing.JPanel { + + private static final String KEY_ROOT = "root"; + private static final String KEY_PORT = "port"; + private static final String KEY_EXTENSIONS = "extensions"; + private final Preferences settings; + + public ConnectToLanguageServerParameters() { + initComponents(); + Preferences prefs = NbPreferences.forModule(ConnectToLanguageServerParameters.class); + settings = prefs.node("connect"); + root.setText(settings.get(KEY_ROOT, "")); + port.setText(settings.get(KEY_PORT, "")); + extensions.setText(settings.get(KEY_EXTENSIONS, "")); + } + + public void confirm() { + settings.put(KEY_ROOT, root.getText()); + settings.put(KEY_PORT, port.getText()); + settings.put(KEY_EXTENSIONS, extensions.getText()); + } + + public String getExtensions() { + return extensions.getText(); + } + + public String getPort() { + return port.getText(); + } + + public String getRoot() { + return root.getText(); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + root = new javax.swing.JTextField(); + jLabel2 = new javax.swing.JLabel(); + port = new javax.swing.JTextField(); + jLabel3 = new javax.swing.JLabel(); + extensions = new javax.swing.JTextField(); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(ConnectToLanguageServerParameters.class, "ConnectToLanguageServerParameters.jLabel1.text")); // NOI18N + + root.setText(org.openide.util.NbBundle.getMessage(ConnectToLanguageServerParameters.class, "ConnectToLanguageServerParameters.root.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(ConnectToLanguageServerParameters.class, "ConnectToLanguageServerParameters.jLabel2.text")); // NOI18N + + port.setText(org.openide.util.NbBundle.getMessage(ConnectToLanguageServerParameters.class, "ConnectToLanguageServerParameters.port.text")); // NOI18N + + org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(ConnectToLanguageServerParameters.class, "ConnectToLanguageServerParameters.jLabel3.text")); // NOI18N + + extensions.setText(org.openide.util.NbBundle.getMessage(ConnectToLanguageServerParameters.class, "ConnectToLanguageServerParameters.extensions.text")); // NOI18N + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); + this.setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 82, Short.MAX_VALUE)) + .addComponent(jLabel3)) + .addGap(20, 20, 20) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(root, javax.swing.GroupLayout.DEFAULT_SIZE, 274, Short.MAX_VALUE) + .addComponent(port) + .addComponent(extensions)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(root, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel2) + .addComponent(port, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel3) + .addComponent(extensions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + }// //GEN-END:initComponents + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField extensions; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JTextField port; + private javax.swing.JTextField root; + // End of variables declaration//GEN-END:variables +} diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/ProjectLSPBindings.java b/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java similarity index 55% rename from lsp.client/src/org/netbeans/modules/lsp/client/ProjectLSPBindings.java rename to lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java index f61a706345d2..0f40497f70a2 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/ProjectLSPBindings.java +++ b/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java @@ -18,42 +18,66 @@ */ package org.netbeans.modules.lsp.client; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetAddress; +import java.net.Socket; +import java.util.Arrays; import java.util.HashMap; import java.util.Map; +import java.util.Map.Entry; import java.util.WeakHashMap; import java.util.concurrent.ExecutionException; import java.util.logging.Level; import java.util.logging.Logger; +import java.util.stream.Collectors; import org.eclipse.lsp4j.InitializeParams; import org.eclipse.lsp4j.InitializeResult; +import org.eclipse.lsp4j.jsonrpc.Launcher; +import org.eclipse.lsp4j.launch.LSPLauncher; import org.eclipse.lsp4j.services.LanguageServer; import org.eclipse.lsp4j.services.TextDocumentService; import org.netbeans.api.editor.mimelookup.MimeLookup; +import org.netbeans.api.progress.*; import org.netbeans.api.project.FileOwnerQuery; import org.netbeans.api.project.Project; import org.netbeans.modules.lsp.client.bindings.LanguageClientImpl; -import org.netbeans.modules.lsp.client.bindings.TextDocumentSyncServerCapabilityHandler; import org.netbeans.modules.lsp.client.spi.LanguageServerProvider; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; +import org.openide.util.Exceptions; +import org.openide.util.NbBundle.Messages; /** * * @author lahvac */ -public class ProjectLSPBindings { +public class LSPBindings { - private static final Map> project2MimeType2Server = new WeakHashMap<>(); - - public static ProjectLSPBindings getBindings(FileObject file) { + private static final Map> project2MimeType2Server = new WeakHashMap<>(); + private static final Map> workspace2Extension2Server = new WeakHashMap<>(); + + public static LSPBindings getBindings(FileObject file) { + for (Entry> e : workspace2Extension2Server.entrySet()) { + if (FileUtil.isParentOf(e.getKey(), file)) { + LSPBindings bindings = e.getValue().get(file.getExt()); + + if (bindings != null) { + return bindings; + } + + break; + } + } Project prj = FileOwnerQuery.getOwner(file); if (prj == null) return null; String mimeType = FileUtil.getMIMEType(file); - - ProjectLSPBindings bindings = + + LSPBindings bindings = project2MimeType2Server.computeIfAbsent(prj, p -> new HashMap<>()) .computeIfAbsent(mimeType, mt -> { LanguageClientImpl lci = new LanguageClientImpl(); @@ -66,23 +90,55 @@ public static ProjectLSPBindings getBindings(FileObject file) { initParams.setRootUri(prj.getProjectDirectory().toURI().toString()); //XXX: what if a different root is expected???? initParams.setProcessId(0); InitializeResult result = server.initialize(initParams).get(); - return new ProjectLSPBindings(server, result); + return new LSPBindings(server, result); } catch (InterruptedException | ExecutionException ex) { LOG.log(Level.FINE, null, ex); } } } - return new ProjectLSPBindings(null, null); + return new LSPBindings(null, null); }); - + return bindings.server != null ? bindings : null; } - private static final Logger LOG = Logger.getLogger(ProjectLSPBindings.class.getName()); + private static final Logger LOG = Logger.getLogger(LSPBindings.class.getName()); + + @Messages("LBL_Connecting=Connecting to language server") + public static void addBindings(FileObject root, int port, String... extensions) { + BaseProgressUtils.showProgressDialogAndRun(() -> { + try { + Socket s = new Socket(InetAddress.getLocalHost(), port); + LanguageClientImpl lc = new LanguageClientImpl(); + InputStream in = s.getInputStream(); + OutputStream out = s.getOutputStream(); + Launcher launcher = LSPLauncher.createClientLauncher(lc, in, new OutputStream() { + @Override + public void write(int w) throws IOException { + out.write(w); + if (w == '\n') + out.flush(); + } + }); + launcher.startListening(); + LanguageServer server = launcher.getRemoteProxy(); + + InitializeParams initParams = new InitializeParams(); + initParams.setRootUri(root.toURI().toString()); + initParams.setProcessId(0); + InitializeResult result = server.initialize(initParams).get(); + LSPBindings bindings = new LSPBindings(server, result); + + workspace2Extension2Server.put(root, Arrays.stream(extensions).collect(Collectors.toMap(k -> k, v -> bindings))); + } catch (InterruptedException | ExecutionException | IOException ex) { + Exceptions.printStackTrace(ex); + } + }, Bundle.LBL_Connecting()); + } private final LanguageServer server; private final InitializeResult initResult; - private ProjectLSPBindings(LanguageServer server, InitializeResult initResult) { + private LSPBindings(LanguageServer server, InitializeResult initResult) { this.server = server; this.initResult = initResult; } @@ -95,5 +151,5 @@ public InitializeResult getInitResult() { //XXX: defenzive copy? return initResult; } - + } diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java index 41a1ac6782a5..61d016f06a32 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CompletionProviderImpl.java @@ -43,7 +43,7 @@ import org.netbeans.editor.BaseDocument; import org.netbeans.editor.Utilities; import org.netbeans.modules.editor.NbEditorUtilities; -import org.netbeans.modules.lsp.client.ProjectLSPBindings; +import org.netbeans.modules.lsp.client.LSPBindings; import org.netbeans.spi.editor.completion.CompletionProvider; import org.netbeans.spi.editor.completion.CompletionResultSet; import org.netbeans.spi.editor.completion.CompletionTask; @@ -73,7 +73,7 @@ protected void query(CompletionResultSet resultSet, Document doc, int caretOffse //TODO: beep return ; } - ProjectLSPBindings server = ProjectLSPBindings.getBindings(file); + LSPBindings server = LSPBindings.getBindings(file); if (server == null) { return ; } diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/HyperlinkProviderImpl.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/HyperlinkProviderImpl.java index df70752feda4..4c79aa152200 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/HyperlinkProviderImpl.java +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/HyperlinkProviderImpl.java @@ -37,7 +37,7 @@ import org.netbeans.lib.editor.hyperlink.spi.HyperlinkProviderExt; import org.netbeans.lib.editor.hyperlink.spi.HyperlinkType; import org.netbeans.modules.editor.NbEditorUtilities; -import org.netbeans.modules.lsp.client.ProjectLSPBindings; +import org.netbeans.modules.lsp.client.LSPBindings; import org.openide.cookies.LineCookie; import org.openide.filesystems.FileObject; import org.openide.filesystems.URLMapper; @@ -80,7 +80,7 @@ public void performClickAction(Document doc, int offset, HyperlinkType type) { //TODO: beep return ; } - ProjectLSPBindings server = ProjectLSPBindings.getBindings(file); + LSPBindings server = LSPBindings.getBindings(file); if (server == null) { return ; } diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/TextDocumentSyncServerCapabilityHandler.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/TextDocumentSyncServerCapabilityHandler.java index b8c9e1f6314f..1002d256717d 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/TextDocumentSyncServerCapabilityHandler.java +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/TextDocumentSyncServerCapabilityHandler.java @@ -38,7 +38,7 @@ import org.netbeans.api.editor.EditorRegistry; import org.netbeans.editor.BaseDocumentEvent; import org.netbeans.modules.editor.*; -import org.netbeans.modules.lsp.client.ProjectLSPBindings; +import org.netbeans.modules.lsp.client.LSPBindings; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.modules.OnStart; @@ -72,7 +72,7 @@ private void handleChange() { if (file == null) continue; //ignore - ProjectLSPBindings server = ProjectLSPBindings.getBindings(file); + LSPBindings server = LSPBindings.getBindings(file); if (server == null) continue; //ignore From 316cdb393acbfec2e9363ce2e4e396a01e6ffdfb Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Wed, 25 Jul 2018 06:04:18 +0200 Subject: [PATCH 04/15] CompletionItem.getKind() is optional, adjusting to that. --- .../netbeans/modules/lsp/client/bindings/Icons.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Icons.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Icons.java index 9c71e17c710a..56eca531f5de 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Icons.java +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Icons.java @@ -41,10 +41,14 @@ private Icons() { } public static Icon getCompletionIcon(CompletionItemKind completionKind) { - Image img = ImageUtilities.loadImage(ICON_BASE + completionKind.name().toLowerCase(Locale.US) + PNG_EXTENSION); + Image img = null; - if (img == null) { - img = ImageUtilities.loadImage(ICON_BASE + completionKind.name().toLowerCase(Locale.US) + GIF_EXTENSION); + if (completionKind != null) { + img = ImageUtilities.loadImage(ICON_BASE + completionKind.name().toLowerCase(Locale.US) + PNG_EXTENSION); + + if (img == null) { + img = ImageUtilities.loadImage(ICON_BASE + completionKind.name().toLowerCase(Locale.US) + GIF_EXTENSION); + } } if (img == null) { From daf1e61ca0bdcfe81d961ec812b304f9e1f9f2f3 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Sat, 28 Jul 2018 09:42:54 +0200 Subject: [PATCH 05/15] Adding some support for code actions. --- .../modules/lsp/client/LSPBindings.java | 9 + .../lsp/client/bindings/CodeActions.java | 91 ++++++++++ .../client/bindings/LanguageClientImpl.java | 161 +++++++++++++++++- 3 files changed, 255 insertions(+), 6 deletions(-) create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/CodeActions.java diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java b/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java index 0f40497f70a2..da3c9d7e350b 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java +++ b/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java @@ -38,6 +38,7 @@ import org.eclipse.lsp4j.launch.LSPLauncher; import org.eclipse.lsp4j.services.LanguageServer; import org.eclipse.lsp4j.services.TextDocumentService; +import org.eclipse.lsp4j.services.WorkspaceService; import org.netbeans.api.editor.mimelookup.MimeLookup; import org.netbeans.api.progress.*; import org.netbeans.api.project.FileOwnerQuery; @@ -85,9 +86,11 @@ public static LSPBindings getBindings(FileObject file) { LanguageServer server = provider.startServer(prj, lci); if (server != null) { + lci.setServer(server); try { InitializeParams initParams = new InitializeParams(); initParams.setRootUri(prj.getProjectDirectory().toURI().toString()); //XXX: what if a different root is expected???? + initParams.setRootPath(FileUtil.toFile(prj.getProjectDirectory()).getAbsolutePath()); //some servers still expect root path initParams.setProcessId(0); InitializeResult result = server.initialize(initParams).get(); return new LSPBindings(server, result); @@ -122,6 +125,8 @@ public void write(int w) throws IOException { launcher.startListening(); LanguageServer server = launcher.getRemoteProxy(); + lc.setServer(server); + InitializeParams initParams = new InitializeParams(); initParams.setRootUri(root.toURI().toString()); initParams.setProcessId(0); @@ -147,6 +152,10 @@ public TextDocumentService getTextDocumentService() { return server.getTextDocumentService(); } + public WorkspaceService getWorkspaceService() { + return server.getWorkspaceService(); + } + public InitializeResult getInitResult() { //XXX: defenzive copy? return initResult; diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CodeActions.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CodeActions.java new file mode 100644 index 000000000000..8e7e07116f00 --- /dev/null +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/CodeActions.java @@ -0,0 +1,91 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.lsp.client.bindings; + +import java.net.URI; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; +import javax.swing.text.BadLocationException; +import javax.swing.text.JTextComponent; +import org.eclipse.lsp4j.CodeActionContext; +import org.eclipse.lsp4j.CodeActionParams; +import org.eclipse.lsp4j.Command; +import org.eclipse.lsp4j.ExecuteCommandParams; +import org.eclipse.lsp4j.Range; +import org.eclipse.lsp4j.TextDocumentIdentifier; +import org.netbeans.api.editor.mimelookup.MimeRegistration; +import org.netbeans.modules.editor.NbEditorUtilities; +import org.netbeans.modules.lsp.client.LSPBindings; +import org.netbeans.spi.editor.codegen.CodeGenerator; +import org.openide.filesystems.FileObject; +import org.openide.util.Exceptions; +import org.openide.util.Lookup; + +/** + * + * @author lahvac + */ +@MimeRegistration(mimeType="", service=CodeGenerator.Factory.class) +public class CodeActions implements CodeGenerator.Factory { + + @Override + public List create(Lookup context) { + JTextComponent component = context.lookup(JTextComponent.class); + if (component == null) { + return Collections.emptyList(); + } + FileObject file = NbEditorUtilities.getFileObject(component.getDocument()); + if (file == null) { + return Collections.emptyList(); + } + LSPBindings server = LSPBindings.getBindings(file); + if (server == null) { + return Collections.emptyList(); + } + URI uri = file.toURI(); + try { + List commands = + server.getTextDocumentService().codeAction(new CodeActionParams(new TextDocumentIdentifier(uri.toString()), + new Range(Utils.createPosition(component.getDocument(), component.getSelectionStart()), + Utils.createPosition(component.getDocument(), component.getSelectionEnd())), + new CodeActionContext(Collections.emptyList()))).get(); + return commands.stream().map(cmd -> new CodeGenerator() { + @Override + public String getDisplayName() { + return cmd.getTitle(); + } + + @Override + public void invoke() { + try { + server.getWorkspaceService().executeCommand(new ExecuteCommandParams(cmd.getCommand(), cmd.getArguments())).get(); + } catch (InterruptedException | ExecutionException ex) { + Exceptions.printStackTrace(ex); + } + } + }).collect(Collectors.toList()); + } catch (BadLocationException | InterruptedException | ExecutionException ex) { + Exceptions.printStackTrace(ex); + return Collections.emptyList(); + } + } + +} diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java index 453b2230cafa..4403a0734a7a 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java @@ -18,32 +18,55 @@ */ package org.netbeans.modules.lsp.client.bindings; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.io.IOException; import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; +import java.util.Collections; import java.util.EnumMap; import java.util.List; import java.util.Map; +import java.util.Map.Entry; import java.util.concurrent.CompletableFuture; +import java.util.concurrent.ExecutionException; import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; +import javax.swing.text.BadLocationException; import javax.swing.text.Document; +import javax.swing.text.StyledDocument; +import org.eclipse.lsp4j.ApplyWorkspaceEditParams; +import org.eclipse.lsp4j.ApplyWorkspaceEditResponse; +import org.eclipse.lsp4j.CodeActionContext; +import org.eclipse.lsp4j.CodeActionParams; +import org.eclipse.lsp4j.Command; import org.eclipse.lsp4j.Diagnostic; import org.eclipse.lsp4j.DiagnosticSeverity; +import org.eclipse.lsp4j.ExecuteCommandParams; import org.eclipse.lsp4j.MessageActionItem; import org.eclipse.lsp4j.MessageParams; import org.eclipse.lsp4j.PublishDiagnosticsParams; import org.eclipse.lsp4j.ShowMessageRequestParams; +import org.eclipse.lsp4j.TextDocumentIdentifier; +import org.eclipse.lsp4j.TextEdit; +import org.eclipse.lsp4j.WorkspaceEdit; import org.eclipse.lsp4j.services.LanguageClient; +import org.eclipse.lsp4j.services.LanguageServer; +import org.netbeans.spi.editor.hints.ChangeInfo; import org.netbeans.spi.editor.hints.ErrorDescription; import org.netbeans.spi.editor.hints.ErrorDescriptionFactory; +import org.netbeans.spi.editor.hints.Fix; import org.netbeans.spi.editor.hints.HintsController; +import org.netbeans.spi.editor.hints.LazyFixList; import org.netbeans.spi.editor.hints.Severity; import org.openide.cookies.EditorCookie; import org.openide.filesystems.FileObject; import org.openide.filesystems.URLMapper; +import org.openide.text.NbDocument; import org.openide.util.Exceptions; +import org.openide.util.RequestProcessor; /** * @@ -52,6 +75,13 @@ public class LanguageClientImpl implements LanguageClient { private static final Logger LOG = Logger.getLogger(LanguageClientImpl.class.getName()); + private static final RequestProcessor WORKER = new RequestProcessor(LanguageClientImpl.class.getName(), 1, false, false); + + private LanguageServer server; + + public void setServer(LanguageServer server) { + this.server = server; + } @Override public void telemetryEvent(Object arg0) { @@ -59,22 +89,20 @@ public void telemetryEvent(Object arg0) { } @Override - public void publishDiagnostics(PublishDiagnosticsParams arg0) { + public void publishDiagnostics(PublishDiagnosticsParams pdp) { try { - FileObject file = URLMapper.findFileObject(new URI(arg0.getUri()).toURL()); + FileObject file = URLMapper.findFileObject(new URI(pdp.getUri()).toURL()); EditorCookie ec = file.getLookup().lookup(EditorCookie.class); Document doc = ec != null ? ec.getDocument() : null; if (doc == null) return ; //ignore... - List diags = arg0.getDiagnostics().stream().map(d -> - ErrorDescriptionFactory.createErrorDescription(severityMap.get(d.getSeverity()), d.getMessage(), file, Utils.getOffset(doc, d.getRange().getStart()), Utils.getOffset(doc, d.getRange().getEnd())) + List diags = pdp.getDiagnostics().stream().map(d -> + ErrorDescriptionFactory.createErrorDescription(severityMap.get(d.getSeverity()), d.getMessage(), new DiagnosticFixList(pdp.getUri(), d), file, Utils.getOffset(doc, d.getRange().getStart()), Utils.getOffset(doc, d.getRange().getEnd())) ).collect(Collectors.toList()); HintsController.setErrors(doc, LanguageClientImpl.class.getName(), diags); } catch (URISyntaxException | MalformedURLException ex) { LOG.log(Level.FINE, null, ex); } - System.err.println("arg0: " + arg0.getDiagnostics().size()); - System.err.println("publishDiagnostics: " + arg0); } private static final Map severityMap = new EnumMap<>(DiagnosticSeverity.class); @@ -86,6 +114,39 @@ public void publishDiagnostics(PublishDiagnosticsParams arg0) { severityMap.put(DiagnosticSeverity.Warning, Severity.HINT); } + @Override + public CompletableFuture applyEdit(ApplyWorkspaceEditParams params) { + WorkspaceEdit edit = params.getEdit(); + for (Entry> e : edit.getChanges().entrySet()) { + try { + FileObject file = URLMapper.findFileObject(new URI(e.getKey()).toURL()); + EditorCookie ec = file.getLookup().lookup(EditorCookie.class); + Document doc = ec != null ? ec.openDocument() : null; + if (doc == null) { + continue; + } + NbDocument.runAtomic((StyledDocument) doc, () -> { + e.getValue() + .stream() + .sorted((te1, te2) -> te1.getRange().getEnd().getLine() == te2.getRange().getEnd().getLine() ? te1.getRange().getEnd().getCharacter() - te2.getRange().getEnd().getCharacter() : te1.getRange().getEnd().getLine() - te2.getRange().getEnd().getLine()) + .forEach(te -> { + try { + int start = Utils.getOffset(doc, te.getRange().getStart()); + int end = Utils.getOffset(doc, te.getRange().getEnd()); + doc.remove(start, end - start); + doc.insertString(start, te.getNewText(), null); + } catch (BadLocationException ex) { + Exceptions.printStackTrace(ex); + } + }); + }); + } catch (URISyntaxException | IOException ex) { + Exceptions.printStackTrace(ex); + } + } + return CompletableFuture.completedFuture(new ApplyWorkspaceEditResponse(true)); + } + @Override public void showMessage(MessageParams arg0) { System.err.println("showMessage: " + arg0); @@ -102,4 +163,92 @@ public void logMessage(MessageParams arg0) { System.err.println("logMessage: " + arg0); } + private final class DiagnosticFixList implements LazyFixList { + + private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); + private final String fileUri; + private final Diagnostic diagnostic; + private List fixes; + private boolean computing; + private boolean computed; + + public DiagnosticFixList(String fileUri, Diagnostic diagnostic) { + this.fileUri = fileUri; + this.diagnostic = diagnostic; + } + + @Override + public void addPropertyChangeListener(PropertyChangeListener l) { + pcs.addPropertyChangeListener(l); + } + + @Override + public void removePropertyChangeListener(PropertyChangeListener l) { + pcs.removePropertyChangeListener(l); + } + + @Override + public boolean probablyContainsFixes() { + return true; + } + + @Override + public synchronized List getFixes() { + if (!computing && !computed) { + computing = true; + WORKER.post(() -> { + try { + List commands = + server.getTextDocumentService().codeAction(new CodeActionParams(new TextDocumentIdentifier(fileUri), + diagnostic.getRange(), + new CodeActionContext(Collections.singletonList(diagnostic)))).get(); + List fixes = commands.stream() + .map(cmd -> new CommandBasedFix(cmd)) + .collect(Collectors.toList()); + synchronized (this) { + this.fixes = Collections.unmodifiableList(fixes); + this.computed = true; + this.computing = false; + } + pcs.firePropertyChange(PROP_COMPUTED, null, null); + pcs.firePropertyChange(PROP_FIXES, null, null); + } catch (InterruptedException | ExecutionException ex) { + Exceptions.printStackTrace(ex); + } + }); + } + return fixes; + } + + @Override + public synchronized boolean isComputed() { + return computed; + } + + private class CommandBasedFix implements Fix { + + private final Command cmd; + + public CommandBasedFix(Command cmd) { + this.cmd = cmd; + } + + @Override + public String getText() { + return cmd.getTitle(); + } + + @Override + public ChangeInfo implement() throws Exception { + try { + server.getWorkspaceService().executeCommand(new ExecuteCommandParams(cmd.getCommand(), cmd.getArguments())).get(); + } catch (InterruptedException | ExecutionException ex) { + Exceptions.printStackTrace(ex); + } + + return null; + } + } + + } } From 93d8972cef6d470462da5824ea2025691e26db93 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Mon, 30 Jul 2018 07:07:35 +0200 Subject: [PATCH 06/15] First sketch of navigagor implemented using textDocument/documentSymbol. --- lsp.client/nbproject/project.xml | 17 ++ .../modules/lsp/client/LSPBindings.java | 47 ++++- .../modules/lsp/client/bindings/Icons.java | 12 ++ .../client/bindings/LanguageClientImpl.java | 17 +- .../client/bindings/NavigatorPanelImpl.java | 168 ++++++++++++++++++ spi.navigator/apichanges.xml | 15 ++ spi.navigator/manifest.mf | 2 +- spi.navigator/nbproject/project.properties | 2 +- spi.navigator/nbproject/project.xml | 19 +- .../navigator/NavigatorController.java | 4 +- .../modules/navigator/ProviderRegistry.java | 30 +++- .../spi/navigator/NavigatorPanel.java | 22 +++ .../navigator/ProviderRegistryTest.java | 6 +- 13 files changed, 332 insertions(+), 29 deletions(-) create mode 100644 lsp.client/src/org/netbeans/modules/lsp/client/bindings/NavigatorPanelImpl.java diff --git a/lsp.client/nbproject/project.xml b/lsp.client/nbproject/project.xml index 40d3b6fafd2c..054fc913d50e 100644 --- a/lsp.client/nbproject/project.xml +++ b/lsp.client/nbproject/project.xml @@ -113,6 +113,15 @@ 1.45
+ + org.netbeans.spi.navigator + + + + 1 + 1.40 + + org.openide.awt @@ -129,6 +138,14 @@ 7.45 + + org.openide.explorer + + + + 6.65 + + org.openide.filesystems diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java b/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java index da3c9d7e350b..7f674b308f85 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java +++ b/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java @@ -23,8 +23,10 @@ import java.io.OutputStream; import java.net.InetAddress; import java.net.Socket; +import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.WeakHashMap; @@ -49,6 +51,7 @@ import org.openide.filesystems.FileUtil; import org.openide.util.Exceptions; import org.openide.util.NbBundle.Messages; +import org.openide.util.RequestProcessor; /** * @@ -56,8 +59,11 @@ */ public class LSPBindings { + private static final RequestProcessor WORKER = new RequestProcessor(LanguageClientImpl.class.getName(), 1, false, false); + private static final Map> project2MimeType2Server = new WeakHashMap<>(); - private static final Map> workspace2Extension2Server = new WeakHashMap<>(); + private static final Map> workspace2Extension2Server = new HashMap<>(); + private final Map> backgroundTasks = new WeakHashMap<>(); public static LSPBindings getBindings(FileObject file) { for (Entry> e : workspace2Extension2Server.entrySet()) { @@ -86,14 +92,15 @@ public static LSPBindings getBindings(FileObject file) { LanguageServer server = provider.startServer(prj, lci); if (server != null) { - lci.setServer(server); try { InitializeParams initParams = new InitializeParams(); initParams.setRootUri(prj.getProjectDirectory().toURI().toString()); //XXX: what if a different root is expected???? initParams.setRootPath(FileUtil.toFile(prj.getProjectDirectory()).getAbsolutePath()); //some servers still expect root path initParams.setProcessId(0); InitializeResult result = server.initialize(initParams).get(); - return new LSPBindings(server, result); + LSPBindings b = new LSPBindings(server, result); + lci.setBindings(b); + return b; } catch (InterruptedException | ExecutionException ex) { LOG.log(Level.FINE, null, ex); } @@ -125,14 +132,14 @@ public void write(int w) throws IOException { launcher.startListening(); LanguageServer server = launcher.getRemoteProxy(); - lc.setServer(server); - InitializeParams initParams = new InitializeParams(); initParams.setRootUri(root.toURI().toString()); initParams.setProcessId(0); InitializeResult result = server.initialize(initParams).get(); LSPBindings bindings = new LSPBindings(server, result); + lc.setBindings(bindings); + workspace2Extension2Server.put(root, Arrays.stream(extensions).collect(Collectors.toMap(k -> k, v -> bindings))); } catch (InterruptedException | ExecutionException | IOException ex) { Exceptions.printStackTrace(ex); @@ -161,4 +168,34 @@ public InitializeResult getInitResult() { return initResult; } + public static void addBackgroundTask(FileObject file, BackgroundTask task) { + LSPBindings bindings = getBindings(file); + + if (bindings == null) + return ; + + bindings.backgroundTasks.computeIfAbsent(file, f -> new ArrayList<>()).add(task); + bindings.runOnBackground(() -> task.run(bindings, file)); + } + + public static void removeBackgroundTask(FileObject file, BackgroundTask task) { + LSPBindings bindings = getBindings(file); + + if (bindings == null) + return ; + + bindings.backgroundTasks.computeIfAbsent(file, f -> new ArrayList<>()).remove(task); + } + + public void runOnBackground(Runnable r) { + WORKER.post(r); + } + + public void runBackgroundTasks(FileObject file) { + backgroundTasks.computeIfAbsent(file, f -> new ArrayList<>()).stream().forEach(bt -> runOnBackground(() -> bt.run(this, file))); + } + + public interface BackgroundTask { + public void run(LSPBindings bindings, FileObject file); + } } diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Icons.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Icons.java index 56eca531f5de..d2543341da38 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Icons.java +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/Icons.java @@ -24,6 +24,7 @@ import javax.swing.Icon; import javax.swing.ImageIcon; import org.eclipse.lsp4j.CompletionItemKind; +import org.eclipse.lsp4j.SymbolKind; import org.openide.util.ImageUtilities; /** @@ -59,4 +60,15 @@ public static Icon getCompletionIcon(CompletionItemKind completionKind) { } + public static String getSymbolIconBase(SymbolKind symbolKind) { + for (String variant : new String[] { + ICON_BASE + symbolKind.name().toLowerCase(Locale.US) + PNG_EXTENSION, + ICON_BASE + symbolKind.name().toLowerCase(Locale.US) + GIF_EXTENSION, + ICON_BASE + "variable" + GIF_EXTENSION + }) { + if (ImageUtilities.loadImage(variant) != null) + return variant; + } + return null; + } } diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java index 4403a0734a7a..0f77634759f3 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java @@ -53,7 +53,7 @@ import org.eclipse.lsp4j.TextEdit; import org.eclipse.lsp4j.WorkspaceEdit; import org.eclipse.lsp4j.services.LanguageClient; -import org.eclipse.lsp4j.services.LanguageServer; +import org.netbeans.modules.lsp.client.LSPBindings; import org.netbeans.spi.editor.hints.ChangeInfo; import org.netbeans.spi.editor.hints.ErrorDescription; import org.netbeans.spi.editor.hints.ErrorDescriptionFactory; @@ -66,7 +66,6 @@ import org.openide.filesystems.URLMapper; import org.openide.text.NbDocument; import org.openide.util.Exceptions; -import org.openide.util.RequestProcessor; /** * @@ -75,12 +74,11 @@ public class LanguageClientImpl implements LanguageClient { private static final Logger LOG = Logger.getLogger(LanguageClientImpl.class.getName()); - private static final RequestProcessor WORKER = new RequestProcessor(LanguageClientImpl.class.getName(), 1, false, false); - private LanguageServer server; + private LSPBindings bindings; - public void setServer(LanguageServer server) { - this.server = server; + public void setBindings(LSPBindings bindings) { + this.bindings = bindings; } @Override @@ -100,6 +98,7 @@ public void publishDiagnostics(PublishDiagnosticsParams pdp) { ErrorDescriptionFactory.createErrorDescription(severityMap.get(d.getSeverity()), d.getMessage(), new DiagnosticFixList(pdp.getUri(), d), file, Utils.getOffset(doc, d.getRange().getStart()), Utils.getOffset(doc, d.getRange().getEnd())) ).collect(Collectors.toList()); HintsController.setErrors(doc, LanguageClientImpl.class.getName(), diags); + bindings.runBackgroundTasks(file); } catch (URISyntaxException | MalformedURLException ex) { LOG.log(Level.FINE, null, ex); } @@ -196,10 +195,10 @@ public boolean probablyContainsFixes() { public synchronized List getFixes() { if (!computing && !computed) { computing = true; - WORKER.post(() -> { + bindings.runOnBackground(() -> { try { List commands = - server.getTextDocumentService().codeAction(new CodeActionParams(new TextDocumentIdentifier(fileUri), + bindings.getTextDocumentService().codeAction(new CodeActionParams(new TextDocumentIdentifier(fileUri), diagnostic.getRange(), new CodeActionContext(Collections.singletonList(diagnostic)))).get(); List fixes = commands.stream() @@ -241,7 +240,7 @@ public String getText() { @Override public ChangeInfo implement() throws Exception { try { - server.getWorkspaceService().executeCommand(new ExecuteCommandParams(cmd.getCommand(), cmd.getArguments())).get(); + bindings.getWorkspaceService().executeCommand(new ExecuteCommandParams(cmd.getCommand(), cmd.getArguments())).get(); } catch (InterruptedException | ExecutionException ex) { Exceptions.printStackTrace(ex); } diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/NavigatorPanelImpl.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/NavigatorPanelImpl.java new file mode 100644 index 000000000000..78549dc16404 --- /dev/null +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/NavigatorPanelImpl.java @@ -0,0 +1,168 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.lsp.client.bindings; + +import java.awt.BorderLayout; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.swing.JComponent; +import javax.swing.JPanel; +import org.eclipse.lsp4j.DocumentSymbolParams; +import org.eclipse.lsp4j.SymbolInformation; +import org.eclipse.lsp4j.TextDocumentIdentifier; +import org.netbeans.modules.lsp.client.LSPBindings; +import org.netbeans.modules.lsp.client.LSPBindings.BackgroundTask; +import org.netbeans.spi.navigator.NavigatorPanel; +import org.openide.explorer.ExplorerManager; +import org.openide.explorer.view.BeanTreeView; +import org.openide.filesystems.FileObject; +import org.openide.nodes.AbstractNode; +import org.openide.nodes.Children; +import org.openide.nodes.Node; +import org.openide.util.Exceptions; +import org.openide.util.Lookup; +import org.openide.util.LookupEvent; +import org.openide.util.LookupListener; +import org.openide.util.NbBundle.Messages; +import org.openide.util.lookup.ServiceProvider; + +/** + * + * @author lahvac + */ +public class NavigatorPanelImpl extends Children.Keys implements NavigatorPanel, BackgroundTask, LookupListener { + + private static final NavigatorPanelImpl INSTANCE = new NavigatorPanelImpl(); + + private final ExplorerManager manager; + private JComponent view; + private Lookup.Result result; + private FileObject file; + + public NavigatorPanelImpl() { + manager = new ExplorerManager(); + manager.setRootContext(new AbstractNode(this)); + } + + @Override + @Messages("DN_Symbols=Symbols") + public String getDisplayName() { + return Bundle.DN_Symbols(); + } + + @Override + public String getDisplayHint() { + return "symbols"; + } + + @Override + public JComponent getComponent() { + if (view == null) { + class View extends JPanel implements ExplorerManager.Provider { + + public View() { + setLayout(new BorderLayout()); + BeanTreeView btv = new BeanTreeView(); + add(btv, BorderLayout.CENTER); + + btv.setRootVisible(false); + } + + @Override + public ExplorerManager getExplorerManager() { + return manager; + } + } + view = new View(); + } + return view; + } + + @Override + public void panelActivated(Lookup context) { + result = context.lookupResult(FileObject.class); + result.addLookupListener(this); + updateFile(); + } + + @Override + public void panelDeactivated() { + result.removeLookupListener(this); + result = null; + updateFile(); + } + + private void updateFile() { + if (file != null) { + LSPBindings.removeBackgroundTask(file, this); + setKeys(Collections.emptyList()); + file = null; + } + Collection files = result != null ? result.allInstances() : Collections.emptyList(); + file = files.isEmpty() ? null : files.iterator().next(); + if (file != null) { + LSPBindings.addBackgroundTask(file, this); + } + } + + @Override + public Lookup getLookup() { + return Lookup.EMPTY; + } + + @Override + public void run(LSPBindings bindings, FileObject file) { + if (file.equals(this.file)) { + try { + List symbols = bindings.getTextDocumentService().documentSymbol(new DocumentSymbolParams(new TextDocumentIdentifier(file.toURI().toString()))).get(); + + setKeys(symbols); + } catch (InterruptedException | ExecutionException ex) { + Exceptions.printStackTrace(ex); + } + } else { + System.err.println("!!!"); + } + } + + @Override + protected Node[] createNodes(SymbolInformation sym) { + AbstractNode n = new AbstractNode(LEAF); + n.setDisplayName(sym.getName()); + n.setIconBaseWithExtension(Icons.getSymbolIconBase(sym.getKind())); + return new Node[] {n}; + } + + @Override + public void resultChanged(LookupEvent arg0) { + updateFile(); + } + + @ServiceProvider(service=DynamicRegistration.class) + public static final class DynamicRegistrationImpl implements DynamicRegistration { + + @Override + public Collection panelsFor(FileObject file) { + return LSPBindings.getBindings(file) != null ? Collections.singletonList(INSTANCE) : Collections.emptyList(); + } + + } +} diff --git a/spi.navigator/apichanges.xml b/spi.navigator/apichanges.xml index c25649b4057f..9c0578ae6ff6 100644 --- a/spi.navigator/apichanges.xml +++ b/spi.navigator/apichanges.xml @@ -83,6 +83,21 @@ is the proper place. + + + Added SPI interface NavigatorPanel.DynamicRegistration + + + + + +

+ Added SPI interface NavigatorPanel.DynamicRegistration to + allow dynamic registration of NavigatorPanels. +

+
+ +
Added SPI interface NavigatorPanelWithToolbar diff --git a/spi.navigator/manifest.mf b/spi.navigator/manifest.mf index 65c1eef3621b..74b9b2608c09 100644 --- a/spi.navigator/manifest.mf +++ b/spi.navigator/manifest.mf @@ -2,4 +2,4 @@ Manifest-version: 1.0 OpenIDE-Module: org.netbeans.spi.navigator/1 OpenIDE-Module-Layer: org/netbeans/modules/navigator/resources/layer.xml OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/navigator/resources/Bundle.properties -OpenIDE-Module-Specification-Version: 1.40 +OpenIDE-Module-Specification-Version: 1.41 diff --git a/spi.navigator/nbproject/project.properties b/spi.navigator/nbproject/project.properties index 0f4503e8078e..1e6086064420 100644 --- a/spi.navigator/nbproject/project.properties +++ b/spi.navigator/nbproject/project.properties @@ -18,7 +18,7 @@ is.autoload=true javac.compilerargs=-Xlint:unchecked -javac.source=1.6 +javac.source=1.8 javadoc.arch=${basedir}/arch.xml javadoc.apichanges=${basedir}/apichanges.xml diff --git a/spi.navigator/nbproject/project.xml b/spi.navigator/nbproject/project.xml index e0e894d9cce1..d1a6e7431e99 100644 --- a/spi.navigator/nbproject/project.xml +++ b/spi.navigator/nbproject/project.xml @@ -25,6 +25,15 @@ org.netbeans.spi.navigator + + org.netbeans.api.annotations.common + + + + 1 + 1.30 + + org.openide.awt @@ -58,7 +67,7 @@ - org.openide.util.ui + org.openide.util @@ -66,19 +75,19 @@ - org.openide.util + org.openide.util.lookup - 9.3 + 8.0 - org.openide.util.lookup + org.openide.util.ui - 8.0 + 9.3 diff --git a/spi.navigator/src/org/netbeans/modules/navigator/NavigatorController.java b/spi.navigator/src/org/netbeans/modules/navigator/NavigatorController.java index f9b1f9ad3034..e6e2b6c14ff0 100644 --- a/spi.navigator/src/org/netbeans/modules/navigator/NavigatorController.java +++ b/spi.navigator/src/org/netbeans/modules/navigator/NavigatorController.java @@ -555,7 +555,7 @@ private List obtainProviders(Collection nodes, N // search in global lookup first, they had preference for (NavigatorLookupHint curHint : lkpHints) { - Collection providers = ProviderRegistry.getInstance().getProviders(curHint.getContentType()); + Collection providers = ProviderRegistry.getInstance().getProviders(curHint.getContentType(), null); if (providers != null && !providers.isEmpty()) { if (result == null) { result = new ArrayList(providers.size() * lkpHints.size()); @@ -590,7 +590,7 @@ private List obtainProviders(Collection nodes, N } String contentType = fo.getMIMEType(); - Collection providers = ProviderRegistry.getInstance().getProviders(contentType); + Collection providers = ProviderRegistry.getInstance().getProviders(contentType, fo); if (providers == null || providers.isEmpty()) { fileResult = null; break; diff --git a/spi.navigator/src/org/netbeans/modules/navigator/ProviderRegistry.java b/spi.navigator/src/org/netbeans/modules/navigator/ProviderRegistry.java index 1917bdf3ffa6..bdc7ea7d51d3 100644 --- a/spi.navigator/src/org/netbeans/modules/navigator/ProviderRegistry.java +++ b/spi.navigator/src/org/netbeans/modules/navigator/ProviderRegistry.java @@ -19,10 +19,18 @@ package org.netbeans.modules.navigator; +import java.lang.ref.Reference; +import java.lang.ref.SoftReference; +import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; +import java.util.List; import java.util.Map; +import java.util.WeakHashMap; +import java.util.stream.Collectors; import org.netbeans.spi.navigator.NavigatorPanel; +import org.netbeans.spi.navigator.NavigatorPanel.DynamicRegistration; +import org.openide.filesystems.FileObject; import org.openide.util.Lookup; import org.openide.util.lookup.Lookups; @@ -49,6 +57,7 @@ class ProviderRegistry { * no providers. This ensures no useless repetitive searches. */ private Map> contentTypes2Providers; + private Map>> file2Providers; /** Singleton, no external instantiation */ @@ -71,7 +80,7 @@ public static ProviderRegistry getInstance () { * @return Collection of providers, which implements NavigatorPanel interface. * Never return null, only empty List if no provider exists for given content type. */ - public Collection getProviders (String contentType) { + public Collection getProviders (String contentType, FileObject file) { if (contentTypes2Providers == null) { contentTypes2Providers = new HashMap>(15); } @@ -81,8 +90,23 @@ public Collection getProviders (String contentType) { result = loadProviders(contentType); contentTypes2Providers.put(contentType, result); } - - return result; + if (file != null) { + if (file2Providers == null) { + file2Providers = new WeakHashMap<>(); + } + Reference> fileResultRef = file2Providers.computeIfAbsent(file, f -> + new SoftReference<>(Lookup.getDefault().lookupAll(DynamicRegistration.class).stream().flatMap(reg -> reg.panelsFor(file).stream()).collect(Collectors.toList())) + ); + Collection fileResult = fileResultRef != null ? fileResultRef.get() : null; + if (result == null) return fileResult; + if (fileResult == null) return result; + List panels = new ArrayList<>(); + panels.addAll(result); + panels.addAll(fileResult); + return panels; + } else { + return result; + } } /******* private stuff ***********/ diff --git a/spi.navigator/src/org/netbeans/spi/navigator/NavigatorPanel.java b/spi.navigator/src/org/netbeans/spi/navigator/NavigatorPanel.java index 8f248e8170a5..0ac07e46ce28 100644 --- a/spi.navigator/src/org/netbeans/spi/navigator/NavigatorPanel.java +++ b/spi.navigator/src/org/netbeans/spi/navigator/NavigatorPanel.java @@ -23,7 +23,12 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import java.util.Collection; import javax.swing.JComponent; +import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.api.annotations.common.NonNull; +import org.netbeans.api.annotations.common.NullAllowed; +import org.openide.filesystems.FileObject; import org.openide.util.Lookup; /** Navigation related view description. @@ -138,4 +143,21 @@ public interface NavigatorPanel { Registration[] value(); } + /** + * Dynamically create panels for files. + * + * @since 1.41 + */ + interface DynamicRegistration { + + /** + * Dynamically create {@code NavigatorPanel}s for the given file. + * + * @param file for which the panels should be created + * @return a collection of {@code NavigatorPanel}s for the given file + * null is allowed + */ + public @CheckForNull Collection panelsFor(@NonNull FileObject file); + } + } diff --git a/spi.navigator/test/unit/src/org/netbeans/modules/navigator/ProviderRegistryTest.java b/spi.navigator/test/unit/src/org/netbeans/modules/navigator/ProviderRegistryTest.java index fd03cc7472fb..874175d43083 100644 --- a/spi.navigator/test/unit/src/org/netbeans/modules/navigator/ProviderRegistryTest.java +++ b/spi.navigator/test/unit/src/org/netbeans/modules/navigator/ProviderRegistryTest.java @@ -46,13 +46,13 @@ public void testGetProviders () throws Exception { ProviderRegistry providerReg = ProviderRegistry.getInstance(); System.out.println("Asking for non-existent type..."); - assertEquals(0, providerReg.getProviders("image/non_existent_type").size()); + assertEquals(0, providerReg.getProviders("image/non_existent_type", null).size()); System.out.println("Asking for non-existent class..."); - assertEquals(0, providerReg.getProviders("text/plain").size()); + assertEquals(0, providerReg.getProviders("text/plain", null).size()); System.out.println("Asking for valid type and provider..."); - Collection result = providerReg.getProviders(MARVELOUS_DATA_TYPE); + Collection result = providerReg.getProviders(MARVELOUS_DATA_TYPE, null); assertEquals(1, result.size()); NavigatorPanel np = result.iterator().next(); assertTrue(np instanceof MarvelousDataTypeProvider); From e159cbbf26ca8300780c1fed5deefdb87a8fd820 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Tue, 31 Jul 2018 18:23:07 +0200 Subject: [PATCH 07/15] Correcting apichanges.xml --- spi.navigator/apichanges.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spi.navigator/apichanges.xml b/spi.navigator/apichanges.xml index 9c0578ae6ff6..28e50e278c64 100644 --- a/spi.navigator/apichanges.xml +++ b/spi.navigator/apichanges.xml @@ -96,7 +96,7 @@ is the proper place. allow dynamic registration of NavigatorPanels.

- +
From 22878b2412c69cd94f31d046ae230bea9e726dce Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Sat, 1 Sep 2018 09:10:49 +0200 Subject: [PATCH 08/15] Fixing apichanges.xml. --- spi.navigator/apichanges.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spi.navigator/apichanges.xml b/spi.navigator/apichanges.xml index 9c0578ae6ff6..28e50e278c64 100644 --- a/spi.navigator/apichanges.xml +++ b/spi.navigator/apichanges.xml @@ -96,7 +96,7 @@ is the proper place. allow dynamic registration of NavigatorPanels.

- +
From c272ea07b5e60e182b9a70b4ab314ca9712c922f Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Sat, 1 Sep 2018 09:12:13 +0200 Subject: [PATCH 09/15] Do not bind background tasks to diagnostics, but run them actively. --- .../modules/lsp/client/LSPBindings.java | 25 ++++++++++++++----- .../client/bindings/LanguageClientImpl.java | 1 - ...xtDocumentSyncServerCapabilityHandler.java | 3 +++ 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java b/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java index 7f674b308f85..233a8944db8e 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java +++ b/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java @@ -26,6 +26,8 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.IdentityHashMap; +import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -60,10 +62,11 @@ public class LSPBindings { private static final RequestProcessor WORKER = new RequestProcessor(LanguageClientImpl.class.getName(), 1, false, false); + private static final int DELAY = 500; private static final Map> project2MimeType2Server = new WeakHashMap<>(); private static final Map> workspace2Extension2Server = new HashMap<>(); - private final Map> backgroundTasks = new WeakHashMap<>(); + private final Map> backgroundTasks = new WeakHashMap<>(); public static LSPBindings getBindings(FileObject file) { for (Entry> e : workspace2Extension2Server.entrySet()) { @@ -174,8 +177,10 @@ public static void addBackgroundTask(FileObject file, BackgroundTask task) { if (bindings == null) return ; - bindings.backgroundTasks.computeIfAbsent(file, f -> new ArrayList<>()).add(task); - bindings.runOnBackground(() -> task.run(bindings, file)); + RequestProcessor.Task req = WORKER.create(() -> task.run(bindings, file)); + + bindings.backgroundTasks.computeIfAbsent(file, f -> new LinkedHashMap<>()).put(task, req); + bindings.scheduleBackgroundTask(req); } public static void removeBackgroundTask(FileObject file, BackgroundTask task) { @@ -184,15 +189,23 @@ public static void removeBackgroundTask(FileObject file, BackgroundTask task) { if (bindings == null) return ; - bindings.backgroundTasks.computeIfAbsent(file, f -> new ArrayList<>()).remove(task); + RequestProcessor.Task req = bindings.backgroundTasks.computeIfAbsent(file, f -> new LinkedHashMap<>()).remove(task); + + if (req != null) { + req.cancel(); + } } public void runOnBackground(Runnable r) { WORKER.post(r); } - public void runBackgroundTasks(FileObject file) { - backgroundTasks.computeIfAbsent(file, f -> new ArrayList<>()).stream().forEach(bt -> runOnBackground(() -> bt.run(this, file))); + public void scheduleBackgroundTask(RequestProcessor.Task req) { + WORKER.post(req, DELAY); + } + + public void scheduleBackgroundTasks(FileObject file) { + backgroundTasks.computeIfAbsent(file, f -> new IdentityHashMap<>()).values().stream().forEach(this::scheduleBackgroundTask); } public interface BackgroundTask { diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java index 0f77634759f3..4ed1fd5ed0fd 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/LanguageClientImpl.java @@ -98,7 +98,6 @@ public void publishDiagnostics(PublishDiagnosticsParams pdp) { ErrorDescriptionFactory.createErrorDescription(severityMap.get(d.getSeverity()), d.getMessage(), new DiagnosticFixList(pdp.getUri(), d), file, Utils.getOffset(doc, d.getRange().getStart()), Utils.getOffset(doc, d.getRange().getEnd())) ).collect(Collectors.toList()); HintsController.setErrors(doc, LanguageClientImpl.class.getName(), diags); - bindings.runBackgroundTasks(file); } catch (URISyntaxException | MalformedURLException ex) { LOG.log(Level.FINE, null, ex); } diff --git a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/TextDocumentSyncServerCapabilityHandler.java b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/TextDocumentSyncServerCapabilityHandler.java index 1002d256717d..c08a3b900779 100644 --- a/lsp.client/src/org/netbeans/modules/lsp/client/bindings/TextDocumentSyncServerCapabilityHandler.java +++ b/lsp.client/src/org/netbeans/modules/lsp/client/bindings/TextDocumentSyncServerCapabilityHandler.java @@ -46,6 +46,7 @@ /** TODO: asynchronous * TODO: follow the synchronization options + * TODO: close * * @author lahvac */ @@ -85,6 +86,7 @@ private void handleChange() { opened.getDocument().getText(0, opened.getDocument().getLength())); //XXX: should do in render! server.getTextDocumentService().didOpen(new DidOpenTextDocumentParams(textDocumentItem)); + server.scheduleBackgroundTasks(file); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } @@ -128,6 +130,7 @@ private void fireEvent(int start, String newText, String oldText) { VersionedTextDocumentIdentifier di = new VersionedTextDocumentIdentifier(++version); di.setUri(file.toURI().toString()); server.getTextDocumentService().didChange(new DidChangeTextDocumentParams(di, Arrays.asList(event))); + server.scheduleBackgroundTasks(file); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } From a53c4ec871a3785c1f95d064eb92a51ee2572558 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Sat, 1 Sep 2018 11:22:55 +0200 Subject: [PATCH 10/15] Correcting paths. --- ide/libs.lsp/build.xml | 4 ++-- ide/lsp.client/build.xml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ide/libs.lsp/build.xml b/ide/libs.lsp/build.xml index 7b8cdc1347c4..c33fb3a83c5f 100644 --- a/ide/libs.lsp/build.xml +++ b/ide/libs.lsp/build.xml @@ -19,7 +19,7 @@ under the License. --> - + Builds, tests, and runs the project org.netbeans.modules.libs.lsp - + diff --git a/ide/lsp.client/build.xml b/ide/lsp.client/build.xml index b87c9060b3a9..4e726a2fcdce 100644 --- a/ide/lsp.client/build.xml +++ b/ide/lsp.client/build.xml @@ -19,7 +19,7 @@ under the License. --> - + Builds, tests, and runs the project org.netbeans.modules.lsp.client - + From 0733bfa50a2ab70c06f3c3b65067a6f0276de801 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Tue, 11 Sep 2018 07:18:09 +0200 Subject: [PATCH 11/15] Making Gson a separate library, reusing existing Guava. --- ide/c.google.gson/external/binaries-list | 17 ++ .../external/gson-2.7-license.txt | 0 ide/c.google.gson/manifest.mf | 1 + .../nbproject/project.properties | 19 ++ ide/c.google.gson/nbproject/project.xml | 35 +++ ide/libs.lsp/external/binaries-list | 2 - ide/libs.lsp/external/guava-21.0-license.txt | 207 ------------------ ide/libs.lsp/nbproject/project.properties | 2 - ide/libs.lsp/nbproject/project.xml | 39 ++-- nbbuild/cluster.properties | 1 + 10 files changed, 91 insertions(+), 232 deletions(-) create mode 100644 ide/c.google.gson/external/binaries-list rename ide/{libs.lsp => c.google.gson}/external/gson-2.7-license.txt (100%) create mode 100644 ide/c.google.gson/manifest.mf create mode 100644 ide/c.google.gson/nbproject/project.properties create mode 100644 ide/c.google.gson/nbproject/project.xml delete mode 100644 ide/libs.lsp/external/guava-21.0-license.txt diff --git a/ide/c.google.gson/external/binaries-list b/ide/c.google.gson/external/binaries-list new file mode 100644 index 000000000000..2a9ea93cf0f3 --- /dev/null +++ b/ide/c.google.gson/external/binaries-list @@ -0,0 +1,17 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +751F548C85FA49F330CECBB1875893F971B33C4E com.google.code.gson:gson:2.7 diff --git a/ide/libs.lsp/external/gson-2.7-license.txt b/ide/c.google.gson/external/gson-2.7-license.txt similarity index 100% rename from ide/libs.lsp/external/gson-2.7-license.txt rename to ide/c.google.gson/external/gson-2.7-license.txt diff --git a/ide/c.google.gson/manifest.mf b/ide/c.google.gson/manifest.mf new file mode 100644 index 000000000000..d7be9782ae3a --- /dev/null +++ b/ide/c.google.gson/manifest.mf @@ -0,0 +1 @@ +OpenIDE-Module: com.google.gson diff --git a/ide/c.google.gson/nbproject/project.properties b/ide/c.google.gson/nbproject/project.properties new file mode 100644 index 000000000000..3711b8b23300 --- /dev/null +++ b/ide/c.google.gson/nbproject/project.properties @@ -0,0 +1,19 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +release.external/gson-2.7.jar=modules/com-google-gson.jar +is.autoload=true +nbm.module.author=Jan Lahoda diff --git a/ide/c.google.gson/nbproject/project.xml b/ide/c.google.gson/nbproject/project.xml new file mode 100644 index 000000000000..6a98f49b13b2 --- /dev/null +++ b/ide/c.google.gson/nbproject/project.xml @@ -0,0 +1,35 @@ + + + + org.netbeans.modules.apisupport.project + + + com.google.gson + + + + com-google-gson.jar + external/gson-2.7.jar + + + + \ No newline at end of file diff --git a/ide/libs.lsp/external/binaries-list b/ide/libs.lsp/external/binaries-list index d910a1107d41..248d43aea260 100644 --- a/ide/libs.lsp/external/binaries-list +++ b/ide/libs.lsp/external/binaries-list @@ -15,8 +15,6 @@ # specific language governing permissions and limitations # under the License. -751F548C85FA49F330CECBB1875893F971B33C4E com.google.code.gson:gson:2.7 -3A3D111BE1BE1B745EDFA7D91678A12D7ED38709 com.google.guava:guava:21.0 90E34B7C7E0257E3993CA5A939AE94F889D31340 org.eclipse.lsp4j:org.eclipse.lsp4j:0.4.1 467F27E91FD694C05EB663532F2EDE0404025AFE org.eclipse.lsp4j:org.eclipse.lsp4j.generator:0.4.1 F3F93F50BBEB7D58B50E6FFCA615CBFC76491846 org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.4.1 diff --git a/ide/libs.lsp/external/guava-21.0-license.txt b/ide/libs.lsp/external/guava-21.0-license.txt deleted file mode 100644 index a6b8f3b15227..000000000000 --- a/ide/libs.lsp/external/guava-21.0-license.txt +++ /dev/null @@ -1,207 +0,0 @@ -Name: Guava -Description: Google Core Libraries for Java -Origin: GitHub -Version: 21.0 -License: Apache-2.0 - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/ide/libs.lsp/nbproject/project.properties b/ide/libs.lsp/nbproject/project.properties index b9b1c6c11fc7..95fb221a789b 100644 --- a/ide/libs.lsp/nbproject/project.properties +++ b/ide/libs.lsp/nbproject/project.properties @@ -17,8 +17,6 @@ javac.source=1.7 javac.compilerargs=-Xlint -Xlint:-serial -release.external/gson-2.7.jar=modules/ext/gson-2.7.jar -release.external/guava-21.0.jar=modules/ext/guava-21.0.jar release.external/org.eclipse.lsp4j-0.4.1.jar=modules/ext/org.eclipse.lsp4j-0.4.1.jar release.external/org.eclipse.lsp4j.generator-0.4.1.jar=modules/ext/org.eclipse.lsp4j.generator-0.4.1.jar release.external/org.eclipse.lsp4j.jsonrpc-0.4.1.jar=modules/ext/org.eclipse.lsp4j.jsonrpc-0.4.1.jar diff --git a/ide/libs.lsp/nbproject/project.xml b/ide/libs.lsp/nbproject/project.xml index 64b201636b3a..9035a23045c6 100644 --- a/ide/libs.lsp/nbproject/project.xml +++ b/ide/libs.lsp/nbproject/project.xml @@ -24,26 +24,27 @@ org.netbeans.modules.libs.lsp - + + + com.google.gson + + + + 2.7 + + + + com.google.guava + + + + 15.0 + + + org.netbeans.modules.kotlin.support org.netbeans.modules.lsp.client - com.google.common.annotations - com.google.common.base - com.google.common.cache - com.google.common.collect - com.google.common.escape - com.google.common.eventbus - com.google.common.graph - com.google.common.hash - com.google.common.html - com.google.common.io - com.google.common.math - com.google.common.net - com.google.common.primitives - com.google.common.reflect - com.google.common.util.concurrent - com.google.common.xml org.eclipse.lsp4j org.eclipse.lsp4j.jsonrpc org.eclipse.lsp4j.jsonrpc.messages @@ -62,10 +63,6 @@ ext/gson-2.7.jar external/gson-2.7.jar - - ext/guava-21.0.jar - external/guava-21.0.jar - ext/org.eclipse.lsp4j.generator-0.4.1.jar external/org.eclipse.lsp4j.generator-0.4.1.jar diff --git a/nbbuild/cluster.properties b/nbbuild/cluster.properties index fabfd3dbef1e..93b53be28d3a 100644 --- a/nbbuild/cluster.properties +++ b/nbbuild/cluster.properties @@ -287,6 +287,7 @@ nb.cluster.ide=\ bugtracking.bridge,\ bugtracking.commons,\ bugzilla,\ + c.google.gson,\ c.google.guava,\ c.googlecode.javaewah.JavaEWAH,\ c.jcraft.jsch,\ From 345cd76bf53d7c9c00b86cd4a6892fb2a7ac2b19 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Tue, 11 Sep 2018 20:54:45 +0200 Subject: [PATCH 12/15] Adding forgotten build.xml, and removing extraneous class path extension, as noted by jtulach. --- ide/c.google.gson/build.xml | 25 +++++++++++++++++++++++++ ide/libs.lsp/nbproject/project.xml | 4 ---- 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 ide/c.google.gson/build.xml diff --git a/ide/c.google.gson/build.xml b/ide/c.google.gson/build.xml new file mode 100644 index 000000000000..85cd7c905428 --- /dev/null +++ b/ide/c.google.gson/build.xml @@ -0,0 +1,25 @@ + + + + + + \ No newline at end of file diff --git a/ide/libs.lsp/nbproject/project.xml b/ide/libs.lsp/nbproject/project.xml index 9035a23045c6..c545360d61fb 100644 --- a/ide/libs.lsp/nbproject/project.xml +++ b/ide/libs.lsp/nbproject/project.xml @@ -59,10 +59,6 @@ ext/org.eclipse.xtend.lib.macro-2.14.0.jar external/org.eclipse.xtend.lib.macro-2.14.0.jar - - ext/gson-2.7.jar - external/gson-2.7.jar - ext/org.eclipse.lsp4j.generator-0.4.1.jar external/org.eclipse.lsp4j.generator-0.4.1.jar From 4ba531e3f84cb5ce2da991081fabab2c430b59df Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Tue, 11 Sep 2018 22:26:47 +0200 Subject: [PATCH 13/15] Avoid libs.lsp, avoid using lsp4j in SPI, adding test for navigator. --- ide/libs.lsp/build.xml | 25 ------ ide/libs.lsp/manifest.mf | 6 -- ide/libs.lsp/nbproject/project.properties | 25 ------ ide/libs.lsp/nbproject/project.xml | 80 ------------------- .../modules/libs/lsp/Bundle.properties | 18 ----- .../external/binaries-list | 0 .../external/lsp4j-0.4.1-license.txt | 0 .../external/xtend-2.14.0-license.txt | 0 ide/lsp.client/nbproject/project.properties | 6 ++ ide/lsp.client/nbproject/project.xml | 57 +++++++++++-- .../modules/lsp/client/LSPBindings.java | 12 ++- .../LanguageServerProviderAccessor.java | 54 +++++++++++++ .../client/bindings/NavigatorPanelImpl.java | 17 +++- .../client/spi/LanguageServerProvider.java | 40 +++++++++- .../modules/navigator/ProviderRegistry.java | 4 +- .../spi/navigator/NavigatorPanel.java | 5 +- .../navigator/ProviderRegistryTest.java | 34 ++++++++ nbbuild/cluster.properties | 1 - 18 files changed, 210 insertions(+), 174 deletions(-) delete mode 100644 ide/libs.lsp/build.xml delete mode 100644 ide/libs.lsp/manifest.mf delete mode 100644 ide/libs.lsp/nbproject/project.properties delete mode 100644 ide/libs.lsp/nbproject/project.xml delete mode 100644 ide/libs.lsp/src/org/netbeans/modules/libs/lsp/Bundle.properties rename ide/{libs.lsp => lsp.client}/external/binaries-list (100%) rename ide/{libs.lsp => lsp.client}/external/lsp4j-0.4.1-license.txt (100%) rename ide/{libs.lsp => lsp.client}/external/xtend-2.14.0-license.txt (100%) create mode 100644 ide/lsp.client/src/org/netbeans/modules/lsp/client/LanguageServerProviderAccessor.java diff --git a/ide/libs.lsp/build.xml b/ide/libs.lsp/build.xml deleted file mode 100644 index c33fb3a83c5f..000000000000 --- a/ide/libs.lsp/build.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - Builds, tests, and runs the project org.netbeans.modules.libs.lsp - - diff --git a/ide/libs.lsp/manifest.mf b/ide/libs.lsp/manifest.mf deleted file mode 100644 index 2aaca82e5451..000000000000 --- a/ide/libs.lsp/manifest.mf +++ /dev/null @@ -1,6 +0,0 @@ -Manifest-Version: 1.0 -AutoUpdate-Show-In-Client: true -OpenIDE-Module: org.netbeans.modules.libs.lsp -OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/libs/lsp/Bundle.properties -OpenIDE-Module-Specification-Version: 1.0 - diff --git a/ide/libs.lsp/nbproject/project.properties b/ide/libs.lsp/nbproject/project.properties deleted file mode 100644 index 95fb221a789b..000000000000 --- a/ide/libs.lsp/nbproject/project.properties +++ /dev/null @@ -1,25 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -javac.source=1.7 -javac.compilerargs=-Xlint -Xlint:-serial -release.external/org.eclipse.lsp4j-0.4.1.jar=modules/ext/org.eclipse.lsp4j-0.4.1.jar -release.external/org.eclipse.lsp4j.generator-0.4.1.jar=modules/ext/org.eclipse.lsp4j.generator-0.4.1.jar -release.external/org.eclipse.lsp4j.jsonrpc-0.4.1.jar=modules/ext/org.eclipse.lsp4j.jsonrpc-0.4.1.jar -release.external/org.eclipse.xtend.lib-2.14.0.jar=modules/ext/org.eclipse.xtend.lib-2.14.0.jar -release.external/org.eclipse.xtend.lib.macro-2.14.0.jar=modules/ext/org.eclipse.xtend.lib.macro-2.14.0.jar -release.external/org.eclipse.xtext.xbase.lib-2.14.0.jar=modules/ext/org.eclipse.xtext.xbase.lib-2.14.0.jar diff --git a/ide/libs.lsp/nbproject/project.xml b/ide/libs.lsp/nbproject/project.xml deleted file mode 100644 index c545360d61fb..000000000000 --- a/ide/libs.lsp/nbproject/project.xml +++ /dev/null @@ -1,80 +0,0 @@ - - - - org.netbeans.modules.apisupport.project - - - org.netbeans.modules.libs.lsp - - - com.google.gson - - - - 2.7 - - - - com.google.guava - - - - 15.0 - - - - - org.netbeans.modules.kotlin.support - org.netbeans.modules.lsp.client - org.eclipse.lsp4j - org.eclipse.lsp4j.jsonrpc - org.eclipse.lsp4j.jsonrpc.messages - org.eclipse.lsp4j.launch - org.eclipse.lsp4j.services - - - ext/org.eclipse.lsp4j-0.4.1.jar - external/org.eclipse.lsp4j-0.4.1.jar - - - ext/org.eclipse.xtend.lib.macro-2.14.0.jar - external/org.eclipse.xtend.lib.macro-2.14.0.jar - - - ext/org.eclipse.lsp4j.generator-0.4.1.jar - external/org.eclipse.lsp4j.generator-0.4.1.jar - - - ext/org.eclipse.xtend.lib-2.14.0.jar - external/org.eclipse.xtend.lib-2.14.0.jar - - - ext/org.eclipse.xtext.xbase.lib-2.14.0.jar - external/org.eclipse.xtext.xbase.lib-2.14.0.jar - - - ext/org.eclipse.lsp4j.jsonrpc-0.4.1.jar - external/org.eclipse.lsp4j.jsonrpc-0.4.1.jar - - - - diff --git a/ide/libs.lsp/src/org/netbeans/modules/libs/lsp/Bundle.properties b/ide/libs.lsp/src/org/netbeans/modules/libs/lsp/Bundle.properties deleted file mode 100644 index 0f425aacdece..000000000000 --- a/ide/libs.lsp/src/org/netbeans/modules/libs/lsp/Bundle.properties +++ /dev/null @@ -1,18 +0,0 @@ -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. - -OpenIDE-Module-Name=Language Server Protocol Libraries diff --git a/ide/libs.lsp/external/binaries-list b/ide/lsp.client/external/binaries-list similarity index 100% rename from ide/libs.lsp/external/binaries-list rename to ide/lsp.client/external/binaries-list diff --git a/ide/libs.lsp/external/lsp4j-0.4.1-license.txt b/ide/lsp.client/external/lsp4j-0.4.1-license.txt similarity index 100% rename from ide/libs.lsp/external/lsp4j-0.4.1-license.txt rename to ide/lsp.client/external/lsp4j-0.4.1-license.txt diff --git a/ide/libs.lsp/external/xtend-2.14.0-license.txt b/ide/lsp.client/external/xtend-2.14.0-license.txt similarity index 100% rename from ide/libs.lsp/external/xtend-2.14.0-license.txt rename to ide/lsp.client/external/xtend-2.14.0-license.txt diff --git a/ide/lsp.client/nbproject/project.properties b/ide/lsp.client/nbproject/project.properties index 5137752915a4..c94e2f46824c 100644 --- a/ide/lsp.client/nbproject/project.properties +++ b/ide/lsp.client/nbproject/project.properties @@ -17,3 +17,9 @@ javac.source=1.8 javac.compilerargs=-Xlint -Xlint:-serial +release.external/org.eclipse.lsp4j-0.4.1.jar=modules/ext/org.eclipse.lsp4j-0.4.1.jar +release.external/org.eclipse.lsp4j.generator-0.4.1.jar=modules/ext/org.eclipse.lsp4j.generator-0.4.1.jar +release.external/org.eclipse.lsp4j.jsonrpc-0.4.1.jar=modules/ext/org.eclipse.lsp4j.jsonrpc-0.4.1.jar +release.external/org.eclipse.xtend.lib-2.14.0.jar=modules/ext/org.eclipse.xtend.lib-2.14.0.jar +release.external/org.eclipse.xtend.lib.macro-2.14.0.jar=modules/ext/org.eclipse.xtend.lib.macro-2.14.0.jar +release.external/org.eclipse.xtext.xbase.lib-2.14.0.jar=modules/ext/org.eclipse.xtext.xbase.lib-2.14.0.jar diff --git a/ide/lsp.client/nbproject/project.xml b/ide/lsp.client/nbproject/project.xml index 054fc913d50e..995dcae9dc80 100644 --- a/ide/lsp.client/nbproject/project.xml +++ b/ide/lsp.client/nbproject/project.xml @@ -25,6 +25,31 @@ org.netbeans.modules.lsp.client + + com.google.gson + + + + 2.7 + + + + com.google.guava + + + + 15.0 + + + + org.netbeans.api.annotations.common + + + + 1 + 1.30 + + org.netbeans.api.progress @@ -87,14 +112,6 @@ 1.43 - - org.netbeans.modules.libs.lsp - - - - 1.0 - - org.netbeans.modules.projectapi @@ -207,6 +224,30 @@ org.netbeans.modules.kotlin.support org.netbeans.modules.lsp.client.spi + + ext/org.eclipse.lsp4j-0.4.1.jar + external/org.eclipse.lsp4j-0.4.1.jar + + + ext/org.eclipse.xtend.lib.macro-2.14.0.jar + external/org.eclipse.xtend.lib.macro-2.14.0.jar + + + ext/org.eclipse.lsp4j.generator-0.4.1.jar + external/org.eclipse.lsp4j.generator-0.4.1.jar + + + ext/org.eclipse.xtend.lib-2.14.0.jar + external/org.eclipse.xtend.lib-2.14.0.jar + + + ext/org.eclipse.xtext.xbase.lib-2.14.0.jar + external/org.eclipse.xtext.xbase.lib-2.14.0.jar + + + ext/org.eclipse.lsp4j.jsonrpc-0.4.1.jar + external/org.eclipse.lsp4j.jsonrpc-0.4.1.jar + diff --git a/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java b/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java index 233a8944db8e..bf4f7b72795a 100644 --- a/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java +++ b/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java @@ -49,6 +49,7 @@ import org.netbeans.api.project.Project; import org.netbeans.modules.lsp.client.bindings.LanguageClientImpl; import org.netbeans.modules.lsp.client.spi.LanguageServerProvider; +import org.netbeans.modules.lsp.client.spi.LanguageServerProvider.LanguageServerDescription; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; import org.openide.util.Exceptions; @@ -90,12 +91,17 @@ public static LSPBindings getBindings(FileObject file) { LSPBindings bindings = project2MimeType2Server.computeIfAbsent(prj, p -> new HashMap<>()) .computeIfAbsent(mimeType, mt -> { - LanguageClientImpl lci = new LanguageClientImpl(); for (LanguageServerProvider provider : MimeLookup.getLookup(mimeType).lookupAll(LanguageServerProvider.class)) { - LanguageServer server = provider.startServer(prj, lci); + LanguageServerDescription desc = provider.startServer(prj); - if (server != null) { + if (desc != null) { try { + LanguageClientImpl lci = new LanguageClientImpl(); + InputStream in = LanguageServerProviderAccessor.getINSTANCE().getInputStream(desc); + OutputStream out = LanguageServerProviderAccessor.getINSTANCE().getOutputStream(desc); + Launcher launcher = LSPLauncher.createClientLauncher(lci, in, out); + launcher.startListening(); + LanguageServer server = launcher.getRemoteProxy(); InitializeParams initParams = new InitializeParams(); initParams.setRootUri(prj.getProjectDirectory().toURI().toString()); //XXX: what if a different root is expected???? initParams.setRootPath(FileUtil.toFile(prj.getProjectDirectory()).getAbsolutePath()); //some servers still expect root path diff --git a/ide/lsp.client/src/org/netbeans/modules/lsp/client/LanguageServerProviderAccessor.java b/ide/lsp.client/src/org/netbeans/modules/lsp/client/LanguageServerProviderAccessor.java new file mode 100644 index 000000000000..42d7234de498 --- /dev/null +++ b/ide/lsp.client/src/org/netbeans/modules/lsp/client/LanguageServerProviderAccessor.java @@ -0,0 +1,54 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.netbeans.modules.lsp.client; + +import java.io.InputStream; +import java.io.OutputStream; +import org.netbeans.modules.lsp.client.spi.LanguageServerProvider.LanguageServerDescription; +import org.openide.util.Exceptions; + +/** + * + * @author lahvac + */ +public abstract class LanguageServerProviderAccessor { + + public static synchronized LanguageServerProviderAccessor getINSTANCE () { + if (INSTANCE == null) { + try { + Class.forName(LanguageServerDescription.class.getName(), true, LanguageServerDescription.class.getClassLoader()); //NOI18N + assert INSTANCE != null; + } catch (ClassNotFoundException e) { + Exceptions.printStackTrace(e); + } + } + return INSTANCE; + } + + public static void setINSTANCE (LanguageServerProviderAccessor instance) { + assert instance != null; + INSTANCE = instance; + } + + private static volatile LanguageServerProviderAccessor INSTANCE; + + public abstract InputStream getInputStream(LanguageServerDescription desc); + public abstract OutputStream getOutputStream(LanguageServerDescription desc); + public abstract Process getProcess(LanguageServerDescription desc); +} diff --git a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/NavigatorPanelImpl.java b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/NavigatorPanelImpl.java index 78549dc16404..bbc12f31419e 100644 --- a/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/NavigatorPanelImpl.java +++ b/ide/lsp.client/src/org/netbeans/modules/lsp/client/bindings/NavigatorPanelImpl.java @@ -19,6 +19,8 @@ package org.netbeans.modules.lsp.client.bindings; import java.awt.BorderLayout; +import java.net.MalformedURLException; +import java.net.URI; import java.util.Collection; import java.util.Collections; import java.util.List; @@ -34,6 +36,7 @@ import org.openide.explorer.ExplorerManager; import org.openide.explorer.view.BeanTreeView; import org.openide.filesystems.FileObject; +import org.openide.filesystems.URLMapper; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; import org.openide.nodes.Node; @@ -160,8 +163,18 @@ public void resultChanged(LookupEvent arg0) { public static final class DynamicRegistrationImpl implements DynamicRegistration { @Override - public Collection panelsFor(FileObject file) { - return LSPBindings.getBindings(file) != null ? Collections.singletonList(INSTANCE) : Collections.emptyList(); + public Collection panelsFor(URI uri) { + try { + FileObject file = URLMapper.findFileObject(uri.toURL()); + if (file != null) { + return LSPBindings.getBindings(file) != null ? Collections.singletonList(INSTANCE) : Collections.emptyList(); + } else { + return Collections.emptyList(); + } + } catch (MalformedURLException ex) { + //ignore + return Collections.emptyList(); + } } } diff --git a/ide/lsp.client/src/org/netbeans/modules/lsp/client/spi/LanguageServerProvider.java b/ide/lsp.client/src/org/netbeans/modules/lsp/client/spi/LanguageServerProvider.java index f376f9046b88..4108912cafdf 100644 --- a/ide/lsp.client/src/org/netbeans/modules/lsp/client/spi/LanguageServerProvider.java +++ b/ide/lsp.client/src/org/netbeans/modules/lsp/client/spi/LanguageServerProvider.java @@ -18,14 +18,48 @@ */ package org.netbeans.modules.lsp.client.spi; -import org.eclipse.lsp4j.services.LanguageClient; -import org.eclipse.lsp4j.services.LanguageServer; +import java.io.InputStream; +import java.io.OutputStream; +import org.netbeans.api.annotations.common.CheckForNull; +import org.netbeans.api.annotations.common.NonNull; import org.netbeans.api.project.Project; +import org.netbeans.modules.lsp.client.LanguageServerProviderAccessor; /** * * @author lahvac */ public interface LanguageServerProvider { - public LanguageServer startServer(Project prj, LanguageClient lc); + public @CheckForNull LanguageServerDescription startServer(@NonNull Project prj); + public static final class LanguageServerDescription { + private final InputStream in; + private final OutputStream out; + private final Process process; + + public LanguageServerDescription(InputStream in, OutputStream out, Process process) { + this.in = in; + this.out = out; + this.process = process; + } + + static { + LanguageServerProviderAccessor.setINSTANCE(new LanguageServerProviderAccessor() { + @Override + public InputStream getInputStream(LanguageServerDescription desc) { + return desc.in; + } + + @Override + public OutputStream getOutputStream(LanguageServerDescription desc) { + return desc.out; + } + + @Override + public Process getProcess(LanguageServerDescription desc) { + return desc.process; + } + }); + } + + } } diff --git a/ide/spi.navigator/src/org/netbeans/modules/navigator/ProviderRegistry.java b/ide/spi.navigator/src/org/netbeans/modules/navigator/ProviderRegistry.java index bdc7ea7d51d3..6c85b30b57a5 100644 --- a/ide/spi.navigator/src/org/netbeans/modules/navigator/ProviderRegistry.java +++ b/ide/spi.navigator/src/org/netbeans/modules/navigator/ProviderRegistry.java @@ -21,6 +21,7 @@ import java.lang.ref.Reference; import java.lang.ref.SoftReference; +import java.net.URI; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -94,8 +95,9 @@ public Collection getProviders (String contentType, Fi if (file2Providers == null) { file2Providers = new WeakHashMap<>(); } + URI uri = file.toURI(); Reference> fileResultRef = file2Providers.computeIfAbsent(file, f -> - new SoftReference<>(Lookup.getDefault().lookupAll(DynamicRegistration.class).stream().flatMap(reg -> reg.panelsFor(file).stream()).collect(Collectors.toList())) + new SoftReference<>(Lookup.getDefault().lookupAll(DynamicRegistration.class).stream().flatMap(reg -> reg.panelsFor(uri).stream()).collect(Collectors.toList())) ); Collection fileResult = fileResultRef != null ? fileResultRef.get() : null; if (result == null) return fileResult; diff --git a/ide/spi.navigator/src/org/netbeans/spi/navigator/NavigatorPanel.java b/ide/spi.navigator/src/org/netbeans/spi/navigator/NavigatorPanel.java index 0ac07e46ce28..01b5fea4fffa 100644 --- a/ide/spi.navigator/src/org/netbeans/spi/navigator/NavigatorPanel.java +++ b/ide/spi.navigator/src/org/netbeans/spi/navigator/NavigatorPanel.java @@ -23,6 +23,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import java.net.URI; import java.util.Collection; import javax.swing.JComponent; import org.netbeans.api.annotations.common.CheckForNull; @@ -144,7 +145,7 @@ public interface NavigatorPanel { } /** - * Dynamically create panels for files. + * Dynamically create panels for files. Register in the global lookup. * * @since 1.41 */ @@ -157,7 +158,7 @@ interface DynamicRegistration { * @return a collection of {@code NavigatorPanel}s for the given file * null is allowed */ - public @CheckForNull Collection panelsFor(@NonNull FileObject file); + public @CheckForNull Collection panelsFor(@NonNull URI file); } } diff --git a/ide/spi.navigator/test/unit/src/org/netbeans/modules/navigator/ProviderRegistryTest.java b/ide/spi.navigator/test/unit/src/org/netbeans/modules/navigator/ProviderRegistryTest.java index 874175d43083..6528367c0f1a 100644 --- a/ide/spi.navigator/test/unit/src/org/netbeans/modules/navigator/ProviderRegistryTest.java +++ b/ide/spi.navigator/test/unit/src/org/netbeans/modules/navigator/ProviderRegistryTest.java @@ -19,11 +19,18 @@ package org.netbeans.modules.navigator; +import java.net.URI; import java.util.Collection; +import java.util.Collections; import javax.swing.JComponent; import org.netbeans.junit.NbTestCase; import org.netbeans.spi.navigator.NavigatorPanel; +import org.netbeans.spi.navigator.NavigatorPanel.DynamicRegistration; +import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileUtil; import org.openide.util.Lookup; +import org.openide.util.lookup.Lookups; +import org.openide.util.lookup.ProxyLookup; /** @@ -60,6 +67,33 @@ public void testGetProviders () throws Exception { assertEquals(MARVELOUS_DATA_TYPE_NAME, provider.getDisplayName()); } + public void testDynamicGetProviders () throws Exception { + UnitTestUtils.prepareTest(new String [] { "/org/netbeans/modules/navigator/resources/testGetProvidersLayer.xml" }); + FileObject root = FileUtil.createMemoryFileSystem().getRoot(); + FileObject file1 = root.createData("1"); + FileObject file2 = root.createData("2"); + Lookup checkingProvider = Lookups.singleton(new DynamicRegistration() { + @Override + public Collection panelsFor(URI file) { + return file1.toURI().equals(file) ? Collections.singletonList(new MarvelousDataTypeProvider()) + : Collections.emptyList(); + } + }); + Lookups.executeWith(new ProxyLookup(Lookup.getDefault(), checkingProvider), () -> { + ProviderRegistry providerReg = ProviderRegistry.getInstance(); + + System.out.println("Asking for masked out file..."); + assertEquals(0, providerReg.getProviders("image/non_existent_type", file2).size()); + + System.out.println("Asking for valid file..."); + Collection result = providerReg.getProviders("image/non_existent_type", file1); + assertEquals(1, result.size()); + NavigatorPanel np = result.iterator().next(); + assertTrue(np instanceof MarvelousDataTypeProvider); + MarvelousDataTypeProvider provider = (MarvelousDataTypeProvider)np; + assertEquals(MARVELOUS_DATA_TYPE_NAME, provider.getDisplayName()); + }); + } /** Dummy navigator panel provider, just to test right loading and instantiating * for certain data type diff --git a/nbbuild/cluster.properties b/nbbuild/cluster.properties index 93b53be28d3a..f7ce4bf25602 100644 --- a/nbbuild/cluster.properties +++ b/nbbuild/cluster.properties @@ -404,7 +404,6 @@ nb.cluster.ide=\ libs.jsch.agentproxy,\ libs.json_simple,\ libs.jvyamlb,\ - libs.lsp,\ libs.lucene,\ libs.smack,\ libs.svnClientAdapter,\ From 79ec87cd91a663d1f8b50c4c04ac4ba7495fe801 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Wed, 12 Sep 2018 06:33:03 +0200 Subject: [PATCH 14/15] Marking the SPI as under development, adding javadoc and arch.xml. --- ide/lsp.client/arch.xml | 1089 +++++++++++++++++ ide/lsp.client/manifest.mf | 2 +- ide/lsp.client/nbproject/project.properties | 1 + ide/lsp.client/nbproject/project.xml | 5 +- .../modules/lsp/client/LSPBindings.java | 3 +- .../client/spi/LanguageServerProvider.java | 33 +- 6 files changed, 1125 insertions(+), 8 deletions(-) create mode 100644 ide/lsp.client/arch.xml diff --git a/ide/lsp.client/arch.xml b/ide/lsp.client/arch.xml new file mode 100644 index 000000000000..67168baf450d --- /dev/null +++ b/ide/lsp.client/arch.xml @@ -0,0 +1,1089 @@ + + +]> + + + + &api-questions; + + + + +

+ A client for the Language Server Protocol. + Language servers can be registered + using org.netbeans.modules.lsp.client.spi.LanguageServerProvider. + +

+
+ + + + + +

+ Manual tests. +

+
+ + + + + +

+ Unclear. +

+
+ + + + + +

+ + To implement a plugin that binds a language server to NetBeans, implement + org.netbeans.modules.lsp.client.spi.LanguageServerProvider and register it + to MimeLookup using @MimeRegistration. + +

+
+ + + + + +

+ A client for the Language Server Protocol. Servers can either be connected to + it manually, or using a plugin. +

+
+ + + + + + + + + + + + +

+ No. +

+
+ + + + + +

+ Yes. +

+
+ + + + + +

+ Implements the Language Server Protocol. + The implementation is not complete at this time. +

+
+ + + + + +

+ Coexistence is not likely. No settings. +

+
+ + + + + +

+ JRE 8+ +

+
+ + + + + +

+ JRE +

+
+ + + + + + + + + + + + +

+ The LSP4J library, which itself depends on Guava and GSon. +

+
+ + + + + +

+ Any supported platform. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ This module encloses the LSP4J library. +

+
+ + + + + +

+ Yes. +

+
+ + + + + +

+ Yes. +

+
+ + + + + +

+ Both places. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ Not directly from this module, but clients of this SPI are expected to launch + a process as a language server. It is up to them to ensure this works on all + platforms. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ The SPI can be called from any thread, except AWT Event Dispatch Thread. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ The Language Server Protocol. +

+
+ + + + + +

+ Yes, Lookup and MimeLookup. +

+
+ + + + + +

+ Yes. A NavigatorPanel.DynamicRegistration is registered to the global Lookup. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ Possibly yes, stopping any remote running servers. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ Not known. +

+
+ + + + + +

+ Excessive memory consumption is not expected. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ Clients of this module are expected to start a language server that will run + for a long time. +

+
+ + + + + +

+ The performance of the attached language server and the throughput and latency + of the communication channel affect the performance of the language support. +

+
+ + + + + +

+ No enforcement. +

+
+ + + + + +

+ A listeners that listens on all editors is installed on startup. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ Yes, to convert a user-provided String to a FileObject. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ No. +

+
+ + + + + +

+ No. +

+
+ +
diff --git a/ide/lsp.client/manifest.mf b/ide/lsp.client/manifest.mf index 6850bbae8cf9..0a64463565f7 100644 --- a/ide/lsp.client/manifest.mf +++ b/ide/lsp.client/manifest.mf @@ -1,6 +1,6 @@ Manifest-Version: 1.0 AutoUpdate-Show-In-Client: true -OpenIDE-Module: org.netbeans.modules.lsp.client +OpenIDE-Module: org.netbeans.modules.lsp.client/0 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/lsp/client/Bundle.properties OpenIDE-Module-Specification-Version: 1.0 diff --git a/ide/lsp.client/nbproject/project.properties b/ide/lsp.client/nbproject/project.properties index c94e2f46824c..1118a9114b35 100644 --- a/ide/lsp.client/nbproject/project.properties +++ b/ide/lsp.client/nbproject/project.properties @@ -17,6 +17,7 @@ javac.source=1.8 javac.compilerargs=-Xlint -Xlint:-serial +javadoc.arch=${basedir}/arch.xml release.external/org.eclipse.lsp4j-0.4.1.jar=modules/ext/org.eclipse.lsp4j-0.4.1.jar release.external/org.eclipse.lsp4j.generator-0.4.1.jar=modules/ext/org.eclipse.lsp4j.generator-0.4.1.jar release.external/org.eclipse.lsp4j.jsonrpc-0.4.1.jar=modules/ext/org.eclipse.lsp4j.jsonrpc-0.4.1.jar diff --git a/ide/lsp.client/nbproject/project.xml b/ide/lsp.client/nbproject/project.xml index 995dcae9dc80..c032598892b0 100644 --- a/ide/lsp.client/nbproject/project.xml +++ b/ide/lsp.client/nbproject/project.xml @@ -220,10 +220,9 @@
- - org.netbeans.modules.kotlin.support + org.netbeans.modules.lsp.client.spi - + ext/org.eclipse.lsp4j-0.4.1.jar external/org.eclipse.lsp4j-0.4.1.jar diff --git a/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java b/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java index bf4f7b72795a..345541ec9712 100644 --- a/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java +++ b/ide/lsp.client/src/org/netbeans/modules/lsp/client/LSPBindings.java @@ -55,6 +55,7 @@ import org.openide.util.Exceptions; import org.openide.util.NbBundle.Messages; import org.openide.util.RequestProcessor; +import org.openide.util.lookup.Lookups; /** * @@ -92,7 +93,7 @@ public static LSPBindings getBindings(FileObject file) { project2MimeType2Server.computeIfAbsent(prj, p -> new HashMap<>()) .computeIfAbsent(mimeType, mt -> { for (LanguageServerProvider provider : MimeLookup.getLookup(mimeType).lookupAll(LanguageServerProvider.class)) { - LanguageServerDescription desc = provider.startServer(prj); + LanguageServerDescription desc = provider.startServer(Lookups.singleton(prj)); if (desc != null) { try { diff --git a/ide/lsp.client/src/org/netbeans/modules/lsp/client/spi/LanguageServerProvider.java b/ide/lsp.client/src/org/netbeans/modules/lsp/client/spi/LanguageServerProvider.java index 4108912cafdf..52826170d129 100644 --- a/ide/lsp.client/src/org/netbeans/modules/lsp/client/spi/LanguageServerProvider.java +++ b/ide/lsp.client/src/org/netbeans/modules/lsp/client/spi/LanguageServerProvider.java @@ -22,21 +22,48 @@ import java.io.OutputStream; import org.netbeans.api.annotations.common.CheckForNull; import org.netbeans.api.annotations.common.NonNull; -import org.netbeans.api.project.Project; +import org.netbeans.api.annotations.common.NullAllowed; import org.netbeans.modules.lsp.client.LanguageServerProviderAccessor; +import org.openide.util.Lookup; /** + * Possibly start a language server. Should be installed in the Mime Lookup for the + * given mime type that is handled by the given server. * * @author lahvac */ public interface LanguageServerProvider { - public @CheckForNull LanguageServerDescription startServer(@NonNull Project prj); + /**Possibly start a language server. {@code lookup} contains additional + * information. May return null, meaning no server was started. + * + * @param lookup additional information + * @return a description of the running language server handling requests for + * the given mime type, or null if not handled. + */ + public @CheckForNull LanguageServerDescription startServer(@NonNull Lookup lookup); + + /** + * A description of a running language server. + */ public static final class LanguageServerDescription { + + /** + * Create the description of a running language server. + * + * @param in the InputStream that should be used to communicate with the server + * @param out the OutputStream that should be used to communicate with the server + * @param process the process of the running language server, or null if none. + * @return an instance of LanguageServerDescription + */ + public static @NonNull LanguageServerDescription create(@NonNull InputStream in, @NonNull OutputStream out, @NullAllowed Process process) { + return new LanguageServerDescription(in, out, process); + } + private final InputStream in; private final OutputStream out; private final Process process; - public LanguageServerDescription(InputStream in, OutputStream out, Process process) { + private LanguageServerDescription(InputStream in, OutputStream out, Process process) { this.in = in; this.out = out; this.process = process; From c4fa50262074f2e40e1c171288483cfda2d77608 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Thu, 13 Sep 2018 06:38:26 +0200 Subject: [PATCH 15/15] Adding licence header to arch.xml. --- ide/lsp.client/arch.xml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ide/lsp.client/arch.xml b/ide/lsp.client/arch.xml index 67168baf450d..5e8e91c72cad 100644 --- a/ide/lsp.client/arch.xml +++ b/ide/lsp.client/arch.xml @@ -1,4 +1,24 @@ + ]>