From af14ce57eca943b924c2268dea182da59f1da5b6 Mon Sep 17 00:00:00 2001 From: Lars Heinemann Date: Fri, 16 Mar 2018 10:42:28 +0100 Subject: [PATCH] refactor repo to only contain vscode client Signed-off-by: Lars Heinemann --- clients/vscode/.editorconfig => .editorconfig | 0 .gitattributes | 12 - .gitignore | 18 +- .project | 8 +- .settings/org.eclipse.core.resources.prefs | 2 - .travis.yml | 66 ------ .../.vscode => .vscode}/extensions.json | 0 .../vscode/.vscode => .vscode}/launch.json | 0 .../vscode/.vscode => .vscode}/settings.json | 0 .../vscode/.vscode => .vscode}/tasks.json | 0 clients/vscode/.vscodeignore => .vscodeignore | 0 Contributing.md | 25 --- LICENSE | 201 ----------------- .../vscode/LICENSE-2.0.txt => LICENSE-2.0.txt | 0 README.md | 44 ---- clients/vscode/Install.md => Readme.md | 4 +- clients/eclipse/Install.md | 22 -- clients/eclipse/README.md | 22 -- .../camel-lsp-target-platform/.project | 17 -- .../org.eclipse.core.resources.prefs | 2 - .../.settings/org.eclipse.m2e.core.prefs | 4 - .../camel-lsp-target-platform.target | 24 -- .../eclipse/camel-lsp-target-platform/pom.xml | 16 -- .../.classpath | 7 - .../.project | 33 --- .../META-INF/MANIFEST.MF | 16 -- .../build.properties | 4 - .../infinitest.filters | 1 - .../pom.xml | 40 ---- .../CamelLSPLoadedByExtensionPointIT.java | 48 ---- .../CamelLSPStreamConnectionProviderIT.java | 46 ---- .../.classpath | 7 - .../.project | 33 --- .../META-INF/MANIFEST.MF | 15 -- .../OSGI-INF/l10n/bundle.properties | 12 - .../build.properties | 8 - .../plugin.xml | 33 --- .../pom.xml | 49 ----- .../client/ActivatorCamelLspClient.java | 38 ---- .../CamelLSPStreamConnectionProvider.java | 68 ------ .../CamelURICompletionProposalComputer.java | 56 ----- .../.project | 17 -- .../category.xml | 4 - .../pom.xml | 15 -- clients/eclipse/pom.xml | 51 ----- clients/pom.xml | 19 -- clients/vscode/.gitignore | 10 - clients/vscode/.project | 11 - clients/vscode/gulpfile.js => gulpfile.js | 0 {clients/vscode/icons => icons}/icon128.png | Bin {clients/vscode/jars => jars}/Readme.md | 0 ...ration.json => language-configuration.json | 0 clients/vscode/package.json => package.json | 0 pom.xml | 96 -------- .../vscode/scripts => scripts}/preinstall.js | 2 +- server/.classpath | 36 --- server/.project | 23 -- .../org.eclipse.core.resources.prefs | 6 - server/.settings/org.eclipse.jdt.core.prefs | 5 - server/.settings/org.eclipse.m2e.core.prefs | 4 - server/pom.xml | 75 ------- .../lsp/internal/AbstractLanguageServer.java | 163 -------------- .../lsp/internal/CamelLanguageServer.java | 120 ---------- .../internal/CamelTextDocumentService.java | 197 ----------------- .../lsp/internal/CamelWorkspaceService.java | 56 ----- .../camel/tools/lsp/internal/Runner.java | 33 --- ...CamelComponentSchemaCompletionsFuture.java | 38 ---- .../CamelEndpointCompletionProcessor.java | 65 ------ .../CamelOptionSchemaCompletionsFuture.java | 64 ------ .../CamelOptionValuesCompletionsFuture.java | 73 ------ .../tools/lsp/internal/hover/HoverFuture.java | 45 ---- .../lsp/internal/hover/HoverProcessor.java | 58 ----- .../lsp/internal/model/ComponentModel.java | 186 ---------------- .../internal/model/ComponentOptionModel.java | 121 ---------- .../internal/model/EndpointOptionModel.java | 157 ------------- .../lsp/internal/model/util/ModelHelper.java | 95 -------- .../lsp/internal/model/util/StringUtils.java | 207 ------------------ .../parser/CamelComponentURIInstance.java | 44 ---- .../lsp/internal/parser/CamelURIInstance.java | 136 ------------ .../parser/CamelUriElementInstance.java | 49 ----- .../parser/OptionParamKeyURIInstance.java | 50 ----- .../parser/OptionParamURIInstance.java | 74 ------- .../parser/OptionParamValueURIInstance.java | 52 ----- .../lsp/internal/parser/ParserFileHelper.java | 126 ----------- .../internal/parser/PathParamURIInstance.java | 70 ------ server/src/main/resources/log4j.properties | 10 - .../AbstractCamelLanguageServerTest.java | 98 --------- .../lsp/internal/CamelLanguageServerTest.java | 91 -------- .../CamelTextDocumentServiceTest.java | 57 ----- ...CamelComponentOptionBooleanValuesTest.java | 51 ----- ...lComponentOptionEnumerationValuesTest.java | 57 ----- .../CamelComponentOptionsCompletionsTest.java | 74 ------- ...lLanguageServerCompletionPositionTest.java | 106 --------- .../hover/CamelLanguageServerHoverTest.java | 63 ------ .../internal/parser/CamelURIInstanceTest.java | 187 ---------------- .../test/resources/workspace/test-file.xml | 0 {clients/vscode/src => src}/extension.ts | 0 {clients/vscode/src => src}/protocol.ts | 0 {clients/vscode/test => test}/apacheCamel.xml | 0 {clients/vscode/test => test}/index.ts | 0 clients/vscode/tsconfig.json => tsconfig.json | 0 clients/vscode/tslint.json => tslint.json | 0 102 files changed, 13 insertions(+), 4435 deletions(-) rename clients/vscode/.editorconfig => .editorconfig (100%) delete mode 100644 .gitattributes delete mode 100644 .settings/org.eclipse.core.resources.prefs delete mode 100644 .travis.yml rename {clients/vscode/.vscode => .vscode}/extensions.json (100%) rename {clients/vscode/.vscode => .vscode}/launch.json (100%) rename {clients/vscode/.vscode => .vscode}/settings.json (100%) rename {clients/vscode/.vscode => .vscode}/tasks.json (100%) rename clients/vscode/.vscodeignore => .vscodeignore (100%) delete mode 100644 Contributing.md delete mode 100644 LICENSE rename clients/vscode/LICENSE-2.0.txt => LICENSE-2.0.txt (100%) delete mode 100644 README.md rename clients/vscode/Install.md => Readme.md (76%) delete mode 100644 clients/eclipse/Install.md delete mode 100644 clients/eclipse/README.md delete mode 100644 clients/eclipse/camel-lsp-target-platform/.project delete mode 100644 clients/eclipse/camel-lsp-target-platform/.settings/org.eclipse.core.resources.prefs delete mode 100644 clients/eclipse/camel-lsp-target-platform/.settings/org.eclipse.m2e.core.prefs delete mode 100644 clients/eclipse/camel-lsp-target-platform/camel-lsp-target-platform.target delete mode 100644 clients/eclipse/camel-lsp-target-platform/pom.xml delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/.classpath delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/.project delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/META-INF/MANIFEST.MF delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/build.properties delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/infinitest.filters delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/pom.xml delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/src/main/java/org/apache/camel/lsp/eclipse/client/tests/integration/CamelLSPLoadedByExtensionPointIT.java delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/src/main/java/org/apache/camel/lsp/eclipse/client/tests/integration/CamelLSPStreamConnectionProviderIT.java delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client/.classpath delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client/.project delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client/META-INF/MANIFEST.MF delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client/OSGI-INF/l10n/bundle.properties delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client/build.properties delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client/plugin.xml delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client/pom.xml delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client/src/org/apache/camel/lsp/eclipse/client/ActivatorCamelLspClient.java delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client/src/org/apache/camel/lsp/eclipse/client/CamelLSPStreamConnectionProvider.java delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.client/src/org/apache/camel/lsp/eclipse/xml/completion/CamelURICompletionProposalComputer.java delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.updatesite/.project delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.updatesite/category.xml delete mode 100644 clients/eclipse/org.apache.camel.lsp.eclipse.updatesite/pom.xml delete mode 100644 clients/eclipse/pom.xml delete mode 100644 clients/pom.xml delete mode 100644 clients/vscode/.gitignore delete mode 100644 clients/vscode/.project rename clients/vscode/gulpfile.js => gulpfile.js (100%) rename {clients/vscode/icons => icons}/icon128.png (100%) rename {clients/vscode/jars => jars}/Readme.md (100%) rename clients/vscode/language-configuration.json => language-configuration.json (100%) rename clients/vscode/package.json => package.json (100%) delete mode 100644 pom.xml rename {clients/vscode/scripts => scripts}/preinstall.js (53%) delete mode 100644 server/.classpath delete mode 100644 server/.project delete mode 100644 server/.settings/org.eclipse.core.resources.prefs delete mode 100644 server/.settings/org.eclipse.jdt.core.prefs delete mode 100644 server/.settings/org.eclipse.m2e.core.prefs delete mode 100644 server/pom.xml delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/AbstractLanguageServer.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/CamelLanguageServer.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/CamelTextDocumentService.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/CamelWorkspaceService.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/Runner.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentSchemaCompletionsFuture.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelEndpointCompletionProcessor.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelOptionSchemaCompletionsFuture.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelOptionValuesCompletionsFuture.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/hover/HoverFuture.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/hover/HoverProcessor.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/model/ComponentModel.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/model/ComponentOptionModel.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/model/EndpointOptionModel.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/model/util/ModelHelper.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/model/util/StringUtils.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/parser/CamelComponentURIInstance.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/parser/CamelURIInstance.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/parser/CamelUriElementInstance.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/parser/OptionParamKeyURIInstance.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/parser/OptionParamURIInstance.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/parser/OptionParamValueURIInstance.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/parser/ParserFileHelper.java delete mode 100644 server/src/main/java/org/apache/camel/tools/lsp/internal/parser/PathParamURIInstance.java delete mode 100644 server/src/main/resources/log4j.properties delete mode 100644 server/src/test/java/org/apache/camel/tools/lsp/internal/AbstractCamelLanguageServerTest.java delete mode 100644 server/src/test/java/org/apache/camel/tools/lsp/internal/CamelLanguageServerTest.java delete mode 100644 server/src/test/java/org/apache/camel/tools/lsp/internal/CamelTextDocumentServiceTest.java delete mode 100644 server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentOptionBooleanValuesTest.java delete mode 100644 server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentOptionEnumerationValuesTest.java delete mode 100644 server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentOptionsCompletionsTest.java delete mode 100644 server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelLanguageServerCompletionPositionTest.java delete mode 100644 server/src/test/java/org/apache/camel/tools/lsp/internal/hover/CamelLanguageServerHoverTest.java delete mode 100644 server/src/test/java/org/apache/camel/tools/lsp/internal/parser/CamelURIInstanceTest.java delete mode 100644 server/src/test/resources/workspace/test-file.xml rename {clients/vscode/src => src}/extension.ts (100%) rename {clients/vscode/src => src}/protocol.ts (100%) rename {clients/vscode/test => test}/apacheCamel.xml (100%) rename {clients/vscode/test => test}/index.ts (100%) rename clients/vscode/tsconfig.json => tsconfig.json (100%) rename clients/vscode/tslint.json => tslint.json (100%) diff --git a/clients/vscode/.editorconfig b/.editorconfig similarity index 100% rename from clients/vscode/.editorconfig rename to .editorconfig diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index da765a88e..000000000 --- a/.gitattributes +++ /dev/null @@ -1,12 +0,0 @@ -# Set the default behavior, in case people don't have core.autocrlf set. -* text eol=lf - -# Declare files that will always have CRLF line endings on checkout. -*.bat text eol=crlf - -# Denote all files that are truly binary and should not be modified. -*.png binary -*.jpg binary -*.gif binary -*.jar binary - diff --git a/.gitignore b/.gitignore index c65f3e9c4..fadeef716 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,10 @@ -target -*.iml -*.ipr -*.iws +out +server +node_modules +jars/language-server.jar +*.vsix .DS_Store -bin -.metadata -.idea -libs/ - +.vscode-test +package-lock.json +undefined +target diff --git a/.project b/.project index 3477d9802..e725a3ad8 100644 --- a/.project +++ b/.project @@ -1,17 +1,11 @@ - Camel Language Server Protocol + vscode-apache-camel - - org.eclipse.m2e.core.maven2Builder - - - - org.eclipse.m2e.core.maven2Nature diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8b9e9d585..000000000 --- a/.travis.yml +++ /dev/null @@ -1,66 +0,0 @@ -matrix: - include: - - language: java - sudo: false - before_install: - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" - script: - - 'mvn clean verify' - - 'if [[ $TRAVIS_PULL_REQUEST == "false" && $TRAVIS_BRANCH == "master" ]]; then mvn sonar:sonar -Dsonar.login=${SONAR_TOKEN}; fi' - jdk: oraclejdk8 - deploy: - provider: releases - api_key: ${DEPLOY_TOKEN} - file: - - "server/target/camel-lsp-server-1.0.0-SNAPSHOT.jar" - - "clients/eclipse/org.apache.camel.lsp.eclipse.updatesite/target/org.apache.camel.lsp.eclipse.updatesite-1.0.0-SNAPSHOT.zip" - skip_cleanup: true - overwrite: true - on: - branch: master - # tags: true - branches: - only: - - master - cache: - directories: - - $HOME/.m2 - - $HOME/.sonar/cache - - $HOME/.gradle/ - - language: node_js - node_js: "8" - before_install: - - "export DISPLAY=:99.0" - - "sh -e /etc/init.d/xvfb start" - - 'cd clients/vscode' - - 'export PATH=./node_modules/.bin:$PATH' - - 'npm install -g typescript' - install: - - 'npm install --ignore-scripts' - - 'npm install' - - 'npm run vscode:prepublish' - - 'npm install -g vsce' - - 'vsce package' - deploy: - provider: releases - api_key: ${DEPLOY_TOKEN} - file: - - "vscode-apache-camel-0.0.1.vsix" - skip_cleanup: true - overwrite: true - on: - branch: master - # tags: true - branches: - only: - - master - cache: - directories: - - "clients/vscode/node_modules" -env: DISPLAY=:99 -addons: - sonarcloud: - organization: "apupier-github" - branches: - - master diff --git a/clients/vscode/.vscode/extensions.json b/.vscode/extensions.json similarity index 100% rename from clients/vscode/.vscode/extensions.json rename to .vscode/extensions.json diff --git a/clients/vscode/.vscode/launch.json b/.vscode/launch.json similarity index 100% rename from clients/vscode/.vscode/launch.json rename to .vscode/launch.json diff --git a/clients/vscode/.vscode/settings.json b/.vscode/settings.json similarity index 100% rename from clients/vscode/.vscode/settings.json rename to .vscode/settings.json diff --git a/clients/vscode/.vscode/tasks.json b/.vscode/tasks.json similarity index 100% rename from clients/vscode/.vscode/tasks.json rename to .vscode/tasks.json diff --git a/clients/vscode/.vscodeignore b/.vscodeignore similarity index 100% rename from clients/vscode/.vscodeignore rename to .vscodeignore diff --git a/Contributing.md b/Contributing.md deleted file mode 100644 index 766a7663f..000000000 --- a/Contributing.md +++ /dev/null @@ -1,25 +0,0 @@ -First Time Setup --------------- -0. Fork and clone the repository -1. Install Eclipse [Oxygen Java EE](http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/oxygenr) -that will have most needed already installed. Alternately, -you can get the [Eclipse IDE for Java developers](http://www.eclipse.org/downloads/packages/eclipse-ide-java-developers/oxygenr) -and just install Eclipse PDE from marketplace. - -2. Once installed use `File > Open Projects from File System...` and -point it `camel-language-server` and Eclipse should automatically -detect the projects and import it properly. - -3. If you discover an error on `pom.xml` after import about Tycho, you can use Quick Fix -(Ctrl+1) to install the Tycho maven integration. - - -Building from command line ----------------------------- - -1. Install [Apache Maven](https://maven.apache.org/) - -2. This command will build the server: -```bash - $ mvn clean verify -```` \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 8dada3eda..000000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,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/clients/vscode/LICENSE-2.0.txt b/LICENSE-2.0.txt similarity index 100% rename from clients/vscode/LICENSE-2.0.txt rename to LICENSE-2.0.txt diff --git a/README.md b/README.md deleted file mode 100644 index 9e9fc276f..000000000 --- a/README.md +++ /dev/null @@ -1,44 +0,0 @@ -[![Build Status](https://travis-ci.org/apupier/camel-language-server.svg?branch=master)](https://travis-ci.org/apupier/camel-language-server) - -camel-language-server -===================== - -camel-language-server is a server implementation that provides Camel DSL smartness. -The server adheres to the [language server protocol](https://github.com/Microsoft/language-server-protocol) -and can be used with any editor that supports the protocol. The server utilizes [Apache Camel](http://camel.apache.org/) and [M2Eclipse](http://www.eclipse.org/m2e/). - - -Features --------------- -* Code completion -* Hover - -Features planned --------------- -* As you type reporting of parsing and compilation errors -* More advanced Code completion -* Code outline -* Code navigation -* Code lens (references) -* Highlights -* Code formatting - -Installation ------------- - -Please see installation guide for each IDE: - -* [Eclipse](clients/eclipse/Install.md) -* [VS Code](clients/vscode/Install.md) - - -Feedback ---------- - -* File a bug in [GitHub Issues](https://github.com/lhein/camel-language-server/issues). - - -License -------- -ASL 2.0, See [LICENSE](LICENSE) file. - diff --git a/clients/vscode/Install.md b/Readme.md similarity index 76% rename from clients/vscode/Install.md rename to Readme.md index 7526ff88e..a34bb50f0 100644 --- a/clients/vscode/Install.md +++ b/Readme.md @@ -2,10 +2,10 @@ How to install -------------- * Install VS Code -* Go to latest release page https://github.com/apupier/camel-language-server/releases/latest/ +* Go to latest release page https://github.com/camel-idea-plugin/camel-lsp-client-vscode/releases/latest/ * Download the vscode-apache-camel-0.0.1.vsix file * [Install from *.vsix](https://code.visualstudio.com/docs/editor/extension-gallery#_install-from-a-vsix) ** Open Extensions View (Ctrl+Shift+X) ** Click on the three dots at the top right of the view and then "Install from VSIX..." ** Select the file and click Install -* Enjoy! \ No newline at end of file +* Enjoy! diff --git a/clients/eclipse/Install.md b/clients/eclipse/Install.md deleted file mode 100644 index e6d89e415..000000000 --- a/clients/eclipse/Install.md +++ /dev/null @@ -1,22 +0,0 @@ -How to Install --------------- - -* Install Eclipse -* Go to latest release page https://github.com/apupier/camel-language-server/releases/latest/ -* Download zipped update site named org.apache.camel.lsp.eclipse.updatesite-1.0.0-SNAPSHOT.zip -* In Eclipse, Help -> Install New Software... -* Click Add... -* Click Archive... -* Select the zipped file downloaded -* Click Ok -* Select the "Apache Camel LSP Client Extensions Plugin" -* Click Next -* Click Next -* Accept license if asked -* Click Finish -* Wait... -* Click "Install Anyway" -* Click "Restart Now" -* Enjoy! - -tips: you can install it on top of [Fuse Tooling](https://tools.jboss.org/features/fusetools.html) which will provide even more help for development. \ No newline at end of file diff --git a/clients/eclipse/README.md b/clients/eclipse/README.md deleted file mode 100644 index 626771875..000000000 --- a/clients/eclipse/README.md +++ /dev/null @@ -1,22 +0,0 @@ -How to debug Camel Language Server from Eclipse client -====================================================== - -1. Add debug arguments to the list org.apache.camel.lsp.eclipse.client.CamelLSPStreamConnectionProvider.computeCommands() - -You will end up with something like: - - private static List computeCommands() { - List commands = new ArrayList<>(); - commands.add("java"); - commands.addAll(debugArguments()); - commands.add("-jar"); - commands.add(computeCamelLanguageServerJarPath()); - return commands; - } - - private static List debugArguments() { - return Arrays.asList("-Xdebug","-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=3000"); - } - - -2. Create a Remote Java Application Debug Launch configuration in Eclipse \ No newline at end of file diff --git a/clients/eclipse/camel-lsp-target-platform/.project b/clients/eclipse/camel-lsp-target-platform/.project deleted file mode 100644 index 04ae9d0c2..000000000 --- a/clients/eclipse/camel-lsp-target-platform/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - camel-lsp-target-platform - - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.m2e.core.maven2Nature - - diff --git a/clients/eclipse/camel-lsp-target-platform/.settings/org.eclipse.core.resources.prefs b/clients/eclipse/camel-lsp-target-platform/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 99f26c020..000000000 --- a/clients/eclipse/camel-lsp-target-platform/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,2 +0,0 @@ -eclipse.preferences.version=1 -encoding/=UTF-8 diff --git a/clients/eclipse/camel-lsp-target-platform/.settings/org.eclipse.m2e.core.prefs b/clients/eclipse/camel-lsp-target-platform/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f1c..000000000 --- a/clients/eclipse/camel-lsp-target-platform/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/clients/eclipse/camel-lsp-target-platform/camel-lsp-target-platform.target b/clients/eclipse/camel-lsp-target-platform/camel-lsp-target-platform.target deleted file mode 100644 index b42c7ef62..000000000 --- a/clients/eclipse/camel-lsp-target-platform/camel-lsp-target-platform.target +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/clients/eclipse/camel-lsp-target-platform/pom.xml b/clients/eclipse/camel-lsp-target-platform/pom.xml deleted file mode 100644 index f90b2134a..000000000 --- a/clients/eclipse/camel-lsp-target-platform/pom.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - 4.0.0 - - - org.apache.camel.tools.lsp - eclipse - 1.0.0-SNAPSHOT - - - eclipse-target-definition - camel-lsp-target-platform - ${base.name} :: Clients :: Eclipse Client :: Target Platform - diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/.classpath b/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/.classpath deleted file mode 100644 index 44f19f651..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/.project b/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/.project deleted file mode 100644 index 7ab3e468c..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - Camel LSP Eclipse Integration Tests - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.sonarlint.eclipse.core.sonarlintBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/META-INF/MANIFEST.MF b/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/META-INF/MANIFEST.MF deleted file mode 100644 index 5d8442852..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/META-INF/MANIFEST.MF +++ /dev/null @@ -1,16 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %Bundle-Name -Bundle-SymbolicName: org.apache.camel.lsp.eclipse.client.tests.integration;singleton:=true -Bundle-Version: 1.0.0.qualifier -Bundle-Vendor: %Bundle-Vendor -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Bundle-ActivationPolicy: lazy -Require-Bundle: org.junit;bundle-version="4.12.0", - org.assertj;bundle-version="1.7.1", - org.eclipse.lsp4e;bundle-version="0.3.0", - org.apache.camel.lsp.eclipse.client;bundle-version="1.0.0", - org.eclipse.ui.ide;bundle-version="3.13.1", - org.eclipse.core.resources;bundle-version="3.12.0", - org.eclipse.core.runtime;bundle-version="3.13.0", - org.eclipse.ui.genericeditor;bundle-version="1.0.1" diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/build.properties b/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/build.properties deleted file mode 100644 index 67d4ba9ad..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/main/java/ -output.. = bin/ -bin.includes = .,\ - META-INF/ diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/infinitest.filters b/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/infinitest.filters deleted file mode 100644 index ae0fc02eb..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/infinitest.filters +++ /dev/null @@ -1 +0,0 @@ -.*IT \ No newline at end of file diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/pom.xml b/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/pom.xml deleted file mode 100644 index 31e6f268b..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - 4.0.0 - - - org.apache.camel.tools.lsp - eclipse - 1.0.0-SNAPSHOT - - org.apache.camel.lsp.eclipse.client.tests.integration - ${base.name} :: Clients :: Eclipse Client :: Integration Tests - eclipse-test-plugin - - - 0.26.0 - - - - - - org.eclipse.tycho - tycho-surefire-plugin - ${tycho.version} - - - - true - true - - **/*IT.class - - ${tycho.testArgLine} -XX:+HeapDumpOnOutOfMemoryError - ${project.basedir}/target/work sp@cé - - - - - diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/src/main/java/org/apache/camel/lsp/eclipse/client/tests/integration/CamelLSPLoadedByExtensionPointIT.java b/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/src/main/java/org/apache/camel/lsp/eclipse/client/tests/integration/CamelLSPLoadedByExtensionPointIT.java deleted file mode 100644 index aba5fc579..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/src/main/java/org/apache/camel/lsp/eclipse/client/tests/integration/CamelLSPLoadedByExtensionPointIT.java +++ /dev/null @@ -1,48 +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. - */ -package org.apache.camel.lsp.eclipse.client.tests.integration; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.ByteArrayInputStream; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.ide.IDE; -import org.eclipse.ui.internal.genericeditor.ExtensionBasedTextEditor; -import org.junit.Test; - -public class CamelLSPLoadedByExtensionPointIT { - - @Test - public void testGenericEditorCanOpenCamelFile() throws Exception { - IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); - IProject project = root.getProject(CamelLSPLoadedByExtensionPointIT.class.getSimpleName()); - project.create(null); - project.open(null); - IFile camelFile = project.getFile("camelFile.xml"); - camelFile.create(new ByteArrayInputStream("\n".getBytes()), IResource.FORCE, null); - IEditorPart openEditor = IDE.openEditor(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(), camelFile, "org.eclipse.ui.genericeditor.GenericEditor"); - assertThat(openEditor).isInstanceOf(ExtensionBasedTextEditor.class); - } - -} diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/src/main/java/org/apache/camel/lsp/eclipse/client/tests/integration/CamelLSPStreamConnectionProviderIT.java b/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/src/main/java/org/apache/camel/lsp/eclipse/client/tests/integration/CamelLSPStreamConnectionProviderIT.java deleted file mode 100644 index 319975283..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client.tests.integration/src/main/java/org/apache/camel/lsp/eclipse/client/tests/integration/CamelLSPStreamConnectionProviderIT.java +++ /dev/null @@ -1,46 +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. - */ -package org.apache.camel.lsp.eclipse.client.tests.integration; - - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.InputStream; - -import org.apache.camel.lsp.eclipse.client.CamelLSPStreamConnectionProvider; -import org.junit.Test; - -public class CamelLSPStreamConnectionProviderIT { - - @Test - public void testStart() throws Exception { - CamelLSPStreamConnectionProvider provider = new CamelLSPStreamConnectionProvider(); - provider.start(); - InputStream inputStream = provider.getInputStream(); - assertThat(inputStream).isNotNull(); - byte[] buffer = new byte[1024]; - boolean isConnected = false; - int time = 0; - while (!isConnected && time < 10000 && inputStream.read(buffer) != -1) { - isConnected = new String(buffer).contains("Connected to Language Server..."); - time += 1000; - } - provider.stop(); - assertThat(isConnected).isTrue(); - } - -} diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client/.classpath b/clients/eclipse/org.apache.camel.lsp.eclipse.client/.classpath deleted file mode 100644 index 16d067f28..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client/.project b/clients/eclipse/org.apache.camel.lsp.eclipse.client/.project deleted file mode 100644 index 73df45cb6..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client/.project +++ /dev/null @@ -1,33 +0,0 @@ - - - Camel LSP Eclipse Client - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - org.sonarlint.eclipse.core.sonarlintBuilder - - - - - - org.eclipse.pde.PluginNature - org.eclipse.jdt.core.javanature - - diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client/META-INF/MANIFEST.MF b/clients/eclipse/org.apache.camel.lsp.eclipse.client/META-INF/MANIFEST.MF deleted file mode 100644 index ad7662b91..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client/META-INF/MANIFEST.MF +++ /dev/null @@ -1,15 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: %Bundle-Name -Bundle-SymbolicName: org.apache.camel.lsp.eclipse.client;singleton:=true -Bundle-Version: 1.0.0.qualifier -Bundle-Vendor: %Bundle-Vendor -Bundle-RequiredExecutionEnvironment: JavaSE-1.8 -Bundle-ActivationPolicy: lazy -Require-Bundle: org.eclipse.lsp4e;bundle-version="0.3.0", - org.eclipse.core.runtime;bundle-version="3.13.0", - org.eclipse.jface.text;bundle-version="3.12.0", - org.eclipse.wst.sse.ui;bundle-version="1.3.600" -Export-Package: org.apache.camel.lsp.eclipse.client;x-friends:="org.apache.camel.lsp.eclipse.client.tests.integration" -Eclipse-BundleShape: dir -Bundle-Activator: org.apache.camel.lsp.eclipse.client.ActivatorCamelLspClient diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client/OSGI-INF/l10n/bundle.properties b/clients/eclipse/org.apache.camel.lsp.eclipse.client/OSGI-INF/l10n/bundle.properties deleted file mode 100644 index 4569d35a1..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client/OSGI-INF/l10n/bundle.properties +++ /dev/null @@ -1,12 +0,0 @@ -############################################################################### -# Copyright (c) 2013 Red Hat, Inc. and others. -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://www.eclipse.org/legal/epl-v10.html -# -# Contributors: -# JBoss by Red Hat - Initial implementation. -############################################################################## -Bundle-Vendor = JBoss by Red Hat -Bundle-Name = Apache Camel LSP Client Extensions Plugin diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client/build.properties b/clients/eclipse/org.apache.camel.lsp.eclipse.client/build.properties deleted file mode 100644 index 01317de1a..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client/build.properties +++ /dev/null @@ -1,8 +0,0 @@ -source.. = src/ -output.. = bin/ -bin.includes = META-INF/,\ - .,\ - plugin.xml,\ - OSGI-INF/,\ - OSGI-INF/l10n/bundle.properties,\ - libs/ diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client/plugin.xml b/clients/eclipse/org.apache.camel.lsp.eclipse.client/plugin.xml deleted file mode 100644 index 5a54f1a01..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client/plugin.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client/pom.xml b/clients/eclipse/org.apache.camel.lsp.eclipse.client/pom.xml deleted file mode 100644 index 9747a6251..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - 4.0.0 - - - org.apache.camel.tools.lsp - eclipse - 1.0.0-SNAPSHOT - - org.apache.camel.lsp.eclipse.client - ${base.name} :: Clients :: Eclipse Client :: Implementation - eclipse-plugin - - - 0.26.0 - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - get-deps - - copy - - generate-resources - - - - - - org.apache.camel.tools.lsp - camel-lsp-server - ${project.version} - - - true - false - ${basedir}/libs/ - - - - - diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client/src/org/apache/camel/lsp/eclipse/client/ActivatorCamelLspClient.java b/clients/eclipse/org.apache.camel.lsp.eclipse.client/src/org/apache/camel/lsp/eclipse/client/ActivatorCamelLspClient.java deleted file mode 100644 index 93a33d54e..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client/src/org/apache/camel/lsp/eclipse/client/ActivatorCamelLspClient.java +++ /dev/null @@ -1,38 +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. - */ -package org.apache.camel.lsp.eclipse.client; - -import org.eclipse.core.runtime.Plugin; - -public class ActivatorCamelLspClient extends Plugin { - - public static final String ID = "org.apache.camel.lsp.eclipse.client"; - private static ActivatorCamelLspClient instance; - - public ActivatorCamelLspClient() { - setInstance(this); - } - - private static void setInstance(ActivatorCamelLspClient activatorCamelLspClient) { - ActivatorCamelLspClient.instance = activatorCamelLspClient; - } - - public static ActivatorCamelLspClient getInstance() { - return instance; - } - -} diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client/src/org/apache/camel/lsp/eclipse/client/CamelLSPStreamConnectionProvider.java b/clients/eclipse/org.apache.camel.lsp.eclipse.client/src/org/apache/camel/lsp/eclipse/client/CamelLSPStreamConnectionProvider.java deleted file mode 100644 index 7749489b3..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client/src/org/apache/camel/lsp/eclipse/client/CamelLSPStreamConnectionProvider.java +++ /dev/null @@ -1,68 +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. - */ -package org.apache.camel.lsp.eclipse.client; - -import java.io.File; -import java.io.IOException; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.eclipse.lsp4e.server.ProcessStreamConnectionProvider; -import org.osgi.framework.Bundle; - -public class CamelLSPStreamConnectionProvider extends ProcessStreamConnectionProvider { - - public CamelLSPStreamConnectionProvider() { - super(computeCommands(), computeWorkingDir()); - } - - private static String computeWorkingDir() { - return System.getProperty("user.dir"); - } - - private static List computeCommands() { - List commands = new ArrayList<>(); - commands.add("java"); - commands.add("-jar"); - commands.add(computeCamelLanguageServerJarPath()); - return commands; - } - - private static String computeCamelLanguageServerJarPath() { - String camelLanguageServerJarPath = ""; - Bundle bundle = Platform.getBundle(ActivatorCamelLspClient.ID); - URL fileURL = bundle.findEntries("/libs", "camel-lsp-server-*.jar", false).nextElement(); - try { - File file = new File(FileLocator.resolve(fileURL).toURI()); - if(Platform.OS_WIN32.equals(Platform.getOS())) { - camelLanguageServerJarPath = "\"" + file.getAbsolutePath() + "\""; - } else { - camelLanguageServerJarPath = file.getAbsolutePath(); - } - } catch (URISyntaxException | IOException exception) { - ActivatorCamelLspClient.getInstance().getLog().log(new Status(IStatus.ERROR, ActivatorCamelLspClient.ID, "Cannot get the Camel LSP Server jar.", exception)); //$NON-NLS-1$ - } - return camelLanguageServerJarPath; - } - -} diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.client/src/org/apache/camel/lsp/eclipse/xml/completion/CamelURICompletionProposalComputer.java b/clients/eclipse/org.apache.camel.lsp.eclipse.client/src/org/apache/camel/lsp/eclipse/xml/completion/CamelURICompletionProposalComputer.java deleted file mode 100644 index 6b8cd056a..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.client/src/org/apache/camel/lsp/eclipse/xml/completion/CamelURICompletionProposalComputer.java +++ /dev/null @@ -1,56 +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. - */ -package org.apache.camel.lsp.eclipse.xml.completion; - -import java.util.Arrays; -import java.util.List; - -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.text.contentassist.ICompletionProposal; -import org.eclipse.jface.text.contentassist.IContextInformation; -import org.eclipse.lsp4e.operations.completion.LSContentAssistProcessor; -import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext; -import org.eclipse.wst.sse.ui.contentassist.ICompletionProposalComputer; - -public class CamelURICompletionProposalComputer implements ICompletionProposalComputer { - - @Override - public List computeCompletionProposals(CompletionProposalInvocationContext context, IProgressMonitor monitor) { - return Arrays.asList(new LSContentAssistProcessor().computeCompletionProposals(context.getViewer(), context.getInvocationOffset())); - } - - @Override - public List computeContextInformation(CompletionProposalInvocationContext context, IProgressMonitor monitor) { - return Arrays.asList(new LSContentAssistProcessor().computeContextInformation(context.getViewer(), context.getInvocationOffset())); - } - - @Override - public String getErrorMessage() { - return null; - } - - @Override - public void sessionEnded() { - // nothing to do - } - - @Override - public void sessionStarted() { - // nothing to do - } - -} diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.updatesite/.project b/clients/eclipse/org.apache.camel.lsp.eclipse.updatesite/.project deleted file mode 100644 index 716d354fe..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.updatesite/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - Camel LSP Eclipse Update Site - - - - - - org.eclipse.pde.UpdateSiteBuilder - - - - - - org.eclipse.pde.UpdateSiteNature - - diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.updatesite/category.xml b/clients/eclipse/org.apache.camel.lsp.eclipse.updatesite/category.xml deleted file mode 100644 index be1c124cb..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.updatesite/category.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/clients/eclipse/org.apache.camel.lsp.eclipse.updatesite/pom.xml b/clients/eclipse/org.apache.camel.lsp.eclipse.updatesite/pom.xml deleted file mode 100644 index 7acf74a1e..000000000 --- a/clients/eclipse/org.apache.camel.lsp.eclipse.updatesite/pom.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - 4.0.0 - - - org.apache.camel.tools.lsp - eclipse - 1.0.0-SNAPSHOT - - org.apache.camel.lsp.eclipse.updatesite - ${base.name} :: Clients :: Eclipse Client :: Update Site - eclipse-repository - diff --git a/clients/eclipse/pom.xml b/clients/eclipse/pom.xml deleted file mode 100644 index 70d4e8199..000000000 --- a/clients/eclipse/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - 4.0.0 - - - org.apache.camel.tools.lsp - clients - 1.0.0-SNAPSHOT - - eclipse - ${base.name} :: Clients :: Eclipse Client - pom - - - 1.0.0 - - - - camel-lsp-target-platform - org.apache.camel.lsp.eclipse.client - org.apache.camel.lsp.eclipse.client.tests.integration - org.apache.camel.lsp.eclipse.updatesite - - - - - - org.eclipse.tycho - tycho-maven-plugin - ${tycho.version} - true - - - org.eclipse.tycho - target-platform-configuration - ${tycho.version} - - - - ${project.groupId} - camel-lsp-target-platform - ${project.version} - - - - - - - diff --git a/clients/pom.xml b/clients/pom.xml deleted file mode 100644 index 58046c961..000000000 --- a/clients/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - 4.0.0 - - - org.apache.camel.tools.lsp - parent - 1.0.0-SNAPSHOT - - clients - ${base.name} :: Clients - pom - - - eclipse - - - diff --git a/clients/vscode/.gitignore b/clients/vscode/.gitignore deleted file mode 100644 index fadeef716..000000000 --- a/clients/vscode/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -out -server -node_modules -jars/language-server.jar -*.vsix -.DS_Store -.vscode-test -package-lock.json -undefined -target diff --git a/clients/vscode/.project b/clients/vscode/.project deleted file mode 100644 index e725a3ad8..000000000 --- a/clients/vscode/.project +++ /dev/null @@ -1,11 +0,0 @@ - - - vscode-apache-camel - - - - - - - - diff --git a/clients/vscode/gulpfile.js b/gulpfile.js similarity index 100% rename from clients/vscode/gulpfile.js rename to gulpfile.js diff --git a/clients/vscode/icons/icon128.png b/icons/icon128.png similarity index 100% rename from clients/vscode/icons/icon128.png rename to icons/icon128.png diff --git a/clients/vscode/jars/Readme.md b/jars/Readme.md similarity index 100% rename from clients/vscode/jars/Readme.md rename to jars/Readme.md diff --git a/clients/vscode/language-configuration.json b/language-configuration.json similarity index 100% rename from clients/vscode/language-configuration.json rename to language-configuration.json diff --git a/clients/vscode/package.json b/package.json similarity index 100% rename from clients/vscode/package.json rename to package.json diff --git a/pom.xml b/pom.xml deleted file mode 100644 index d8b20f787..000000000 --- a/pom.xml +++ /dev/null @@ -1,96 +0,0 @@ - - 4.0.0 - org.apache.camel.tools.lsp - parent - 1.0.0-SNAPSHOT - pom - ${base.name} :: Parent - - Apache Camel Language Server - UTF-8 - - 1.8 - 1.8 - - jacoco - reuseReports - **/*Test.*,**/test/**/*,**/*IT.* - - ../target/jacoco.exec - ../../../target/jacoco-it.exec - ${sonar.jacoco.reportPath},${sonar.jacoco.itReportPath} - - - server - clients - - - - - org.jacoco - jacoco-maven-plugin - 0.7.9 - - true - org.apache.camel.tools.lsp.*,org.apache.camel.lsp.* - - - - agent-for-ut - - prepare-agent - - - ${sonar.jacoco.reportPath} - - - - agent-for-it - - prepare-agent-integration - - - ${sonar.jacoco.itReportPath} - - - - - - maven-surefire-plugin - 2.20.1 - - ${argLine} - - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.5.1 - - ${maven.compiler.source} - ${maven.compiler.target} - - - - - org.apache.maven.plugins - maven-clean-plugin - 2.5 - - - - ${basedir}/libs - - - - - - - - diff --git a/clients/vscode/scripts/preinstall.js b/scripts/preinstall.js similarity index 53% rename from clients/vscode/scripts/preinstall.js rename to scripts/preinstall.js index 3b2667a02..2845daf4a 100644 --- a/clients/vscode/scripts/preinstall.js +++ b/scripts/preinstall.js @@ -1,7 +1,7 @@ 'use strict'; const fs = require('fs'); const download = require('download') -var url = "https://github.com/apupier/camel-language-server/releases/download/untagged-5a182c0119681071de73/camel-lsp-server-1.0.0-SNAPSHOT.jar" +var url = "https://github.com/lhein/camel-language-server/releases/download/untagged-91e507435585e8ecfacd/camel-lsp-server-1.0.0-SNAPSHOT.jar" download(url).then(data => { fs.writeFileSync('./jars/language-server.jar', data); diff --git a/server/.classpath b/server/.classpath deleted file mode 100644 index ace82666f..000000000 --- a/server/.classpath +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/server/.project b/server/.project deleted file mode 100644 index 87d0a53b5..000000000 --- a/server/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - Camel LSP Server Impl - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.m2e.core.maven2Builder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.m2e.core.maven2Nature - - diff --git a/server/.settings/org.eclipse.core.resources.prefs b/server/.settings/org.eclipse.core.resources.prefs deleted file mode 100644 index 29abf9995..000000000 --- a/server/.settings/org.eclipse.core.resources.prefs +++ /dev/null @@ -1,6 +0,0 @@ -eclipse.preferences.version=1 -encoding//src/main/java=UTF-8 -encoding//src/main/resources=UTF-8 -encoding//src/test/java=UTF-8 -encoding//src/test/resources=UTF-8 -encoding/=UTF-8 diff --git a/server/.settings/org.eclipse.jdt.core.prefs b/server/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 714351aec..000000000 --- a/server/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,5 +0,0 @@ -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 -org.eclipse.jdt.core.compiler.compliance=1.8 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.8 diff --git a/server/.settings/org.eclipse.m2e.core.prefs b/server/.settings/org.eclipse.m2e.core.prefs deleted file mode 100644 index f897a7f1c..000000000 --- a/server/.settings/org.eclipse.m2e.core.prefs +++ /dev/null @@ -1,4 +0,0 @@ -activeProfiles= -eclipse.preferences.version=1 -resolveWorkspaceProjects=true -version=1 diff --git a/server/pom.xml b/server/pom.xml deleted file mode 100644 index fccbd8cab..000000000 --- a/server/pom.xml +++ /dev/null @@ -1,75 +0,0 @@ - - 4.0.0 - - org.apache.camel.tools.lsp - parent - 1.0.0-SNAPSHOT - - camel-lsp-server - ${base.name} :: Server Implementation - - 0.3.0 - 2.20.2 - - - - - org.springframework.boot - spring-boot-maven-plugin - 1.4.0.RELEASE - - - - repackage - - - - - - - - - org.eclipse.lsp4j - org.eclipse.lsp4j.jsonrpc - ${lsp4j.version} - - - org.eclipse.lsp4j - org.eclipse.lsp4j - ${lsp4j.version} - - - org.slf4j - slf4j-api - 1.7.6 - - - org.slf4j - slf4j-log4j12 - 1.7.6 - - - org.apache.camel - camel-catalog - ${camel.version} - - - org.apache.camel - camel-route-parser - ${camel.version} - - - junit - junit - 4.12 - test - - - org.assertj - assertj-core - 3.8.0 - test - - - diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/AbstractLanguageServer.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/AbstractLanguageServer.java deleted file mode 100644 index 848d709bd..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/AbstractLanguageServer.java +++ /dev/null @@ -1,163 +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. - */ -package org.apache.camel.tools.lsp.internal; - -import java.io.IOException; - -import org.eclipse.lsp4j.services.TextDocumentService; -import org.eclipse.lsp4j.services.WorkspaceService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author lhein - */ -public abstract class AbstractLanguageServer { - - private static final String OS = System.getProperty("os.name").toLowerCase(); - - private final class CamelServerRunnable implements Runnable { - @Override - public void run() { - LOGGER.info("Starting Camel Language Server..."); - while (!shutdown && parentProcessStillRunning()) { - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - LOGGER.error(e.getMessage(), e); - Thread.currentThread().interrupt(); - } - } - LOGGER.info("Camel Language Server - Client vanished..."); - } - } - - private static final Logger LOGGER = LoggerFactory.getLogger(AbstractLanguageServer.class); - - private Thread runner; - private volatile boolean shutdown; - private long parentProcessId; - private WorkspaceService workspaceService; - private TextDocumentService textDocumentService; - - /** - * starts the language server process - * - * @return the exit code of the process - */ - public int startServer() { - runner = new Thread(new CamelServerRunnable(), "Camel Language Client Watcher"); - runner.start(); - return 0; - } - - /** - * Checks whether the parent process is still running. - * If not, then we assume it has crashed, and we have to terminate the Camel Language Server. - * - * @return true if the parent process is still running - */ - protected boolean parentProcessStillRunning() { - // Wait until parent process id is available - - if (parentProcessId == 0) { - LOGGER.info("Waiting for a client connection..."); - } else { - LOGGER.info("Checking for client process pid: {0}", parentProcessId); - } - - if (parentProcessId == 0) return true; - - String command; - if (OS.indexOf("win") != -1) { // && "x86".equals(ARCH) - command = "cmd /c \"tasklist /FI \"PID eq " + parentProcessId + "\" | findstr " + parentProcessId + "\""; - } else { - command = "ps -p " + parentProcessId; - } - try { - Process process = Runtime.getRuntime().exec(command); - int processResult = process.waitFor(); - return processResult == 0; - } catch (IOException | InterruptedException e) { - LOGGER.error(e.getMessage(), e); - return true; - } - } - - /** - * stops the server - */ - public void stopServer() { - LOGGER.info("Stopping language server"); - runner.interrupt(); - } - - /** - * shuts the server down - */ - public void shutdownServer() { - LOGGER.info("Shutting down language server"); - shutdown = true; - } - - /** - * returns the parent process id - * - * @return - */ - protected synchronized long getParentProcessId() { - return parentProcessId; - } - - /** - * sets the parent process id - * - * @param processId - */ - protected synchronized void setParentProcessId(long processId) { - LOGGER.info("Setting client pid to {0}", processId); - parentProcessId = processId; - } - - /** - * @return the textDocumentService - */ - public TextDocumentService getTextDocumentService() { - return this.textDocumentService; - } - - /** - * @param textDocumentService the textDocumentService to set - */ - protected void setTextDocumentService(TextDocumentService textDocumentService) { - this.textDocumentService = textDocumentService; - } - - /** - * @return the workspaceService - */ - protected WorkspaceService getWorkspaceService() { - return this.workspaceService; - } - - /** - * @param workspaceService the workspaceService to set - */ - protected void setWorkspaceService(WorkspaceService workspaceService) { - this.workspaceService = workspaceService; - } -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/CamelLanguageServer.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/CamelLanguageServer.java deleted file mode 100644 index c07d4da37..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/CamelLanguageServer.java +++ /dev/null @@ -1,120 +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. - */ -package org.apache.camel.tools.lsp.internal; - -import java.util.Arrays; -import java.util.concurrent.CompletableFuture; - -import org.eclipse.lsp4j.CompletionOptions; -import org.eclipse.lsp4j.InitializeParams; -import org.eclipse.lsp4j.InitializeResult; -import org.eclipse.lsp4j.MessageParams; -import org.eclipse.lsp4j.MessageType; -import org.eclipse.lsp4j.ServerCapabilities; -import org.eclipse.lsp4j.TextDocumentSyncKind; -import org.eclipse.lsp4j.services.LanguageClient; -import org.eclipse.lsp4j.services.LanguageClientAware; -import org.eclipse.lsp4j.services.LanguageServer; -import org.eclipse.lsp4j.services.WorkspaceService; - -/** - * this is the actual server implementation - * - * @author lhein - */ -public class CamelLanguageServer extends AbstractLanguageServer implements LanguageServer, LanguageClientAware { - - public static final String LANGUAGE_ID = "LANGUAGE_ID_APACHE_CAMEL"; - - private LanguageClient client; - - public CamelLanguageServer() { - super.setTextDocumentService(new CamelTextDocumentService()); - super.setWorkspaceService(new CamelWorkspaceService()); - } - - @Override - public void connect(LanguageClient client) { - this.client = client; - sendLogMessageNotification(MessageType.Info, "Connected to Language Server..."); - } - - @Override - public void exit() { - super.stopServer(); - System.exit(0); - } - - @Override - public CompletableFuture initialize(InitializeParams params) { - sendLogMessageNotification(MessageType.Info, "Initializing capabilities of the server..."); - Integer processId = params.getProcessId(); - if(processId != null) { - setParentProcessId(processId.longValue()); - } else { - sendLogMessageNotification(MessageType.Info, "Missing Parent process ID!!"); - setParentProcessId(0); - } - - InitializeResult result = new InitializeResult(); - - ServerCapabilities capabilities = new ServerCapabilities(); - capabilities.setTextDocumentSync(TextDocumentSyncKind.Full); - capabilities.setCompletionProvider(new CompletionOptions(Boolean.TRUE, Arrays.asList(".","?","&", "\"", "="))); - capabilities.setHoverProvider(Boolean.TRUE); - - result.setCapabilities(capabilities); - return CompletableFuture.completedFuture(result); - } - - @Override - public CompletableFuture shutdown() { - super.shutdownServer(); - return CompletableFuture.completedFuture(new Object()); - } - - @Override - public WorkspaceService getWorkspaceService() { - return super.getWorkspaceService(); - } - - /** - * Sends the given log message notification back to the client - * as a notification - * - * @param type - * the type of message - * @param msg - * The message to send back to the client - */ - public void sendLogMessageNotification(final MessageType type, final String msg) { - client.logMessage(new MessageParams(type, msg)); - } - - /** - * Sends the given show message notification back to the client - * as a notification - * - * @param type - * the type of message - * @param msg - * The message to send back to the client - */ - public void sendShowMessageNotification(final MessageType type, final String msg) { - client.showMessage(new MessageParams(type, msg)); - } -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/CamelTextDocumentService.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/CamelTextDocumentService.java deleted file mode 100644 index 389c884be..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/CamelTextDocumentService.java +++ /dev/null @@ -1,197 +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. - */ -package org.apache.camel.tools.lsp.internal; - -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.CompletableFuture; - -import org.apache.camel.catalog.CamelCatalog; -import org.apache.camel.catalog.DefaultCamelCatalog; -import org.apache.camel.tools.lsp.internal.completion.CamelEndpointCompletionProcessor; -import org.apache.camel.tools.lsp.internal.hover.HoverProcessor; -import org.eclipse.lsp4j.CodeActionParams; -import org.eclipse.lsp4j.CodeLens; -import org.eclipse.lsp4j.CodeLensParams; -import org.eclipse.lsp4j.Command; -import org.eclipse.lsp4j.CompletionItem; -import org.eclipse.lsp4j.CompletionList; -import org.eclipse.lsp4j.DidChangeTextDocumentParams; -import org.eclipse.lsp4j.DidCloseTextDocumentParams; -import org.eclipse.lsp4j.DidOpenTextDocumentParams; -import org.eclipse.lsp4j.DidSaveTextDocumentParams; -import org.eclipse.lsp4j.DocumentFormattingParams; -import org.eclipse.lsp4j.DocumentHighlight; -import org.eclipse.lsp4j.DocumentOnTypeFormattingParams; -import org.eclipse.lsp4j.DocumentRangeFormattingParams; -import org.eclipse.lsp4j.DocumentSymbolParams; -import org.eclipse.lsp4j.Hover; -import org.eclipse.lsp4j.Location; -import org.eclipse.lsp4j.ReferenceParams; -import org.eclipse.lsp4j.RenameParams; -import org.eclipse.lsp4j.SignatureHelp; -import org.eclipse.lsp4j.SymbolInformation; -import org.eclipse.lsp4j.TextDocumentContentChangeEvent; -import org.eclipse.lsp4j.TextDocumentItem; -import org.eclipse.lsp4j.TextDocumentPositionParams; -import org.eclipse.lsp4j.TextEdit; -import org.eclipse.lsp4j.WorkspaceEdit; -import org.eclipse.lsp4j.jsonrpc.messages.Either; -import org.eclipse.lsp4j.services.TextDocumentService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author lhein - */ -public class CamelTextDocumentService implements TextDocumentService { - - private static final Logger LOGGER = LoggerFactory.getLogger(CamelTextDocumentService.class); - private Map openedDocuments = new HashMap<>(); - private CompletableFuture camelCatalog; - - public CamelTextDocumentService() { - camelCatalog = CompletableFuture.supplyAsync(() -> { - DefaultCamelCatalog res = new DefaultCamelCatalog(true); - res.loadVersion("2.20.2"); - return res; - }); - } - - @Override - public CompletableFuture, CompletionList>> completion(TextDocumentPositionParams completionRequest) { - LOGGER.info("completion: " + completionRequest.getTextDocument().getUri()); - TextDocumentItem textDocumentItem = openedDocuments.get(completionRequest.getTextDocument().getUri()); - return new CamelEndpointCompletionProcessor(textDocumentItem, camelCatalog).getCompletions(completionRequest.getPosition()).thenApply(Either::forLeft); - } - - @Override - public CompletableFuture resolveCompletionItem(CompletionItem unresolved) { - LOGGER.info("resolveCompletionItem: " + unresolved.getDetail()); - return CompletableFuture.completedFuture(unresolved); - } - - @Override - public CompletableFuture hover(TextDocumentPositionParams position) { - LOGGER.info("hover: " + position.getTextDocument()); - TextDocumentItem textDocumentItem = openedDocuments.get(position.getTextDocument().getUri()); - return new HoverProcessor(textDocumentItem, camelCatalog).getHover(position.getPosition()); - } - - @Override - public CompletableFuture signatureHelp(TextDocumentPositionParams position) { - LOGGER.info("signatureHelp: " + position.getTextDocument()); - return CompletableFuture.completedFuture(null); - } - - @Override - public CompletableFuture> definition(TextDocumentPositionParams position) { - LOGGER.info("definition: " + position.getTextDocument()); - return CompletableFuture.completedFuture(Collections.emptyList()); - } - - @Override - public CompletableFuture> references(ReferenceParams params) { - LOGGER.info("references: " + params.getTextDocument()); - return CompletableFuture.completedFuture(Collections.emptyList()); - } - - @Override - public CompletableFuture> documentHighlight(TextDocumentPositionParams position) { - LOGGER.info("documentHighlight: " + position.getTextDocument()); - return CompletableFuture.completedFuture(Collections.emptyList()); - } - - @Override - public CompletableFuture> documentSymbol(DocumentSymbolParams params) { - LOGGER.info("documentSymbol: " + params.getTextDocument()); - return CompletableFuture.completedFuture(Collections.emptyList()); - } - - @Override - public CompletableFuture> codeAction(CodeActionParams params) { - LOGGER.info("codeAction: " + params.getTextDocument()); - return CompletableFuture.completedFuture(Collections.emptyList()); - } - - @Override - public CompletableFuture> codeLens(CodeLensParams params) { - LOGGER.info("codeLens: " + params.getTextDocument()); - return CompletableFuture.completedFuture(Collections.emptyList()); - } - - @Override - public CompletableFuture resolveCodeLens(CodeLens unresolved) { - LOGGER.info("resolveCodeLens: " + unresolved.getCommand().getCommand()); - return CompletableFuture.completedFuture(null); - } - - @Override - public CompletableFuture> formatting(DocumentFormattingParams params) { - LOGGER.info("formatting: " + params.getTextDocument()); - return CompletableFuture.completedFuture(Collections.emptyList()); - } - - @Override - public CompletableFuture> rangeFormatting(DocumentRangeFormattingParams params) { - LOGGER.info("rangeFormatting: " + params.getTextDocument()); - return CompletableFuture.completedFuture(Collections.emptyList()); - } - - @Override - public CompletableFuture> onTypeFormatting(DocumentOnTypeFormattingParams params) { - LOGGER.info("onTypeFormatting: " + params.getTextDocument()); - return CompletableFuture.completedFuture(Collections.emptyList()); - } - - @Override - public CompletableFuture rename(RenameParams params) { - LOGGER.info("rename: " + params.getTextDocument()); - return CompletableFuture.completedFuture(null); - } - - @Override - public void didOpen(DidOpenTextDocumentParams params) { - TextDocumentItem textDocument = params.getTextDocument(); - LOGGER.info("didOpen: {0}", textDocument); - openedDocuments.put(textDocument.getUri(), textDocument); - } - - @Override - public void didChange(DidChangeTextDocumentParams params) { - LOGGER.info("didChange: " + params.getTextDocument()); - List contentChanges = params.getContentChanges(); - TextDocumentItem textDocumentItem = openedDocuments.get(params.getTextDocument().getUri()); - if (!contentChanges.isEmpty()) { - textDocumentItem.setText(contentChanges.get(0).getText()); - } - } - - @Override - public void didClose(DidCloseTextDocumentParams params) { - LOGGER.info("didClose: " + params.getTextDocument()); - openedDocuments.remove(params.getTextDocument().getUri()); - } - - @Override - public void didSave(DidSaveTextDocumentParams params) { - LOGGER.info("didSave: " + params.getTextDocument()); - } - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/CamelWorkspaceService.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/CamelWorkspaceService.java deleted file mode 100644 index b193ce7e7..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/CamelWorkspaceService.java +++ /dev/null @@ -1,56 +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. - */ -package org.apache.camel.tools.lsp.internal; - -import java.util.Collections; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -import org.eclipse.lsp4j.DidChangeConfigurationParams; -import org.eclipse.lsp4j.DidChangeWatchedFilesParams; -import org.eclipse.lsp4j.FileEvent; -import org.eclipse.lsp4j.SymbolInformation; -import org.eclipse.lsp4j.WorkspaceSymbolParams; -import org.eclipse.lsp4j.services.WorkspaceService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author lhein - */ -public class CamelWorkspaceService implements WorkspaceService { - - private static final Logger LOGGER = LoggerFactory.getLogger(CamelWorkspaceService.class); - - @Override - public CompletableFuture> symbol(WorkspaceSymbolParams params) { - LOGGER.info("SERVER: symbolQuery: " + params.getQuery()); - return CompletableFuture.completedFuture(Collections.emptyList()); - } - - @Override - public void didChangeConfiguration(DidChangeConfigurationParams params) { - Object settings = params.getSettings(); - LOGGER.info("SERVER: changeConfig: settings -> {0}", settings); - } - - @Override - public void didChangeWatchedFiles(DidChangeWatchedFilesParams params) { - List settings = params.getChanges(); - LOGGER.info("SERVER: changeWatchedFiles: size -> {0}", settings.size()); - } -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/Runner.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/Runner.java deleted file mode 100644 index a5133ffad..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/Runner.java +++ /dev/null @@ -1,33 +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. - */ -package org.apache.camel.tools.lsp.internal; - -import org.eclipse.lsp4j.jsonrpc.Launcher; -import org.eclipse.lsp4j.services.LanguageClient; - -/** - * @author lhein - */ -public class Runner { - - public static void main(String[] args) { - CamelLanguageServer server = new CamelLanguageServer(); - Launcher launcher = Launcher.createLauncher(server, LanguageClient.class, System.in, System.out); - server.connect(launcher.getRemoteProxy()); - launcher.startListening(); - } -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentSchemaCompletionsFuture.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentSchemaCompletionsFuture.java deleted file mode 100644 index 177a69e17..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentSchemaCompletionsFuture.java +++ /dev/null @@ -1,38 +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. - */ -package org.apache.camel.tools.lsp.internal.completion; - -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; - -import org.apache.camel.catalog.CamelCatalog; -import org.apache.camel.tools.lsp.internal.model.util.ModelHelper; -import org.eclipse.lsp4j.CompletionItem; - -public final class CamelComponentSchemaCompletionsFuture implements Function> { - @Override - public List apply(CamelCatalog catalog) { - return catalog.findComponentNames().stream() - .map(componentName -> ModelHelper.generateComponentModel(catalog.componentJSonSchema(componentName), true)) - .map(componentModel -> { - CompletionItem completionItem = new CompletionItem(componentModel.getSyntax()); - completionItem.setDocumentation(componentModel.getDescription()); - return completionItem; - }).collect(Collectors.toList()); - } -} \ No newline at end of file diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelEndpointCompletionProcessor.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelEndpointCompletionProcessor.java deleted file mode 100644 index 0906d090f..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelEndpointCompletionProcessor.java +++ /dev/null @@ -1,65 +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. - */ -package org.apache.camel.tools.lsp.internal.completion; - -import java.util.Collections; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -import org.apache.camel.catalog.CamelCatalog; -import org.apache.camel.tools.lsp.internal.parser.CamelURIInstance; -import org.apache.camel.tools.lsp.internal.parser.CamelUriElementInstance; -import org.apache.camel.tools.lsp.internal.parser.ParserFileHelper; -import org.eclipse.lsp4j.CompletionItem; -import org.eclipse.lsp4j.Position; -import org.eclipse.lsp4j.TextDocumentItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Node; - -public class CamelEndpointCompletionProcessor { - - private static final Logger LOGGER = LoggerFactory.getLogger(CamelEndpointCompletionProcessor.class); - private TextDocumentItem textDocumentItem; - private ParserFileHelper parserFileHelper = new ParserFileHelper(); - private CompletableFuture camelCatalog; - - public CamelEndpointCompletionProcessor(TextDocumentItem textDocumentItem, CompletableFuture camelCatalog) { - this.textDocumentItem = textDocumentItem; - this.camelCatalog = camelCatalog; - } - - public CompletableFuture> getCompletions(Position position) { - if(textDocumentItem != null) { - try { - Node correspondingCamelNode = parserFileHelper.getCorrespondingCamelNodeForCompletion(textDocumentItem, position.getLine()); - if (correspondingCamelNode != null) { - String line = parserFileHelper.getLine(textDocumentItem, position); - String camelComponentUri = parserFileHelper.getCamelComponentUri(textDocumentItem, position); - CamelURIInstance camelURIInstance = new CamelURIInstance(camelComponentUri, correspondingCamelNode); - int positionInCamelUri = position.getCharacter() - line.indexOf("uri=") - 5; - CamelUriElementInstance camelUriElementInstance = camelURIInstance.getSpecificElement(positionInCamelUri); - return camelUriElementInstance.getCompletions(camelCatalog, positionInCamelUri); - } - } catch (Exception e) { - LOGGER.error("Error searching for corresponding node elements", e); - } - } - return CompletableFuture.completedFuture(Collections.emptyList()); - } - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelOptionSchemaCompletionsFuture.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelOptionSchemaCompletionsFuture.java deleted file mode 100644 index 413eae514..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelOptionSchemaCompletionsFuture.java +++ /dev/null @@ -1,64 +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. - */ -package org.apache.camel.tools.lsp.internal.completion; - -import java.util.List; -import java.util.function.Function; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -import org.apache.camel.catalog.CamelCatalog; -import org.apache.camel.tools.lsp.internal.model.EndpointOptionModel; -import org.apache.camel.tools.lsp.internal.model.util.ModelHelper; -import org.eclipse.lsp4j.CompletionItem; - -public class CamelOptionSchemaCompletionsFuture implements Function> { - - private String camelComponentName; - private boolean isProducer; - - public CamelOptionSchemaCompletionsFuture(String camelComponentName, boolean isProducer) { - this.camelComponentName = camelComponentName; - this.isProducer = isProducer; - } - - @Override - public List apply(CamelCatalog catalog) { - Stream endpointOptions = ModelHelper.generateComponentModel(catalog.componentJSonSchema(camelComponentName), true).getEndpointOptions().stream(); - return endpointOptions - .filter(endpoint -> "parameter".equals(endpoint.getKind())) - .filter(endpoint -> { - String group = endpoint.getGroup(); - if (isProducer) { - return !"consumer".equals(group); - } else { - return !"producer".equals(group); - } - }) - .map(parameter -> { - CompletionItem completionItem = new CompletionItem(parameter.getName()); - String insertText = parameter.getName() + "="; - if(parameter.getDefaultValue() != null) { - insertText += parameter.getDefaultValue(); - } - completionItem.setInsertText(insertText); - return completionItem; - }) - .collect(Collectors.toList()); - } - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelOptionValuesCompletionsFuture.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelOptionValuesCompletionsFuture.java deleted file mode 100644 index 3ad27ca75..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/completion/CamelOptionValuesCompletionsFuture.java +++ /dev/null @@ -1,73 +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. - */ -package org.apache.camel.tools.lsp.internal.completion; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; -import java.util.Optional; -import java.util.function.Function; - -import org.apache.camel.catalog.CamelCatalog; -import org.apache.camel.tools.lsp.internal.model.EndpointOptionModel; -import org.apache.camel.tools.lsp.internal.model.util.ModelHelper; -import org.apache.camel.tools.lsp.internal.parser.OptionParamValueURIInstance; -import org.eclipse.lsp4j.CompletionItem; - -public class CamelOptionValuesCompletionsFuture implements Function> { - - private static final String BOOLEAN_TYPE = "boolean"; - private OptionParamValueURIInstance optionParamValueURIInstance; - - public CamelOptionValuesCompletionsFuture(OptionParamValueURIInstance optionParamValueURIInstance) { - this.optionParamValueURIInstance = optionParamValueURIInstance; - } - - @Override - public List apply(CamelCatalog camelCatalog) { - Optional endpointModel = retrieveEndpointOptionModel(camelCatalog); - if(endpointModel.isPresent()) { - EndpointOptionModel endpointOptionModel = endpointModel.get(); - String enums = endpointOptionModel.getEnums(); - if (enums != null && !enums.isEmpty()) { - return computeCompletionForEnums(enums); - } else if(BOOLEAN_TYPE.equals(endpointOptionModel.getType())) { - return Arrays.asList(new CompletionItem(Boolean.TRUE.toString()), new CompletionItem(Boolean.FALSE.toString())); - } - } - return Collections.emptyList(); - } - - private List computeCompletionForEnums(String enums) { - List completionItems = new ArrayList<>(); - for(String enumValue : enums.split(",")) { - completionItems.add(new CompletionItem(enumValue)); - } - return completionItems; - } - - private Optional retrieveEndpointOptionModel(CamelCatalog camelCatalog) { - String componentName = optionParamValueURIInstance.getOptionParamURIInstance().getComponentName(); - String keyName = optionParamValueURIInstance.getOptionParamURIInstance().getKey().getKeyName(); - List endpointOptions = ModelHelper.generateComponentModel(camelCatalog.componentJSonSchema(componentName), true).getEndpointOptions(); - return endpointOptions.stream() - .filter(endpoint -> keyName.equals(endpoint.getName())) - .findAny(); - } - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/hover/HoverFuture.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/hover/HoverFuture.java deleted file mode 100644 index 30ac67920..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/hover/HoverFuture.java +++ /dev/null @@ -1,45 +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. - */ -package org.apache.camel.tools.lsp.internal.hover; - -import java.util.Collections; -import java.util.function.Function; - -import org.apache.camel.catalog.CamelCatalog; -import org.apache.camel.tools.lsp.internal.model.ComponentModel; -import org.apache.camel.tools.lsp.internal.model.util.ModelHelper; -import org.eclipse.lsp4j.Hover; -import org.eclipse.lsp4j.jsonrpc.messages.Either; - -public class HoverFuture implements Function { - - private String componentName; - - public HoverFuture(String componentName) { - this.componentName = componentName; - } - - @Override - public Hover apply(CamelCatalog camelCatalog) { - Hover hover = new Hover(); - ComponentModel componentModel = ModelHelper.generateComponentModel(camelCatalog.componentJSonSchema(componentName), true); - hover.setContents(Collections.singletonList((Either.forLeft(componentModel.getDescription())))); - return hover; - } - - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/hover/HoverProcessor.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/hover/HoverProcessor.java deleted file mode 100644 index 23783adbc..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/hover/HoverProcessor.java +++ /dev/null @@ -1,58 +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. - */ -package org.apache.camel.tools.lsp.internal.hover; - -import java.util.Collections; -import java.util.concurrent.CompletableFuture; - -import org.apache.camel.catalog.CamelCatalog; -import org.apache.camel.tools.lsp.internal.model.util.StringUtils; -import org.apache.camel.tools.lsp.internal.parser.ParserFileHelper; -import org.eclipse.lsp4j.Hover; -import org.eclipse.lsp4j.Position; -import org.eclipse.lsp4j.TextDocumentItem; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class HoverProcessor { - - private static final Logger LOGGER = LoggerFactory.getLogger(HoverProcessor.class); - private TextDocumentItem textDocumentItem; - private CompletableFuture camelCatalog; - - public HoverProcessor(TextDocumentItem textDocumentItem, CompletableFuture camelCatalog) { - this.textDocumentItem = textDocumentItem; - this.camelCatalog = camelCatalog; - } - - public CompletableFuture getHover(Position position) { - try { - ParserFileHelper parserFileHelper = new ParserFileHelper(); - if(parserFileHelper.getCorrespondingCamelNodeForCompletion(textDocumentItem, position.getLine()) != null){ - String camelComponentUri = parserFileHelper.getCamelComponentUri(textDocumentItem, position); - String componentName = StringUtils.asComponentName(camelComponentUri); - if (componentName != null) { - return camelCatalog.thenApply(new HoverFuture(componentName)); - } - } - } catch (Exception e) { - LOGGER.error("Error searching hover", e); - } - return CompletableFuture.completedFuture(new Hover(Collections.emptyList())); - } - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/model/ComponentModel.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/model/ComponentModel.java deleted file mode 100644 index 0e0b013a9..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/model/ComponentModel.java +++ /dev/null @@ -1,186 +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. - */ -package org.apache.camel.tools.lsp.internal.model; - -import java.util.ArrayList; -import java.util.List; - -public class ComponentModel { - - private String kind; - private String scheme; - private String syntax; - private String alternativeSyntax; - private String alternativeSchemes; - private String title; - private String description; - private String label; - private String deprecated; - private String consumerOnly; - private String producerOnly; - private String javaType; - private String groupId; - private String artifactId; - private String version; - private final List componentOptions = new ArrayList<>(); - private final List endpointOptions = new ArrayList<>(); - - public String getKind() { - return kind; - } - - public void setKind(String kind) { - this.kind = kind; - } - - public String getScheme() { - return scheme; - } - - public void setScheme(String scheme) { - this.scheme = scheme; - } - - public String getSyntax() { - return syntax; - } - - public void setSyntax(String syntax) { - this.syntax = syntax; - } - - public String getAlternativeSyntax() { - return alternativeSyntax; - } - - public void setAlternativeSyntax(String alternativeSyntax) { - this.alternativeSyntax = alternativeSyntax; - } - - public String getAlternativeSchemes() { - return alternativeSchemes; - } - - public void setAlternativeSchemes(String alternativeSchemes) { - this.alternativeSchemes = alternativeSchemes; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getDeprecated() { - return deprecated; - } - - public void setDeprecated(String deprecated) { - this.deprecated = deprecated; - } - - public String getConsumerOnly() { - return consumerOnly; - } - - public void setConsumerOnly(String consumerOnly) { - this.consumerOnly = consumerOnly; - } - - public String getProducerOnly() { - return producerOnly; - } - - public void setProducerOnly(String producerOnly) { - this.producerOnly = producerOnly; - } - - public String getJavaType() { - return javaType; - } - - public void setJavaType(String javaType) { - this.javaType = javaType; - } - - public String getGroupId() { - return groupId; - } - - public void setGroupId(String groupId) { - this.groupId = groupId; - } - - public String getArtifactId() { - return artifactId; - } - - public void setArtifactId(String artifactId) { - this.artifactId = artifactId; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public List getComponentOptions() { - return componentOptions; - } - - public void addComponentOption(ComponentOptionModel option) { - componentOptions.add(option); - } - - public List getEndpointOptions() { - return endpointOptions; - } - - public void addEndpointOption(EndpointOptionModel option) { - endpointOptions.add(option); - } - - public ComponentOptionModel getComponentOption(String name) { - return componentOptions.stream().filter(o -> o.getName().equals(name)).findFirst().orElse(null); - } - - public EndpointOptionModel getEndpointOption(String name) { - return endpointOptions.stream().filter(o -> o.getName().equals(name)).findFirst().orElse(null); - } - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/model/ComponentOptionModel.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/model/ComponentOptionModel.java deleted file mode 100644 index dd1487d50..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/model/ComponentOptionModel.java +++ /dev/null @@ -1,121 +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. - */ -package org.apache.camel.tools.lsp.internal.model; - -public class ComponentOptionModel { - - private String name; - private String kind; - private String group; - private String required; - private String type; - private String javaType; - private String deprecated; - private String secret; - private String description; - private String defaultValue; - private String enums; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getKind() { - return kind; - } - - public void setKind(String kind) { - this.kind = kind; - } - - public String getGroup() { - return group; - } - - public void setGroup(String group) { - this.group = group; - } - - public String getRequired() { - return required; - } - - public void setRequired(String required) { - this.required = required; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getJavaType() { - return javaType; - } - - public void setJavaType(String javaType) { - this.javaType = javaType; - } - - public String getDeprecated() { - return deprecated; - } - - public void setDeprecated(String deprecated) { - this.deprecated = deprecated; - } - - public String getSecret() { - return secret; - } - - public void setSecret(String secret) { - this.secret = secret; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - public String getEnums() { - return enums; - } - - public void setEnums(String enums) { - this.enums = enums; - } - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/model/EndpointOptionModel.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/model/EndpointOptionModel.java deleted file mode 100644 index 0d849fd94..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/model/EndpointOptionModel.java +++ /dev/null @@ -1,157 +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. - */ -package org.apache.camel.tools.lsp.internal.model; - -public class EndpointOptionModel { - - private String name; - private String kind; - private String group; - private String label; - private String required; - private String type; - private String javaType; - private String enums; - private String prefix; - private String multiValue; - private String deprecated; - private String secret; - private String defaultValue; - private String description; - private String enumValues; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getKind() { - return kind; - } - - public void setKind(String kind) { - this.kind = kind; - } - - public String getGroup() { - return group; - } - - public void setGroup(String group) { - this.group = group; - } - - public String getLabel() { - return label; - } - - public void setLabel(String label) { - this.label = label; - } - - public String getRequired() { - return required; - } - - public void setRequired(String required) { - this.required = required; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getJavaType() { - return javaType; - } - - public void setJavaType(String javaType) { - this.javaType = javaType; - } - - public String getEnums() { - return enums; - } - - public void setEnums(String enums) { - this.enums = enums; - } - - public String getPrefix() { - return prefix; - } - - public void setPrefix(String prefix) { - this.prefix = prefix; - } - - public String getMultiValue() { - return multiValue; - } - - public void setMultiValue(String multiValue) { - this.multiValue = multiValue; - } - - public String getDeprecated() { - return deprecated; - } - - public void setDeprecated(String deprecated) { - this.deprecated = deprecated; - } - - public String getSecret() { - return secret; - } - - public void setSecret(String secret) { - this.secret = secret; - } - - public String getDefaultValue() { - return defaultValue; - } - - public void setDefaultValue(String defaultValue) { - this.defaultValue = defaultValue; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getEnumValues() { - return enumValues; - } - - public void setEnumValues(String enumValues) { - this.enumValues = enumValues; - } - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/model/util/ModelHelper.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/model/util/ModelHelper.java deleted file mode 100644 index 2eb0208c2..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/model/util/ModelHelper.java +++ /dev/null @@ -1,95 +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. - */ -package org.apache.camel.tools.lsp.internal.model.util; - -import static org.apache.camel.tools.lsp.internal.model.util.StringUtils.getSafeValue; - -import java.util.List; -import java.util.Map; - -import org.apache.camel.catalog.JSonSchemaHelper; -import org.apache.camel.tools.lsp.internal.model.ComponentModel; -import org.apache.camel.tools.lsp.internal.model.ComponentOptionModel; -import org.apache.camel.tools.lsp.internal.model.EndpointOptionModel; - -public final class ModelHelper { - - private ModelHelper() { - // utility class - } - - public static ComponentModel generateComponentModel(String json, boolean includeOptions) { - List> rows = JSonSchemaHelper.parseJsonSchema("component", json, false); - - ComponentModel component = new ComponentModel(); - component.setScheme(getSafeValue("scheme", rows)); - component.setSyntax(getSafeValue("syntax", rows)); - component.setAlternativeSyntax(getSafeValue("alternativeSyntax", rows)); - component.setAlternativeSchemes(getSafeValue("alternativeSchemes", rows)); - component.setTitle(getSafeValue("title", rows)); - component.setDescription(getSafeValue("description", rows)); - component.setLabel(getSafeValue("label", rows)); - component.setDeprecated(getSafeValue("deprecated", rows)); - component.setConsumerOnly(getSafeValue("consumerOnly", rows)); - component.setProducerOnly(getSafeValue("producerOnly", rows)); - component.setJavaType(getSafeValue("javaType", rows)); - component.setGroupId(getSafeValue("groupId", rows)); - component.setArtifactId(getSafeValue("artifactId", rows)); - component.setVersion(getSafeValue("version", rows)); - - if (includeOptions) { - rows = JSonSchemaHelper.parseJsonSchema("componentProperties", json, true); - for (Map row : rows) { - ComponentOptionModel option = new ComponentOptionModel(); - option.setName(getSafeValue("name", row)); - option.setKind(getSafeValue("kind", row)); - option.setGroup(getSafeValue("group", row)); - option.setRequired(getSafeValue("required", row)); - option.setType(getSafeValue("type", row)); - option.setJavaType(getSafeValue("javaType", row)); - option.setEnums(getSafeValue("enum", row)); - option.setDeprecated(getSafeValue("deprecated", row)); - option.setSecret(getSafeValue("secret", row)); - option.setDefaultValue(getSafeValue("defaultValue", row)); - option.setDescription(getSafeValue("description", row)); - component.addComponentOption(option); - } - - rows = JSonSchemaHelper.parseJsonSchema("properties", json, true); - for (Map row : rows) { - EndpointOptionModel option = new EndpointOptionModel(); - option.setName(getSafeValue("name", row)); - option.setKind(getSafeValue("kind", row)); - option.setGroup(getSafeValue("group", row)); - option.setLabel(getSafeValue("label", row)); - option.setRequired(getSafeValue("required", row)); - option.setType(getSafeValue("type", row)); - option.setJavaType(getSafeValue("javaType", row)); - option.setEnums(getSafeValue("enum", row)); - option.setPrefix(getSafeValue("prefix", row)); - option.setMultiValue(getSafeValue("multiValue", row)); - option.setDeprecated(getSafeValue("deprecated", row)); - option.setSecret(getSafeValue("secret", row)); - option.setDefaultValue(getSafeValue("defaultValue", row)); - option.setDescription(getSafeValue("description", row)); - component.addEndpointOption(option); - } - } - - return component; - } -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/model/util/StringUtils.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/model/util/StringUtils.java deleted file mode 100644 index 1300df8db..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/model/util/StringUtils.java +++ /dev/null @@ -1,207 +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. - */ -package org.apache.camel.tools.lsp.internal.model.util; - -import java.util.List; -import java.util.Map; - -/** - * Various utility methods. - */ -public final class StringUtils { - - private StringUtils() { - } - - /** - * Whether to given value has a question mark or not - */ - static boolean hasQuestionMark(String val) { - return val != null && val.indexOf('?') > 0; - } - - /** - * Gets the value as a Camel component name - */ - public static String asComponentName(String val) { - if (val == null) { - return null; - } - - int pos = val.indexOf(':'); - if (pos > 0) { - return val.substring(0, pos); - } - return null; - } - - /** - * Gets the value as a Camel language name - */ - public static String asLanguageName(String val) { - if (val == null) { - return null; - } - - if (val.startsWith("tokenize")) { - return "tokenize"; - } else if (val.equals("js") || val.equals("javascript")) { - return "javaScript"; - } - - return val; - } - - /** - * Gets the value with the key in a safe way, eg returning an empty string if there was no value for the key. - */ - public static String getSafeValue(String key, List> rows) { - for (Map row : rows) { - String value = row.get(key); - if (value != null) { - return value; - } - } - return ""; - } - - /** - * Gets the value with the key in a safe way, eg returning an empty string if there was no value for the key. - */ - public static String getSafeValue(String key, Map rows) { - String value = rows.get(key); - if (value != null) { - return value; - } - return ""; - } - - /** - * To wrap a big line by a separator. - * - * @param line the big line - * @param separator the separator char such as & - * @param newLine the new line to use when breaking into a new line - * @param watermark a watermark to denote the size to cut after - */ - public static String wrapSeparator(String line, String separator, String newLine, int watermark) { - StringBuilder sb = new StringBuilder(); - String[] parts = line.split(separator); - - StringBuilder part = new StringBuilder(); - for (int i = 0; i < parts.length; i++) { - String word = parts[i]; - part.append(word); - if (i < parts.length - 1) { - part.append(separator); - } - // did we hit watermark then reset - if (part.length() >= watermark) { - // move separator to new line - String add = part.toString(); - if (add.endsWith(separator)) { - add = add.substring(0, add.length() - separator.length()); - } - sb.append(add); - sb.append(newLine); - sb.append(separator); - part.setLength(0); - } - } - // any leftover - if (part.length() > 0) { - sb.append(part.toString()); - } - - String answer = sb.toString(); - if (answer.endsWith(newLine)) { - answer = answer.substring(0, answer.length() - newLine.length()); - } - return answer; - } - - /** - * To wrap a big line by words. - * - * @param line the big line - * @param newLine the new line to use when breaking into a new line - * @param watermark a watermark to denote the size to cut after - * @param wrapLongWords whether to wrap long words - */ - public static String wrapWords(String line, String newLine, int watermark, boolean wrapLongWords) { - if (line == null) { - return null; - } else { - if (newLine == null) { - newLine = System.lineSeparator(); - } - - if (watermark < 1) { - watermark = 1; - } - - int inputLineLength = line.length(); - int offset = 0; - StringBuilder sb = new StringBuilder(inputLineLength + 32); - - while (inputLineLength - offset > watermark) { - if (line.charAt(offset) == 32) { - ++offset; - } else { - int spaceToWrapAt = line.lastIndexOf(32, watermark + offset); - if (spaceToWrapAt >= offset) { - sb.append(line.substring(offset, spaceToWrapAt)); - sb.append(newLine); - offset = spaceToWrapAt + 1; - } else if (wrapLongWords) { - sb.append(line.substring(offset, watermark + offset)); - sb.append(newLine); - offset += watermark; - } else { - spaceToWrapAt = line.indexOf(32, watermark + offset); - if (spaceToWrapAt >= 0) { - sb.append(line.substring(offset, spaceToWrapAt)); - sb.append(newLine); - offset = spaceToWrapAt + 1; - } else { - sb.append(line.substring(offset)); - offset = inputLineLength; - } - } - } - } - - sb.append(line.substring(offset)); - return sb.toString(); - } - } - - /** - * Is the string empty - */ - public static boolean isEmpty(String str) { - return str == null || str.trim().length() == 0; - } - - /** - * Is the string NOT empty - */ - public static boolean isNotEmpty(String str) { - return !isEmpty(str); - } - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/CamelComponentURIInstance.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/CamelComponentURIInstance.java deleted file mode 100644 index 5cf2d5599..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/CamelComponentURIInstance.java +++ /dev/null @@ -1,44 +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. - */ -package org.apache.camel.tools.lsp.internal.parser; - -import java.util.List; -import java.util.concurrent.CompletableFuture; - -import org.apache.camel.catalog.CamelCatalog; -import org.apache.camel.tools.lsp.internal.completion.CamelComponentSchemaCompletionsFuture; -import org.eclipse.lsp4j.CompletionItem; - -public class CamelComponentURIInstance extends CamelUriElementInstance { - - private String componentName; - - public CamelComponentURIInstance(String componentName, int endPosition) { - super(0, endPosition); - this.componentName = componentName; - } - - public String getComponentName() { - return componentName; - } - - @Override - public CompletableFuture> getCompletions(CompletableFuture camelCatalog, int positionInCamelUri) { - return camelCatalog.thenApply(new CamelComponentSchemaCompletionsFuture()); - } - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/CamelURIInstance.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/CamelURIInstance.java deleted file mode 100644 index 0b864500e..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/CamelURIInstance.java +++ /dev/null @@ -1,136 +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. - */ -package org.apache.camel.tools.lsp.internal.parser; - -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.concurrent.CompletableFuture; - -import org.apache.camel.catalog.CamelCatalog; -import org.apache.camel.tools.lsp.internal.completion.CamelComponentSchemaCompletionsFuture; -import org.eclipse.lsp4j.CompletionItem; -import org.w3c.dom.Node; - -public class CamelURIInstance extends CamelUriElementInstance { - - private static final String CAMEL_PATH_SEPARATOR_REGEX = ":|/"; - private static final String PARAMETERS_SEPARATOR = "&"; - private static final List PRODUCER_NODE_TAG = Arrays.asList("to", "interceptSendToEndpoint", "wireTap", "deadLetterChanel"); - private CamelComponentURIInstance component; - private Set pathParams = new HashSet<>(); - private Set optionParams = new HashSet<>(); - private Node node; - - public CamelURIInstance(String uriToParse) { - this(uriToParse, null); - } - - public CamelURIInstance(String uriToParse, Node node) { - super(0, uriToParse != null ? uriToParse.length() : 0); - this.node = node; - if(uriToParse != null && !uriToParse.isEmpty()) { - int posDoubleDot = uriToParse.indexOf(':'); - if (posDoubleDot > 0) { - component = new CamelComponentURIInstance(uriToParse.substring(0, posDoubleDot), posDoubleDot); - int posEndofPathParams = getPosEndOfPathParams(posDoubleDot, uriToParse); - initPathParams(uriToParse, posDoubleDot, posEndofPathParams); - initOptionParams(uriToParse, posEndofPathParams); - } else { - component = new CamelComponentURIInstance(uriToParse, uriToParse.length()); - } - } - } - - private void initOptionParams(String uriToParse, int posEndofPathParams) { - if(uriToParse.length() > posEndofPathParams) { - String[] allOptionParams = uriToParse.substring(posEndofPathParams + 1).split(PARAMETERS_SEPARATOR); - int currentPosition = posEndofPathParams + 1; - for (String optionParam : allOptionParams) { - optionParams.add(new OptionParamURIInstance(this, optionParam, currentPosition, currentPosition + optionParam.length())); - currentPosition += optionParam.length() + 5; - } - if(uriToParse.endsWith(PARAMETERS_SEPARATOR)) { - optionParams.add(new OptionParamURIInstance(this, "", currentPosition, currentPosition)); - } - } - } - - private void initPathParams(String uriToParse, int posDoubleDot, int posEndofPathParams) { - String[] allPathParams = uriToParse.substring(posDoubleDot + 1, posEndofPathParams).split(CAMEL_PATH_SEPARATOR_REGEX); - int currentPosition = posDoubleDot + 1; - for (String pathParam : allPathParams) { - pathParams.add(new PathParamURIInstance(pathParam, currentPosition, currentPosition+pathParam.length())); - currentPosition += pathParam.length() + 1; - } - } - - private int getPosEndOfPathParams(int posDoubleDot, String uriToParse) { - int questionMarkPosition = uriToParse.indexOf('?', posDoubleDot); - if (questionMarkPosition > 0) { - return questionMarkPosition; - } else { - return uriToParse.length(); - } - } - - public CamelComponentURIInstance getComponent() { - return component; - } - - public Set getPathParams() { - return pathParams; - } - - public Set getOptionParams() { - return optionParams; - } - - public CamelUriElementInstance getSpecificElement(int position) { - if (component != null && component.isInRange(position)) { - return component; - } else { - for (PathParamURIInstance pathParamURIInstance : pathParams) { - if(pathParamURIInstance.isInRange(position)) { - return pathParamURIInstance; - } - } - for (OptionParamURIInstance optionParamURIInstance : optionParams) { - if (optionParamURIInstance.isInRange(position)) { - return optionParamURIInstance.getSpecificElement(position); - } - } - } - return this; - } - - @Override - public CompletableFuture> getCompletions(CompletableFuture camelCatalog, int positionInCamelUri) { - if(getStartPosition() <= positionInCamelUri && positionInCamelUri <= getEndPosition()) { - return camelCatalog.thenApply(new CamelComponentSchemaCompletionsFuture()); - } else { - return CompletableFuture.completedFuture(Collections.emptyList()); - } - } - - public boolean isProducer() { - return PRODUCER_NODE_TAG.contains(node.getNodeName()); - } - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/CamelUriElementInstance.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/CamelUriElementInstance.java deleted file mode 100644 index cfc1aa6f4..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/CamelUriElementInstance.java +++ /dev/null @@ -1,49 +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. - */ -package org.apache.camel.tools.lsp.internal.parser; - -import java.util.List; -import java.util.concurrent.CompletableFuture; - -import org.apache.camel.catalog.CamelCatalog; -import org.eclipse.lsp4j.CompletionItem; - -public abstract class CamelUriElementInstance { - - private int startPosition; - private int endPosition; - - public CamelUriElementInstance(int startPosition, int endPosition) { - this.startPosition = startPosition; - this.endPosition = endPosition; - } - - public int getStartPosition() { - return startPosition; - } - - public int getEndPosition() { - return endPosition; - } - - public boolean isInRange(int position) { - return startPosition <= position && position <= endPosition; - } - - public abstract CompletableFuture> getCompletions(CompletableFuture camelCatalog, int positionInCamelUri); - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/OptionParamKeyURIInstance.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/OptionParamKeyURIInstance.java deleted file mode 100644 index cff1de982..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/OptionParamKeyURIInstance.java +++ /dev/null @@ -1,50 +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. - */ -package org.apache.camel.tools.lsp.internal.parser; - -import java.util.List; -import java.util.concurrent.CompletableFuture; - -import org.apache.camel.catalog.CamelCatalog; -import org.apache.camel.tools.lsp.internal.completion.CamelOptionSchemaCompletionsFuture; -import org.eclipse.lsp4j.CompletionItem; - -public class OptionParamKeyURIInstance extends CamelUriElementInstance { - - private String keyName; - private OptionParamURIInstance optionParamURIInstance; - - public OptionParamKeyURIInstance(OptionParamURIInstance optionParamURIInstance, String keyName, int startPosition, int endPosition) { - super(startPosition, endPosition); - this.optionParamURIInstance = optionParamURIInstance; - this.keyName = keyName; - } - - public String getKeyName() { - return keyName; - } - - @Override - public CompletableFuture> getCompletions(CompletableFuture camelCatalog, int positionInCamelUri) { - return camelCatalog.thenApply(new CamelOptionSchemaCompletionsFuture(getComponentName(), optionParamURIInstance.isProducer())); - } - - public String getComponentName() { - return optionParamURIInstance.getComponentName(); - } - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/OptionParamURIInstance.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/OptionParamURIInstance.java deleted file mode 100644 index a450236f5..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/OptionParamURIInstance.java +++ /dev/null @@ -1,74 +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. - */ -package org.apache.camel.tools.lsp.internal.parser; - -import java.util.Collections; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -import org.apache.camel.catalog.CamelCatalog; -import org.eclipse.lsp4j.CompletionItem; - -public class OptionParamURIInstance extends CamelUriElementInstance { - - private OptionParamKeyURIInstance key; - private OptionParamValueURIInstance value; - private CamelURIInstance camelURIInstance; - - public OptionParamURIInstance(CamelURIInstance camelURIInstance, String optionParam, int startPosition, int endPosition) { - super(startPosition, endPosition); - this.camelURIInstance = camelURIInstance; - String[] splittedParams = optionParam.split("="); - String keyName = splittedParams[0]; - key = new OptionParamKeyURIInstance(this, splittedParams[0], startPosition, startPosition + keyName.length()); - if (splittedParams.length > 1) { - value = new OptionParamValueURIInstance(this, splittedParams[1], startPosition + keyName.length() + 1, endPosition); - } else if(optionParam.endsWith("=")){ - value = new OptionParamValueURIInstance(this, null, startPosition + keyName.length() + 1, endPosition); - } - } - - public OptionParamKeyURIInstance getKey() { - return key; - } - - public OptionParamValueURIInstance getValue() { - return value; - } - - public CamelUriElementInstance getSpecificElement(int position) { - if(key.isInRange(position)) { - return key; - } else { - return value; - } - } - - @Override - public CompletableFuture> getCompletions(CompletableFuture camelCatalog, int positionInCamelUri) { - return CompletableFuture.completedFuture(Collections.emptyList()); - } - - public String getComponentName() { - return camelURIInstance.getComponent().getComponentName(); - } - - public boolean isProducer() { - return camelURIInstance.isProducer(); - } - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/OptionParamValueURIInstance.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/OptionParamValueURIInstance.java deleted file mode 100644 index d8de62be3..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/OptionParamValueURIInstance.java +++ /dev/null @@ -1,52 +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. - */ -package org.apache.camel.tools.lsp.internal.parser; - -import java.util.List; -import java.util.concurrent.CompletableFuture; - -import org.apache.camel.catalog.CamelCatalog; -import org.apache.camel.tools.lsp.internal.completion.CamelOptionValuesCompletionsFuture; -import org.eclipse.lsp4j.CompletionItem; - -public class OptionParamValueURIInstance extends CamelUriElementInstance { - - private String valueName; - private OptionParamURIInstance optionParamURIInstance; - - public OptionParamValueURIInstance(OptionParamURIInstance optionParamURIInstance, String value, int startPosition, int endPosition) { - super(startPosition, endPosition); - this.optionParamURIInstance = optionParamURIInstance; - this.valueName = value; - } - - public String getValueName() { - return valueName; - } - - @Override - public CompletableFuture> getCompletions(CompletableFuture camelCatalog, int positionInCamelUri) { - return camelCatalog.thenApply(new CamelOptionValuesCompletionsFuture(this)); - } - - public OptionParamURIInstance getOptionParamURIInstance() { - return optionParamURIInstance; - } - - - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/ParserFileHelper.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/ParserFileHelper.java deleted file mode 100644 index 746754c5b..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/ParserFileHelper.java +++ /dev/null @@ -1,126 +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. - */ -package org.apache.camel.tools.lsp.internal.parser; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.nio.charset.StandardCharsets; -import java.util.Arrays; -import java.util.List; - -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.apache.camel.parser.helper.XmlLineNumberParser; -import org.eclipse.lsp4j.Position; -import org.eclipse.lsp4j.TextDocumentItem; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -public class ParserFileHelper { - - private static final String NAMESPACEURI_CAMEL_BLUEPRINT = "http://camel.apache.org/schema/blueprint"; - private static final String NAMESPACEURI_CAMEL_SPRING = "http://camel.apache.org/schema/spring"; - private static final List CAMEL_NODES_TAG = Arrays.asList("to", "from"); - - public String getLine(TextDocumentItem textDocumentItem, Position position) { - String text = textDocumentItem.getText(); - String[] lines = text.split("\\r?\\n", position.getLine() + 2); - if (lines.length >= position.getLine() + 1) { - return lines[position.getLine()]; - } - return null; - } - - public String getCamelComponentUri(String line, int characterPosition) { - int uriAttribute = line.indexOf("uri=\""); - if(uriAttribute != -1) { - int nextQuote = line.indexOf('\"', uriAttribute + 5); - if (isBetween(characterPosition, uriAttribute + 5, nextQuote)) { - return line.substring(uriAttribute + 5, nextQuote); - } - } - return null; - } - - public String getCamelComponentUri(TextDocumentItem textDocumentItem, Position position) { - return getCamelComponentUri(getLine(textDocumentItem, position), position.getCharacter()); - } - - private boolean isBetween(int position, int start, int end) { - return end != -1 && position <= end && position >= start; - } - - /** - * @param textDocumentItem - * @param line - * @return Currently returns the first from Camel Node ignoring the exact position - * @throws Exception - */ - public Node getCorrespondingCamelNodeForCompletion(TextDocumentItem textDocumentItem, int line) throws Exception { - if (hasElementFromCamelNamespace(textDocumentItem)) { - Document parseXml = XmlLineNumberParser.parseXml(new ByteArrayInputStream(textDocumentItem.getText().getBytes(StandardCharsets.UTF_8))); - Element documentElement = parseXml.getDocumentElement(); - return findElementAtLine(line, documentElement); - } else { - return null; - } - } - - private boolean hasElementFromCamelNamespace(TextDocumentItem textDocumentItem) throws SAXException, IOException, ParserConfigurationException { - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - dbf.setNamespaceAware(true); - Document xmlParsed = dbf.newDocumentBuilder().parse(new ByteArrayInputStream(textDocumentItem.getText().getBytes(StandardCharsets.UTF_8))); - for (String camelNodeTag : CAMEL_NODES_TAG) { - if(hasElementFromCamelNameSpaces(xmlParsed.getElementsByTagName(camelNodeTag))){ - return true; - } - } - return false; - } - - private Node findElementAtLine(int line, Node node) { - if(CAMEL_NODES_TAG.contains(node.getNodeName())) { - return node; - } - NodeList childNodes = node.getChildNodes(); - for (int i = 0; i < childNodes.getLength(); i++) { - Node childNode = childNodes.item(i); - String nodeLineStart = (String)childNode.getUserData(XmlLineNumberParser.LINE_NUMBER); - String nodeLineEnd = (String)childNode.getUserData(XmlLineNumberParser.LINE_NUMBER_END); - // -1 is due to Camel XMLLineParser which is starting index at 1 although LSP is starting at 0 - if (nodeLineStart != null && nodeLineEnd != null && isBetween(line, Integer.parseInt(nodeLineStart) - 1, Integer.parseInt(nodeLineEnd) - 1)) { - return findElementAtLine(line, childNode); - } - } - return null; - } - - private boolean hasElementFromCamelNameSpaces(NodeList childNodes) { - for (int i = 0; i < childNodes.getLength(); i++) { - Node child = childNodes.item(i); - if (NAMESPACEURI_CAMEL_BLUEPRINT.equals(child.getNamespaceURI()) || NAMESPACEURI_CAMEL_SPRING.equals(child.getNamespaceURI())) { - return true; - } - } - return false; - } - -} diff --git a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/PathParamURIInstance.java b/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/PathParamURIInstance.java deleted file mode 100644 index fd1fc2751..000000000 --- a/server/src/main/java/org/apache/camel/tools/lsp/internal/parser/PathParamURIInstance.java +++ /dev/null @@ -1,70 +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. - */ -package org.apache.camel.tools.lsp.internal.parser; - -import java.util.Collections; -import java.util.List; -import java.util.Objects; -import java.util.concurrent.CompletableFuture; - -import org.apache.camel.catalog.CamelCatalog; -import org.apache.camel.tools.lsp.internal.completion.CamelComponentSchemaCompletionsFuture; -import org.eclipse.lsp4j.CompletionItem; - -public class PathParamURIInstance extends CamelUriElementInstance { - - private String value; - - public PathParamURIInstance(String value, int startPosition, int endPosition) { - super(startPosition, endPosition); - this.value = value; - } - - public String getValue() { - return value; - } - - @Override - public CompletableFuture> getCompletions(CompletableFuture camelCatalog, int positionInCamelUri) { - if(getStartPosition() <= positionInCamelUri && positionInCamelUri <= getEndPosition()) { - return camelCatalog.thenApply(new CamelComponentSchemaCompletionsFuture()); - } else { - return CompletableFuture.completedFuture(Collections.emptyList()); - } - } - - @Override - public boolean equals(Object obj) { - if(obj instanceof PathParamURIInstance) { - return value.equals(((PathParamURIInstance) obj).getValue()) - && getStartPosition() == ((PathParamURIInstance) obj).getStartPosition() - && getEndPosition() == ((PathParamURIInstance) obj).getEndPosition(); - } - return super.equals(obj); - } - - @Override - public int hashCode() { - return Objects.hash(value, getStartPosition(), getEndPosition()); - } - - @Override - public String toString() { - return "Value: "+value+" start position:"+getStartPosition()+ " end position:"+getEndPosition(); - } - -} diff --git a/server/src/main/resources/log4j.properties b/server/src/main/resources/log4j.properties deleted file mode 100644 index 92cfa8df1..000000000 --- a/server/src/main/resources/log4j.properties +++ /dev/null @@ -1,10 +0,0 @@ -# Define the root logger with appender file -log4j.rootLogger = DEBUG, FILE -log4j.appender.FILE=org.apache.log4j.RollingFileAppender -log4j.appender.FILE.maxFileSize=20MB -log4j.appender.FILE.File=log-camel-lsp.out -log4j.appender.FILE.ImmediateFlush=true -log4j.appender.FILE.Threshold=debug -log4j.appender.FILE.Append=true -log4j.appender.FILE.layout=org.apache.log4j.PatternLayout -log4j.appender.FILE.layout.conversionPattern=%m%n diff --git a/server/src/test/java/org/apache/camel/tools/lsp/internal/AbstractCamelLanguageServerTest.java b/server/src/test/java/org/apache/camel/tools/lsp/internal/AbstractCamelLanguageServerTest.java deleted file mode 100644 index f2f1beaef..000000000 --- a/server/src/test/java/org/apache/camel/tools/lsp/internal/AbstractCamelLanguageServerTest.java +++ /dev/null @@ -1,98 +0,0 @@ -package org.apache.camel.tools.lsp.internal; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.io.File; -import java.net.URISyntaxException; -import java.nio.file.Paths; -import java.util.List; -import java.util.Random; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; - -import org.eclipse.lsp4j.CompletionItem; -import org.eclipse.lsp4j.CompletionList; -import org.eclipse.lsp4j.DidOpenTextDocumentParams; -import org.eclipse.lsp4j.InitializeParams; -import org.eclipse.lsp4j.InitializeResult; -import org.eclipse.lsp4j.MessageActionItem; -import org.eclipse.lsp4j.MessageParams; -import org.eclipse.lsp4j.Position; -import org.eclipse.lsp4j.PublishDiagnosticsParams; -import org.eclipse.lsp4j.ShowMessageRequestParams; -import org.eclipse.lsp4j.TextDocumentIdentifier; -import org.eclipse.lsp4j.TextDocumentItem; -import org.eclipse.lsp4j.TextDocumentPositionParams; -import org.eclipse.lsp4j.jsonrpc.messages.Either; -import org.eclipse.lsp4j.services.LanguageClient; -import org.eclipse.lsp4j.services.TextDocumentService; - -public abstract class AbstractCamelLanguageServerTest { - - protected static final String AHC_DOCUMENTATION = "To call external HTTP services using Async Http Client."; - protected static final String DUMMY_URI = "dummyUri"; - protected CompletionItem expectedAhcCompletioncompletionItem; - - public AbstractCamelLanguageServerTest() { - super(); - expectedAhcCompletioncompletionItem = new CompletionItem("ahc:httpUri"); - expectedAhcCompletioncompletionItem.setDocumentation(AHC_DOCUMENTATION); - } - - final class DummyLanguageClient implements LanguageClient { - @Override - public void telemetryEvent(Object object) { - } - - @Override - public CompletableFuture showMessageRequest(ShowMessageRequestParams requestParams) { - return null; - } - - @Override - public void showMessage(MessageParams messageParams) { - } - - @Override - public void publishDiagnostics(PublishDiagnosticsParams diagnostics) { - } - - @Override - public void logMessage(MessageParams message) { - } - } - - protected CamelLanguageServer initializeLanguageServer(String text) - throws URISyntaxException, InterruptedException, ExecutionException { - InitializeParams params = new InitializeParams(); - params.setProcessId(new Random().nextInt()); - params.setRootUri(getTestResource("/workspace/").toURI().toString()); - CamelLanguageServer camelLanguageServer = new CamelLanguageServer(); - camelLanguageServer.connect(new DummyLanguageClient()); - CompletableFuture initialize = camelLanguageServer.initialize(params); - - assertThat(initialize).isCompleted(); - assertThat(initialize.get().getCapabilities().getCompletionProvider().getResolveProvider()).isTrue(); - - camelLanguageServer.getTextDocumentService().didOpen(new DidOpenTextDocumentParams(createTestTextDocument(text))); - - return camelLanguageServer; - } - - private TextDocumentItem createTestTextDocument(String text) { - return new TextDocumentItem(DUMMY_URI, CamelLanguageServer.LANGUAGE_ID, 0, text); - } - - protected CompletableFuture, CompletionList>> getCompletionFor(CamelLanguageServer camelLanguageServer, Position position) { - TextDocumentService textDocumentService = camelLanguageServer.getTextDocumentService(); - - TextDocumentPositionParams dummyCompletionPositionRequest = new TextDocumentPositionParams(new TextDocumentIdentifier(DUMMY_URI), position); - CompletableFuture, CompletionList>> completions = textDocumentService.completion(dummyCompletionPositionRequest); - return completions; - } - - public File getTestResource(String name) throws URISyntaxException { - return Paths.get(CamelLanguageServerTest.class.getResource(name).toURI()).toFile(); - } - -} \ No newline at end of file diff --git a/server/src/test/java/org/apache/camel/tools/lsp/internal/CamelLanguageServerTest.java b/server/src/test/java/org/apache/camel/tools/lsp/internal/CamelLanguageServerTest.java deleted file mode 100644 index 16c5c7a24..000000000 --- a/server/src/test/java/org/apache/camel/tools/lsp/internal/CamelLanguageServerTest.java +++ /dev/null @@ -1,91 +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. - */ -package org.apache.camel.tools.lsp.internal; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.List; -import java.util.concurrent.CompletableFuture; - -import org.eclipse.lsp4j.CompletionItem; -import org.eclipse.lsp4j.CompletionList; -import org.eclipse.lsp4j.Position; -import org.eclipse.lsp4j.jsonrpc.messages.Either; -import org.junit.Test; - - -public class CamelLanguageServerTest extends AbstractCamelLanguageServerTest { - - @Test - public void testProvideCompletionForCamelBlueprintNamespace() throws Exception { - CamelLanguageServer camelLanguageServer = initializeLanguageServer("\n"); - - CompletableFuture, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(0, 11)); - - assertThat(completions.get().getLeft()).contains(expectedAhcCompletioncompletionItem); - } - - @Test - public void testProvideCompletionForToCamelBlueprintNamespace() throws Exception { - CamelLanguageServer camelLanguageServer = initializeLanguageServer("\n"); - - CompletableFuture, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(0, 9)); - - assertThat(completions.get().getLeft()).contains(expectedAhcCompletioncompletionItem); - } - - @Test - public void testProvideCompletionForCamelSpringNamespace() throws Exception { - CamelLanguageServer camelLanguageServer = initializeLanguageServer("\n"); - - CompletableFuture, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(0, 11)); - - assertThat(completions.get().getLeft()).contains(expectedAhcCompletioncompletionItem); - } - - @Test - public void testProvideCompletionforMultiline() throws Exception { - CamelLanguageServer camelLanguageServer = initializeLanguageServer( - "\n" + - "\n" + - ""); - - CompletableFuture, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(1, 9)); - - assertThat(completions.get().getLeft()).contains(expectedAhcCompletioncompletionItem); - } - - @Test - public void testDONTProvideCompletionForNotCamelnamespace() throws Exception { - CamelLanguageServer camelLanguageServer = initializeLanguageServer("\n"); - - CompletableFuture, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(0, 11)); - - assertThat(completions.get().getLeft()).isEmpty(); - assertThat(completions.get().getRight()).isNull(); - } - - @Test - public void testDONTProvideCompletionWhenNotAfterURIEqualQuote() throws Exception { - CamelLanguageServer camelLanguageServer = initializeLanguageServer("\n"); - - CompletableFuture, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(0, 6)); - - assertThat(completions.get().getLeft()).isEmpty(); - assertThat(completions.get().getRight()).isNull(); - } -} diff --git a/server/src/test/java/org/apache/camel/tools/lsp/internal/CamelTextDocumentServiceTest.java b/server/src/test/java/org/apache/camel/tools/lsp/internal/CamelTextDocumentServiceTest.java deleted file mode 100644 index a9731cc40..000000000 --- a/server/src/test/java/org/apache/camel/tools/lsp/internal/CamelTextDocumentServiceTest.java +++ /dev/null @@ -1,57 +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. - */ -package org.apache.camel.tools.lsp.internal; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Collections; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -import org.eclipse.lsp4j.CompletionItem; -import org.eclipse.lsp4j.CompletionList; -import org.eclipse.lsp4j.DidChangeTextDocumentParams; -import org.eclipse.lsp4j.Position; -import org.eclipse.lsp4j.TextDocumentContentChangeEvent; -import org.eclipse.lsp4j.VersionedTextDocumentIdentifier; -import org.eclipse.lsp4j.jsonrpc.messages.Either; -import org.junit.Test; - -public class CamelTextDocumentServiceTest extends AbstractCamelLanguageServerTest { - - @Test - public void testChangeEventUpdatesStoredText() throws Exception { - CamelLanguageServer camelLanguageServer = initializeLanguageServer("\n"); - - DidChangeTextDocumentParams changeEvent = new DidChangeTextDocumentParams(); - VersionedTextDocumentIdentifier textDocument = new VersionedTextDocumentIdentifier(); - textDocument.setUri(DUMMY_URI); - changeEvent.setTextDocument(textDocument); - TextDocumentContentChangeEvent contentChange = new TextDocumentContentChangeEvent("\n"); - changeEvent.setContentChanges(Collections.singletonList(contentChange)); - camelLanguageServer.getTextDocumentService().didChange(changeEvent); - - //check old position doesn't provide completion - CompletableFuture, CompletionList>> completionsAtOldPosition = getCompletionFor(camelLanguageServer, new Position(0, 11)); - assertThat(completionsAtOldPosition.get().getLeft()).isEmpty(); - - //check new position provides completion - CompletableFuture, CompletionList>> completionsAtNewPosition = getCompletionFor(camelLanguageServer, new Position(0, 58)); - assertThat(completionsAtNewPosition.get().getLeft()).isNotEmpty(); - - } -} diff --git a/server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentOptionBooleanValuesTest.java b/server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentOptionBooleanValuesTest.java deleted file mode 100644 index b13f1b718..000000000 --- a/server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentOptionBooleanValuesTest.java +++ /dev/null @@ -1,51 +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. - */ -package org.apache.camel.tools.lsp.internal.completion; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.net.URISyntaxException; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; - -import org.apache.camel.tools.lsp.internal.AbstractCamelLanguageServerTest; -import org.apache.camel.tools.lsp.internal.CamelLanguageServer; -import org.eclipse.lsp4j.CompletionItem; -import org.eclipse.lsp4j.CompletionList; -import org.eclipse.lsp4j.Position; -import org.eclipse.lsp4j.jsonrpc.messages.Either; -import org.junit.Test; - -public class CamelComponentOptionBooleanValuesTest extends AbstractCamelLanguageServerTest { - - @Test - public void testProvideBooleanValues() throws Exception { - testProvideCamelOptions("\n", 0, 37); - } - - private void testProvideCamelOptions(String textTotest, int line, int character) throws URISyntaxException, InterruptedException, ExecutionException { - CamelLanguageServer camelLanguageServer = initializeLanguageServer(textTotest); - - CompletableFuture, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(line, character)); - - assertThat(completions.get().getLeft()).contains( - new CompletionItem("true"), - new CompletionItem("false")); - } - -} diff --git a/server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentOptionEnumerationValuesTest.java b/server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentOptionEnumerationValuesTest.java deleted file mode 100644 index f602a51b1..000000000 --- a/server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentOptionEnumerationValuesTest.java +++ /dev/null @@ -1,57 +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. - */ -package org.apache.camel.tools.lsp.internal.completion; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.net.URISyntaxException; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; - -import org.apache.camel.tools.lsp.internal.AbstractCamelLanguageServerTest; -import org.apache.camel.tools.lsp.internal.CamelLanguageServer; -import org.eclipse.lsp4j.CompletionItem; -import org.eclipse.lsp4j.CompletionList; -import org.eclipse.lsp4j.Position; -import org.eclipse.lsp4j.jsonrpc.messages.Either; -import org.junit.Test; - -public class CamelComponentOptionEnumerationValuesTest extends AbstractCamelLanguageServerTest { - - @Test - public void testProvideEnumValues() throws Exception { - testProvideCamelOptions("\n", 0, 43); - } - - private void testProvideCamelOptions(String textTotest, int line, int character) throws URISyntaxException, InterruptedException, ExecutionException { - CamelLanguageServer camelLanguageServer = initializeLanguageServer(textTotest); - - CompletableFuture, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(line, character)); - - assertThat(completions.get().getLeft()).contains( - new CompletionItem("InOnly"), - new CompletionItem("RobustInOnly"), - new CompletionItem("InOut"), - new CompletionItem("InOptionalOut"), - new CompletionItem("OutOnly"), - new CompletionItem("RobustOutOnly"), - new CompletionItem("OutIn"), - new CompletionItem("OutOptionalIn")); - } - -} diff --git a/server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentOptionsCompletionsTest.java b/server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentOptionsCompletionsTest.java deleted file mode 100644 index 2b12174bb..000000000 --- a/server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelComponentOptionsCompletionsTest.java +++ /dev/null @@ -1,74 +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. - */ -package org.apache.camel.tools.lsp.internal.completion; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.net.URISyntaxException; -import java.util.List; -import java.util.concurrent.CompletableFuture; -import java.util.concurrent.ExecutionException; - -import org.apache.camel.tools.lsp.internal.AbstractCamelLanguageServerTest; -import org.apache.camel.tools.lsp.internal.CamelLanguageServer; -import org.eclipse.lsp4j.CompletionItem; -import org.eclipse.lsp4j.CompletionList; -import org.eclipse.lsp4j.Position; -import org.eclipse.lsp4j.jsonrpc.messages.Either; -import org.junit.Test; - -public class CamelComponentOptionsCompletionsTest extends AbstractCamelLanguageServerTest { - - @Test - public void testProvideCamelOptions() throws Exception { - testProvideCamelOptions("\n", 0, 21, getBridgeEndpointExpectedCompletionItem()); - } - - @Test - public void testProvideCamelOptionsForConsumerOnly() throws Exception { - CompletionItem completionItem = new CompletionItem("bridgeErrorHandler"); - completionItem.setInsertText("bridgeErrorHandler=false"); - testProvideCamelOptions("\n", 0, 27, completionItem); - } - - @Test - public void testProvideCamelOptionsForConsumerOrProducer() throws Exception { - CompletionItem completionItem = new CompletionItem("clientConfigOptions"); - completionItem.setInsertText("clientConfigOptions="); - testProvideCamelOptions("\n", 0, 23, completionItem); - } - - @Test - public void testProvideCamelOptionsWhenAlreadyContainOptions() throws Exception { - testProvideCamelOptions("\n", 0, 41, getBridgeEndpointExpectedCompletionItem()); - } - - private void testProvideCamelOptions(String textTotest, int line, int character, CompletionItem completionItemExpected) throws URISyntaxException, InterruptedException, ExecutionException { - CamelLanguageServer camelLanguageServer = initializeLanguageServer(textTotest); - - CompletableFuture, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(line, character)); - - assertThat(completions.get().getLeft()).contains(completionItemExpected); - } - - private CompletionItem getBridgeEndpointExpectedCompletionItem() { - CompletionItem completionItem = new CompletionItem("bridgeEndpoint"); - completionItem.setInsertText("bridgeEndpoint=false"); - return completionItem; - } - -} diff --git a/server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelLanguageServerCompletionPositionTest.java b/server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelLanguageServerCompletionPositionTest.java deleted file mode 100644 index 75781af76..000000000 --- a/server/src/test/java/org/apache/camel/tools/lsp/internal/completion/CamelLanguageServerCompletionPositionTest.java +++ /dev/null @@ -1,106 +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. - */ -package org.apache.camel.tools.lsp.internal.completion; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -import org.apache.camel.tools.lsp.internal.AbstractCamelLanguageServerTest; -import org.apache.camel.tools.lsp.internal.CamelLanguageServer; -import org.eclipse.lsp4j.CompletionItem; -import org.eclipse.lsp4j.CompletionList; -import org.eclipse.lsp4j.Position; -import org.eclipse.lsp4j.jsonrpc.messages.Either; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameter; -import org.junit.runners.Parameterized.Parameters; - -@RunWith(Parameterized.class) -public class CamelLanguageServerCompletionPositionTest extends AbstractCamelLanguageServerTest { - - @Parameters(name="{4} - Position ({1},{2})") - public static Collection data() { - return Arrays.asList(new Object[][] { - { "\n", 0, 0, false, "Empty URI" }, - { "\n", 0, 1, false, "Empty URI" }, - { "\n", 0, 2, false, "Empty URI"}, - { "\n", 0, 3, false, "Empty URI"}, - { "\n", 0, 4, false, "Empty URI"}, - { "\n", 0, 5, false, "Empty URI"}, - { "\n", 0, 6, false, "Empty URI"}, - { "\n", 0, 7, false, "Empty URI"}, - { "\n", 0, 8, false, "Empty URI"}, - { "\n", 0, 9, false, "Empty URI"}, - { "\n", 0, 10, false, "Empty URI" }, - { "\n", 0, 11, true, "Empty URI" }, - { "\n", 0, 12, false, "Empty URI" }, - { "\n", 0, 13, false, "Empty URI" }, - { "\n", 0, 14, false, "Empty URI" }, - { "\n", 0, 15, false, "Empty URI" }, - - { "\n", 0, 10, false, "Uri with some value" }, - { "\n", 0, 11, true, "Uri with some value" }, - { "\n", 0, 12, true, "Uri with some value" }, - { "\n", 0, 13, true, "Uri with some value" }, - { "\n", 0, 14, true, "Uri with some value" }, - { "\n", 0, 15, false, "Uri with some value" }, - - { "\n", 0, 14, true, "Uri with a syntax provided" }, - { "\n", 0, 16, true, "Uri with a syntax provided" }, - { "\n", 0, 17, true, "Uri with a syntax provided" }, - { "\n", 0, 18, true, "Uri with a syntax provided" }, - { "\n", 0, 19, true, "Uri with a syntax provided" }, - { "\n", 0, 20, true, "Uri with a syntax provided" }, - { "\n", 0, 21, true, "Uri with a syntax provided" }, - { "\n", 0, 22, true, "Uri with a syntax provided" }, - { "\n", 0, 23, false, "Uri with a syntax provided" }, - { "\n", 0, 24, false, "Uri with a syntax provided" } - - }); - } - - @Parameter - public String textToTest; - @Parameter(1) - public int line; - @Parameter(2) - public int character; - @Parameter(3) - public boolean shouldHaveCompletion; - @Parameter(4) - public String testNameQualification; - - @Test - public void testProvideCompletionForCamelBlueprintNamespace() throws Exception { - CamelLanguageServer camelLanguageServer = initializeLanguageServer(textToTest); - - CompletableFuture, CompletionList>> completions = getCompletionFor(camelLanguageServer, new Position(line, character)); - - if(shouldHaveCompletion) { - assertThat(completions.get().getLeft()).contains(expectedAhcCompletioncompletionItem); - } else { - assertThat(completions.get().getLeft()).doesNotContain(expectedAhcCompletioncompletionItem); - assertThat(completions.get().getRight()).isNull(); - } - } -} diff --git a/server/src/test/java/org/apache/camel/tools/lsp/internal/hover/CamelLanguageServerHoverTest.java b/server/src/test/java/org/apache/camel/tools/lsp/internal/hover/CamelLanguageServerHoverTest.java deleted file mode 100644 index 83833e0a9..000000000 --- a/server/src/test/java/org/apache/camel/tools/lsp/internal/hover/CamelLanguageServerHoverTest.java +++ /dev/null @@ -1,63 +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. - */ -package org.apache.camel.tools.lsp.internal.hover; - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.concurrent.CompletableFuture; - -import org.apache.camel.tools.lsp.internal.AbstractCamelLanguageServerTest; -import org.apache.camel.tools.lsp.internal.CamelLanguageServer; -import org.eclipse.lsp4j.Hover; -import org.eclipse.lsp4j.Position; -import org.eclipse.lsp4j.TextDocumentIdentifier; -import org.eclipse.lsp4j.TextDocumentPositionParams; -import org.junit.Test; - -public class CamelLanguageServerHoverTest extends AbstractCamelLanguageServerTest { - - @Test - public void testProvideDocumentationOnHover() throws Exception { - CamelLanguageServer camelLanguageServer = initializeLanguageServer("\n"); - - TextDocumentPositionParams position = new TextDocumentPositionParams(new TextDocumentIdentifier(DUMMY_URI), new Position(0, 13)); - CompletableFuture hover = camelLanguageServer.getTextDocumentService().hover(position); - - assertThat(hover.get().getContents().get(0).getLeft()).isEqualTo(AHC_DOCUMENTATION); - } - - @Test - public void testDontProvideDocumentationOnHoverForBadPlaces() throws Exception { - CamelLanguageServer camelLanguageServer = initializeLanguageServer("\n"); - - TextDocumentPositionParams position = new TextDocumentPositionParams(new TextDocumentIdentifier(DUMMY_URI), new Position(0, 4)); - CompletableFuture hover = camelLanguageServer.getTextDocumentService().hover(position); - - assertThat(hover.get().getContents()).isEmpty(); - } - - @Test - public void testDontProvideDocumentationOnHoverWhenEndingWithAnd() throws Exception { - CamelLanguageServer camelLanguageServer = initializeLanguageServer("\n"); - - TextDocumentPositionParams position = new TextDocumentPositionParams(new TextDocumentIdentifier(DUMMY_URI), new Position(0, 15)); - CompletableFuture hover = camelLanguageServer.getTextDocumentService().hover(position); - - assertThat(hover.get().getContents()).isEmpty(); - } - -} diff --git a/server/src/test/java/org/apache/camel/tools/lsp/internal/parser/CamelURIInstanceTest.java b/server/src/test/java/org/apache/camel/tools/lsp/internal/parser/CamelURIInstanceTest.java deleted file mode 100644 index e9544d62d..000000000 --- a/server/src/test/java/org/apache/camel/tools/lsp/internal/parser/CamelURIInstanceTest.java +++ /dev/null @@ -1,187 +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. - */ -package org.apache.camel.tools.lsp.internal.parser; - - -import static org.assertj.core.api.Assertions.assertThat; - -import java.util.Iterator; - -import org.junit.Test; - -public class CamelURIInstanceTest { - - @Test - public void testEmptyUri() throws Exception { - CamelURIInstance camelURIInstance = new CamelURIInstance(""); - assertThat(camelURIInstance.getComponent()).isNull(); - assertThat(camelURIInstance.getOptionParams()).isEmpty(); - assertThat(camelURIInstance.getOptionParams()).isEmpty(); - } - - @Test - public void testComponentOnlyInUri() throws Exception { - CamelURIInstance camelURIInstance = new CamelURIInstance("timer"); - assertThat(camelURIInstance.getComponent().getComponentName()).isEqualTo("timer"); - assertThat(camelURIInstance.getComponent().getEndPosition()).isEqualTo(5); - } - - @Test - public void testComponentWithSomethingElseInUri() throws Exception { - CamelURIInstance camelURIInstance = new CamelURIInstance("timer:timerName"); - assertThat(camelURIInstance.getComponent().getComponentName()).isEqualTo("timer"); - assertThat(camelURIInstance.getComponent().getEndPosition()).isEqualTo(5); - } - - @Test - public void testPathParam() throws Exception { - CamelURIInstance camelURIInstance = new CamelURIInstance("timer:timerName"); - PathParamURIInstance pathParam = camelURIInstance.getPathParams().iterator().next(); - assertThat(pathParam.getValue()).isEqualTo("timerName"); - assertThat(pathParam.getStartPosition()).isEqualTo(6); - assertThat(pathParam.getEndPosition()).isEqualTo(15); - } - - @Test - public void testMultiplePathParam() throws Exception { - CamelURIInstance camelURIInstance = new CamelURIInstance("amqp:destinationType:destinationName"); - assertThat(camelURIInstance.getPathParams()).containsOnly( - new PathParamURIInstance("destinationType", 5, 20), - new PathParamURIInstance("destinationName", 21, 36)); - } - - @Test - public void testMultiplePathParamWithSomethingElseInUri() throws Exception { - CamelURIInstance camelURIInstance = new CamelURIInstance("amqp:destinationType:destinationName?anOption"); - assertThat(camelURIInstance.getPathParams()).containsOnly( - new PathParamURIInstance("destinationType", 5, 20), - new PathParamURIInstance("destinationName", 21, 36)); - } - - @Test - public void testMultiplePathParamWithSlashDelimiter() throws Exception { - CamelURIInstance camelURIInstance = new CamelURIInstance("atmos:name/operation"); - assertThat(camelURIInstance.getPathParams()).containsOnly( - new PathParamURIInstance("name", 6, 10), - new PathParamURIInstance("operation", 11, 20)); - } - - @Test - public void testOptionParam() throws Exception { - CamelURIInstance camelURIInstance = new CamelURIInstance("timer:timerName?delay=1000"); - OptionParamURIInstance optionParam = camelURIInstance.getOptionParams().iterator().next(); - checkDelayTimerParam(optionParam); - } - - private void checkDelayTimerParam(OptionParamURIInstance optionParam) { - assertThat(optionParam.getStartPosition()).isEqualTo(16); - assertThat(optionParam.getEndPosition()).isEqualTo(26); - assertThat(optionParam.getKey().getKeyName()).isEqualTo("delay"); - assertThat(optionParam.getKey().getStartPosition()).isEqualTo(16); - assertThat(optionParam.getKey().getEndPosition()).isEqualTo(21); - assertThat(optionParam.getValue().getValueName()).isEqualTo("1000"); - assertThat(optionParam.getValue().getStartPosition()).isEqualTo(22); - assertThat(optionParam.getValue().getEndPosition()).isEqualTo(26); - } - - @Test - public void testSeveralOptionParam() throws Exception { - CamelURIInstance camelURIInstance = new CamelURIInstance("timer:timerName?delay=1000&period=2000"); - Iterator iterator = camelURIInstance.getOptionParams().iterator(); - OptionParamURIInstance firstOptionParam = iterator.next(); - OptionParamURIInstance secondOptionParam = iterator.next(); - if("delay".equals(firstOptionParam.getKey().getKeyName())) { - checkDelayTimerParam(firstOptionParam); - checkTimerPeriodParam(secondOptionParam); - } else { - checkDelayTimerParam(secondOptionParam); - checkTimerPeriodParam(firstOptionParam); - } - } - - private void checkTimerPeriodParam(OptionParamURIInstance secondOptionParam) { - assertThat(secondOptionParam.getStartPosition()).isEqualTo(31); - assertThat(secondOptionParam.getEndPosition()).isEqualTo(42); - assertThat(secondOptionParam.getKey().getKeyName()).isEqualTo("period"); - assertThat(secondOptionParam.getKey().getStartPosition()).isEqualTo(31); - assertThat(secondOptionParam.getKey().getEndPosition()).isEqualTo(37); - assertThat(secondOptionParam.getValue().getValueName()).isEqualTo("2000"); - assertThat(secondOptionParam.getValue().getStartPosition()).isEqualTo(38); - assertThat(secondOptionParam.getValue().getEndPosition()).isEqualTo(42); - } - - @Test - public void testEmptyOptionParam() throws Exception { - CamelURIInstance camelURIInstance = new CamelURIInstance("timer:timerName?"); - OptionParamURIInstance optionParam = camelURIInstance.getOptionParams().iterator().next(); - assertThat(optionParam.getStartPosition()).isEqualTo(16); - assertThat(optionParam.getEndPosition()).isEqualTo(16); - assertThat(optionParam.getKey().getKeyName()).isEqualTo(""); - assertThat(optionParam.getKey().getStartPosition()).isEqualTo(16); - assertThat(optionParam.getKey().getEndPosition()).isEqualTo(16); - assertThat(optionParam.getValue()).isNull(); - } - - @Test - public void testEmptyOptionValueParam() throws Exception { - CamelURIInstance camelURIInstance = new CamelURIInstance("timer:timerName?delay"); - OptionParamURIInstance optionParam = camelURIInstance.getOptionParams().iterator().next(); - assertThat(optionParam.getStartPosition()).isEqualTo(16); - assertThat(optionParam.getEndPosition()).isEqualTo(21); - assertThat(optionParam.getKey().getKeyName()).isEqualTo("delay"); - assertThat(optionParam.getKey().getStartPosition()).isEqualTo(16); - assertThat(optionParam.getKey().getEndPosition()).isEqualTo(21); - assertThat(optionParam.getValue()).isNull(); - } - - @Test - public void testEmptyOptionValueParamWithAnd() throws Exception { - CamelURIInstance camelURIInstance = new CamelURIInstance("timer:timerName?delay&"); - Iterator iterator = camelURIInstance.getOptionParams().iterator(); - OptionParamURIInstance firstOptionParam = iterator.next(); - OptionParamURIInstance secondOptionParam = iterator.next(); - if("delay".equals(firstOptionParam.getKey().getKeyName())) { - checkDelayParameter(firstOptionParam); - } else { - checkDelayParameter(secondOptionParam); - } - } - - private void checkDelayParameter(OptionParamURIInstance firstOptionParam) { - assertThat(firstOptionParam.getStartPosition()).isEqualTo(16); - assertThat(firstOptionParam.getEndPosition()).isEqualTo(21); - assertThat(firstOptionParam.getKey().getKeyName()).isEqualTo("delay"); - assertThat(firstOptionParam.getKey().getStartPosition()).isEqualTo(16); - assertThat(firstOptionParam.getKey().getEndPosition()).isEqualTo(21); - assertThat(firstOptionParam.getValue()).isNull(); - } - - @Test - public void testEmptyOptionValueParamWithEqual() throws Exception { - CamelURIInstance camelURIInstance = new CamelURIInstance("timer:timerName?delay="); - OptionParamURIInstance optionParam = camelURIInstance.getOptionParams().iterator().next(); - assertThat(optionParam.getStartPosition()).isEqualTo(16); - assertThat(optionParam.getEndPosition()).isEqualTo(22); - assertThat(optionParam.getKey().getKeyName()).isEqualTo("delay"); - assertThat(optionParam.getKey().getStartPosition()).isEqualTo(16); - assertThat(optionParam.getKey().getEndPosition()).isEqualTo(21); - assertThat(optionParam.getValue().getValueName()).isEqualTo(null); - assertThat(optionParam.getValue().getStartPosition()).isEqualTo(22); - assertThat(optionParam.getValue().getEndPosition()).isEqualTo(22); - } - -} diff --git a/server/src/test/resources/workspace/test-file.xml b/server/src/test/resources/workspace/test-file.xml deleted file mode 100644 index e69de29bb..000000000 diff --git a/clients/vscode/src/extension.ts b/src/extension.ts similarity index 100% rename from clients/vscode/src/extension.ts rename to src/extension.ts diff --git a/clients/vscode/src/protocol.ts b/src/protocol.ts similarity index 100% rename from clients/vscode/src/protocol.ts rename to src/protocol.ts diff --git a/clients/vscode/test/apacheCamel.xml b/test/apacheCamel.xml similarity index 100% rename from clients/vscode/test/apacheCamel.xml rename to test/apacheCamel.xml diff --git a/clients/vscode/test/index.ts b/test/index.ts similarity index 100% rename from clients/vscode/test/index.ts rename to test/index.ts diff --git a/clients/vscode/tsconfig.json b/tsconfig.json similarity index 100% rename from clients/vscode/tsconfig.json rename to tsconfig.json diff --git a/clients/vscode/tslint.json b/tslint.json similarity index 100% rename from clients/vscode/tslint.json rename to tslint.json