From b016d619cb2d9bdb37681045015fbb6ee7272896 Mon Sep 17 00:00:00 2001
From: Sergii Kabashniuk
Date: Wed, 19 Apr 2017 17:33:59 +0300
Subject: [PATCH] 3656 Port Languages Server Support to lsp4j (#4765)
* Initial import from https://github.com/eclipse/che/pull/4160
* Added formatting for changed files
* Organize imports
* Added missing logback and removed unused dependency
* Fix plugin-languageserver compilation issue
* Move lsp4j dependency to lsp plugin
---
.../che/dto/generator/DtoGenerator.java | 81 ++---
.../eclipse/che/ide/filters/FuzzyMatches.java | 3 -
.../org/eclipse/che/ide/filters/Matcher.java | 7 +-
.../che-plugin-csharp-lang-server/pom.xml | 12 +-
.../CSharpLanguageServerLauncher.java | 36 +-
.../che-plugin-json-server/pom.xml | 16 +-
.../languageserver/JsonLanguageServer.java | 57 ----
.../JsonLanguageServerLauncher.java | 37 ++-
.../che-plugin-languageserver-ide/pom.xml | 78 +++--
.../api/languageserver/util/EitherUtil.java | 50 +++
.../languageserver/util/JsonSerializable.java | 24 +-
.../che/api/languageserver/util/JsonUtil.java | 42 +++
.../ide/LanguageServerExtension.java | 33 +-
.../ide/LanguageServerFileTypeRegister.java | 19 +-
.../ide/LanguageServerResources.java | 2 +-
.../ide/editor/DiagnosticAnnotation.java | 74 +++--
.../ide/editor/DiagnosticCollector.java | 5 +-
.../editor/LanguageServerAnnotationModel.java | 14 +-
...guageServerCodeassistProcessorFactory.java | 5 +-
.../LanguageServerEditorConfiguration.java | 20 +-
...guageServerEditorConfigurationFactory.java | 2 +-
.../editor/LanguageServerEditorProvider.java | 25 +-
.../ide/editor/LanguageServerFormatter.java | 67 ++--
.../LanguageServerFormatterFactory.java | 2 +-
.../LanguageServerReconcileStrategy.java | 7 +-
...anguageServerReconcileStrategyFactory.java | 2 +-
.../editor/PublishDiagnosticsProcessor.java | 16 +-
.../ide/editor/ShowMessageProcessor.java | 57 ++--
.../codeassist/CompletionImageProvider.java | 3 +-
...CompletionItemBasedCompletionProposal.java | 55 ++--
.../LanguageServerCodeAssistProcessor.java | 55 ++--
.../codeassist/LatestCompletionResult.java | 59 ++--
.../quickassist/ApplyTextEditAction.java | 28 +-
.../LanguageServerQuickAssistProcessor.java | 55 ++--
.../quickassist/QuickassistActionEvent.java | 9 +-
.../LanguageServerSignatureHelp.java | 14 +-
.../LanguageServerSignatureHelpFactory.java | 2 +-
.../editor/signature/ParamterInfoImpl.java | 6 +-
.../editor/signature/SignatureHelpImpl.java | 9 +-
.../editor/signature/SignatureInfoImpl.java | 10 +-
.../sync/FullTextDocumentSynchronize.java | 14 +-
.../IncrementalTextDocumentSynchronize.java | 23 +-
.../sync/TextDocumentSynchronizeFactory.java | 3 +-
.../ide/highlighting/OccurrencesProvider.java | 56 ++--
.../ide/hover/HoverProvider.java | 35 +-
.../ide/location/OpenLocationPresenter.java | 18 +-
.../ide/location/OpenLocationView.java | 8 +-
.../ide/location/OpenLocationViewImpl.java | 12 +-
.../declaration/FindDefinitionAction.java | 17 +-
.../references/FindReferencesAction.java | 31 +-
.../navigation/symbol/GoToSymbolAction.java | 51 +--
.../ide/navigation/symbol/SymbolEntry.java | 10 +-
.../navigation/symbol/SymbolKindHelper.java | 5 +-
.../workspace/FindSymbolAction.java | 45 +--
.../ide/navigation/workspace/SymbolEntry.java | 14 +-
.../ide/quickopen/QuickOpenEntry.java | 19 +-
.../ide/quickopen/QuickOpenEntryGroup.java | 24 +-
.../ide/quickopen/QuickOpenViewImpl.java | 157 +++++----
.../ide/registry/LanguageServerRegistry.java | 42 ++-
.../LanguageServerRegistryServiceClient.java | 16 +-
.../service/TextDocumentServiceClient.java | 150 ++++-----
.../ide/service/WorkspaceServiceClient.java | 21 +-
.../ide/util/DtoBuildHelper.java | 34 +-
.../ide/util/OpenFileInEditorHelper.java | 5 +-
.../api/languageserver/LanguageServer.gwt.xml | 2 +-
.../languageserver/LanguageServer.gwt.xml | 5 +-
.../resources/org/eclipse/lsp4j/Lsp4j.gwt.xml | 18 +
.../lsp4j/jsonrpc/messages/Either.java | 52 +++
.../che-plugin-php-lang-server/pom.xml | 12 +-
.../PhpLanguageServerLauncher.java | 37 +--
.../che-plugin-python-lang-server/pom.xml | 12 +-
.../PythonLanguageSeverLauncher.java | 36 +-
.../che-plugin-web-ext-server/pom.xml | 12 +-
.../plugin/web/typescript/TSLSLauncher.java | 27 +-
pom.xml | 5 +
.../pom.xml | 84 +++++
.../generator/ClientDtoGenerator.java | 51 +++
.../generator/ClientJsonImpl.java | 115 +++++++
.../generator/ConversionGenerator.java | 99 ++++++
.../generator/DtoGenerator.java | 311 ++++++++++++++++++
.../languageserver/generator/EitherUtil.java | 104 ++++++
.../generator/FromJsonGenerator.java | 175 ++++++++++
.../languageserver/generator/JsonImpl.java | 139 ++++++++
.../generator/ServerDtoGenerator.java | 74 +++++
.../generator/ServerJsonImpl.java | 115 +++++++
.../generator/ToDtoGenerator.java | 142 ++++++++
.../generator/ToJsonGenerator.java | 153 +++++++++
.../maven/plugin/DtoGeneratorMojo.java | 63 ++++
.../pom.xml | 79 +----
.../shared/ProjectExtensionKey.java | 36 +-
.../event/LanguageServerInitializeEvent.java | 48 +++
.../LanguageServerInitializeEventDto.java | 34 --
.../shared/lsapi/CancelParamsDTO.java | 23 --
.../shared/lsapi/ClientCapabilitiesDTO.java | 19 --
.../shared/lsapi/CodeActionContextDTO.java | 30 --
.../shared/lsapi/CodeActionParamsDTO.java | 51 ---
.../shared/lsapi/CodeLensDTO.java | 46 ---
.../shared/lsapi/CodeLensOptionsDTO.java | 23 --
.../shared/lsapi/CodeLensParamsDTO.java | 28 --
.../shared/lsapi/CommandDTO.java | 35 --
.../shared/lsapi/CompletionItemDTO.java | 88 -----
.../shared/lsapi/CompletionListDTO.java | 43 ---
.../shared/lsapi/CompletionOptionsDTO.java | 31 --
.../shared/lsapi/DiagnosticDTO.java | 48 ---
.../DidChangeConfigurationParamsDTO.java | 20 --
.../lsapi/DidChangeTextDocumentParamsDTO.java | 48 ---
.../lsapi/DidChangeWatchedFilesParamsDTO.java | 30 --
.../lsapi/DidCloseTextDocumentParamsDTO.java | 28 --
.../lsapi/DidOpenTextDocumentParamsDTO.java | 38 ---
.../lsapi/DidSaveTextDocumentParamsDTO.java | 28 --
.../lsapi/DocumentFormattingParamsDTO.java | 38 ---
.../shared/lsapi/DocumentHighlightDTO.java | 34 --
.../DocumentOnTypeFormattingOptionsDTO.java | 30 --
.../DocumentOnTypeFormattingParamsDTO.java | 54 ---
.../DocumentRangeFormattingParamsDTO.java | 48 ---
.../shared/lsapi/DocumentSymbolParamsDTO.java | 28 --
.../shared/lsapi/FileEventDTO.java | 29 --
.../shared/lsapi/FormattingOptionsDTO.java | 35 --
.../languageserver/shared/lsapi/HoverDTO.java | 40 ---
.../shared/lsapi/InitializeErrorDTO.java | 24 --
.../shared/lsapi/InitializeResultDTO.java | 39 ---
.../shared/lsapi/LanguageDescriptionDTO.java | 40 ---
.../shared/lsapi/LocationDTO.java | 27 --
.../shared/lsapi/MarkedStringDTO.java | 22 --
.../shared/lsapi/MessageActionItemDTO.java | 23 --
.../shared/lsapi/MessageDTO.java | 20 --
.../shared/lsapi/MessageParamsDTO.java | 29 --
.../shared/lsapi/NotificationMessageDTO.java | 30 --
.../shared/lsapi/ParameterInformationDTO.java | 29 --
.../shared/lsapi/PositionDTO.java | 28 --
.../lsapi/PublishDiagnosticsParamsDTO.java | 36 --
.../languageserver/shared/lsapi/RangeDTO.java | 38 ---
.../shared/lsapi/ReferenceContextDTO.java | 23 --
.../shared/lsapi/ReferenceParamsDTO.java | 50 ---
.../shared/lsapi/RenameParamsDTO.java | 46 ---
.../shared/lsapi/RequestMessageDTO.java | 35 --
.../shared/lsapi/ResponseErrorDTO.java | 35 --
.../shared/lsapi/ResponseMessageDTO.java | 41 ---
.../shared/lsapi/ServerCapabilitiesDTO.java | 118 -------
.../lsapi/ShowMessageRequestParamsDTO.java | 41 ---
.../shared/lsapi/SignatureHelpDTO.java | 40 ---
.../shared/lsapi/SignatureHelpOptionsDTO.java | 25 --
.../shared/lsapi/SignatureInformationDTO.java | 41 ---
.../shared/lsapi/SymbolInformationDTO.java | 44 ---
.../TextDocumentContentChangeEventDTO.java | 39 ---
.../lsapi/TextDocumentIdentifierDTO.java | 23 --
.../shared/lsapi/TextDocumentItemDTO.java | 39 ---
.../lsapi/TextDocumentPositionParamsDTO.java | 43 ---
.../shared/lsapi/TextEditDTO.java | 36 --
.../VersionedTextDocumentIdentifierDTO.java | 28 --
.../shared/lsapi/WorkspaceEditDTO.java | 32 --
.../lsapi/WorkspaceSymbolParamsDTO.java | 27 --
.../shared/model/ExtendedCompletionItem.java | 22 ++
.../shared/model/ExtendedCompletionList.java | 39 +++
.../model/ExtendedInitializeResult.java | 62 ++++
.../model/ExtendedWorkspaceSymbolParams.java | 21 ++
.../shared/model/LanguageDescription.java | 73 +++-
.../model/impl/InitializeResultImpl.java | 43 ---
.../model/impl/LanguageDescriptionImpl.java | 102 ------
.../shared/util/JsonDecision.java | 5 +
wsagent/che-core-api-languageserver/pom.xml | 99 +++++-
.../che/api/languageserver/DtoConverter.java | 120 -------
.../exception/LanguageServerException.java | 1 +
.../launcher/LanguageServerLauncher.java | 6 +-
.../LanguageServerLauncherTemplate.java | 11 +-
.../messager/InitializeEventMessenger.java | 21 +-
.../PublishDiagnosticsParamsMessenger.java | 13 +-
.../messager/ShowMessageMessenger.java | 24 +-
.../registry/LanguageServerDescription.java | 3 +-
.../registry/LanguageServerRegistry.java | 3 +-
.../registry/LanguageServerRegistryImpl.java | 5 +-
.../registry/ServerInitializer.java | 3 +-
.../registry/ServerInitializerImpl.java | 79 +++--
.../registry/ServerInitializerObserver.java | 9 +-
.../service/LanguageRegistryService.java | 77 ++---
.../service/TextDocumentService.java | 196 ++++++-----
.../service/WorkspaceService.java | 25 +-
.../api/languageserver/util/EitherUtil.java | 50 +++
.../che/api/languageserver/util/JsonUtil.java | 42 +++
.../languageserver/dto/DtoConversionTest.java | 149 +++++++++
.../LanguageServerRegistryImplTest.java | 14 +-
.../registry/ServerInitializerImplTest.java | 13 +-
wsagent/pom.xml | 1 +
183 files changed, 3628 insertions(+), 3835 deletions(-)
delete mode 100644 plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/languageserver/JsonLanguageServer.java
create mode 100644 plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/api/languageserver/util/EitherUtil.java
rename wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKeyDto.java => plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/api/languageserver/util/JsonSerializable.java (51%)
create mode 100644 plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/api/languageserver/util/JsonUtil.java
create mode 100644 plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/lsp4j/Lsp4j.gwt.xml
create mode 100644 plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/lsp4j/jsonrpc/messages/Either.java
create mode 100644 wsagent/che-core-api-languageserver-maven-plugin/pom.xml
create mode 100644 wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ClientDtoGenerator.java
create mode 100644 wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ClientJsonImpl.java
create mode 100644 wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ConversionGenerator.java
create mode 100644 wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/DtoGenerator.java
create mode 100644 wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/EitherUtil.java
create mode 100644 wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/FromJsonGenerator.java
create mode 100644 wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/JsonImpl.java
create mode 100644 wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ServerDtoGenerator.java
create mode 100644 wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ServerJsonImpl.java
create mode 100644 wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ToDtoGenerator.java
create mode 100644 wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ToJsonGenerator.java
create mode 100644 wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/maven/plugin/DtoGeneratorMojo.java
create mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/event/LanguageServerInitializeEvent.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/event/LanguageServerInitializeEventDto.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CancelParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ClientCapabilitiesDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionContextDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensOptionsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CommandDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionItemDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionListDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionOptionsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DiagnosticDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentHighlightDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FileEventDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FormattingOptionsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/HoverDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeErrorDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeResultDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LanguageDescriptionDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LocationDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MarkedStringDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageActionItemDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/NotificationMessageDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ParameterInformationDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PositionDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RangeDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceContextDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RenameParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RequestMessageDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseErrorDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseMessageDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ServerCapabilitiesDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureInformationDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SymbolInformationDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentItemDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextEditDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceEditDTO.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java
create mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedCompletionItem.java
create mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedCompletionList.java
create mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedInitializeResult.java
create mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedWorkspaceSymbolParams.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/InitializeResultImpl.java
delete mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/LanguageDescriptionImpl.java
create mode 100644 wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/util/JsonDecision.java
delete mode 100644 wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/DtoConverter.java
create mode 100644 wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/util/EitherUtil.java
create mode 100644 wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/util/JsonUtil.java
create mode 100644 wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/dto/DtoConversionTest.java
diff --git a/core/che-core-api-dto/src/main/java/org/eclipse/che/dto/generator/DtoGenerator.java b/core/che-core-api-dto/src/main/java/org/eclipse/che/dto/generator/DtoGenerator.java
index cf3059ecc84..bcb6453a2b6 100644
--- a/core/che-core-api-dto/src/main/java/org/eclipse/che/dto/generator/DtoGenerator.java
+++ b/core/che-core-api-dto/src/main/java/org/eclipse/che/dto/generator/DtoGenerator.java
@@ -15,7 +15,6 @@
import org.eclipse.che.dto.server.DtoFactoryVisitor;
import org.eclipse.che.dto.shared.DTO;
-
import org.eclipse.che.dto.shared.DTOImpl;
import org.reflections.Reflections;
import org.reflections.scanners.SubTypesScanner;
@@ -50,10 +49,41 @@ public class DtoGenerator {
/** Flag: A pattern we can use to search an absolute path and find the start of the package definition.") */
private String packageBase = "java.";
+ public static void main(String[] args) {
+ DtoGenerator generator = new DtoGenerator();
+ for (String arg : args) {
+ if (arg.startsWith("--dto_packages=")) {
+ generator.setDtoPackages(arg.substring("--dto_packages=".length()));
+ } else if (arg.startsWith("--gen_file_name=")) {
+ generator.setGenFileName(arg.substring("--gen_file_name=".length()));
+ } else if (arg.startsWith("--impl=")) {
+ generator.setImpl(arg.substring("--impl=".length()));
+ } else if (arg.startsWith("--package_base=")) {
+ generator.setPackageBase(arg.substring("--package_base=".length()));
+ } else {
+ throw new RuntimeException("Unknown flag: " + arg);
+ //System.exit(1);
+ }
+ }
+ generator.generate();
+ }
+
+ private static Set getClasspathForPackages(String[] packages) {
+ Set urls = new HashSet<>();
+ for (String pack : packages) {
+ urls.addAll(ClasspathHelper.forPackage(pack));
+ }
+ return urls;
+ }
+
public String[] getDtoPackages() {
return dtoPackages;
}
+ private void setDtoPackages(String packagesParam) {
+ setDtoPackages(packagesParam.split(","));
+ }
+
public void setDtoPackages(String[] dtoPackages) {
this.dtoPackages = new String[dtoPackages.length];
System.arraycopy(dtoPackages, 0, this.dtoPackages, 0, this.dtoPackages.length);
@@ -83,29 +113,6 @@ public void setPackageBase(String packageBase) {
this.packageBase = packageBase;
}
- public static void main(String[] args) {
- DtoGenerator generator = new DtoGenerator();
- for (String arg : args) {
- if (arg.startsWith("--dto_packages=")) {
- generator.setDtoPackages(arg.substring("--dto_packages=".length()));
- } else if (arg.startsWith("--gen_file_name=")) {
- generator.setGenFileName(arg.substring("--gen_file_name=".length()));
- } else if (arg.startsWith("--impl=")) {
- generator.setImpl(arg.substring("--impl=".length()));
- } else if (arg.startsWith("--package_base=")) {
- generator.setPackageBase(arg.substring("--package_base=".length()));
- } else {
- System.err.println("Unknown flag: " + arg);
- System.exit(1);
- }
- }
- generator.generate();
- }
-
- private void setDtoPackages(String packagesParam) {
- setDtoPackages(packagesParam.split(","));
- }
-
public void generate() {
Set urls = getClasspathForPackages(dtoPackages);
@@ -129,8 +136,9 @@ public void generate() {
try {
DtoTemplate dtoTemplate = new DtoTemplate(packageName, className, impl);
- Reflections reflection = new Reflections(new ConfigurationBuilder().setUrls(urls).setScanners(new SubTypesScanner(), new TypeAnnotationsScanner()));
-
+ Reflections reflection = new Reflections(
+ new ConfigurationBuilder().setUrls(urls).setScanners(new SubTypesScanner(), new TypeAnnotationsScanner()));
+
List> dtos = new ArrayList<>(reflection.getTypesAnnotatedWith(DTO.class));
// We sort alphabetically to ensure deterministic order of routing types.
@@ -145,7 +153,8 @@ public void generate() {
}
reflection = new Reflections(
- new ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader()).setScanners(new SubTypesScanner(), new TypeAnnotationsScanner()));
+ new ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader())
+ .setScanners(new SubTypesScanner(), new TypeAnnotationsScanner()));
List> dtosDependencies = new ArrayList<>(reflection.getTypesAnnotatedWith(DTO.class));
dtosDependencies.removeAll(dtos);
@@ -156,11 +165,11 @@ public void generate() {
for (Class impl : reflection.getSubTypesOf(clazz)) {
if (!(impl.isInterface() || urls.contains(impl.getProtectionDomain().getCodeSource().getLocation()))) {
if ("client".equals(dtoTemplate.getImplType())) {
- if (isClientImpl(impl)) {
- dtoTemplate.addImplementation(clazz, impl);
- }
+ if (isClientImpl(impl)) {
+ dtoTemplate.addImplementation(clazz, impl);
+ }
} else if ("server".equals(dtoTemplate.getImplType())) {
- if (isServerImpl(impl)) {
+ if (isServerImpl(impl)) {
dtoTemplate.addImplementation(clazz, impl);
}
}
@@ -197,18 +206,10 @@ private boolean isServerImpl(Class> impl) {
return a != null && "server".equals(a.value());
}
- private static Set getClasspathForPackages(String[] packages) {
- Set urls = new HashSet<>();
- for (String pack : packages) {
- urls.addAll(ClasspathHelper.forPackage(pack));
- }
- return urls;
- }
-
private static class ClassesComparator implements Comparator {
@Override
public int compare(Class o1, Class o2) {
return o1.getName().compareTo(o2.getName());
}
}
-}
\ No newline at end of file
+}
diff --git a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/filters/FuzzyMatches.java b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/filters/FuzzyMatches.java
index f1dcddd0b00..b42c80cc2be 100644
--- a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/filters/FuzzyMatches.java
+++ b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/filters/FuzzyMatches.java
@@ -22,10 +22,7 @@
import static org.eclipse.che.ide.filters.Matcher.MatcherUtil.or;
-
/**
- * Fuzzy logic to match some string
- *
* @author Evgen Vidolob
*/
@Singleton
diff --git a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/filters/Matcher.java b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/filters/Matcher.java
index e8984d84264..26d3793a09c 100644
--- a/ide/commons-gwt/src/main/java/org/eclipse/che/ide/filters/Matcher.java
+++ b/ide/commons-gwt/src/main/java/org/eclipse/che/ide/filters/Matcher.java
@@ -18,6 +18,7 @@
/**
* Matcher the wey to match some string.
* S
+ *
* @author Evgen Vidolob
*/
public interface Matcher {
@@ -25,8 +26,8 @@ public interface Matcher {
@Nullable
List match(String word, String wordToMatch);
- class MatcherUtil{
- public static Matcher or(final Matcher... matchers) {
+ class MatcherUtil {
+ public static Matcher or(final Matcher... matchers) {
return new Matcher() {
@Override
public List match(String word, String wordToMatch) {
@@ -42,7 +43,7 @@ public List match(String word, String wordToMatch) {
};
}
- public static Matcher and(final Matcher... matchers) {
+ public static Matcher and(final Matcher... matchers) {
return new Matcher() {
@Override
public List match(String word, String wordToMatch) {
diff --git a/plugins/plugin-csharp/che-plugin-csharp-lang-server/pom.xml b/plugins/plugin-csharp/che-plugin-csharp-lang-server/pom.xml
index 96a4b59152a..71f519b8712 100644
--- a/plugins/plugin-csharp/che-plugin-csharp-lang-server/pom.xml
+++ b/plugins/plugin-csharp/che-plugin-csharp-lang-server/pom.xml
@@ -36,10 +36,6 @@
com.google.inject.extensionsguice-multibindings
-
- io.typefox.lsapi
- io.typefox.lsapi.services
- org.eclipse.che.coreche-core-api-core
@@ -68,6 +64,14 @@
org.eclipse.che.pluginche-plugin-csharp-lang-shared
+
+ org.eclipse.lsp4j
+ org.eclipse.lsp4j
+
+
+ org.eclipse.lsp4j
+ org.eclipse.lsp4j.jsonrpc
+ org.slf4jslf4j-api
diff --git a/plugins/plugin-csharp/che-plugin-csharp-lang-server/src/main/java/org/eclipse/che/plugin/csharp/languageserver/CSharpLanguageServerLauncher.java b/plugins/plugin-csharp/che-plugin-csharp-lang-server/src/main/java/org/eclipse/che/plugin/csharp/languageserver/CSharpLanguageServerLauncher.java
index eb969bba199..44876ba2f86 100644
--- a/plugins/plugin-csharp/che-plugin-csharp-lang-server/src/main/java/org/eclipse/che/plugin/csharp/languageserver/CSharpLanguageServerLauncher.java
+++ b/plugins/plugin-csharp/che-plugin-csharp-lang-server/src/main/java/org/eclipse/che/plugin/csharp/languageserver/CSharpLanguageServerLauncher.java
@@ -10,16 +10,16 @@
*******************************************************************************/
package org.eclipse.che.plugin.csharp.languageserver;
-import io.typefox.lsapi.services.json.JsonBasedLanguageServer;
-
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.eclipse.che.api.languageserver.exception.LanguageServerException;
import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncherTemplate;
import org.eclipse.che.api.languageserver.shared.model.LanguageDescription;
-import org.eclipse.che.api.languageserver.shared.model.impl.LanguageDescriptionImpl;
import org.eclipse.che.commons.lang.IoUtil;
+import org.eclipse.lsp4j.jsonrpc.Launcher;
+import org.eclipse.lsp4j.services.LanguageClient;
+import org.eclipse.lsp4j.services.LanguageServer;
import java.io.File;
import java.io.IOException;
@@ -30,6 +30,7 @@
import static java.util.Arrays.asList;
+
/**
* @author Evgen Vidolob
*/
@@ -37,19 +38,12 @@
public class CSharpLanguageServerLauncher extends LanguageServerLauncherTemplate {
private static final String LANGUAGE_ID = "csharp";
- private static final String[] EXTENSIONS = new String[] {"cs", "csx"};
- private static final String[] MIME_TYPES = new String[] {"text/x-csharp"};
- private static final LanguageDescriptionImpl description;
+ private static final String[] EXTENSIONS = new String[]{"cs", "csx"};
+ private static final String[] MIME_TYPES = new String[]{"text/x-csharp"};
+ private static final LanguageDescription description;
private final Path launchScript;
- static {
- description = new LanguageDescriptionImpl();
- description.setFileExtensions(asList(EXTENSIONS));
- description.setLanguageId(LANGUAGE_ID);
- description.setMimeTypes(Arrays.asList(MIME_TYPES));
- }
-
@Inject
public CSharpLanguageServerLauncher() {
launchScript = Paths.get(System.getenv("HOME"), "che/ls-csharp/launch.sh");
@@ -87,10 +81,11 @@ private void restoreDependencies(String projectPath) throws LanguageServerExcept
}
@Override
- protected JsonBasedLanguageServer connectToLanguageServer(Process languageServerProcess) {
- JsonBasedLanguageServer languageServer = new JsonBasedLanguageServer();
- languageServer.connect(languageServerProcess.getInputStream(), languageServerProcess.getOutputStream());
- return languageServer;
+ protected LanguageServer connectToLanguageServer(final Process languageServerProcess, LanguageClient client) {
+ Launcher launcher = Launcher.createLauncher(client, LanguageServer.class, languageServerProcess.getInputStream(),
+ languageServerProcess.getOutputStream());
+ launcher.startListening();
+ return launcher.getRemoteProxy();
}
@Override
@@ -102,4 +97,11 @@ public LanguageDescription getLanguageDescription() {
public boolean isAbleToLaunch() {
return Files.exists(launchScript);
}
+
+ static {
+ description = new LanguageDescription();
+ description.setFileExtensions(asList(EXTENSIONS));
+ description.setLanguageId(LANGUAGE_ID);
+ description.setMimeTypes(Arrays.asList(MIME_TYPES));
+ }
}
diff --git a/plugins/plugin-json/che-plugin-json-server/pom.xml b/plugins/plugin-json/che-plugin-json-server/pom.xml
index 081143ff753..e21ecee924e 100644
--- a/plugins/plugin-json/che-plugin-json-server/pom.xml
+++ b/plugins/plugin-json/che-plugin-json-server/pom.xml
@@ -32,14 +32,6 @@
com.google.inject.extensionsguice-multibindings
-
- io.typefox.lsapi
- io.typefox.lsapi
-
-
- io.typefox.lsapi
- io.typefox.lsapi.services
- org.eclipse.che.coreche-core-api-languageserver
@@ -52,5 +44,13 @@
org.eclipse.che.coreche-core-commons-inject
+
+ org.eclipse.lsp4j
+ org.eclipse.lsp4j
+
+
+ org.eclipse.lsp4j
+ org.eclipse.lsp4j.jsonrpc
+
diff --git a/plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/languageserver/JsonLanguageServer.java b/plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/languageserver/JsonLanguageServer.java
deleted file mode 100644
index b9840fc679d..00000000000
--- a/plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/languageserver/JsonLanguageServer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2012-2017 Codenvy, S.A.
- * 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:
- * Codenvy, S.A. - initial API and implementation
- *******************************************************************************/
-package org.eclipse.che.plugin.json.languageserver;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.che.api.languageserver.registry.ServerInitializerObserver;
-import org.eclipse.che.api.languageserver.shared.model.LanguageDescription;
-
-import io.typefox.lsapi.ServerCapabilities;
-import io.typefox.lsapi.services.LanguageServer;
-import io.typefox.lsapi.services.json.JsonBasedLanguageServer;
-
-/**
- * Implements the specifics related to the JSON language server.
- *
- * After the Initialize Request the client must send a 'json/schemaAssociations'
- * notification in order to associate JSON schemas to popular JSON files. This
- * automatically enables code completion, validation, hover, etc. capabilities
- * for these files without the need of adding a "$schema" key.
- *
- * @author Kaloyan Raev
- */
-public class JsonLanguageServer extends JsonBasedLanguageServer implements ServerInitializerObserver {
-
- private final static String JSON_SCHEMA_ASSOCIATIONS = "json/schemaAssociations";
-
- @Override
- public void onServerInitialized(LanguageServer server, ServerCapabilities capabilities,
- LanguageDescription languageDescription, String projectPath) {
- registerSchemaAssociations();
- }
-
- private void registerSchemaAssociations() {
- Map associations = new HashMap<>();
- associations.put("/*.schema.json", new String[] { "http://json-schema.org/draft-04/schema#" });
- associations.put("/bower.json", new String[] { "http://json.schemastore.org/bower" });
- associations.put("/.bower.json", new String[] { "http://json.schemastore.org/bower" });
- associations.put("/.bowerrc", new String[] { "http://json.schemastore.org/bowerrc" });
- associations.put("/composer.json", new String[] { "https://getcomposer.org/schema.json" });
- associations.put("/package.json", new String[] { "http://json.schemastore.org/package" });
- associations.put("/jsconfig.json", new String[] { "http://json.schemastore.org/jsconfig" });
- associations.put("/tsconfig.json", new String[] { "http://json.schemastore.org/tsconfig" });
-
- sendNotification(JSON_SCHEMA_ASSOCIATIONS, associations);
- }
-
-}
\ No newline at end of file
diff --git a/plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/languageserver/JsonLanguageServerLauncher.java b/plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/languageserver/JsonLanguageServerLauncher.java
index bf7c6a23fa4..6be52d9e1d9 100644
--- a/plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/languageserver/JsonLanguageServerLauncher.java
+++ b/plugins/plugin-json/che-plugin-json-server/src/main/java/org/eclipse/che/plugin/json/languageserver/JsonLanguageServerLauncher.java
@@ -10,15 +10,15 @@
*******************************************************************************/
package org.eclipse.che.plugin.json.languageserver;
-import io.typefox.lsapi.services.json.JsonBasedLanguageServer;
-
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.eclipse.che.api.languageserver.exception.LanguageServerException;
import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncherTemplate;
import org.eclipse.che.api.languageserver.shared.model.LanguageDescription;
-import org.eclipse.che.api.languageserver.shared.model.impl.LanguageDescriptionImpl;
+import org.eclipse.lsp4j.jsonrpc.Launcher;
+import org.eclipse.lsp4j.services.LanguageClient;
+import org.eclipse.lsp4j.services.LanguageServer;
import java.io.IOException;
import java.nio.file.Files;
@@ -35,19 +35,13 @@
public class JsonLanguageServerLauncher extends LanguageServerLauncherTemplate {
private static final String LANGUAGE_ID = "json";
- private static final String[] EXTENSIONS = new String[] {"json", "bowerrc", "jshintrc", "jscsrc", "eslintrc", "babelrc"};
- private static final String[] MIME_TYPES = new String[] {"application/json"};
- private static final LanguageDescriptionImpl description;
+ private static final String[] EXTENSIONS = new String[]{"json", "bowerrc", "jshintrc", "jscsrc", "eslintrc",
+ "babelrc"};
+ private static final String[] MIME_TYPES = new String[]{"application/json"};
+ private static final LanguageDescription description;
private final Path launchScript;
- static {
- description = new LanguageDescriptionImpl();
- description.setFileExtensions(asList(EXTENSIONS));
- description.setLanguageId(LANGUAGE_ID);
- description.setMimeTypes(asList(MIME_TYPES));
- }
-
@Inject
public JsonLanguageServerLauncher() {
launchScript = Paths.get(System.getenv("HOME"), "che/ls-json/launch.sh");
@@ -63,10 +57,12 @@ public boolean isAbleToLaunch() {
return Files.exists(launchScript);
}
- protected JsonBasedLanguageServer connectToLanguageServer(Process languageServerProcess) {
- JsonBasedLanguageServer languageServer = new JsonLanguageServer();
- languageServer.connect(languageServerProcess.getInputStream(), languageServerProcess.getOutputStream());
- return languageServer;
+ protected LanguageServer connectToLanguageServer(final Process languageServerProcess, LanguageClient client) {
+ Launcher launcher = Launcher.createLauncher(client, LanguageServer.class,
+ languageServerProcess.getInputStream(),
+ languageServerProcess.getOutputStream());
+ launcher.startListening();
+ return launcher.getRemoteProxy();
}
protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException {
@@ -79,4 +75,11 @@ protected Process startLanguageServerProcess(String projectPath) throws Language
throw new LanguageServerException("Can't start JSON language server", e);
}
}
+
+ static {
+ description = new LanguageDescription();
+ description.setFileExtensions(asList(EXTENSIONS));
+ description.setLanguageId(LANGUAGE_ID);
+ description.setMimeTypes(asList(MIME_TYPES));
+ }
}
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/pom.xml b/plugins/plugin-languageserver/che-plugin-languageserver-ide/pom.xml
index 2cdaace76f1..03bf6681f3c 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/pom.xml
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/pom.xml
@@ -42,10 +42,6 @@
com.google.inject.extensionsguice-assistedinject
-
- io.typefox.lsapi
- io.typefox.lsapi
- javax.injectjavax.inject
@@ -54,10 +50,6 @@
javax.validationvalidation-api
-
- org.eclipse.che.core
- che-core-api-dto
- org.eclipse.che.coreche-core-api-languageserver-shared
@@ -82,6 +74,24 @@
org.eclipse.che.coreche-core-orion-editor
+
+ org.eclipse.lsp4j
+ org.eclipse.lsp4j
+
+
+ org.eclipse.xtext.xbase.lib
+ org.eclipse.xtext
+
+
+ org.eclipse.xtend.lib
+ org.eclipse.xtend
+
+
+
+
+ org.eclipse.xtext
+ org.eclipse.xtext.xbase.lib.gwt
+ org.vectomaticlib-gwt-svg
@@ -122,10 +132,15 @@
**/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LatestCompletionResult.java
- **/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/ApplyTextEditAction.java
- **/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/LanguageServerQuickAssistProcessor.java
- **/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/LanguageServerQuickAssistProcessorFactory.java
- **/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/QuickassistActionEvent.java
+ **/Lsp4j.gwt.xml
+ **/Either.java
+ **/EitherUtil.java
+ **/JsonUtil.java
+ **/JsonSerializable.java
+ **/ApplyTextEditAction.java
+ **/QuickassistActionEvent.java
+ **/LanguageServerQuickAssistProcessorFactory.java
+ **/LanguageServerQuickAssistProcessor.java
@@ -162,27 +177,18 @@
-
+ org.eclipse.che.core
- che-core-api-dto-maven-plugin
+ che-core-api-languageserver-maven-plugin${project.version}
- generate-client-dtogenerate-sourcesgenerate
-
-
- org.eclipse.che.api.languageserver.shared
-
- ${dto-generator-out-directory}
- org.eclipse.che.api.languageserver.shared.dto.DtoClientImpls
- client
-
-
+
${project.groupId}
@@ -190,6 +196,30 @@
${project.version}
+
+
+ org.eclipse.lsp4j
+ org.eclipse.che.api.languageserver.shared.event
+ org.eclipse.che.api.languageserver.shared.model
+
+ ${dto-generator-out-directory}
+ org.eclipse.che.api.languageserver.shared.dto.DtoClientImpls
+ client
+
+
+
+ org.apache.maven.plugins
+ maven-dependency-plugin
+
+
+ analyze
+
+
+ org.eclipse.xtext:org.eclipse.xtext.xbase.lib.gwt
+
+
+
+
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/api/languageserver/util/EitherUtil.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/api/languageserver/util/EitherUtil.java
new file mode 100644
index 00000000000..a7f59e017f7
--- /dev/null
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/api/languageserver/util/EitherUtil.java
@@ -0,0 +1,50 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Red Hat.
+ * 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:
+ * Red Hat - Initial Contribution
+ *******************************************************************************/
+package org.eclipse.che.api.languageserver.util;
+
+import com.google.gwt.json.client.JSONValue;
+
+import org.eclipse.che.api.languageserver.shared.util.JsonDecision;
+import org.eclipse.lsp4j.jsonrpc.messages.Either;
+
+
+/**
+ * Code to be called by generated DTO classes to determine whether a json
+ * element matches the kind of expected type in an {@link Either} field.
+ *
+ * @author Thomas Mäder
+ */
+public class EitherUtil {
+ public static boolean matches(JSONValue element, JsonDecision[] classes) {
+ for (JsonDecision cls : classes) {
+ if (matches(element, cls)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static boolean matches(JSONValue element, JsonDecision decision) {
+ if (decision == JsonDecision.LIST) {
+ return element.isArray() != null;
+ }
+ if (decision == JsonDecision.BOOLEAN) {
+ return element.isBoolean() != null;
+ }
+ if (decision == JsonDecision.NUMBER) {
+ return element.isNumber() != null;
+ }
+ if (decision == JsonDecision.STRING) {
+ return element.isString() != null;
+ }
+ return element.isObject() != null;
+ }
+}
diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKeyDto.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/api/languageserver/util/JsonSerializable.java
similarity index 51%
rename from wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKeyDto.java
rename to plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/api/languageserver/util/JsonSerializable.java
index f96908e29f0..26319efeffa 100644
--- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKeyDto.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/api/languageserver/util/JsonSerializable.java
@@ -1,27 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2012-2017 Codenvy, S.A.
+ * Copyright (c) 2017 Red Hat.
* 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:
- * Codenvy, S.A. - initial API and implementation
+ * Red Hat - Initial Contribution
*******************************************************************************/
-package org.eclipse.che.api.languageserver.shared;
+package org.eclipse.che.api.languageserver.util;
-import org.eclipse.che.dto.shared.DTO;
+import com.google.gwt.json.client.JSONValue;
/**
- * @author Evgen Vidolob
+ * Extend JsonSerializable with a conversion to a json value. This is
+ * used in the generated DTO conversions.
+ *
+ * @author Thomas Mäder
*/
-@DTO
-public interface ProjectExtensionKeyDto {
- String getProject();
-
- void setProject(String project);
-
- String getExtension();
-
- void setExtension(String extension);
+public interface JsonSerializable extends org.eclipse.che.ide.dto.JsonSerializable {
+ JSONValue toJsonElement();
}
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/api/languageserver/util/JsonUtil.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/api/languageserver/util/JsonUtil.java
new file mode 100644
index 00000000000..6d3c07455e5
--- /dev/null
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/api/languageserver/util/JsonUtil.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Red Hat.
+ * 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:
+ * Red Hat - Initial Contribution
+ *******************************************************************************/
+package org.eclipse.che.api.languageserver.util;
+
+
+import com.google.gwt.json.client.JSONBoolean;
+import com.google.gwt.json.client.JSONNumber;
+import com.google.gwt.json.client.JSONString;
+import com.google.gwt.json.client.JSONValue;
+
+/**
+ * Utility to convert stuff that is not statically typed in lsp4j (java.lang.Object)
+ *
+ * @author Thomas Mäder
+ */
+public class JsonUtil {
+ public static JSONValue convertToJson(Object value) {
+ if (value instanceof Enum) {
+ return new JSONString(((Enum>)value).name());
+ } else if (value instanceof String) {
+ return new JSONString((String)value);
+ } else if (value instanceof Number) {
+ return new JSONNumber(((Number)value).doubleValue());
+ } else if (value instanceof Boolean) {
+ return JSONBoolean.getInstance((boolean)value);
+ } else if (value instanceof JsonSerializable) {
+ return ((JsonSerializable)value).toJsonElement();
+ } else if (value instanceof JSONValue) {
+ return (JSONValue)value;
+ }
+ throw new RuntimeException("Unexpected runtime value: " + value);
+ }
+
+}
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerExtension.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerExtension.java
index 342b2e5152f..93989fca51f 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerExtension.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerExtension.java
@@ -13,11 +13,7 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.google.web.bindery.event.shared.EventBus;
-import org.eclipse.che.api.languageserver.shared.lsapi.DidCloseTextDocumentParamsDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.DidOpenTextDocumentParamsDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.DidSaveTextDocumentParamsDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentItemDTO;
+
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
import org.eclipse.che.ide.api.action.ActionManager;
@@ -39,6 +35,11 @@
import org.eclipse.che.plugin.languageserver.ide.navigation.symbol.GoToSymbolAction;
import org.eclipse.che.plugin.languageserver.ide.navigation.workspace.FindSymbolAction;
import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient;
+import org.eclipse.lsp4j.DidCloseTextDocumentParams;
+import org.eclipse.lsp4j.DidOpenTextDocumentParams;
+import org.eclipse.lsp4j.DidSaveTextDocumentParams;
+import org.eclipse.lsp4j.TextDocumentIdentifier;
+import org.eclipse.lsp4j.TextDocumentItem;
import static org.eclipse.che.ide.api.action.IdeActions.GROUP_ASSISTANT;
@@ -80,9 +81,9 @@ protected void registerAction(ActionManager actionManager,
} else {
keyBindingManager.getGlobal().addKey(new KeyBuilder().action().charCode(KeyCodeMap.F12).build(), "LSGoToSymbolAction");
}
- keyBindingManager.getGlobal().addKey(new KeyBuilder().alt().charCode('n').build(),"LSFindSymbolAction");
- keyBindingManager.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.F7).build(),"LSFindReferencesAction");
- keyBindingManager.getGlobal().addKey(new KeyBuilder().charCode(KeyCodeMap.F4).build(),"LSFindDefinitionAction");
+ keyBindingManager.getGlobal().addKey(new KeyBuilder().alt().charCode('n').build(), "LSFindSymbolAction");
+ keyBindingManager.getGlobal().addKey(new KeyBuilder().alt().charCode(KeyCodeMap.F7).build(), "LSFindReferencesAction");
+ keyBindingManager.getGlobal().addKey(new KeyBuilder().charCode(KeyCodeMap.F4).build(), "LSFindDefinitionAction");
}
@@ -99,7 +100,7 @@ public void onFileOperation(final FileEvent event) {
if (location.getFileExtension() == null || !fileTypeRegister.hasLSForExtension(location.getFileExtension())) {
return;
}
- final TextDocumentIdentifierDTO documentId = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
+ final TextDocumentIdentifier documentId = dtoFactory.createDto(TextDocumentIdentifier.class);
documentId.setUri(location.toString());
switch (event.getOperationType()) {
case OPEN:
@@ -116,18 +117,18 @@ public void onFileOperation(final FileEvent event) {
});
}
- private void onSave(TextDocumentIdentifierDTO documentId,
+ private void onSave(TextDocumentIdentifier documentId,
DtoFactory dtoFactory,
TextDocumentServiceClient serviceClient) {
- DidSaveTextDocumentParamsDTO saveEvent = dtoFactory.createDto(DidSaveTextDocumentParamsDTO.class);
+ DidSaveTextDocumentParams saveEvent = dtoFactory.createDto(DidSaveTextDocumentParams.class);
saveEvent.setTextDocument(documentId);
serviceClient.didSave(saveEvent);
}
- private void onClose(TextDocumentIdentifierDTO documentId,
+ private void onClose(TextDocumentIdentifier documentId,
DtoFactory dtoFactory,
TextDocumentServiceClient serviceClient) {
- DidCloseTextDocumentParamsDTO closeEvent = dtoFactory.createDto(DidCloseTextDocumentParamsDTO.class);
+ DidCloseTextDocumentParams closeEvent = dtoFactory.createDto(DidCloseTextDocumentParams.class);
closeEvent.setTextDocument(documentId);
serviceClient.didClose(closeEvent);
}
@@ -139,15 +140,15 @@ private void onOpen(final FileEvent event,
event.getFile().getContent().then(new Operation() {
@Override
public void apply(String text) throws OperationException {
- TextDocumentItemDTO documentItem = dtoFactory.createDto(TextDocumentItemDTO.class);
+ TextDocumentItem documentItem = dtoFactory.createDto(TextDocumentItem.class);
documentItem.setUri(event.getFile().getLocation().toString());
documentItem.setVersion(LanguageServerEditorConfiguration.INITIAL_DOCUMENT_VERSION);
documentItem.setText(text);
documentItem.setLanguageId(fileTypeRegister.findLangId(event.getFile().getLocation().getFileExtension()));
- DidOpenTextDocumentParamsDTO openEvent = dtoFactory.createDto(DidOpenTextDocumentParamsDTO.class);
+ DidOpenTextDocumentParams openEvent = dtoFactory.createDto(DidOpenTextDocumentParams.class);
openEvent.setTextDocument(documentItem);
- openEvent.setUri(event.getFile().getLocation().toString());
+ openEvent.getTextDocument().setUri(event.getFile().getLocation().toString());
openEvent.setText(text);
serviceClient.didOpen(openEvent);
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerFileTypeRegister.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerFileTypeRegister.java
index 3196b5d32aa..fa75a60bae7 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerFileTypeRegister.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerFileTypeRegister.java
@@ -14,12 +14,8 @@
import com.google.gwt.core.client.JsArrayString;
import com.google.inject.Inject;
import com.google.inject.Singleton;
-import static com.google.common.collect.Lists.newArrayList;
-
-import java.util.List;
-import java.util.logging.Logger;
-import org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO;
+import org.eclipse.che.api.languageserver.shared.model.LanguageDescription;
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
import org.eclipse.che.api.promises.client.Promise;
@@ -39,7 +35,9 @@
import org.eclipse.che.plugin.languageserver.ide.service.LanguageServerRegistryServiceClient;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
+import java.util.logging.Logger;
import static com.google.common.collect.Lists.newArrayList;
@@ -49,8 +47,7 @@
@Singleton
public class LanguageServerFileTypeRegister implements WsAgentComponent {
-
-
+
private final LanguageServerRegistryServiceClient serverLanguageRegistry;
private final FileTypeRegistry fileTypeRegistry;
private final LanguageServerResources resources;
@@ -89,13 +86,13 @@ public LanguageServerFileTypeRegister(LanguageServerRegistryServiceClient server
@Override
public void start(final Callback callback) {
- Promise> registeredLanguages = serverLanguageRegistry.getSupportedLanguages();
- registeredLanguages.then(new Operation>() {
+ Promise> registeredLanguages = serverLanguageRegistry.getSupportedLanguages();
+ registeredLanguages.then(new Operation>() {
@Override
- public void apply(List langs) throws OperationException {
+ public void apply(List langs) throws OperationException {
if (!langs.isEmpty()) {
JsArrayString contentTypes = JsArrayString.createArray().cast();
- for (LanguageDescriptionDTO lang : langs) {
+ for (LanguageDescription lang : langs) {
String primaryExtension = lang.getFileExtensions().get(0);
for (String ext : lang.getFileExtensions()) {
final FileType fileType = new FileType(resources.file(), ext);
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerResources.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerResources.java
index 3eb50c40d5c..332b1b51eaa 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerResources.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerResources.java
@@ -108,7 +108,7 @@ interface LSCss extends CssResource {
String codeassistantHighlight();
}
- interface QuickOpenListCss extends SimpleList.Css{
+ interface QuickOpenListCss extends SimpleList.Css {
int menuListBorderPx();
String listItem();
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticAnnotation.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticAnnotation.java
index 681710012ab..ee24fbba635 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticAnnotation.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticAnnotation.java
@@ -12,12 +12,12 @@
import elemental.dom.Element;
import elemental.js.dom.JsElement;
-import io.typefox.lsapi.DiagnosticSeverity;
-import org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO;
import org.eclipse.che.ide.api.editor.text.annotation.Annotation;
import org.eclipse.che.ide.util.dom.Elements;
import org.eclipse.che.plugin.languageserver.ide.LanguageServerResources;
+import org.eclipse.lsp4j.Diagnostic;
+import org.eclipse.lsp4j.DiagnosticSeverity;
import org.vectomatic.dom.svg.ui.SVGImage;
/**
@@ -42,10 +42,10 @@ public class DiagnosticAnnotation extends Annotation {
private static JsElement fgWarningElement = new SVGImage(RESOURCES.markWarning()).getElement().cast();
private static JsElement fgErrorElement = new SVGImage(RESOURCES.markError()).getElement().cast();
- private DiagnosticDTO diagnostic;
- private Element imageElement = null;
+ private Diagnostic diagnostic;
+ private Element imageElement = null;
- public DiagnosticAnnotation(DiagnosticDTO diagnostic) {
+ public DiagnosticAnnotation(Diagnostic diagnostic) {
this.diagnostic = diagnostic;
@@ -55,31 +55,31 @@ public DiagnosticAnnotation(DiagnosticDTO diagnostic) {
setType(ERROR_ANNOTATION_TYPE);
} else {
switch (severity) {
- case Error:
- layer = ERROR_LAYER;
- setType(ERROR_ANNOTATION_TYPE);
- break;
- case Warning:
- layer = WARNING_LAYER;
- setType(WARNING_ANNOTATION_TYPE);
- break;
- case Information:
- layer = INFO_LAYER;
- setType(INFO_ANNOTATION_TYPE);
- break;
- case Hint:
- layer = HINT_LAYER;
- setType(HINT_ANNOTATION_TYPE);
- break;
- default:
- layer = ERROR_LAYER;
- setType(ERROR_ANNOTATION_TYPE);
- break;
+ case Error:
+ layer = ERROR_LAYER;
+ setType(ERROR_ANNOTATION_TYPE);
+ break;
+ case Warning:
+ layer = WARNING_LAYER;
+ setType(WARNING_ANNOTATION_TYPE);
+ break;
+ case Information:
+ layer = INFO_LAYER;
+ setType(INFO_ANNOTATION_TYPE);
+ break;
+ case Hint:
+ layer = HINT_LAYER;
+ setType(HINT_ANNOTATION_TYPE);
+ break;
+ default:
+ layer = ERROR_LAYER;
+ setType(ERROR_ANNOTATION_TYPE);
+ break;
}
}
}
- public DiagnosticDTO getDiagnostic() {
+ public Diagnostic getDiagnostic() {
return diagnostic;
}
@@ -88,7 +88,9 @@ public String getText() {
return diagnostic.getMessage();
}
+
private void initializeImage() {
+
imageElement = Elements.createDivElement();
imageElement.setClassName(RESOURCES.css().markElement());
@@ -101,16 +103,16 @@ private void initializeImage() {
private Element getSelectedImageElement() {
final String type = getType();
switch (type) {
- case HINT_ANNOTATION_TYPE:
- return fgTaskElement;
- case INFO_ANNOTATION_TYPE:
- return fgInfoElement;
- case WARNING_ANNOTATION_TYPE:
- return fgWarningElement;
- case ERROR_ANNOTATION_TYPE:
- return fgErrorElement;
- default:
- return null;
+ case HINT_ANNOTATION_TYPE:
+ return fgTaskElement;
+ case INFO_ANNOTATION_TYPE:
+ return fgInfoElement;
+ case WARNING_ANNOTATION_TYPE:
+ return fgWarningElement;
+ case ERROR_ANNOTATION_TYPE:
+ return fgErrorElement;
+ default:
+ return null;
}
}
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticCollector.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticCollector.java
index d7b6966247b..1f943d1798a 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticCollector.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/DiagnosticCollector.java
@@ -10,8 +10,7 @@
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.ide.editor;
-
-import org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO;
+import org.eclipse.lsp4j.Diagnostic;
/**
* @author Evgen Vidolob
@@ -23,7 +22,7 @@ public interface DiagnosticCollector {
* @param diagnostic
* Diagnostic - The discovered diagnostic.
*/
- void acceptDiagnostic(DiagnosticDTO diagnostic);
+ void acceptDiagnostic(Diagnostic diagnostic);
/**
* Notification sent before starting the diagnostic process.
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerAnnotationModel.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerAnnotationModel.java
index a68b61c8dc9..3aba79e7bec 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerAnnotationModel.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerAnnotationModel.java
@@ -13,8 +13,6 @@
import com.google.inject.assistedinject.Assisted;
import com.google.inject.assistedinject.AssistedInject;
-import org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO;
import org.eclipse.che.ide.api.editor.annotation.AnnotationModelImpl;
import org.eclipse.che.ide.api.editor.document.Document;
import org.eclipse.che.ide.api.editor.document.DocumentHandle;
@@ -24,6 +22,8 @@
import org.eclipse.che.ide.api.editor.texteditor.EditorResources;
import org.eclipse.che.ide.editor.orion.client.OrionAnnotationSeverityProvider;
import org.eclipse.che.plugin.languageserver.ide.LanguageServerResources;
+import org.eclipse.lsp4j.Diagnostic;
+import org.eclipse.lsp4j.Range;
import java.util.ArrayList;
import java.util.HashMap;
@@ -36,7 +36,7 @@
public class LanguageServerAnnotationModel extends AnnotationModelImpl implements DiagnosticCollector, OrionAnnotationSeverityProvider {
private final LanguageServerResources.LSCss lsCss;
private final EditorResources.EditorCss editorCss;
- private List diagnostics;
+ private List diagnostics;
private List generatedAnnotations = new ArrayList<>();
@AssistedInject
@@ -48,10 +48,10 @@ public LanguageServerAnnotationModel(@Assisted final DocumentPositionMap docPosi
this.editorCss = editorResources.editorCss();
}
- protected Position createPositionFromDiagnostic(final DiagnosticDTO diagnostic) {
+ protected Position createPositionFromDiagnostic(final Diagnostic diagnostic) {
DocumentHandle documentHandle = getDocumentHandle();
Document document = documentHandle.getDocument();
- RangeDTO range = diagnostic.getRange();
+ Range range = diagnostic.getRange();
int start = document.getIndexFromPosition(new TextPosition(range.getStart().getLine(), range.getStart().getCharacter()));
int end = document.getIndexFromPosition(new TextPosition(range.getEnd().getLine(), range.getEnd().getCharacter()));
@@ -75,7 +75,7 @@ protected Position createPositionFromDiagnostic(final DiagnosticDTO diagnostic)
}
@Override
- public void acceptDiagnostic(final DiagnosticDTO problem) {
+ public void acceptDiagnostic(final Diagnostic problem) {
diagnostics.add(problem);
}
@@ -100,7 +100,7 @@ private void reportDiagnostic() {
if (diagnostics != null && !diagnostics.isEmpty()) {
- for (final DiagnosticDTO diagnostic : diagnostics) {
+ for (final Diagnostic diagnostic : diagnostics) {
final Position position = createPositionFromDiagnostic(diagnostic);
if (position != null) {
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerCodeassistProcessorFactory.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerCodeassistProcessorFactory.java
index 071d277e3ad..56d618a16fc 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerCodeassistProcessorFactory.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerCodeassistProcessorFactory.java
@@ -10,14 +10,13 @@
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.ide.editor;
-import io.typefox.lsapi.ServerCapabilities;
-
import org.eclipse.che.plugin.languageserver.ide.editor.codeassist.LanguageServerCodeAssistProcessor;
+import org.eclipse.lsp4j.ServerCapabilities;
/**
* @author Evgen Vidolob
*/
public interface LanguageServerCodeassistProcessorFactory {
-
+
LanguageServerCodeAssistProcessor create(ServerCapabilities capabilities);
}
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerEditorConfiguration.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerEditorConfiguration.java
index c9370eadfe8..e531abc228f 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerEditorConfiguration.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerEditorConfiguration.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.ide.editor;
-import io.typefox.lsapi.ServerCapabilities;
-
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.assistedinject.Assisted;
@@ -30,6 +28,7 @@
import org.eclipse.che.plugin.languageserver.ide.editor.quickassist.LanguageServerQuickAssistProcessor;
import org.eclipse.che.plugin.languageserver.ide.editor.quickassist.LanguageServerQuickAssistProcessorFactory;
import org.eclipse.che.plugin.languageserver.ide.editor.signature.LanguageServerSignatureHelpFactory;
+import org.eclipse.lsp4j.ServerCapabilities;
import java.util.HashMap;
import java.util.Map;
@@ -50,7 +49,8 @@ public class LanguageServerEditorConfiguration extends DefaultTextEditorConfigur
private final LanguageServerQuickAssistProcessor quickAssistProcessor;
@Inject
- public LanguageServerEditorConfiguration(@Assisted TextEditor editor, LanguageServerCodeassistProcessorFactory codeAssistProcessor,
+ public LanguageServerEditorConfiguration(@Assisted TextEditor editor,
+ LanguageServerCodeassistProcessorFactory codeAssistProcessor,
LanguageServerQuickAssistProcessorFactory quickAssistProcessorFactory,
Provider docPositionMapProvider,
LanguageServerAnnotationModelFactory annotationModelFactory,
@@ -60,13 +60,12 @@ public LanguageServerEditorConfiguration(@Assisted TextEditor editor, LanguageSe
@Assisted ServerCapabilities serverCapabilities) {
codeAssistProcessorFactory = codeAssistProcessor;
quickAssistProcessor = quickAssistProcessorFactory.create(editor);
- if ((serverCapabilities.isDocumentFormattingProvider() != null && serverCapabilities.isDocumentFormattingProvider())
- || (serverCapabilities.isDocumentRangeFormattingProvider() != null
- && serverCapabilities.isDocumentRangeFormattingProvider())
- || serverCapabilities.getDocumentOnTypeFormattingProvider() != null) {
+ if ((serverCapabilities.getDocumentFormattingProvider() != null && serverCapabilities.getDocumentFormattingProvider())
+ || (serverCapabilities.getDocumentRangeFormattingProvider() != null && serverCapabilities.getDocumentRangeFormattingProvider())
+ || serverCapabilities.getDocumentOnTypeFormattingProvider() != null) {
this.formatter = formatterFactory.create(serverCapabilities);
} else {
- this.formatter= null;
+ this.formatter = null;
}
this.serverCapabilities = serverCapabilities;
DocumentPositionMap documentPositionMap = docPositionMapProvider.get();
@@ -96,10 +95,7 @@ public Map getContentAssistantProcessors() {
@Override
public QuickAssistProcessor getQuickAssistProcessor() {
- if (serverCapabilities.isCodeActionProvider()) {
- return quickAssistProcessor;
- }
- return null;
+ return quickAssistProcessor;
}
@Override
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerEditorConfigurationFactory.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerEditorConfigurationFactory.java
index 97101de1e87..ff1d2cc4b99 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerEditorConfigurationFactory.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerEditorConfigurationFactory.java
@@ -10,9 +10,9 @@
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.ide.editor;
+import org.eclipse.lsp4j.ServerCapabilities;
import org.eclipse.che.ide.api.editor.texteditor.TextEditor;
-import io.typefox.lsapi.ServerCapabilities;
/**
* @author Evgen Vidolob
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerEditorProvider.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerEditorProvider.java
index 26572eaf11e..bdf977f1f5f 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerEditorProvider.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerEditorProvider.java
@@ -10,8 +10,7 @@
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.ide.editor;
-import io.typefox.lsapi.InitializeResult;
-
+import org.eclipse.che.api.languageserver.shared.model.ExtendedInitializeResult;
import org.eclipse.che.api.promises.client.Function;
import org.eclipse.che.api.promises.client.FunctionException;
import org.eclipse.che.api.promises.client.Promise;
@@ -37,9 +36,11 @@
*/
public class LanguageServerEditorProvider implements AsyncEditorProvider, EditorProvider {
- private LanguageServerEditorConfigurationFactory editorConfigurationFactory;
- private final LanguageServerRegistry registry;
- private final LoaderFactory loaderFactory;
+ private final LanguageServerRegistry registry;
+ private final LoaderFactory loaderFactory;
+ private LanguageServerEditorConfigurationFactory editorConfigurationFactory;
+ @com.google.inject.Inject
+ private EditorBuilder editorBuilder;
@Inject
public LanguageServerEditorProvider(LanguageServerEditorConfigurationFactory editorConfigurationFactory,
@@ -60,11 +61,6 @@ public String getDescription() {
return "Code Editor";
}
-
- @com.google.inject.Inject
- private EditorBuilder editorBuilder;
-
-
@Override
public TextEditor getEditor() {
if (editorBuilder == null) {
@@ -83,13 +79,14 @@ public Promise createEditor(VirtualFile file) {
if (file instanceof File) {
File resource = (File)file;
- Promise promise =
- registry.getOrInitializeServer(resource.getRelatedProject().get().getPath(), resource.getExtension(), resource.getLocation().toString());
+ Promise promise =
+ registry.getOrInitializeServer(resource.getRelatedProject().get().getPath(), resource.getExtension(),
+ resource.getLocation().toString());
final MessageLoader loader = loaderFactory.newLoader("Initializing Language Server for " + resource.getExtension());
loader.show();
- return promise.thenPromise(new Function>() {
+ return promise.thenPromise(new Function>() {
@Override
- public Promise apply(InitializeResult arg) throws FunctionException {
+ public Promise apply(ExtendedInitializeResult arg) throws FunctionException {
loader.hide();
if (editorBuilder == null) {
Log.debug(AbstractTextEditorProvider.class, "No builder registered for default editor type - giving up.");
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java
index d1ed032e503..ffa8b1c0bdd 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatter.java
@@ -10,19 +10,9 @@
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.ide.editor;
-import io.typefox.lsapi.ServerCapabilities;
-
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
-import org.eclipse.che.api.languageserver.shared.lsapi.DocumentFormattingParamsDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.DocumentOnTypeFormattingParamsDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.DocumentRangeFormattingParamsDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.FormattingOptionsDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.TextEditDTO;
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
import org.eclipse.che.api.promises.client.Promise;
@@ -42,6 +32,15 @@
import org.eclipse.che.ide.editor.preferences.editorproperties.EditorPropertiesManager;
import org.eclipse.che.ide.util.loging.Log;
import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient;
+import org.eclipse.lsp4j.DocumentFormattingParams;
+import org.eclipse.lsp4j.DocumentOnTypeFormattingParams;
+import org.eclipse.lsp4j.DocumentRangeFormattingParams;
+import org.eclipse.lsp4j.FormattingOptions;
+import org.eclipse.lsp4j.Position;
+import org.eclipse.lsp4j.Range;
+import org.eclipse.lsp4j.ServerCapabilities;
+import org.eclipse.lsp4j.TextDocumentIdentifier;
+import org.eclipse.lsp4j.TextEdit;
import java.util.Collections;
import java.util.List;
@@ -76,10 +75,10 @@ public void format(Document document) {
TextRange selectedRange = document.getSelectedTextRange();
if (selectedRange != null && !selectedRange.getFrom().equals(selectedRange.getTo()) &&
- capabilities.isDocumentRangeFormattingProvider()) {
+ capabilities.getDocumentRangeFormattingProvider()) {
//selection formatting
formatRange(selectedRange, document);
- } else if (capabilities.isDocumentFormattingProvider()) {
+ } else if (capabilities.getDocumentFormattingProvider()) {
//full document formatting
formatFullDocument(document);
}
@@ -98,8 +97,8 @@ public void onDocumentChange(DocumentChangeEvent event) {
if (capabilities.getDocumentOnTypeFormattingProvider().getFirstTriggerCharacter().equals(event.getText())) {
Document document = event.getDocument().getDocument();
- DocumentOnTypeFormattingParamsDTO params = dtoFactory.createDto(DocumentOnTypeFormattingParamsDTO.class);
- TextDocumentIdentifierDTO identifier = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
+ DocumentOnTypeFormattingParams params = dtoFactory.createDto(DocumentOnTypeFormattingParams.class);
+ TextDocumentIdentifier identifier = dtoFactory.createDto(TextDocumentIdentifier.class);
identifier.setUri(document.getFile().getLocation().toString());
params.setTextDocument(identifier);
params.setOptions(getFormattingOptions());
@@ -107,12 +106,12 @@ public void onDocumentChange(DocumentChangeEvent event) {
TextPosition position = document.getPositionFromIndex(event.getOffset());
- PositionDTO start = dtoFactory.createDto(PositionDTO.class);
+ Position start = dtoFactory.createDto(Position.class);
start.setLine(position.getLine());
start.setCharacter(position.getCharacter());
params.setPosition(start);
- Promise> promise = client.onTypeFormatting(params);
+ Promise> promise = client.onTypeFormatting(params);
handleFormatting(promise, document);
}
@@ -122,21 +121,21 @@ public void onDocumentChange(DocumentChangeEvent event) {
}
private void formatFullDocument(Document document) {
- DocumentFormattingParamsDTO params = dtoFactory.createDto(DocumentFormattingParamsDTO.class);
+ DocumentFormattingParams params = dtoFactory.createDto(DocumentFormattingParams.class);
- TextDocumentIdentifierDTO identifier = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
+ TextDocumentIdentifier identifier = dtoFactory.createDto(TextDocumentIdentifier.class);
identifier.setUri(document.getFile().getLocation().toString());
params.setTextDocument(identifier);
params.setOptions(getFormattingOptions());
- Promise> promise = client.formatting(params);
+ Promise> promise = client.formatting(params);
handleFormatting(promise, document);
}
- private void handleFormatting(Promise> promise, final Document document) {
- promise.then(new Operation>() {
+ private void handleFormatting(Promise> promise, final Document document) {
+ promise.then(new Operation>() {
@Override
- public void apply(List arg) throws OperationException {
+ public void apply(List arg) throws OperationException {
applyEdits(arg, document);
}
}).catchError(new Operation() {
@@ -147,7 +146,7 @@ public void apply(PromiseError arg) throws OperationException {
});
}
- private void applyEdits(List edits, Document document) {
+ private void applyEdits(List edits, Document document) {
HandlesUndoRedo undoRedo = null;
if (editor instanceof UndoableEditor) {
@@ -157,11 +156,11 @@ private void applyEdits(List edits, Document document) {
if (undoRedo != null) {
undoRedo.beginCompoundChange();
}
-
+
// #2437: apply the text edits from last to first to avoid messing up the document
Collections.reverse(edits);
- for (TextEditDTO change : edits) {
- RangeDTO range = change.getRange();
+ for (TextEdit change : edits) {
+ Range range = change.getRange();
document.replace(range.getStart().getLine(), range.getStart().getCharacter(),
range.getEnd().getLine(), range.getEnd().getCharacter(), change.getNewText());
}
@@ -174,8 +173,8 @@ private void applyEdits(List edits, Document document) {
}
}
- private FormattingOptionsDTO getFormattingOptions() {
- FormattingOptionsDTO options = dtoFactory.createDto(FormattingOptionsDTO.class);
+ private FormattingOptions getFormattingOptions() {
+ FormattingOptions options = dtoFactory.createDto(FormattingOptions.class);
options.setInsertSpaces(Boolean.parseBoolean(getEditorProperty(EditorProperties.EXPAND_TAB)));
options.setTabSize(Integer.parseInt(getEditorProperty(EditorProperties.TAB_SIZE)));
return options;
@@ -186,17 +185,17 @@ private String getEditorProperty(EditorProperties property) {
}
private void formatRange(TextRange selectedRange, Document document) {
- DocumentRangeFormattingParamsDTO params = dtoFactory.createDto(DocumentRangeFormattingParamsDTO.class);
+ DocumentRangeFormattingParams params = dtoFactory.createDto(DocumentRangeFormattingParams.class);
- TextDocumentIdentifierDTO identifier = dtoFactory.createDto(TextDocumentIdentifierDTO.class);
+ TextDocumentIdentifier identifier = dtoFactory.createDto(TextDocumentIdentifier.class);
identifier.setUri(document.getFile().getLocation().toString());
params.setTextDocument(identifier);
params.setOptions(getFormattingOptions());
- RangeDTO range = dtoFactory.createDto(RangeDTO.class);
- PositionDTO start = dtoFactory.createDto(PositionDTO.class);
- PositionDTO end = dtoFactory.createDto(PositionDTO.class);
+ Range range = dtoFactory.createDto(Range.class);
+ Position start = dtoFactory.createDto(Position.class);
+ Position end = dtoFactory.createDto(Position.class);
start.setLine(selectedRange.getFrom().getLine());
start.setCharacter(selectedRange.getFrom().getCharacter());
@@ -209,7 +208,7 @@ private void formatRange(TextRange selectedRange, Document document) {
params.setRange(range);
- Promise> promise = client.rangeFormatting(params);
+ Promise> promise = client.rangeFormatting(params);
handleFormatting(promise, document);
}
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatterFactory.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatterFactory.java
index 98a1ad68c11..22ad1f82a1c 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatterFactory.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerFormatterFactory.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.ide.editor;
-import io.typefox.lsapi.ServerCapabilities;
+import org.eclipse.lsp4j.ServerCapabilities;
/**
* @author Evgen Vidolob
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerReconcileStrategy.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerReconcileStrategy.java
index 8084c028255..dd5457b2882 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerReconcileStrategy.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerReconcileStrategy.java
@@ -10,9 +10,6 @@
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.ide.editor;
-import io.typefox.lsapi.ServerCapabilities;
-import io.typefox.lsapi.TextDocumentSyncKind;
-
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
@@ -24,6 +21,8 @@
import org.eclipse.che.ide.api.editor.text.Region;
import org.eclipse.che.plugin.languageserver.ide.editor.sync.TextDocumentSynchronize;
import org.eclipse.che.plugin.languageserver.ide.editor.sync.TextDocumentSynchronizeFactory;
+import org.eclipse.lsp4j.ServerCapabilities;
+import org.eclipse.lsp4j.TextDocumentSyncKind;
/**
* Responsible for document synchronization
@@ -32,8 +31,8 @@
*/
public class LanguageServerReconcileStrategy implements ReconcilingStrategy {
- private int version = 0;
private final TextDocumentSynchronize synchronize;
+ private int version = 0;
@Inject
public LanguageServerReconcileStrategy(TextDocumentSynchronizeFactory synchronizeFactory,
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerReconcileStrategyFactory.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerReconcileStrategyFactory.java
index 99ac4fb183b..f6219463d15 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerReconcileStrategyFactory.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/LanguageServerReconcileStrategyFactory.java
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.ide.editor;
-import io.typefox.lsapi.ServerCapabilities;
+import org.eclipse.lsp4j.ServerCapabilities;
/**
* @author Evgen Vidolob
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/PublishDiagnosticsProcessor.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/PublishDiagnosticsProcessor.java
index 479d5e7cb9b..6d7fafbe640 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/PublishDiagnosticsProcessor.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/PublishDiagnosticsProcessor.java
@@ -13,29 +13,29 @@
import com.google.inject.Inject;
import com.google.inject.Singleton;
-import org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.PublishDiagnosticsParamsDTO;
import org.eclipse.che.ide.api.editor.EditorAgent;
import org.eclipse.che.ide.api.editor.EditorPartPresenter;
import org.eclipse.che.ide.api.editor.annotation.AnnotationModel;
import org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration;
import org.eclipse.che.ide.api.editor.texteditor.TextEditor;
import org.eclipse.che.ide.resource.Path;
+import org.eclipse.lsp4j.Diagnostic;
+import org.eclipse.lsp4j.PublishDiagnosticsParams;
/**
* @author Anatolii Bazko
*/
@Singleton
public class PublishDiagnosticsProcessor {
-
+
private final EditorAgent editorAgent;
-
- @Inject
+
+ @Inject
public PublishDiagnosticsProcessor(EditorAgent editorAgent) {
this.editorAgent = editorAgent;
}
- public void processDiagnostics(PublishDiagnosticsParamsDTO diagnosticsMessage) {
+ public void processDiagnostics(PublishDiagnosticsParams diagnosticsMessage) {
EditorPartPresenter openedEditor = editorAgent.getOpenedEditor(new Path(diagnosticsMessage.getUri()));
//TODO add markers
if (openedEditor == null) {
@@ -43,13 +43,13 @@ public void processDiagnostics(PublishDiagnosticsParamsDTO diagnosticsMessage) {
}
if (openedEditor instanceof TextEditor) {
- TextEditorConfiguration editorConfiguration = ((TextEditor) openedEditor).getConfiguration();
+ TextEditorConfiguration editorConfiguration = ((TextEditor)openedEditor).getConfiguration();
AnnotationModel annotationModel = editorConfiguration.getAnnotationModel();
if (annotationModel != null && annotationModel instanceof DiagnosticCollector) {
DiagnosticCollector collector = (DiagnosticCollector)annotationModel;
collector.beginReporting();
try {
- for (DiagnosticDTO diagnostic : diagnosticsMessage.getDiagnostics()) {
+ for (Diagnostic diagnostic : diagnosticsMessage.getDiagnostics()) {
collector.acceptDiagnostic(diagnostic);
}
} finally {
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/ShowMessageProcessor.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/ShowMessageProcessor.java
index 2a77c9800cf..3ed6feaff18 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/ShowMessageProcessor.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/ShowMessageProcessor.java
@@ -10,48 +10,47 @@
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.ide.editor;
-import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
import org.eclipse.che.ide.api.notification.NotificationManager;
import org.eclipse.che.ide.api.notification.StatusNotification;
import org.eclipse.che.ide.util.loging.Log;
+import org.eclipse.lsp4j.MessageParams;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-
-import io.typefox.lsapi.MessageParams;
+import static org.eclipse.che.ide.api.notification.StatusNotification.DisplayMode.FLOAT_MODE;
/**
* A processor for incoming window/showMessage notifications sent
* by a language server.
- *
+ *
* @author xcoulon
*/
@Singleton
public class ShowMessageProcessor {
- private final NotificationManager notificationManager;
-
- @Inject
- public ShowMessageProcessor(final NotificationManager notificationManager) {
- this.notificationManager = notificationManager;
- }
-
- public void processNotification(final MessageParams messageParams) {
- Log.debug(getClass(), "Received a 'ShowMessage' message: " + messageParams.getMessage());
- switch(messageParams.getType()) {
- case Error:
- this.notificationManager.notify(messageParams.getMessage(), StatusNotification.Status.FAIL, FLOAT_MODE);
- break;
- case Warning:
- this.notificationManager.notify(messageParams.getMessage(), StatusNotification.Status.WARNING, FLOAT_MODE);
- break;
- case Info:
- case Log:
- default:
- this.notificationManager.notify(messageParams.getMessage(), StatusNotification.Status.SUCCESS, FLOAT_MODE);
- break;
- }
- }
+ private final NotificationManager notificationManager;
+
+ @Inject
+ public ShowMessageProcessor(final NotificationManager notificationManager) {
+ this.notificationManager = notificationManager;
+ }
+
+ public void processNotification(final MessageParams messageParams) {
+ Log.debug(getClass(), "Received a 'ShowMessage' message: " + messageParams.getMessage());
+ switch (messageParams.getType()) {
+ case Error:
+ this.notificationManager.notify(messageParams.getMessage(), StatusNotification.Status.FAIL, FLOAT_MODE);
+ break;
+ case Warning:
+ this.notificationManager.notify(messageParams.getMessage(), StatusNotification.Status.WARNING, FLOAT_MODE);
+ break;
+ case Info:
+ case Log:
+ default:
+ this.notificationManager.notify(messageParams.getMessage(), StatusNotification.Status.SUCCESS, FLOAT_MODE);
+ break;
+ }
+ }
}
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionImageProvider.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionImageProvider.java
index e6282ae89ba..0fddb583a7c 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionImageProvider.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionImageProvider.java
@@ -10,13 +10,12 @@
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.ide.editor.codeassist;
-import io.typefox.lsapi.CompletionItemKind;
-
import com.google.inject.Inject;
import com.google.inject.Singleton;
import org.eclipse.che.ide.api.icon.Icon;
import org.eclipse.che.plugin.languageserver.ide.LanguageServerResources;
+import org.eclipse.lsp4j.CompletionItemKind;
import org.vectomatic.dom.svg.ui.SVGResource;
import java.util.HashMap;
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionItemBasedCompletionProposal.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionItemBasedCompletionProposal.java
index faa74d311f2..d12f63dfdf5 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionItemBasedCompletionProposal.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/CompletionItemBasedCompletionProposal.java
@@ -10,16 +10,15 @@
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.ide.editor.codeassist;
+
import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.Overflow;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Widget;
-import io.typefox.lsapi.ServerCapabilities;
-import org.eclipse.che.api.languageserver.shared.lsapi.CompletionItemDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO;
+
+import org.eclipse.che.api.languageserver.shared.model.ExtendedCompletionItem;
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
import org.eclipse.che.api.promises.client.Promise;
@@ -33,6 +32,10 @@
import org.eclipse.che.ide.filters.Match;
import org.eclipse.che.plugin.languageserver.ide.LanguageServerResources;
import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient;
+import org.eclipse.lsp4j.CompletionItem;
+import org.eclipse.lsp4j.Range;
+import org.eclipse.lsp4j.ServerCapabilities;
+import org.eclipse.lsp4j.TextDocumentIdentifier;
import java.util.List;
@@ -44,19 +47,19 @@
*/
public class CompletionItemBasedCompletionProposal implements CompletionProposal {
- private CompletionItemDTO completionItem;
private final TextDocumentServiceClient documentServiceClient;
- private final TextDocumentIdentifierDTO documentId;
+ private final TextDocumentIdentifier documentId;
private final LanguageServerResources resources;
private final Icon icon;
private final ServerCapabilities serverCapabilities;
private final List highlights;
private final int offset;
- private boolean resolved;
+ private ExtendedCompletionItem completionItem;
+ private boolean resolved;
- CompletionItemBasedCompletionProposal(CompletionItemDTO completionItem,
+ CompletionItemBasedCompletionProposal(ExtendedCompletionItem completionItem,
TextDocumentServiceClient documentServiceClient,
- TextDocumentIdentifierDTO documentId,
+ TextDocumentIdentifier documentId,
LanguageServerResources resources,
Icon icon,
ServerCapabilities serverCapabilities,
@@ -76,9 +79,9 @@ public class CompletionItemBasedCompletionProposal implements CompletionProposal
@Override
public void getAdditionalProposalInfo(final AsyncCallback callback) {
if (completionItem.getDocumentation() == null && canResolve()) {
- resolve().then(new Operation() {
+ resolve().then(new Operation() {
@Override
- public void apply(CompletionItemDTO item) throws OperationException {
+ public void apply(ExtendedCompletionItem item) throws OperationException {
completionItem = item;
resolved = true;
callback.onSuccess(createAdditionalInfoWidget());
@@ -114,43 +117,43 @@ private Widget createAdditionalInfoWidget() {
@Override
public String getDisplayString() {
SafeHtmlBuilder builder = new SafeHtmlBuilder();
-
+
String label = completionItem.getLabel();
int pos = 0;
for (Match highlight : highlights) {
if (highlight.getStart() == highlight.getEnd()) {
continue;
}
-
+
if (pos < highlight.getStart()) {
appendPlain(builder, label.substring(pos, highlight.getStart()));
}
-
+
appendHighlighted(builder, label.substring(highlight.getStart(), highlight.getEnd()));
pos = highlight.getEnd();
}
-
+
if (pos < label.length()) {
appendPlain(builder, label.substring(pos));
}
-
+
if (completionItem.getDetail() != null) {
appendDetail(builder, completionItem.getDetail());
}
-
+
return builder.toSafeHtml().asString();
}
-
+
private void appendPlain(SafeHtmlBuilder builder, String text) {
builder.appendEscaped(text);
}
-
+
private void appendHighlighted(SafeHtmlBuilder builder, String text) {
builder.appendHtmlConstant("");
builder.appendEscaped(text);
builder.appendHtmlConstant("");
}
-
+
private void appendDetail(SafeHtmlBuilder builder, String text) {
builder.appendHtmlConstant(" ");
builder.appendEscaped(text);
@@ -174,17 +177,17 @@ private boolean canResolve() {
serverCapabilities.getCompletionProvider().getResolveProvider();
}
- private Promise resolve() {
+ private Promise resolve() {
completionItem.setTextDocumentIdentifier(documentId);
return documentServiceClient.resolveCompletionItem(completionItem);
}
private static class CompletionImpl implements Completion {
- private CompletionItemDTO completionItem;
- private int offset;
+ private CompletionItem completionItem;
+ private int offset;
- public CompletionImpl(CompletionItemDTO completionItem, int offset) {
+ public CompletionImpl(CompletionItem completionItem, int offset) {
this.completionItem = completionItem;
this.offset = offset;
}
@@ -192,7 +195,7 @@ public CompletionImpl(CompletionItemDTO completionItem, int offset) {
@Override
public void apply(Document document) {
if (completionItem.getTextEdit() != null) {
- RangeDTO range = completionItem.getTextEdit().getRange();
+ Range range = completionItem.getTextEdit().getRange();
int startOffset = document.getIndexFromPosition(
new TextPosition(range.getStart().getLine(), range.getStart().getCharacter()));
int endOffset = offset + document.getIndexFromPosition(
@@ -206,7 +209,7 @@ public void apply(Document document) {
@Override
public LinearRange getSelection(Document document) {
- RangeDTO range = completionItem.getTextEdit().getRange();
+ Range range = completionItem.getTextEdit().getRange();
int startOffset = document
.getIndexFromPosition(new TextPosition(range.getStart().getLine(), range.getStart().getCharacter()))
+ completionItem.getTextEdit().getNewText().length();
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LanguageServerCodeAssistProcessor.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LanguageServerCodeAssistProcessor.java
index f649116666d..5b72c689fe3 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LanguageServerCodeAssistProcessor.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LanguageServerCodeAssistProcessor.java
@@ -12,11 +12,9 @@
import com.google.inject.Inject;
import com.google.inject.assistedinject.Assisted;
-import io.typefox.lsapi.ServerCapabilities;
-import org.eclipse.che.api.languageserver.shared.lsapi.CompletionItemDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.CompletionListDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO;
+
+import org.eclipse.che.api.languageserver.shared.model.ExtendedCompletionItem;
+import org.eclipse.che.api.languageserver.shared.model.ExtendedCompletionList;
import org.eclipse.che.api.promises.client.Operation;
import org.eclipse.che.api.promises.client.OperationException;
import org.eclipse.che.api.promises.client.PromiseError;
@@ -29,6 +27,10 @@
import org.eclipse.che.plugin.languageserver.ide.LanguageServerResources;
import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient;
import org.eclipse.che.plugin.languageserver.ide.util.DtoBuildHelper;
+import org.eclipse.lsp4j.CompletionItem;
+import org.eclipse.lsp4j.ServerCapabilities;
+import org.eclipse.lsp4j.TextDocumentIdentifier;
+import org.eclipse.lsp4j.TextDocumentPositionParams;
import java.util.ArrayList;
import java.util.List;
@@ -43,11 +45,11 @@ public class LanguageServerCodeAssistProcessor implements CodeAssistProcessor {
private final DtoBuildHelper dtoBuildHelper;
private final LanguageServerResources resources;
private final CompletionImageProvider imageProvider;
- private final ServerCapabilities serverCapabilities;
+ private final ServerCapabilities serverCapabilities;
private final TextDocumentServiceClient documentServiceClient;
- private final FuzzyMatches fuzzyMatches;
- private String lastErrorMessage;
+ private final FuzzyMatches fuzzyMatches;
private final LatestCompletionResult latestCompletionResult;
+ private String lastErrorMessage;
@Inject
public LanguageServerCodeAssistProcessor(TextDocumentServiceClient documentServiceClient,
@@ -66,11 +68,12 @@ public LanguageServerCodeAssistProcessor(TextDocumentServiceClient documentServi
}
@Override
- public void computeCompletionProposals(TextEditor editor, final int offset, final boolean triggered, final CodeAssistCallback callback) {
+ public void computeCompletionProposals(TextEditor editor, final int offset, final boolean triggered,
+ final CodeAssistCallback callback) {
this.lastErrorMessage = null;
- TextDocumentPositionParamsDTO documentPosition = dtoBuildHelper.createTDPP(editor.getDocument(), offset);
- final TextDocumentIdentifierDTO documentId = documentPosition.getTextDocument();
+ TextDocumentPositionParams documentPosition = dtoBuildHelper.createTDPP(editor.getDocument(), offset);
+ final TextDocumentIdentifier documentId = documentPosition.getTextDocument();
String currentLine = editor.getDocument().getLineContent(documentPosition.getPosition().getLine());
final String currentWord = getCurrentWord(currentLine, documentPosition.getPosition().getCharacter());
@@ -78,9 +81,9 @@ public void computeCompletionProposals(TextEditor editor, final int offset, fina
// no need to send new completion request
computeProposals(currentWord, offset - latestCompletionResult.getOffset(), callback);
} else {
- documentServiceClient.completion(documentPosition).then(new Operation() {
+ documentServiceClient.completion(documentPosition).then(new Operation() {
@Override
- public void apply(CompletionListDTO list) throws OperationException {
+ public void apply(ExtendedCompletionList list) throws OperationException {
latestCompletionResult.update(documentId, offset, currentWord, list);
computeProposals(currentWord, 0, callback);
}
@@ -108,15 +111,15 @@ private String getCurrentWord(String text, int offset) {
private boolean isWordChar(char c) {
return c >= 'a' && c <= 'z' ||
- c >= 'A' && c <= 'Z' ||
- c >= '0' && c <= '9' ||
- c >= '\u007f' && c <= '\u00ff' ||
- c == '$' ||
- c == '_' ||
- c == '-';
+ c >= 'A' && c <= 'Z' ||
+ c >= '0' && c <= '9' ||
+ c >= '\u007f' && c <= '\u00ff' ||
+ c == '$' ||
+ c == '_' ||
+ c == '-';
}
- private List filter(String word, CompletionItemDTO item) {
+ private List filter(String word, CompletionItem item) {
return filter(word, item.getLabel(), item.getFilterText());
}
@@ -124,7 +127,7 @@ private List filter(String word, String label, String filterText) {
if (filterText == null || filterText.isEmpty()) {
filterText = label;
}
-
+
// check if the word matches the filterText
if (fuzzyMatches.fuzzyMatch(word, filterText) != null) {
// return the highlights based on the label
@@ -132,20 +135,20 @@ private List filter(String word, String label, String filterText) {
// return empty list of highlights if nothing matches the label
return (highlights == null) ? new ArrayList() : highlights;
}
-
+
return null;
}
private void computeProposals(String currentWord, int offset, CodeAssistCallback callback) {
List proposals = newArrayList();
- for (CompletionItemDTO item : latestCompletionResult.getCompletionList().getItems()) {
+ for (ExtendedCompletionItem item : latestCompletionResult.getCompletionList().getItems()) {
List highlights = filter(currentWord, item);
if (highlights != null) {
- proposals.add(new CompletionItemBasedCompletionProposal(item,
+ proposals.add(new CompletionItemBasedCompletionProposal(item,
documentServiceClient,
latestCompletionResult.getDocumentId(),
- resources,
- imageProvider.getIcon(item.getKind()),
+ resources,
+ imageProvider.getIcon(item.getKind()),
serverCapabilities,
highlights,
offset));
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LatestCompletionResult.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LatestCompletionResult.java
index fbf35f7814d..a9a97836799 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LatestCompletionResult.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/codeassist/LatestCompletionResult.java
@@ -10,35 +10,35 @@
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.ide.editor.codeassist;
-import org.eclipse.che.api.languageserver.shared.lsapi.CompletionListDTO;
-import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO;
+import org.eclipse.che.api.languageserver.shared.model.ExtendedCompletionList;
+import org.eclipse.lsp4j.TextDocumentIdentifier;
/**
* Contains the latest completion result retrieved from the completion service.
- *
+ *
* @author Kaloyan Raev
*/
public class LatestCompletionResult {
- private TextDocumentIdentifierDTO documentId;
- private int offset;
- private String word;
- private CompletionListDTO completionList;
+ private TextDocumentIdentifier documentId;
+ private int offset;
+ private String word;
+ private ExtendedCompletionList completionList;
/**
* Returns the identifier of document used to compute the latest completion
* result.
- *
+ *
* @return the document identifier
*/
- public TextDocumentIdentifierDTO getDocumentId() {
+ public TextDocumentIdentifier getDocumentId() {
return this.documentId;
}
/**
* Returns the offset position in document used to compute the latest
* completion result.
- *
+ *
* @return the offset
*/
public int getOffset() {
@@ -48,7 +48,7 @@ public int getOffset() {
/**
* Returns the word at the cursor at the time of computing the latest
* completion result.
- *
+ *
* @return the word
*/
public String getWord() {
@@ -57,17 +57,17 @@ public String getWord() {
/**
* Returns the latest completion list DTO object.
- *
+ *
* @return the completion list
*/
- public CompletionListDTO getCompletionList() {
+ public ExtendedCompletionList getCompletionList() {
return this.completionList;
}
/**
* Checks if the completion result is still good for the given document
* position.
- *
+ *
*
* The following checks are executed:
*
@@ -85,39 +85,38 @@ public CompletionListDTO getCompletionList() {
* Only if all checks are satisfied then the latest completion result can be
* reused for the given document position.
*
- *
+ *
* @param documentId
- * a text document identifier
+ * a text document identifier
* @param offset
- * an offset position in the document
+ * an offset position in the document
* @param word
- * the word at the current position in the document
- *
+ * the word at the current position in the document
* @return true if the completion result can still be used for
- * the given document position, false otherwise.
+ * the given document position, false otherwise.
*/
- public boolean isGoodFor(TextDocumentIdentifierDTO documentId, int offset, String word) {
+ public boolean isGoodFor(TextDocumentIdentifier documentId, int offset, String word) {
return completionList != null &&
- !completionList.isIncomplete() &&
+ !completionList.isInComplete() &&
this.documentId.getUri().equals(documentId.getUri()) &&
- word.startsWith(this.word) &&
+ word.startsWith(this.word) &&
offset - this.offset == word.length() - this.word.length();
}
/**
* Updates the latest completion result.
- *
+ *
* @param documentId
- * a text document identifier
+ * a text document identifier
* @param offset
- * an offset position in the document
+ * an offset position in the document
* @param word
- * the word at the current position in the document
+ * the word at the current position in the document
* @param completionList
- * a completion list
+ * a completion list
*/
- public void update(TextDocumentIdentifierDTO documentId, int offset, String word,
- CompletionListDTO completionList) {
+ public void update(TextDocumentIdentifier documentId, int offset, String word,
+ ExtendedCompletionList completionList) {
this.documentId = documentId;
this.offset = offset;
this.word = word;
diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/ApplyTextEditAction.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/ApplyTextEditAction.java
index 96727c80f31..d6e5d823fa1 100644
--- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/ApplyTextEditAction.java
+++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/ApplyTextEditAction.java
@@ -10,26 +10,28 @@
*******************************************************************************/
package org.eclipse.che.plugin.languageserver.ide.editor.quickassist;
-import java.util.List;
+import com.google.gwt.json.client.JSONValue;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
-import org.eclipse.che.api.languageserver.shared.dto.DtoClientImpls.TextEditDTOImpl;
+import org.eclipse.che.api.languageserver.shared.dto.DtoClientImpls;
import org.eclipse.che.ide.api.action.Action;
import org.eclipse.che.ide.api.action.ActionEvent;
import org.eclipse.che.ide.api.editor.EditorAgent;
import org.eclipse.che.ide.api.editor.EditorPartPresenter;
import org.eclipse.che.ide.api.editor.document.Document;
import org.eclipse.che.ide.api.editor.texteditor.TextEditor;
+import org.eclipse.che.ide.dto.DtoFactory;
+import org.eclipse.che.plugin.languageserver.ide.util.DtoBuildHelper;
+import org.eclipse.lsp4j.Position;
+import org.eclipse.lsp4j.Range;
+import org.eclipse.lsp4j.TextEdit;
-import com.google.gwt.json.client.JSONValue;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
+import java.util.List;
-import io.typefox.lsapi.Position;
-import io.typefox.lsapi.Range;
-import io.typefox.lsapi.TextEdit;
/**
- * Applies a list of {@link TextEdit} changes to the current editor.
+ * Applies a list of {@link org.eclipse.lsp4j.TextEdit} changes to the current editor.
*
* @author Thomas Mäder
*
@@ -37,11 +39,15 @@
@Singleton
public class ApplyTextEditAction extends Action {
private EditorAgent editorAgent;
+ private DtoFactory dtoFactory;
@Inject
- public ApplyTextEditAction(EditorAgent editorAgent) {
+ public ApplyTextEditAction(EditorAgent editorAgent,
+ DtoFactory dtoFactory,
+ DtoBuildHelper dtoBuildHelper) {
super("Apply Text Edit");
this.editorAgent = editorAgent;
+ this.dtoFactory = dtoFactory;
}
@Override
@@ -55,7 +61,7 @@ public void actionPerformed(ActionEvent e) {
List