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.extensions guice-multibindings - - io.typefox.lsapi - io.typefox.lsapi.services - org.eclipse.che.core che-core-api-core @@ -68,6 +64,14 @@ org.eclipse.che.plugin che-plugin-csharp-lang-shared + + org.eclipse.lsp4j + org.eclipse.lsp4j + + + org.eclipse.lsp4j + org.eclipse.lsp4j.jsonrpc + org.slf4j slf4j-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.extensions guice-multibindings - - io.typefox.lsapi - io.typefox.lsapi - - - io.typefox.lsapi - io.typefox.lsapi.services - org.eclipse.che.core che-core-api-languageserver @@ -52,5 +44,13 @@ org.eclipse.che.core che-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.extensions guice-assistedinject - - io.typefox.lsapi - io.typefox.lsapi - javax.inject javax.inject @@ -54,10 +50,6 @@ javax.validation validation-api - - org.eclipse.che.core - che-core-api-dto - org.eclipse.che.core che-core-api-languageserver-shared @@ -82,6 +74,24 @@ org.eclipse.che.core che-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.vectomatic lib-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-dto generate-sources generate - - - 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 arguments = ((QuickassistActionEvent) e).getArguments(); for (Object arg : arguments) { if ((arg instanceof JSONValue)) { - TextEditDTOImpl edit = TextEditDTOImpl.fromJsonObject((JSONValue) arg); + TextEdit edit = DtoClientImpls.TextEditDto.fromJson((JSONValue) arg); Range range = edit.getRange(); Position start = range.getStart(); Position end = range.getEnd(); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/LanguageServerQuickAssistProcessor.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/LanguageServerQuickAssistProcessor.java index c4a065738f3..8b4211652e9 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/LanguageServerQuickAssistProcessor.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/LanguageServerQuickAssistProcessor.java @@ -12,17 +12,7 @@ import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.Widget; -import org.eclipse.che.api.languageserver.shared.dto.DtoClientImpls.CodeActionContextDTOImpl; -import org.eclipse.che.api.languageserver.shared.dto.DtoClientImpls.CodeActionParamsDTOImpl; -import org.eclipse.che.api.languageserver.shared.dto.DtoClientImpls.PositionDTOImpl; -import org.eclipse.che.api.languageserver.shared.dto.DtoClientImpls.RangeDTOImpl; -import org.eclipse.che.api.languageserver.shared.dto.DtoClientImpls.TextDocumentIdentifierDTOImpl; -import org.eclipse.che.api.languageserver.shared.lsapi.CodeActionContextDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.CodeActionParamsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.CommandDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO; + import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.action.Action; import org.eclipse.che.ide.api.action.ActionManager; @@ -35,13 +25,19 @@ import org.eclipse.che.ide.api.editor.quickfix.QuickAssistInvocationContext; import org.eclipse.che.ide.api.editor.quickfix.QuickAssistProcessor; import org.eclipse.che.ide.api.editor.text.LinearRange; -import org.eclipse.che.ide.api.editor.text.Position; import org.eclipse.che.ide.api.editor.text.TextPosition; import org.eclipse.che.ide.api.editor.text.annotation.Annotation; import org.eclipse.che.ide.api.icon.Icon; import org.eclipse.che.ide.api.parts.PerspectiveManager; import org.eclipse.che.plugin.languageserver.ide.editor.DiagnosticAnnotation; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; +import org.eclipse.lsp4j.CodeActionContext; +import org.eclipse.lsp4j.CodeActionParams; +import org.eclipse.lsp4j.Command; +import org.eclipse.lsp4j.Diagnostic; +import org.eclipse.lsp4j.Position; +import org.eclipse.lsp4j.Range; +import org.eclipse.lsp4j.TextDocumentIdentifier; import javax.inject.Inject; @@ -65,10 +61,10 @@ public class LanguageServerQuickAssistProcessor implements QuickAssistProcessor private PerspectiveManager perspectiveManager; private final class ActionCompletionProposal implements CompletionProposal { - private final CommandDTO command; - private final Action action; + private final Command command; + private final Action action; - private ActionCompletionProposal(CommandDTO command, Action action) { + private ActionCompletionProposal(Command command, Action action) { this.command = command; this.action = action; } @@ -121,30 +117,31 @@ public void computeQuickAssistProposals(QuickAssistInvocationContext invocationC QueryAnnotationsEvent.QueryCallback annotationCallback = new QueryAnnotationsEvent.QueryCallback() { @Override - public void respond(Map annotations) { - List diagnostics = new ArrayList<>(); + public void respond(Map annotations) { + List diagnostics = new ArrayList<>(); // iteration with range never returns anything; need to filter ourselves. // https://github.com/eclipse/che/issues/4338 annotations.entrySet().stream().filter((e) -> e.getValue().overlapsWith(range.getStartOffset(), range.getLength())) .map(Entry::getKey).map(a -> (DiagnosticAnnotation) a).map(DiagnosticAnnotation::getDiagnostic) .collect(Collectors.toList()); - CodeActionContextDTO context = CodeActionContextDTOImpl.make().withDiagnostics(diagnostics); - CodeActionParamsDTO params = CodeActionParamsDTOImpl.make().withContext(context); - params.setTextDocument(TextDocumentIdentifierDTOImpl.make().withUri(document.getFile().getLocation().toString())); + CodeActionContext context = new CodeActionContext(diagnostics); TextPosition start = document.getPositionFromIndex(range.getStartOffset()); TextPosition end = document.getPositionFromIndex(range.getStartOffset() + range.getLength()); - PositionDTO rangeStart = toPositionDto(start); - PositionDTO rangeEnd = toPositionDto(end); - RangeDTO rangeParam = RangeDTOImpl.make().withStart(rangeStart); + Position rangeStart = new Position(start.getLine(), start.getCharacter()); + Position rangeEnd = new Position(end.getLine(), end.getCharacter()); + Range rangeParam = new Range(rangeStart, rangeEnd); rangeParam.setEnd(rangeEnd); - params.setRange(rangeParam); - Promise> codeAction = textDocumentService.codeAction(params); + TextDocumentIdentifier textDocumentIdentifier = new TextDocumentIdentifier(document.getFile().getLocation().toString()); + + CodeActionParams params = new CodeActionParams(textDocumentIdentifier, rangeParam, context); + + Promise> codeAction = textDocumentService.codeAction(params); List proposals = new ArrayList<>(); codeAction.then((commands) -> { - for (CommandDTO command : commands) { + for (Command command : commands) { Action action = actionManager.getAction(command.getCommand()); if (action != null) { proposals.add(new ActionCompletionProposal(command, action)); @@ -154,12 +151,6 @@ public void respond(Map annotations) { callback.proposalComputed(proposals); }); } - - private PositionDTO toPositionDto(TextPosition start) { - PositionDTO rangeStart = PositionDTOImpl.make().withLine(start.getLine()); - rangeStart.setCharacter(start.getCharacter()); - return rangeStart; - } }; QueryAnnotationsEvent event = new QueryAnnotationsEvent.Builder().withFilter(a -> a instanceof DiagnosticAnnotation) .withCallback(annotationCallback).build(); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/QuickassistActionEvent.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/QuickassistActionEvent.java index 8be652bb677..51030eacf26 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/QuickassistActionEvent.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/quickassist/QuickassistActionEvent.java @@ -9,13 +9,13 @@ * Red Hat - Initial Contribution *******************************************************************************/package org.eclipse.che.plugin.languageserver.ide.editor.quickassist; -import java.util.List; - import org.eclipse.che.ide.api.action.ActionEvent; import org.eclipse.che.ide.api.action.ActionManager; import org.eclipse.che.ide.api.action.Presentation; import org.eclipse.che.ide.api.parts.PerspectiveManager; +import java.util.List; + /** * An extension of {@link ActionEvent} to pass command paramenters as a list of Objects to the action. * @author Thomas Mäder @@ -25,7 +25,10 @@ public class QuickassistActionEvent extends ActionEvent { private List arguments; - public QuickassistActionEvent(Presentation presentation, ActionManager actionManager, PerspectiveManager perspectiveManager, List arguments) { + public QuickassistActionEvent(Presentation presentation, + ActionManager actionManager, + PerspectiveManager perspectiveManager, + List arguments) { super(presentation, actionManager, perspectiveManager); this.arguments= arguments; } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelp.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelp.java index b63ecd035d7..cdd0a873031 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelp.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelp.java @@ -10,15 +10,11 @@ *******************************************************************************/ package org.eclipse.che.plugin.languageserver.ide.editor.signature; -import io.typefox.lsapi.ServerCapabilities; - import com.google.common.base.Optional; import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; import com.google.web.bindery.event.shared.HandlerRegistration; -import org.eclipse.che.api.languageserver.shared.lsapi.SignatureHelpDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import org.eclipse.che.api.promises.client.Function; import org.eclipse.che.api.promises.client.FunctionException; import org.eclipse.che.api.promises.client.Promise; @@ -35,6 +31,8 @@ import org.eclipse.che.ide.api.notification.StatusNotification; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; import org.eclipse.che.plugin.languageserver.ide.util.DtoBuildHelper; +import org.eclipse.lsp4j.ServerCapabilities; +import org.eclipse.lsp4j.TextDocumentPositionParams; import java.util.List; @@ -64,11 +62,11 @@ public LanguageServerSignatureHelp(TextDocumentServiceClient client, @Override public Promise> signatureHelp(Document document, int offset) { - TextDocumentPositionParamsDTO paramsDTO = helper.createTDPP(document, offset); - Promise promise = client.signatureHelp(paramsDTO); - return promise.then(new Function>() { + TextDocumentPositionParams paramsDTO = helper.createTDPP(document, offset); + Promise promise = client.signatureHelp(paramsDTO); + return promise.then(new Function>() { @Override - public Optional apply(SignatureHelpDTO arg) throws FunctionException { + public Optional apply(org.eclipse.lsp4j.SignatureHelp arg) throws FunctionException { if (arg == null) { return Optional.absent(); } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelpFactory.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelpFactory.java index 68aa4581c34..2f2dccc8d20 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelpFactory.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/LanguageServerSignatureHelpFactory.java @@ -10,7 +10,7 @@ *******************************************************************************/ package org.eclipse.che.plugin.languageserver.ide.editor.signature; -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/signature/ParamterInfoImpl.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/ParamterInfoImpl.java index a5c16fe7396..72e27082ee5 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/ParamterInfoImpl.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/ParamterInfoImpl.java @@ -12,17 +12,17 @@ import com.google.common.base.Optional; -import org.eclipse.che.api.languageserver.shared.lsapi.ParameterInformationDTO; import org.eclipse.che.ide.api.editor.signature.ParameterInfo; +import org.eclipse.lsp4j.ParameterInformation; /** * @author Evgen Vidolob */ class ParamterInfoImpl implements ParameterInfo { - private final ParameterInformationDTO dto; + private final ParameterInformation dto; - public ParamterInfoImpl(ParameterInformationDTO dto) { + public ParamterInfoImpl(ParameterInformation dto) { this.dto = dto; } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureHelpImpl.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureHelpImpl.java index c95afe556c6..6a2e24ae82e 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureHelpImpl.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureHelpImpl.java @@ -12,10 +12,9 @@ import com.google.common.base.Optional; -import org.eclipse.che.api.languageserver.shared.lsapi.SignatureHelpDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.SignatureInformationDTO; import org.eclipse.che.ide.api.editor.signature.SignatureHelp; import org.eclipse.che.ide.api.editor.signature.SignatureInfo; +import org.eclipse.lsp4j.SignatureInformation; import java.util.ArrayList; import java.util.List; @@ -29,12 +28,12 @@ class SignatureHelpImpl implements SignatureHelp { private final Optional activeSignature; private final Optional activeParameter; - public SignatureHelpImpl(SignatureHelpDTO dto) { + public SignatureHelpImpl(org.eclipse.lsp4j.SignatureHelp dto) { activeParameter = Optional.fromNullable(dto.getActiveParameter()); activeSignature = Optional.fromNullable(dto.getActiveSignature()); signatureInfos = new ArrayList<>(dto.getSignatures().size()); - for (SignatureInformationDTO signatureInformationDTO : dto.getSignatures()) { - signatureInfos.add(new SignatureInfoImpl(signatureInformationDTO)); + for (SignatureInformation SignatureInformation : dto.getSignatures()) { + signatureInfos.add(new SignatureInfoImpl(SignatureInformation)); } } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureInfoImpl.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureInfoImpl.java index 8164ff9da2c..e127e2f0e6a 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureInfoImpl.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/signature/SignatureInfoImpl.java @@ -12,10 +12,10 @@ import com.google.common.base.Optional; -import org.eclipse.che.api.languageserver.shared.lsapi.ParameterInformationDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.SignatureInformationDTO; import org.eclipse.che.ide.api.editor.signature.ParameterInfo; import org.eclipse.che.ide.api.editor.signature.SignatureInfo; +import org.eclipse.lsp4j.ParameterInformation; +import org.eclipse.lsp4j.SignatureInformation; import java.util.ArrayList; import java.util.List; @@ -26,11 +26,11 @@ class SignatureInfoImpl implements SignatureInfo { - private final SignatureInformationDTO dto; + private final SignatureInformation dto; private List parameterInfos; - public SignatureInfoImpl(SignatureInformationDTO dto) { + public SignatureInfoImpl(SignatureInformation dto) { this.dto = dto; } @@ -48,7 +48,7 @@ public Optional getDocumentation() { public Optional> getParameters() { if (parameterInfos == null && dto.getParameters() != null) { parameterInfos = new ArrayList<>(dto.getParameters().size()); - for (ParameterInformationDTO informationDTO : dto.getParameters()) { + for (ParameterInformation informationDTO : dto.getParameters()) { parameterInfos.add(new ParamterInfoImpl(informationDTO)); } return Optional.of(parameterInfos); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/FullTextDocumentSynchronize.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/FullTextDocumentSynchronize.java index 3b784c873c5..8cc4d0b5769 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/FullTextDocumentSynchronize.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/FullTextDocumentSynchronize.java @@ -13,13 +13,13 @@ import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.api.languageserver.shared.lsapi.DidChangeTextDocumentParamsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentContentChangeEventDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.VersionedTextDocumentIdentifierDTO; import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; import org.eclipse.che.ide.dto.DtoFactory; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; +import org.eclipse.lsp4j.DidChangeTextDocumentParams; +import org.eclipse.lsp4j.TextDocumentContentChangeEvent; +import org.eclipse.lsp4j.VersionedTextDocumentIdentifier; import java.util.Collections; @@ -31,7 +31,7 @@ @Singleton class FullTextDocumentSynchronize implements TextDocumentSynchronize { - private final DtoFactory dtoFactory; + private final DtoFactory dtoFactory; private final TextDocumentServiceClient textDocumentService; @Inject @@ -44,14 +44,14 @@ public FullTextDocumentSynchronize(DtoFactory dtoFactory, TextDocumentServiceCli public void syncTextDocument(DocumentChangeEvent event, int version) { Document document = event.getDocument().getDocument(); - DidChangeTextDocumentParamsDTO changeDTO = dtoFactory.createDto(DidChangeTextDocumentParamsDTO.class); + DidChangeTextDocumentParams changeDTO = dtoFactory.createDto(DidChangeTextDocumentParams.class); String uri = document.getFile().getLocation().toString(); changeDTO.setUri(uri); - VersionedTextDocumentIdentifierDTO versionedDocId = dtoFactory.createDto(VersionedTextDocumentIdentifierDTO.class); + VersionedTextDocumentIdentifier versionedDocId = dtoFactory.createDto(VersionedTextDocumentIdentifier.class); versionedDocId.setUri(uri); versionedDocId.setVersion(version); changeDTO.setTextDocument(versionedDocId); - TextDocumentContentChangeEventDTO actualChange = dtoFactory.createDto(TextDocumentContentChangeEventDTO.class); + TextDocumentContentChangeEvent actualChange = dtoFactory.createDto(TextDocumentContentChangeEvent.class); actualChange.setText(event.getDocument().getDocument().getContents()); changeDTO.setContentChanges(Collections.singletonList(actualChange)); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/IncrementalTextDocumentSynchronize.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/IncrementalTextDocumentSynchronize.java index cc80111964d..196e79104d9 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/IncrementalTextDocumentSynchronize.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/IncrementalTextDocumentSynchronize.java @@ -12,16 +12,17 @@ import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.api.languageserver.shared.lsapi.DidChangeTextDocumentParamsDTO; -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.TextDocumentContentChangeEventDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.VersionedTextDocumentIdentifierDTO; + import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; import org.eclipse.che.ide.api.editor.text.TextPosition; import org.eclipse.che.ide.dto.DtoFactory; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; +import org.eclipse.lsp4j.DidChangeTextDocumentParams; +import org.eclipse.lsp4j.Position; +import org.eclipse.lsp4j.Range; +import org.eclipse.lsp4j.TextDocumentContentChangeEvent; +import org.eclipse.lsp4j.VersionedTextDocumentIdentifier; import java.util.Collections; @@ -53,25 +54,25 @@ public void syncTextDocument(DocumentChangeEvent event, int version) { endPosition = new TextPosition(startPosition.getLine(), startPosition.getCharacter()); } - DidChangeTextDocumentParamsDTO changeDTO = dtoFactory.createDto(DidChangeTextDocumentParamsDTO.class); + DidChangeTextDocumentParams changeDTO = dtoFactory.createDto(DidChangeTextDocumentParams.class); String uri = document.getFile().getLocation().toString(); changeDTO.setUri(uri); - VersionedTextDocumentIdentifierDTO versionedDocId = dtoFactory.createDto(VersionedTextDocumentIdentifierDTO.class); + VersionedTextDocumentIdentifier versionedDocId = dtoFactory.createDto(VersionedTextDocumentIdentifier.class); versionedDocId.setUri(uri); versionedDocId.setVersion(version); changeDTO.setTextDocument(versionedDocId); - RangeDTO range = dtoFactory.createDto(RangeDTO.class); - PositionDTO start = dtoFactory.createDto(PositionDTO.class); + Range range = dtoFactory.createDto(Range.class); + Position start = dtoFactory.createDto(Position.class); start.setLine(startPosition.getLine()); start.setCharacter(startPosition.getCharacter()); - PositionDTO end = dtoFactory.createDto(PositionDTO.class); + Position end = dtoFactory.createDto(Position.class); end.setLine(endPosition.getLine()); end.setCharacter(endPosition.getCharacter()); range.setStart(start); range.setEnd(end); - TextDocumentContentChangeEventDTO actualChange = dtoFactory.createDto(TextDocumentContentChangeEventDTO.class); + TextDocumentContentChangeEvent actualChange = dtoFactory.createDto(TextDocumentContentChangeEvent.class); actualChange.setRange(range); actualChange.setText(event.getText()); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/TextDocumentSynchronizeFactory.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/TextDocumentSynchronizeFactory.java index b00fcace864..5411c64dc97 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/TextDocumentSynchronizeFactory.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/editor/sync/TextDocumentSynchronizeFactory.java @@ -10,12 +10,11 @@ *******************************************************************************/ package org.eclipse.che.plugin.languageserver.ide.editor.sync; -import io.typefox.lsapi.TextDocumentSyncKind; - import com.google.inject.Inject; import com.google.inject.Singleton; import org.eclipse.che.ide.api.editor.events.DocumentChangeEvent; +import org.eclipse.lsp4j.TextDocumentSyncKind; /** * Provide synchronizes for according {@link TextDocumentSyncKind} diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/highlighting/OccurrencesProvider.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/highlighting/OccurrencesProvider.java index d8bafabf8a9..7f7434b98dd 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/highlighting/OccurrencesProvider.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/highlighting/OccurrencesProvider.java @@ -10,10 +10,9 @@ *******************************************************************************/ package org.eclipse.che.plugin.languageserver.ide.highlighting; -import java.util.logging.Logger; +import com.google.inject.Inject; +import com.google.inject.Singleton; -import org.eclipse.che.api.languageserver.shared.lsapi.DocumentHighlightDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import org.eclipse.che.api.promises.client.Function; import org.eclipse.che.api.promises.client.FunctionException; import org.eclipse.che.api.promises.client.Promise; @@ -28,25 +27,27 @@ import org.eclipse.che.plugin.languageserver.ide.editor.LanguageServerEditorConfiguration; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; import org.eclipse.che.plugin.languageserver.ide.util.DtoBuildHelper; +import org.eclipse.lsp4j.DocumentHighlight; +import org.eclipse.lsp4j.TextDocumentPositionParams; -import com.google.inject.Inject; -import com.google.inject.Singleton; +import java.util.logging.Logger; /** * Provides occurrences highlights for the Orion Editor. - * + * * @author Xavier Coulon, Red Hat */ @Singleton public class OccurrencesProvider implements OrionOccurrencesHandler { - private static final Logger LOGGER = Logger.getLogger(OccurrencesProvider.class.getName()); - private final EditorAgent editorAgent; + private static final Logger LOGGER = Logger.getLogger(OccurrencesProvider.class.getName()); + private final EditorAgent editorAgent; private final TextDocumentServiceClient client; private final DtoBuildHelper helper; /** * Constructor. + * * @param editorAgent * @param client * @param helper @@ -60,7 +61,7 @@ public OccurrencesProvider(EditorAgent editorAgent, TextDocumentServiceClient cl @Override public JsPromise computeOccurrences( - OrionOccurrenceContextOverlay context) { + OrionOccurrenceContextOverlay context) { final EditorPartPresenter activeEditor = editorAgent.getActiveEditor(); if (activeEditor == null || !(activeEditor instanceof TextEditor)) { return null; @@ -70,29 +71,30 @@ public JsPromise computeOccurrences( return null; } final LanguageServerEditorConfiguration configuration = (LanguageServerEditorConfiguration)editor.getConfiguration(); - if (configuration.getServerCapabilities().isDocumentHighlightProvider() == null || !configuration.getServerCapabilities().isDocumentHighlightProvider()) { + if (configuration.getServerCapabilities().getDocumentHighlightProvider() == null || + !configuration.getServerCapabilities().getDocumentHighlightProvider()) { return null; } final Document document = editor.getDocument(); - final TextDocumentPositionParamsDTO paramsDTO = helper.createTDPP(document, context.getStart()); + final TextDocumentPositionParams paramsDTO = helper.createTDPP(document, context.getStart()); // FIXME: the result should be a Promise> but the typefox API returns a single DocumentHighlightDTO - Promise promise = client.documentHighlight(paramsDTO); - Promise then = promise.then(new Function() { + Promise promise = client.documentHighlight(paramsDTO); + Promise then = promise.then(new Function() { @Override - public OrionOccurrenceOverlay[] apply(DocumentHighlightDTO highlight) throws FunctionException { - if(highlight == null) { - return new OrionOccurrenceOverlay[0]; - } - final OrionOccurrenceOverlay[] occurrences = new OrionOccurrenceOverlay[1]; - final OrionOccurrenceOverlay occurrence = OrionOccurrenceOverlay.create(); - // FIXME: this assumes that the language server will - // compute a range based on 'line 1', ie, the whole - // file content is on line 1 and the location to - // highlight is given by the 'character' position - // only. - occurrence.setStart(highlight.getRange().getStart().getCharacter()); - occurrence.setEnd(highlight.getRange().getEnd().getCharacter() + 1); - occurrences[0] = occurrence; + public OrionOccurrenceOverlay[] apply(DocumentHighlight highlight) throws FunctionException { + if (highlight == null) { + return new OrionOccurrenceOverlay[0]; + } + final OrionOccurrenceOverlay[] occurrences = new OrionOccurrenceOverlay[1]; + final OrionOccurrenceOverlay occurrence = OrionOccurrenceOverlay.create(); + // FIXME: this assumes that the language server will + // compute a range based on 'line 1', ie, the whole + // file content is on line 1 and the location to + // highlight is given by the 'character' position + // only. + occurrence.setStart(highlight.getRange().getStart().getCharacter()); + occurrence.setEnd(highlight.getRange().getEnd().getCharacter() + 1); + occurrences[0] = occurrence; return occurrences; } }); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/hover/HoverProvider.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/hover/HoverProvider.java index 25fd1a4dd06..54da2848e4d 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/hover/HoverProvider.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/hover/HoverProvider.java @@ -14,9 +14,6 @@ import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.api.languageserver.shared.lsapi.HoverDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.MarkedStringDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import org.eclipse.che.api.promises.client.Function; import org.eclipse.che.api.promises.client.FunctionException; import org.eclipse.che.api.promises.client.Promise; @@ -32,12 +29,12 @@ import org.eclipse.che.plugin.languageserver.ide.editor.LanguageServerEditorConfiguration; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; import org.eclipse.che.plugin.languageserver.ide.util.DtoBuildHelper; +import org.eclipse.lsp4j.Hover; +import org.eclipse.lsp4j.TextDocumentPositionParams; import java.util.ArrayList; import java.util.List; -import io.typefox.lsapi.MarkedString; - /** * Provides hover LS functionality for Orion editor. * @@ -70,22 +67,22 @@ public JsPromise computeHover(OrionHoverContextOverlay contex } LanguageServerEditorConfiguration configuration = (LanguageServerEditorConfiguration)editor.getConfiguration(); - if (configuration.getServerCapabilities().isHoverProvider() == null || !configuration.getServerCapabilities().isHoverProvider()) { + if (configuration.getServerCapabilities().getHoverProvider() == null + || !configuration.getServerCapabilities().getHoverProvider()) { return null; } Document document = editor.getDocument(); - TextDocumentPositionParamsDTO paramsDTO = helper.createTDPP(document, context.getOffset()); - + TextDocumentPositionParams paramsDTO = helper.createTDPP(document, context.getOffset()); - Promise promise = client.hover(paramsDTO); - Promise then = promise.then(new Function() { + Promise promise = client.hover(paramsDTO); + Promise then = promise.then(new Function() { @Override - public OrionHoverOverlay apply(HoverDTO arg) throws FunctionException { + public OrionHoverOverlay apply(Hover arg) throws FunctionException { OrionHoverOverlay hover = OrionHoverOverlay.create(); hover.setType("markdown"); String content = renderContent(arg); - //do not show hover with only white spaces + // do not show hover with only white spaces if (StringUtils.isNullOrWhitespace(content)) { return null; } @@ -94,17 +91,11 @@ public OrionHoverOverlay apply(HoverDTO arg) throws FunctionException { return hover; } - private String renderContent(HoverDTO hover) { + private String renderContent(Hover hover) { List contents = new ArrayList(); - for (MarkedStringDTO dto : hover.getContents()) { - String lang = dto.getLanguage(); - if (lang == null || MarkedString.PLAIN_STRING.equals(lang)) { - // plain markdown text - contents.add(dto.getValue()); - } else { - // markdown code block - contents.add("```" + lang + "\n" + dto.getValue() + "\n```"); - } + for (String dto : hover.getContents()) { + // plain markdown text + contents.add(dto); } return Joiner.on("\n\n").join(contents); } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationPresenter.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationPresenter.java index f3ee01856ad..4e7cf819000 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationPresenter.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationPresenter.java @@ -15,8 +15,6 @@ import com.google.inject.Inject; import com.google.inject.assistedinject.Assisted; -import org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO; import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.Promise; @@ -30,6 +28,8 @@ import org.eclipse.che.ide.api.parts.base.BasePresenter; import org.eclipse.che.plugin.languageserver.ide.LanguageServerResources; import org.eclipse.che.plugin.languageserver.ide.util.OpenFileInEditorHelper; +import org.eclipse.lsp4j.Location; +import org.eclipse.lsp4j.Range; import org.vectomatic.dom.svg.ui.SVGResource; import java.util.List; @@ -44,7 +44,7 @@ public class OpenLocationPresenter extends BasePresenter implements OpenLocation private final WorkspaceAgent workspaceAgent; private final OpenFileInEditorHelper helper; private final NotificationManager notificationManager; - private final String title; + private final String title; @Inject public OpenLocationPresenter(LanguageServerResources resources, @@ -65,10 +65,10 @@ public OpenLocationPresenter(LanguageServerResources resources, //TODO maybe we should use some generic data object not a DTO - public void openLocation(Promise> promise) { - promise.then(new Operation>() { + public void openLocation(Promise> promise) { + promise.then(new Operation>() { @Override - public void apply(List arg) throws OperationException { + public void apply(List arg) throws OperationException { showLocations(arg); } }).catchError(new Operation() { @@ -84,7 +84,7 @@ public void showError(PromiseError arg) { .notify(title, arg.getMessage(), StatusNotification.Status.FAIL, StatusNotification.DisplayMode.FLOAT_MODE); } - private void showLocations(List locations) { + private void showLocations(List locations) { view.setLocations(locations); openPart(); } @@ -120,8 +120,8 @@ private void openPart() { } @Override - public void onLocationSelected(LocationDTO location) { - RangeDTO range = location.getRange(); + public void onLocationSelected(Location location) { + Range range = location.getRange(); helper.openFile(location.getUri(), new TextRange(new TextPosition( range.getStart().getLine(), range.getStart().getCharacter()), new TextPosition(range.getEnd().getLine(), range.getEnd().getCharacter()))); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationView.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationView.java index 51d28e02821..ffa8e974e79 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationView.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationView.java @@ -12,9 +12,9 @@ import com.google.inject.ImplementedBy; -import org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO; import org.eclipse.che.ide.api.mvp.View; import org.eclipse.che.ide.api.parts.base.BaseActionDelegate; +import org.eclipse.lsp4j.Location; import java.util.List; @@ -24,12 +24,12 @@ @ImplementedBy(OpenLocationViewImpl.class) public interface OpenLocationView extends View { - void setLocations(List locations); + void setLocations(List locations); void setTitle(String title); - interface ActionDelegate extends BaseActionDelegate{ + interface ActionDelegate extends BaseActionDelegate { - void onLocationSelected(LocationDTO location); + void onLocationSelected(Location location); } } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationViewImpl.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationViewImpl.java index 118d24c7486..b726025b6d6 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationViewImpl.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/location/OpenLocationViewImpl.java @@ -14,7 +14,6 @@ import com.google.gwt.user.client.ui.DockLayoutPanel; import com.google.inject.Inject; -import org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO; import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.data.tree.AbstractTreeNode; import org.eclipse.che.ide.api.data.tree.HasAction; @@ -28,6 +27,7 @@ import org.eclipse.che.ide.ui.smartTree.Tree; import org.eclipse.che.ide.ui.smartTree.presentation.HasPresentation; import org.eclipse.che.ide.ui.smartTree.presentation.NodePresentation; +import org.eclipse.lsp4j.Location; import javax.validation.constraints.NotNull; import java.util.Collections; @@ -59,10 +59,10 @@ public String getKey(@NotNull Node item) { } @Override - public void setLocations(List locations) { + public void setLocations(List locations) { tree.getNodeStorage().clear(); //TODO workaround, tree has bug with adding list of nodes - for (LocationDTO location : locations) { + for (Location location : locations) { tree.getNodeStorage().add(new LocationNode(location)); } @@ -74,10 +74,10 @@ public void setLocations(List locations) { } private class LocationNode extends AbstractTreeNode implements HasAction, HasPresentation { - private final LocationDTO location; - private NodePresentation nodePresentation; + private final Location location; + private NodePresentation nodePresentation; - public LocationNode(LocationDTO location) { + public LocationNode(Location location) { this.location = location; } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/declaration/FindDefinitionAction.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/declaration/FindDefinitionAction.java index 8ac951eae17..7e42bcaa758 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/declaration/FindDefinitionAction.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/declaration/FindDefinitionAction.java @@ -10,13 +10,9 @@ *******************************************************************************/ package org.eclipse.che.plugin.languageserver.ide.navigation.declaration; -import io.typefox.lsapi.ServerCapabilities; - import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.Promise; @@ -32,6 +28,9 @@ import org.eclipse.che.plugin.languageserver.ide.location.OpenLocationPresenterFactory; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; import org.eclipse.che.plugin.languageserver.ide.util.DtoBuildHelper; +import org.eclipse.lsp4j.Location; +import org.eclipse.lsp4j.ServerCapabilities; +import org.eclipse.lsp4j.TextDocumentPositionParams; import javax.validation.constraints.NotNull; import java.util.List; @@ -69,7 +68,7 @@ public void updateInPerspective(@NotNull ActionEvent event) { if (configuration instanceof LanguageServerEditorConfiguration) { ServerCapabilities capabilities = ((LanguageServerEditorConfiguration)configuration).getServerCapabilities(); event.getPresentation() - .setEnabledAndVisible(capabilities.isDefinitionProvider() != null && capabilities.isDefinitionProvider()); + .setEnabledAndVisible(capabilities.getDefinitionProvider() != null && capabilities.getDefinitionProvider()); return; } } @@ -82,12 +81,12 @@ public void actionPerformed(ActionEvent e) { EditorPartPresenter activeEditor = editorAgent.getActiveEditor(); TextEditor textEditor = ((TextEditor)activeEditor); - TextDocumentPositionParamsDTO paramsDTO = dtoBuildHelper.createTDPP(textEditor.getDocument(), textEditor.getCursorPosition()); + TextDocumentPositionParams paramsDTO = dtoBuildHelper.createTDPP(textEditor.getDocument(), textEditor.getCursorPosition()); - final Promise> promise = client.definition(paramsDTO); - promise.then(new Operation>() { + final Promise> promise = client.definition(paramsDTO); + promise.then(new Operation>() { @Override - public void apply(List arg) throws OperationException { + public void apply(List arg) throws OperationException { if (arg.size() == 1) { presenter.onLocationSelected(arg.get(0)); } else { diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/references/FindReferencesAction.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/references/FindReferencesAction.java index ba6ed65515e..7e94fa0c759 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/references/FindReferencesAction.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/references/FindReferencesAction.java @@ -10,15 +10,8 @@ *******************************************************************************/ package org.eclipse.che.plugin.languageserver.ide.navigation.references; -import io.typefox.lsapi.ServerCapabilities; - import com.google.inject.Inject; -import org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.ReferenceContextDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.ReferenceParamsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO; import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.action.AbstractPerspectiveAction; import org.eclipse.che.ide.api.action.ActionEvent; @@ -31,6 +24,12 @@ import org.eclipse.che.plugin.languageserver.ide.location.OpenLocationPresenter; import org.eclipse.che.plugin.languageserver.ide.location.OpenLocationPresenterFactory; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; +import org.eclipse.lsp4j.Location; +import org.eclipse.lsp4j.Position; +import org.eclipse.lsp4j.ReferenceContext; +import org.eclipse.lsp4j.ReferenceParams; +import org.eclipse.lsp4j.ServerCapabilities; +import org.eclipse.lsp4j.TextDocumentIdentifier; import javax.validation.constraints.NotNull; import java.util.List; @@ -66,7 +65,7 @@ public void updateInPerspective(@NotNull ActionEvent event) { if (configuration instanceof LanguageServerEditorConfiguration) { ServerCapabilities capabilities = ((LanguageServerEditorConfiguration)configuration).getServerCapabilities(); event.getPresentation() - .setEnabledAndVisible(capabilities.isReferencesProvider() != null && capabilities.isReferencesProvider()); + .setEnabledAndVisible(capabilities.getReferencesProvider() != null && capabilities.getReferencesProvider()); return; } } @@ -83,23 +82,23 @@ public void actionPerformed(ActionEvent e) { } TextEditor textEditor = ((TextEditor)activeEditor); String path = activeEditor.getEditorInput().getFile().getLocation().toString(); - ReferenceParamsDTO paramsDTO = dtoFactory.createDto(ReferenceParamsDTO.class); + ReferenceParams paramsDTO = dtoFactory.createDto(ReferenceParams.class); - PositionDTO positionDTO = dtoFactory.createDto(PositionDTO.class); - positionDTO.setLine(textEditor.getCursorPosition().getLine()); - positionDTO.setCharacter(textEditor.getCursorPosition().getCharacter()); + Position Position = dtoFactory.createDto(Position.class); + Position.setLine(textEditor.getCursorPosition().getLine()); + Position.setCharacter(textEditor.getCursorPosition().getCharacter()); - TextDocumentIdentifierDTO identifierDTO = dtoFactory.createDto(TextDocumentIdentifierDTO.class); + TextDocumentIdentifier identifierDTO = dtoFactory.createDto(TextDocumentIdentifier.class); identifierDTO.setUri(path); - ReferenceContextDTO contextDTO = dtoFactory.createDto(ReferenceContextDTO.class); + ReferenceContext contextDTO = dtoFactory.createDto(ReferenceContext.class); contextDTO.setIncludeDeclaration(true); paramsDTO.setUri(path); - paramsDTO.setPosition(positionDTO); + paramsDTO.setPosition(Position); paramsDTO.setTextDocument(identifierDTO); paramsDTO.setContext(contextDTO); - Promise> promise = client.references(paramsDTO); + Promise> promise = client.references(paramsDTO); presenter.openLocation(promise); } } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/GoToSymbolAction.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/GoToSymbolAction.java index ada8a2aeb67..b7a9b2950a1 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/GoToSymbolAction.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/GoToSymbolAction.java @@ -12,11 +12,7 @@ import com.google.inject.Inject; import com.google.inject.Singleton; -import io.typefox.lsapi.ServerCapabilities; -import org.eclipse.che.api.languageserver.shared.lsapi.DocumentSymbolParamsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.SymbolInformationDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO; + import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.Promise; @@ -41,6 +37,11 @@ import org.eclipse.che.plugin.languageserver.ide.quickopen.QuickOpenModel; import org.eclipse.che.plugin.languageserver.ide.quickopen.QuickOpenPresenter; import org.eclipse.che.plugin.languageserver.ide.service.TextDocumentServiceClient; +import org.eclipse.lsp4j.DocumentSymbolParams; +import org.eclipse.lsp4j.Range; +import org.eclipse.lsp4j.ServerCapabilities; +import org.eclipse.lsp4j.SymbolInformation; +import org.eclipse.lsp4j.TextDocumentIdentifier; import javax.validation.constraints.NotNull; import java.util.ArrayList; @@ -61,18 +62,18 @@ public class GoToSymbolAction extends AbstractPerspectiveAction implements Quick public static final String SCOPE_PREFIX = ":"; private final LanguageServerLocalization - localization; - private final TextDocumentServiceClient client; - private final EditorAgent editorAgent; - private final DtoFactory dtoFactory; - private final NotificationManager notificationManager; - private final FuzzyMatches fuzzyMatches; - private final SymbolKindHelper symbolKindHelper; - private QuickOpenPresenter presenter; - private List cachedItems; - private LinearRange selectedLinearRange; - private TextEditor activeEditor; - private TextPosition cursorPosition; + localization; + private final TextDocumentServiceClient client; + private final EditorAgent editorAgent; + private final DtoFactory dtoFactory; + private final NotificationManager notificationManager; + private final FuzzyMatches fuzzyMatches; + private final SymbolKindHelper symbolKindHelper; + private QuickOpenPresenter presenter; + private List cachedItems; + private LinearRange selectedLinearRange; + private TextEditor activeEditor; + private TextPosition cursorPosition; @Inject public GoToSymbolAction(QuickOpenPresenter presenter, @@ -97,16 +98,16 @@ public GoToSymbolAction(QuickOpenPresenter presenter, @Override public void actionPerformed(ActionEvent e) { - DocumentSymbolParamsDTO paramsDTO = dtoFactory.createDto(DocumentSymbolParamsDTO.class); - TextDocumentIdentifierDTO identifierDTO = dtoFactory.createDto(TextDocumentIdentifierDTO.class); + DocumentSymbolParams paramsDTO = dtoFactory.createDto(DocumentSymbolParams.class); + TextDocumentIdentifier identifierDTO = dtoFactory.createDto(TextDocumentIdentifier.class); identifierDTO.setUri(editorAgent.getActiveEditor().getEditorInput().getFile().getLocation().toString()); paramsDTO.setTextDocument(identifierDTO); activeEditor = (TextEditor)editorAgent.getActiveEditor(); cursorPosition = activeEditor.getDocument().getCursorPosition(); - client.documentSymbol(paramsDTO).then(new Operation>() { + client.documentSymbol(paramsDTO).then(new Operation>() { @Override - public void apply(List arg) throws OperationException { + public void apply(List arg) throws OperationException { cachedItems = arg; presenter.run(GoToSymbolAction.this); @@ -128,7 +129,7 @@ public void updateInPerspective(@NotNull ActionEvent event) { if (configuration instanceof LanguageServerEditorConfiguration) { ServerCapabilities capabilities = ((LanguageServerEditorConfiguration)configuration).getServerCapabilities(); event.getPresentation() - .setEnabledAndVisible(capabilities.isDocumentSymbolProvider() != null && capabilities.isDocumentSymbolProvider()); + .setEnabledAndVisible(capabilities.getDocumentSymbolProvider() != null && capabilities.getDocumentSymbolProvider()); return; } @@ -141,14 +142,14 @@ public Promise getModel(String value) { return Promises.resolve(new QuickOpenModel(toQuickOpenEntries(cachedItems, value))); } - private List toQuickOpenEntries(List items, final String value) { + private List toQuickOpenEntries(List items, final String value) { List result = new ArrayList<>(); String normalValue = value; if (value.startsWith(SCOPE_PREFIX)) { normalValue = normalValue.substring(SCOPE_PREFIX.length()); } - for (SymbolInformationDTO item : items) { + for (SymbolInformation item : items) { String label = item.getName().trim(); List highlights = fuzzyMatches.fuzzyMatch(normalValue, label); @@ -158,7 +159,7 @@ private List toQuickOpenEntries(List items, f description = item.getContainerName(); } - RangeDTO range = item.getLocation().getRange(); + Range range = item.getLocation().getRange(); TextRange textRange = new TextRange(new TextPosition(range.getStart().getLine(), range.getStart().getCharacter()), new TextPosition(range.getEnd().getLine(), range.getEnd().getCharacter())); //TODO add icons diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/SymbolEntry.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/SymbolEntry.java index c2138ee2973..cc197f710c0 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/SymbolEntry.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/SymbolEntry.java @@ -24,11 +24,11 @@ */ class SymbolEntry extends QuickOpenEntryGroup { - private String name; - private String type; - private String description; - private TextRange range; - private TextEditor editor; + private String name; + private String type; + private String description; + private TextRange range; + private TextEditor editor; private SVGResource icon; public SymbolEntry(String name, diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/SymbolKindHelper.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/SymbolKindHelper.java index 26bbe9ecc25..c36f0248b55 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/SymbolKindHelper.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/symbol/SymbolKindHelper.java @@ -10,12 +10,11 @@ *******************************************************************************/ package org.eclipse.che.plugin.languageserver.ide.navigation.symbol; -import io.typefox.lsapi.SymbolKind; - import com.google.inject.Inject; import com.google.inject.Singleton; import org.eclipse.che.plugin.languageserver.ide.LanguageServerResources; +import org.eclipse.lsp4j.SymbolKind; import org.vectomatic.dom.svg.ui.SVGResource; import java.util.HashMap; @@ -23,7 +22,7 @@ /** * Provides icons and text description for {@link SymbolKind} - * + * * @author Evgen Vidolob */ @Singleton diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/workspace/FindSymbolAction.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/workspace/FindSymbolAction.java index 6d3a97d65d7..9c8a4346e00 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/workspace/FindSymbolAction.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/workspace/FindSymbolAction.java @@ -14,10 +14,8 @@ import com.google.common.collect.Sets; import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.SymbolInformationDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.WorkspaceSymbolParamsDTO; + +import org.eclipse.che.api.languageserver.shared.model.ExtendedWorkspaceSymbolParams; import org.eclipse.che.api.promises.async.Task; import org.eclipse.che.api.promises.async.ThrottledDelayer; import org.eclipse.che.api.promises.client.Function; @@ -38,6 +36,9 @@ import org.eclipse.che.plugin.languageserver.ide.quickopen.QuickOpenPresenter; import org.eclipse.che.plugin.languageserver.ide.service.WorkspaceServiceClient; import org.eclipse.che.plugin.languageserver.ide.util.OpenFileInEditorHelper; +import org.eclipse.lsp4j.Location; +import org.eclipse.lsp4j.Range; +import org.eclipse.lsp4j.SymbolInformation; import javax.validation.constraints.NotNull; import java.util.ArrayList; @@ -54,16 +55,16 @@ @Singleton public class FindSymbolAction extends AbstractPerspectiveAction implements QuickOpenPresenter.QuickOpenPresenterOpts { - private static final Set SUPPORTED_OPEN_TYPES = Sets.newHashSet("class", "interface", "enum","function", "method"); - private static final int SEARCH_DELAY = 500; + private static final Set SUPPORTED_OPEN_TYPES = Sets.newHashSet("class", "interface", "enum", "function", "method"); + private static final int SEARCH_DELAY = 500; - private final OpenFileInEditorHelper editorHelper; - private final QuickOpenPresenter presenter; - private final WorkspaceServiceClient workspaceServiceClient; - private final DtoFactory dtoFactory; - private final EditorAgent editorAgent; - private final SymbolKindHelper symbolKindHelper; - private final FuzzyMatches fuzzyMatches; + private final OpenFileInEditorHelper editorHelper; + private final QuickOpenPresenter presenter; + private final WorkspaceServiceClient workspaceServiceClient; + private final DtoFactory dtoFactory; + private final EditorAgent editorAgent; + private final SymbolKindHelper symbolKindHelper; + private final FuzzyMatches fuzzyMatches; private final ThrottledDelayer> delayer; @Inject @@ -101,7 +102,7 @@ public void actionPerformed(ActionEvent e) { public Promise getModel(final String value) { Promise> promise; - if (Strings.isNullOrEmpty(value)|| editorAgent.getActiveEditor() == null) { + if (Strings.isNullOrEmpty(value) || editorAgent.getActiveEditor() == null) { promise = Promises.resolve(Collections.emptyList()); } else { promise = delayer.trigger(new Task>>() { @@ -120,29 +121,29 @@ public QuickOpenModel apply(List arg) throws FunctionException { } private Promise> searchSymbols(final String value) { - WorkspaceSymbolParamsDTO params = dtoFactory.createDto(WorkspaceSymbolParamsDTO.class); + ExtendedWorkspaceSymbolParams params = dtoFactory.createDto(ExtendedWorkspaceSymbolParams.class); params.setQuery(value); params.setFileUri(editorAgent.getActiveEditor().getEditorInput().getFile().getLocation().toString()); - return workspaceServiceClient.symbol(params).then(new Function, List>() { + return workspaceServiceClient.symbol(params).then(new Function, List>() { @Override - public List apply(List types) throws FunctionException { + public List apply(List types) throws FunctionException { return toSymbolEntries(types, value); } }); } - private List toSymbolEntries(List types, String value) { + private List toSymbolEntries(List types, String value) { List result = new ArrayList<>(); - for (SymbolInformationDTO element : types) { - if(!SUPPORTED_OPEN_TYPES.contains(symbolKindHelper.from(element.getKind()))){ + for (SymbolInformation element : types) { + if (!SUPPORTED_OPEN_TYPES.contains(symbolKindHelper.from(element.getKind()))) { continue; } List matches = fuzzyMatches.fuzzyMatch(value, element.getName()); if (matches != null) { - LocationDTO location = element.getLocation(); + Location location = element.getLocation(); if (location != null && location.getUri() != null) { String filePath = location.getUri(); - RangeDTO locationRange = location.getRange(); + Range locationRange = location.getRange(); TextRange range = null; if (locationRange != null) { diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/workspace/SymbolEntry.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/workspace/SymbolEntry.java index 85ae8dcf31d..c4fb32137d0 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/workspace/SymbolEntry.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/navigation/workspace/SymbolEntry.java @@ -23,12 +23,12 @@ */ class SymbolEntry extends EditorQuickOpenEntry { - private String name; - private String parameters; - private String description; - private String filePath; - private String type; - private TextRange range; + private String name; + private String parameters; + private String description; + private String filePath; + private String type; + private TextRange range; private SVGResource icon; public SymbolEntry(String name, @@ -70,7 +70,7 @@ public SVGResource getIcon() { return icon; } - public String getType(){ + public String getType() { return type; } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/quickopen/QuickOpenEntry.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/quickopen/QuickOpenEntry.java index 239eb30e9ca..6e4d5b03fe3 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/quickopen/QuickOpenEntry.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/quickopen/QuickOpenEntry.java @@ -28,7 +28,7 @@ public class QuickOpenEntry { private final String id; private List labelHighlights; - private boolean hidden; + private boolean hidden; public QuickOpenEntry() { this(Collections.emptyList()); @@ -41,6 +41,7 @@ public QuickOpenEntry(List labelHighlights) { /** * A identifier for the entry + * * @return the id */ public String getId() { @@ -56,6 +57,7 @@ public String getLabel() { /** * Detail information. Optional. + * * @return */ public String getDetail() { @@ -64,6 +66,7 @@ public String getDetail() { /** * The icon of the entry. + * * @return */ public SVGResource getIcon() { @@ -72,6 +75,7 @@ public SVGResource getIcon() { /** * A another description, can be shown right to the label + * * @return */ public String getDescription() { @@ -84,6 +88,7 @@ public String getURI() { /** * Additional CSS class name. + * * @return */ public String getAdditionalClass() { @@ -98,18 +103,20 @@ public void setHidden(boolean hidden) { this.hidden = hidden; } - public void setHighlights(List highlights) { - labelHighlights = highlights; - } - public List getHighlights() { return labelHighlights; } + public void setHighlights(List highlights) { + labelHighlights = highlights; + } + /** * Called when the entry selected for opening. * Returns a boolean value indicating if an action was performed. - * @param mode gives an indicating if the element is previewed or opened. + * + * @param mode + * gives an indicating if the element is previewed or opened. * @return */ public boolean run(Mode mode) { diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/quickopen/QuickOpenEntryGroup.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/quickopen/QuickOpenEntryGroup.java index 2ab20a297cc..8b060a2218c 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/quickopen/QuickOpenEntryGroup.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/quickopen/QuickOpenEntryGroup.java @@ -60,32 +60,32 @@ public String getLabel() { @Override public String getDetail() { - return entry!= null ? entry.getDetail() : super.getDetail(); + return entry != null ? entry.getDetail() : super.getDetail(); } @Override public SVGResource getIcon() { - return entry!= null ?entry.getIcon(): super.getIcon(); + return entry != null ? entry.getIcon() : super.getIcon(); } @Override public String getDescription() { - return entry!= null ? entry.getDescription(): super.getDescription(); + return entry != null ? entry.getDescription() : super.getDescription(); } @Override public String getURI() { - return entry!= null ? entry.getURI() :super.getURI(); + return entry != null ? entry.getURI() : super.getURI(); } @Override public String getAdditionalClass() { - return entry!= null ? entry.getAdditionalClass() : super.getAdditionalClass(); + return entry != null ? entry.getAdditionalClass() : super.getAdditionalClass(); } @Override public boolean isHidden() { - return entry!= null ? entry.isHidden() : super.isHidden(); + return entry != null ? entry.isHidden() : super.isHidden(); } @Override @@ -97,6 +97,11 @@ public void setHidden(boolean hidden) { } } + @Override + public List getHighlights() { + return entry != null ? entry.getHighlights() : super.getHighlights(); + } + @Override public void setHighlights(List highlights) { if (entry != null) { @@ -106,13 +111,8 @@ public void setHighlights(List highlights) { } } - @Override - public List getHighlights() { - return entry!= null ? entry.getHighlights() : super.getHighlights(); - } - @Override public boolean run(Mode mode) { - return entry!= null ? entry.run(mode): super.run(mode); + return entry != null ? entry.run(mode) : super.run(mode); } } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/quickopen/QuickOpenViewImpl.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/quickopen/QuickOpenViewImpl.java index 11befabcfed..d01530082b9 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/quickopen/QuickOpenViewImpl.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/quickopen/QuickOpenViewImpl.java @@ -10,6 +10,9 @@ *******************************************************************************/ package org.eclipse.che.plugin.languageserver.ide.quickopen; +import elemental.dom.Element; +import elemental.html.SpanElement; + import com.google.gwt.core.client.Scheduler; import com.google.gwt.event.dom.client.KeyCodes; import com.google.gwt.event.dom.client.KeyDownEvent; @@ -27,8 +30,7 @@ import com.google.gwt.user.client.ui.PopupPanel; import com.google.gwt.user.client.ui.TextBox; import com.google.inject.Inject; -import elemental.dom.Element; -import elemental.html.SpanElement; + import org.eclipse.che.ide.Resources; import org.eclipse.che.ide.api.autocomplete.AutoCompleteResources; import org.eclipse.che.ide.filters.Match; @@ -48,93 +50,86 @@ public class QuickOpenViewImpl extends PopupPanel implements QuickOpenView { private final AutoCompleteResources.Css css; - - @UiField - TextBox nameField; - - @UiField - DockLayoutPanel layoutPanel; - - @UiField - FlowPanel actionsPanel; - - @UiField - HTML actionsContainer; - - private ActionDelegate delegate; - private Resources resources; private final LanguageServerResources languageServerResources; - private SimpleList list; - private final SimpleList.ListItemRenderer listItemRenderer = - new SimpleList.ListItemRenderer() { - @Override - public void render(Element itemElement, QuickOpenEntry itemData) { - Element label = Elements.createSpanElement(css.proposalLabel()); - Element icon = Elements.createSpanElement(css.proposalIcon()); - Element group = Elements.createSpanElement(css.proposalGroup()); - - SafeHtmlBuilder builder = new SafeHtmlBuilder(); - List highlights = itemData.getHighlights(); - String text = itemData.getLabel(); - int pos = 0; - SpanElement spanElement = Elements.createSpanElement(); - for (Match highlight : highlights) { - if (highlight.getStart() == highlight.getEnd()) { - continue; + new SimpleList.ListItemRenderer() { + @Override + public void render(Element itemElement, QuickOpenEntry itemData) { + Element label = Elements.createSpanElement(css.proposalLabel()); + Element icon = Elements.createSpanElement(css.proposalIcon()); + Element group = Elements.createSpanElement(css.proposalGroup()); + + SafeHtmlBuilder builder = new SafeHtmlBuilder(); + List highlights = itemData.getHighlights(); + String text = itemData.getLabel(); + int pos = 0; + SpanElement spanElement = Elements.createSpanElement(); + for (Match highlight : highlights) { + if (highlight.getStart() == highlight.getEnd()) { + continue; + } + + if (pos < highlight.getStart()) { + builder.appendHtmlConstant(""); + builder.appendEscaped(text.substring(pos, highlight.getStart())); + builder.appendHtmlConstant(""); + } + + builder.appendHtmlConstant(""); + builder.appendEscaped(text.substring(highlight.getStart(), highlight.getEnd())); + builder.appendHtmlConstant(""); + pos = highlight.getEnd(); } - if (pos < highlight.getStart()) { + if (pos < text.length()) { builder.appendHtmlConstant(""); - builder.appendEscaped(text.substring(pos, highlight.getStart())); + builder.appendEscaped(text.substring(pos)); builder.appendHtmlConstant(""); } - - builder.appendHtmlConstant(""); - builder.appendEscaped(text.substring(highlight.getStart(), highlight.getEnd())); - builder.appendHtmlConstant(""); - pos = highlight.getEnd(); - } - - if (pos < text.length()) { - builder.appendHtmlConstant(""); - builder.appendEscaped(text.substring(pos)); - builder.appendHtmlConstant(""); - } - spanElement.setInnerHTML(builder.toSafeHtml().asString()); - label.getStyle().setPaddingLeft("5px"); - label.getStyle().setPaddingRight("5px"); - if (itemData.getIcon() != null) { - SVGImage svgImage = new SVGImage(itemData.getIcon()); - icon.appendChild((elemental.dom.Node)svgImage.getElement()); - itemElement.appendChild(icon); - } - if(itemData instanceof QuickOpenEntryGroup) { - QuickOpenEntryGroup entryGroup = (QuickOpenEntryGroup)itemData; - if(entryGroup.isWithBorder()) { - Elements.addClassName(languageServerResources.quickOpenListCss().groupSeparator(), itemElement); - } - if (entryGroup.getGroupLabel() != null) { - group.setInnerText(entryGroup.getGroupLabel()); + spanElement.setInnerHTML(builder.toSafeHtml().asString()); + label.getStyle().setPaddingLeft("5px"); + label.getStyle().setPaddingRight("5px"); + if (itemData.getIcon() != null) { + SVGImage svgImage = new SVGImage(itemData.getIcon()); + icon.appendChild((elemental.dom.Node)svgImage.getElement()); + itemElement.appendChild(icon); } - } else { - if (itemData.getDescription() != null) { - group.setInnerText(itemData.getDescription()); + if (itemData instanceof QuickOpenEntryGroup) { + QuickOpenEntryGroup entryGroup = (QuickOpenEntryGroup)itemData; + if (entryGroup.isWithBorder()) { + Elements.addClassName(languageServerResources.quickOpenListCss().groupSeparator(), itemElement); + } + if (entryGroup.getGroupLabel() != null) { + group.setInnerText(entryGroup.getGroupLabel()); + } + } else { + if (itemData.getDescription() != null) { + group.setInnerText(itemData.getDescription()); + } } - } - - label.appendChild(spanElement); - itemElement.appendChild(label); - itemElement.appendChild(group); - } - @Override - public Element createElement() { - return Elements.createDivElement(); - } - }; + label.appendChild(spanElement); + itemElement.appendChild(label); + itemElement.appendChild(group); + } - private QuickOpenModel model; + @Override + public Element createElement() { + return Elements.createDivElement(); + } + }; + @UiField + TextBox nameField; + @UiField + DockLayoutPanel layoutPanel; + @UiField + FlowPanel actionsPanel; + @UiField + HTML actionsContainer; + private ActionDelegate delegate; + private Resources resources; + private SimpleList list; + private QuickOpenModel model; private final SimpleList.ListEventDelegate eventDelegate = new SimpleList.ListEventDelegate() { @Override @@ -192,7 +187,7 @@ public void show(final String value) { setPopupPositionAndShow(new PositionCallback() { @Override public void setPosition(int offsetWidth, int offsetHeight) { - setPopupPosition((Window.getClientWidth() / 2) - (offsetWidth/2), 60); + setPopupPosition((Window.getClientWidth() / 2) - (offsetWidth / 2), 60); } }); @@ -211,7 +206,7 @@ public void setModel(QuickOpenModel model) { actionsContainer.getElement().setInnerHTML(""); Element itemHolder = Elements.createDivElement(); itemHolder.setClassName(css.items()); - actionsContainer.getElement().appendChild(((com.google.gwt.dom.client.Element) itemHolder)); + actionsContainer.getElement().appendChild(((com.google.gwt.dom.client.Element)itemHolder)); list = SimpleList.create((SimpleList.View)actionsContainer.getElement().cast(), (Element)actionsContainer.getElement(), itemHolder, languageServerResources.quickOpenListCss(), listItemRenderer, eventDelegate); @@ -221,7 +216,7 @@ public void setModel(QuickOpenModel model) { layoutPanel.setWidgetHidden(actionsPanel, false); layoutPanel.setHeight("200px"); - if(!nameField.getValue().isEmpty()){ + if (!nameField.getValue().isEmpty()) { list.getSelectionModel().setSelectedItem(0); run(list.getSelectionModel().getSelectedItem(), false); } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/registry/LanguageServerRegistry.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/registry/LanguageServerRegistry.java index 2368104a946..6312e297d84 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/registry/LanguageServerRegistry.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/registry/LanguageServerRegistry.java @@ -10,19 +10,15 @@ *******************************************************************************/ package org.eclipse.che.plugin.languageserver.ide.registry; -import io.typefox.lsapi.InitializeResult; -import io.typefox.lsapi.ServerCapabilities; - import com.google.gwt.core.client.Callback; 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.ProjectExtensionKey; -import org.eclipse.che.api.languageserver.shared.event.LanguageServerInitializeEventDto; -import org.eclipse.che.api.languageserver.shared.lsapi.InitializeResultDTO; +import org.eclipse.che.api.languageserver.shared.event.LanguageServerInitializeEvent; +import org.eclipse.che.api.languageserver.shared.model.ExtendedInitializeResult; import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; -import org.eclipse.che.api.languageserver.shared.model.impl.InitializeResultImpl; import org.eclipse.che.api.promises.client.Operation; import org.eclipse.che.api.promises.client.OperationException; import org.eclipse.che.api.promises.client.Promise; @@ -40,6 +36,7 @@ import org.eclipse.che.ide.websocket.rest.SubscriptionHandler; import org.eclipse.che.ide.websocket.rest.Unmarshallable; import org.eclipse.che.plugin.languageserver.ide.service.LanguageServerRegistryServiceClient; +import org.eclipse.lsp4j.ServerCapabilities; import java.util.HashMap; import java.util.List; @@ -56,8 +53,8 @@ public class LanguageServerRegistry { private final EventBus eventBus; private final LanguageServerRegistryServiceClient client; - private final Map projectToInitResult; - private final Map> callbackMap; + private final Map projectToInitResult; + private final Map> callbackMap; @Inject public LanguageServerRegistry(EventBus eventBus, @@ -72,19 +69,19 @@ public LanguageServerRegistry(EventBus eventBus, * Registers language server description and capabilities. */ protected void register(String projectPath, LanguageDescription languageDescription, ServerCapabilities capabilities) { - InitializeResult initializeResult = new InitializeResultImpl(capabilities, languageDescription); + ExtendedInitializeResult initializeResult = new ExtendedInitializeResult(projectPath, capabilities, languageDescription); for (String ext : languageDescription.getFileExtensions()) { ProjectExtensionKey key = createProjectKey(projectPath, ext); projectToInitResult.put(key, initializeResult); if (callbackMap.containsKey(key)) { - Callback callback = callbackMap.remove(key); + Callback callback = callbackMap.remove(key); callback.onSuccess(initializeResult); } } } - public Promise getOrInitializeServer(String projectPath, String ext, String filePath) { + public Promise getOrInitializeServer(String projectPath, String ext, String filePath) { final ProjectExtensionKey key = createProjectKey(projectPath, ext); if (projectToInitResult.containsKey(key)) { return Promises.resolve(projectToInitResult.get(key)); @@ -92,9 +89,9 @@ public Promise getOrInitializeServer(String projectPath, Strin //call initialize service client.initializeServer(filePath); //wait for response - return CallbackPromiseHelper.createFromCallback(new CallbackPromiseHelper.Call() { + return CallbackPromiseHelper.createFromCallback(new CallbackPromiseHelper.Call() { @Override - public void makeCall(Callback callback) { + public void makeCall(Callback callback) { callbackMap.put(key, callback); } }); @@ -106,12 +103,12 @@ protected void registerAllServers() { eventBus.addHandler(WsAgentStateEvent.TYPE, new WsAgentStateHandler() { @Override public void onWsAgentStarted(WsAgentStateEvent event) { - Promise> registeredLanguages = client.getRegisteredLanguages(); + Promise> registeredLanguages = client.getRegisteredLanguages(); - registeredLanguages.then(new Operation>() { + registeredLanguages.then(new Operation>() { @Override - public void apply(List initialResults) throws OperationException { - for (InitializeResultDTO initializeResultDTO : initialResults) { + public void apply(List initialResults) throws OperationException { + for (ExtendedInitializeResult initializeResultDTO : initialResults) { for (LanguageDescription languageDescription : initializeResultDTO.getSupportedLanguages()) { register(initializeResultDTO.getProject(), languageDescription, @@ -123,7 +120,8 @@ public void apply(List initialResults) throws OperationExce } @Override - public void onWsAgentStopped(WsAgentStateEvent event) { } + public void onWsAgentStopped(WsAgentStateEvent event) { + } }); } @@ -136,13 +134,13 @@ protected void subscribeToInitializeEvent(final DtoUnmarshallerFactory unmarshal @Override public void onWsAgentStarted(WsAgentStateEvent event) { MessageBus messageBus = messageBusProvider.getMachineMessageBus(); - Unmarshallable unmarshaller = - unmarshallerFactory.newWSUnmarshaller(LanguageServerInitializeEventDto.class); + Unmarshallable unmarshaller = + unmarshallerFactory.newWSUnmarshaller(LanguageServerInitializeEvent.class); try { - messageBus.subscribe("languageserver", new SubscriptionHandler(unmarshaller) { + messageBus.subscribe("languageserver", new SubscriptionHandler(unmarshaller) { @Override - protected void onMessageReceived(LanguageServerInitializeEventDto initializeEvent) { + protected void onMessageReceived(LanguageServerInitializeEvent initializeEvent) { register(initializeEvent.getProjectPath(), initializeEvent.getSupportedLanguages(), initializeEvent.getServerCapabilities()); diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/LanguageServerRegistryServiceClient.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/LanguageServerRegistryServiceClient.java index b12caffcd13..fbde369eb63 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/LanguageServerRegistryServiceClient.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/LanguageServerRegistryServiceClient.java @@ -12,8 +12,8 @@ import com.google.inject.Inject; -import org.eclipse.che.api.languageserver.shared.lsapi.InitializeResultDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO; +import org.eclipse.che.api.languageserver.shared.model.ExtendedInitializeResult; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.rest.AsyncRequestFactory; @@ -33,8 +33,8 @@ public class LanguageServerRegistryServiceClient { public static final String BASE_URI = "/languageserver"; private final DtoUnmarshallerFactory unmarshallerFactory; - private final AsyncRequestFactory asyncRequestFactory; - private final AppContext appContext; + private final AsyncRequestFactory asyncRequestFactory; + private final AppContext appContext; @Inject public LanguageServerRegistryServiceClient(DtoUnmarshallerFactory unmarshallerFactory, @@ -48,21 +48,21 @@ public LanguageServerRegistryServiceClient(DtoUnmarshallerFactory unmarshallerFa /** * @return all supported languages */ - public Promise> getSupportedLanguages() { + public Promise> getSupportedLanguages() { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + BASE_URI + "/supported"; return asyncRequestFactory.createGetRequest(requestUrl) .header(ACCEPT, APPLICATION_JSON) - .send(unmarshallerFactory.newListUnmarshaller(LanguageDescriptionDTO.class)); + .send(unmarshallerFactory.newListUnmarshaller(LanguageDescription.class)); } /** * @return all registered languages */ - public Promise> getRegisteredLanguages() { + public Promise> getRegisteredLanguages() { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + BASE_URI + "/registered"; return asyncRequestFactory.createGetRequest(requestUrl) .header(ACCEPT, APPLICATION_JSON) - .send(unmarshallerFactory.newListUnmarshaller(InitializeResultDTO.class)); + .send(unmarshallerFactory.newListUnmarshaller(ExtendedInitializeResult.class)); } public void initializeServer(String path) { diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/TextDocumentServiceClient.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/TextDocumentServiceClient.java index ee289ef4574..2a650f5b1cb 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/TextDocumentServiceClient.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/TextDocumentServiceClient.java @@ -10,34 +10,11 @@ *******************************************************************************/ package org.eclipse.che.plugin.languageserver.ide.service; -import static org.eclipse.che.ide.MimeType.APPLICATION_JSON; -import static org.eclipse.che.ide.rest.HTTPHeader.ACCEPT; -import static org.eclipse.che.ide.rest.HTTPHeader.CONTENT_TYPE; - -import java.util.List; +import com.google.inject.Inject; +import com.google.inject.Singleton; -import org.eclipse.che.api.languageserver.shared.lsapi.CodeActionParamsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.CommandDTO; -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.DidChangeTextDocumentParamsDTO; -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.DocumentFormattingParamsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.DocumentHighlightDTO; -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.DocumentSymbolParamsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.HoverDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.PublishDiagnosticsParamsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.ReferenceParamsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.ShowMessageRequestParamsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.SignatureHelpDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.SymbolInformationDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.TextEditDTO; +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.Promise; @@ -55,11 +32,33 @@ import org.eclipse.che.ide.websocket.rest.SubscriptionHandler; import org.eclipse.che.plugin.languageserver.ide.editor.PublishDiagnosticsProcessor; import org.eclipse.che.plugin.languageserver.ide.editor.ShowMessageProcessor; +import org.eclipse.lsp4j.CodeActionParams; +import org.eclipse.lsp4j.Command; +import org.eclipse.lsp4j.CompletionItem; +import org.eclipse.lsp4j.DidChangeTextDocumentParams; +import org.eclipse.lsp4j.DidCloseTextDocumentParams; +import org.eclipse.lsp4j.DidOpenTextDocumentParams; +import org.eclipse.lsp4j.DidSaveTextDocumentParams; +import org.eclipse.lsp4j.DocumentFormattingParams; +import org.eclipse.lsp4j.DocumentHighlight; +import org.eclipse.lsp4j.DocumentOnTypeFormattingParams; +import org.eclipse.lsp4j.DocumentRangeFormattingParams; +import org.eclipse.lsp4j.DocumentSymbolParams; +import org.eclipse.lsp4j.Hover; +import org.eclipse.lsp4j.Location; +import org.eclipse.lsp4j.PublishDiagnosticsParams; +import org.eclipse.lsp4j.ReferenceParams; +import org.eclipse.lsp4j.ShowMessageRequestParams; +import org.eclipse.lsp4j.SignatureHelp; +import org.eclipse.lsp4j.SymbolInformation; +import org.eclipse.lsp4j.TextDocumentPositionParams; +import org.eclipse.lsp4j.TextEdit; -import com.google.inject.Inject; -import com.google.inject.Singleton; +import java.util.List; -import io.typefox.lsapi.CompletionItem; +import static org.eclipse.che.ide.MimeType.APPLICATION_JSON; +import static org.eclipse.che.ide.rest.HTTPHeader.ACCEPT; +import static org.eclipse.che.ide.rest.HTTPHeader.CONTENT_TYPE; /** @@ -105,9 +104,9 @@ public void apply(MessageBus messageBus) throws OperationException { * @param position * @return */ - public Promise completion(TextDocumentPositionParamsDTO position) { + public Promise completion(TextDocumentPositionParams position) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/completion"; - Unmarshallable unmarshaller = unmarshallerFactory.newUnmarshaller(CompletionListDTO.class); + Unmarshallable unmarshaller = unmarshallerFactory.newUnmarshaller(ExtendedCompletionList.class); return asyncRequestFactory.createPostRequest(requestUrl, null).header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON).data(((JsonSerializable)position).toJson()).send(unmarshaller); } @@ -118,9 +117,9 @@ public Promise completion(TextDocumentPositionParamsDTO posit * @param completionItem * @return */ - public Promise resolveCompletionItem(CompletionItemDTO completionItem) { + public Promise resolveCompletionItem(CompletionItem completionItem) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/completionItem/resolve"; - Unmarshallable unmarshaller = unmarshallerFactory.newUnmarshaller(CompletionItemDTO.class); + Unmarshallable unmarshaller = unmarshallerFactory.newUnmarshaller(ExtendedCompletionItem.class); return asyncRequestFactory.createPostRequest(requestUrl, completionItem) .header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON).send(unmarshaller); @@ -132,9 +131,9 @@ public Promise resolveCompletionItem(CompletionItemDTO comple * @param params * @return */ - public Promise> documentSymbol(DocumentSymbolParamsDTO params) { + public Promise> documentSymbol(DocumentSymbolParams params) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/documentSymbol"; - Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(SymbolInformationDTO.class); + Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(SymbolInformation.class); return asyncRequestFactory.createPostRequest(requestUrl, params) .header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON) @@ -147,9 +146,9 @@ public Promise> documentSymbol(DocumentSymbolParamsDT * @param params * @return */ - public Promise> references(ReferenceParamsDTO params) { + public Promise> references(ReferenceParams params) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/references"; - Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(LocationDTO.class); + Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(Location.class); return asyncRequestFactory.createPostRequest(requestUrl, params) .header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON) @@ -162,9 +161,9 @@ public Promise> references(ReferenceParamsDTO params) { * @param params * @return */ - public Promise> definition(TextDocumentPositionParamsDTO params) { + public Promise> definition(TextDocumentPositionParams params) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/definition"; - Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(LocationDTO.class); + Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(Location.class); return asyncRequestFactory.createPostRequest(requestUrl, params) .header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON) @@ -177,9 +176,9 @@ public Promise> definition(TextDocumentPositionParamsDTO param * @param params * @return */ - public Promise hover(TextDocumentPositionParamsDTO params) { + public Promise hover(TextDocumentPositionParams params) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/hover"; - Unmarshallable unmarshaller = unmarshallerFactory.newUnmarshaller(HoverDTO.class); + Unmarshallable unmarshaller = unmarshallerFactory.newUnmarshaller(Hover.class); return asyncRequestFactory.createPostRequest(requestUrl, params) .header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON) @@ -192,9 +191,9 @@ public Promise hover(TextDocumentPositionParamsDTO params) { * @param params * @return */ - public Promise signatureHelp(TextDocumentPositionParamsDTO params) { + public Promise signatureHelp(TextDocumentPositionParams params) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/signatureHelp"; - Unmarshallable unmarshaller = unmarshallerFactory.newUnmarshaller(SignatureHelpDTO.class); + Unmarshallable unmarshaller = unmarshallerFactory.newUnmarshaller(SignatureHelp.class); return asyncRequestFactory.createPostRequest(requestUrl, params) .header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON) @@ -207,9 +206,9 @@ public Promise signatureHelp(TextDocumentPositionParamsDTO par * @param params * @return */ - public Promise> formatting(DocumentFormattingParamsDTO params) { + public Promise> formatting(DocumentFormattingParams params) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/formatting"; - Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(TextEditDTO.class); + Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(TextEdit.class); return asyncRequestFactory.createPostRequest(requestUrl, params) .header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON) @@ -222,9 +221,9 @@ public Promise> formatting(DocumentFormattingParamsDTO params) * @param params * @return */ - public Promise> rangeFormatting(DocumentRangeFormattingParamsDTO params) { + public Promise> rangeFormatting(DocumentRangeFormattingParams params) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/rangeFormatting"; - Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(TextEditDTO.class); + Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(TextEdit.class); return asyncRequestFactory.createPostRequest(requestUrl, params) .header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON) @@ -237,9 +236,9 @@ public Promise> rangeFormatting(DocumentRangeFormattingParamsD * @param params * @return */ - public Promise> onTypeFormatting(DocumentOnTypeFormattingParamsDTO params) { + public Promise> onTypeFormatting(DocumentOnTypeFormattingParams params) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/onTypeFormatting"; - Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(TextEditDTO.class); + Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(TextEdit.class); return asyncRequestFactory.createPostRequest(requestUrl, params) .header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON) @@ -252,7 +251,7 @@ public Promise> onTypeFormatting(DocumentOnTypeFormattingParam * @param change * @return */ - public void didChange(DidChangeTextDocumentParamsDTO change) { + public void didChange(DidChangeTextDocumentParams change) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/didChange"; asyncRequestFactory.createPostRequest(requestUrl, null).header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON).data(((JsonSerializable)change).toJson()).send(); @@ -264,7 +263,7 @@ public void didChange(DidChangeTextDocumentParamsDTO change) { * @param openEvent * @return */ - public void didOpen(DidOpenTextDocumentParamsDTO openEvent) { + public void didOpen(DidOpenTextDocumentParams openEvent) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/didOpen"; asyncRequestFactory.createPostRequest(requestUrl, null).header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON).data(((JsonSerializable)openEvent).toJson()).send(); @@ -276,7 +275,7 @@ public void didOpen(DidOpenTextDocumentParamsDTO openEvent) { * @param closeEvent * @return */ - public void didClose(DidCloseTextDocumentParamsDTO closeEvent) { + public void didClose(DidCloseTextDocumentParams closeEvent) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/didClose"; asyncRequestFactory.createPostRequest(requestUrl, null).header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON).data(((JsonSerializable)closeEvent).toJson()).send(); @@ -288,44 +287,47 @@ public void didClose(DidCloseTextDocumentParamsDTO closeEvent) { * @param saveEvent * @return */ - public void didSave(DidSaveTextDocumentParamsDTO saveEvent) { + public void didSave(DidSaveTextDocumentParams saveEvent) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/didSave"; asyncRequestFactory.createPostRequest(requestUrl, null).header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON).data(((JsonSerializable)saveEvent).toJson()).send(); } - + /** - * GWT client implementation of {@link io.typefox.lsapi.TextDocumentService#documentHighlight(io.typefox.lsapi.TextDocumentPositionParams position)} + * GWT client implementation of {@link io.typefox.lsapi.TextDocumentService#documentHighlight(io.typefox.lsapi.TextDocumentPositionParams + * position)} * * @param position * @return a {@link Promise} of an array of {@link DocumentHighlightDTO} which will be computed by the language server. */ - public Promise documentHighlight(TextDocumentPositionParamsDTO position) { + public Promise documentHighlight(TextDocumentPositionParams position) { final String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/documentHighlight"; - final Unmarshallable unmarshaller = unmarshallerFactory.newUnmarshaller(DocumentHighlightDTO.class); + final Unmarshallable unmarshaller = unmarshallerFactory.newUnmarshaller(DocumentHighlight.class); return asyncRequestFactory.createPostRequest(requestUrl, null).header(ACCEPT, APPLICATION_JSON) - .header(CONTENT_TYPE, APPLICATION_JSON).data(((JsonSerializable)position).toJson()).send(unmarshaller); + .header(CONTENT_TYPE, APPLICATION_JSON).data(((JsonSerializable)position).toJson()).send(unmarshaller); } - - public Promise> codeAction(CodeActionParamsDTO params) { + + + + public Promise> codeAction(CodeActionParams params) { final String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/textDocument/codeAction"; - final Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(CommandDTO.class); + final Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(Command.class); return asyncRequestFactory.createPostRequest(requestUrl, null).header(ACCEPT, APPLICATION_JSON) - .header(CONTENT_TYPE, APPLICATION_JSON).data(((JsonSerializable)params).toJson()).send(unmarshaller); + .header(CONTENT_TYPE, APPLICATION_JSON).data(((JsonSerializable)params).toJson()).send(unmarshaller); } /** - * Subscribes to websocket for 'textDocument/publishDiagnostics' notifications. + * Subscribes to websocket for 'textDocument/publishDiagnostics' notifications. */ private void subscribeToPublishDiagnostics(final MessageBus messageBus) { - org.eclipse.che.ide.websocket.rest.Unmarshallable unmarshaller = - unmarshallerFactory.newWSUnmarshaller(PublishDiagnosticsParamsDTO.class); + org.eclipse.che.ide.websocket.rest.Unmarshallable unmarshaller = + unmarshallerFactory.newWSUnmarshaller(PublishDiagnosticsParams.class); try { messageBus.subscribe("languageserver/textDocument/publishDiagnostics", - new SubscriptionHandler(unmarshaller) { + new SubscriptionHandler(unmarshaller) { @Override - protected void onMessageReceived(PublishDiagnosticsParamsDTO statusEvent) { + protected void onMessageReceived(PublishDiagnosticsParams statusEvent) { publishDiagnosticsProcessor.processDiagnostics(statusEvent); } @@ -341,17 +343,17 @@ protected void onErrorReceived(Throwable exception) { } /** - * Subscribes to websocket for 'window/showMessage' notifications. + * Subscribes to websocket for 'window/showMessage' notifications. */ private void subscribeToShowMessages(final MessageBus messageBus) { - final org.eclipse.che.ide.websocket.rest.Unmarshallable unmarshaller = - unmarshallerFactory.newWSUnmarshaller(ShowMessageRequestParamsDTO.class); + final org.eclipse.che.ide.websocket.rest.Unmarshallable unmarshaller = + unmarshallerFactory.newWSUnmarshaller(ShowMessageRequestParams.class); try { messageBus.subscribe("languageserver/window/showMessage", - new SubscriptionHandler(unmarshaller) { + new SubscriptionHandler(unmarshaller) { @Override - protected void onMessageReceived(ShowMessageRequestParamsDTO showMessageRequestParamsDTO) { - showMessageProcessor.processNotification(showMessageRequestParamsDTO); + protected void onMessageReceived(ShowMessageRequestParams ShowMessageRequestParams) { + showMessageProcessor.processNotification(ShowMessageRequestParams); } @Override diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/WorkspaceServiceClient.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/WorkspaceServiceClient.java index 0bdbfc1f6e0..9207267ed69 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/WorkspaceServiceClient.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/service/WorkspaceServiceClient.java @@ -13,13 +13,14 @@ import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.api.languageserver.shared.lsapi.SymbolInformationDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.WorkspaceSymbolParamsDTO; import org.eclipse.che.api.promises.client.Promise; import org.eclipse.che.ide.api.app.AppContext; import org.eclipse.che.ide.rest.AsyncRequestFactory; import org.eclipse.che.ide.rest.DtoUnmarshallerFactory; import org.eclipse.che.ide.rest.Unmarshallable; +import org.eclipse.lsp4j.SymbolInformation; +import org.eclipse.lsp4j.WorkspaceSymbolParams; + import java.util.List; import static org.eclipse.che.ide.MimeType.APPLICATION_JSON; @@ -32,15 +33,15 @@ @Singleton public class WorkspaceServiceClient { private final DtoUnmarshallerFactory unmarshallerFactory; - private final AppContext appContext; - private final AsyncRequestFactory asyncRequestFactory; - - + private final AppContext appContext; + private final AsyncRequestFactory asyncRequestFactory; + + @Inject public WorkspaceServiceClient(final DtoUnmarshallerFactory unmarshallerFactory, final AppContext appContext, final AsyncRequestFactory asyncRequestFactory - ) { + ) { this.unmarshallerFactory = unmarshallerFactory; this.appContext = appContext; this.asyncRequestFactory = asyncRequestFactory; @@ -52,13 +53,13 @@ public WorkspaceServiceClient(final DtoUnmarshallerFactory unmarshallerFactory, * @param params * @return */ - public Promise> symbol(WorkspaceSymbolParamsDTO params) { + public Promise> symbol(WorkspaceSymbolParams params) { String requestUrl = appContext.getDevMachine().getWsAgentBaseUrl() + "/languageserver/workspace/symbol"; - Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(SymbolInformationDTO.class); + Unmarshallable> unmarshaller = unmarshallerFactory.newListUnmarshaller(SymbolInformation.class); return asyncRequestFactory.createPostRequest(requestUrl, params) .header(ACCEPT, APPLICATION_JSON) .header(CONTENT_TYPE, APPLICATION_JSON) .send(unmarshaller); } - + } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/util/DtoBuildHelper.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/util/DtoBuildHelper.java index f31b70e1e51..56c84174784 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/util/DtoBuildHelper.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/util/DtoBuildHelper.java @@ -13,12 +13,12 @@ import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentIdentifierDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; import org.eclipse.che.ide.api.editor.document.Document; import org.eclipse.che.ide.api.editor.text.TextPosition; import org.eclipse.che.ide.dto.DtoFactory; +import org.eclipse.lsp4j.Position; +import org.eclipse.lsp4j.TextDocumentIdentifier; +import org.eclipse.lsp4j.TextDocumentPositionParams; /** * Helps to create LS DTO objects @@ -34,34 +34,34 @@ public DtoBuildHelper(DtoFactory dtoFactory) { this.dtoFactory = dtoFactory; } - public TextDocumentPositionParamsDTO createTDPP(Document document, int cursorOffset) { - TextDocumentPositionParamsDTO paramsDTO = dtoFactory.createDto(TextDocumentPositionParamsDTO.class); - TextDocumentIdentifierDTO identifierDTO = dtoFactory.createDto(TextDocumentIdentifierDTO.class); + public TextDocumentPositionParams createTDPP(Document document, int cursorOffset) { + TextDocumentPositionParams paramsDTO = dtoFactory.createDto(TextDocumentPositionParams.class); + TextDocumentIdentifier identifierDTO = dtoFactory.createDto(TextDocumentIdentifier.class); identifierDTO.setUri(document.getFile().getLocation().toString()); - PositionDTO positionDTO = dtoFactory.createDto(PositionDTO.class); + Position Position = dtoFactory.createDto(Position.class); TextPosition position = document.getPositionFromIndex(cursorOffset); - positionDTO.setCharacter(position.getCharacter()); - positionDTO.setLine(position.getLine()); + Position.setCharacter(position.getCharacter()); + Position.setLine(position.getLine()); paramsDTO.setUri(document.getFile().getLocation().toString()); paramsDTO.setTextDocument(identifierDTO); - paramsDTO.setPosition(positionDTO); + paramsDTO.setPosition(Position); return paramsDTO; } - public TextDocumentPositionParamsDTO createTDPP(Document document, TextPosition position) { - TextDocumentPositionParamsDTO paramsDTO = dtoFactory.createDto(TextDocumentPositionParamsDTO.class); - TextDocumentIdentifierDTO identifierDTO = dtoFactory.createDto(TextDocumentIdentifierDTO.class); + public TextDocumentPositionParams createTDPP(Document document, TextPosition position) { + TextDocumentPositionParams paramsDTO = dtoFactory.createDto(TextDocumentPositionParams.class); + TextDocumentIdentifier identifierDTO = dtoFactory.createDto(TextDocumentIdentifier.class); identifierDTO.setUri(document.getFile().getLocation().toString()); - PositionDTO positionDTO = dtoFactory.createDto(PositionDTO.class); - positionDTO.setCharacter(position.getCharacter()); - positionDTO.setLine(position.getLine()); + Position Position = dtoFactory.createDto(Position.class); + Position.setCharacter(position.getCharacter()); + Position.setLine(position.getLine()); paramsDTO.setUri(document.getFile().getLocation().toString()); paramsDTO.setTextDocument(identifierDTO); - paramsDTO.setPosition(positionDTO); + paramsDTO.setPosition(Position); return paramsDTO; } } diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/util/OpenFileInEditorHelper.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/util/OpenFileInEditorHelper.java index 76a6e4d48f5..1da2583bd34 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/util/OpenFileInEditorHelper.java +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/java/org/eclipse/che/plugin/languageserver/ide/util/OpenFileInEditorHelper.java @@ -32,6 +32,7 @@ /** * Util class, helps to open file by path in editor + * * @author Evgen Vidolob */ @Singleton @@ -39,7 +40,7 @@ public class OpenFileInEditorHelper { private final EditorAgent editorAgent; private final ProjectExplorerPresenter projectExplorer; - private final AppContext appContext; + private final AppContext appContext; @Inject public OpenFileInEditorHelper(EditorAgent editorAgent, @@ -73,7 +74,7 @@ private Function, Optional> openNode(final TextRange select return new Function, Optional>() { @Override public Optional apply(Optional node) { - if(node.isPresent()){ + if (node.isPresent()) { openFile(node.get(), selectionRange); } return node; diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/api/languageserver/LanguageServer.gwt.xml b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/api/languageserver/LanguageServer.gwt.xml index 5e795f32c07..8f0cda72169 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/api/languageserver/LanguageServer.gwt.xml +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/api/languageserver/LanguageServer.gwt.xml @@ -15,5 +15,5 @@ - + diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/plugin/languageserver/LanguageServer.gwt.xml b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/plugin/languageserver/LanguageServer.gwt.xml index f3c27d2499a..ed4207242af 100644 --- a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/plugin/languageserver/LanguageServer.gwt.xml +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/che/plugin/languageserver/LanguageServer.gwt.xml @@ -22,10 +22,9 @@ - + - - + diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/lsp4j/Lsp4j.gwt.xml b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/lsp4j/Lsp4j.gwt.xml new file mode 100644 index 00000000000..94204b04d14 --- /dev/null +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/lsp4j/Lsp4j.gwt.xml @@ -0,0 +1,18 @@ + + + + + + + diff --git a/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/lsp4j/jsonrpc/messages/Either.java b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/lsp4j/jsonrpc/messages/Either.java new file mode 100644 index 00000000000..407b9aea0f8 --- /dev/null +++ b/plugins/plugin-languageserver/che-plugin-languageserver-ide/src/main/resources/org/eclipse/lsp4j/jsonrpc/messages/Either.java @@ -0,0 +1,52 @@ +package org.eclipse.lsp4j.jsonrpc.messages; + +import org.eclipse.lsp4j.jsonrpc.validation.NonNull; + +/** + * An either type maps union types in protocol specifications. + * + * @param + * @param + */ +public class Either { + + private final L left; + private final R right; + + protected Either(L left, R right) { + super(); + this.left = left; + this.right = right; + } + + public static Either forLeft(@NonNull L left) { + return new Either(left, null); + } + + public static Either forRight(@NonNull R right) { + return new Either(null, right); + } + + public L getLeft() { + return left; + } + + public R getRight() { + return right; + } + + public boolean isLeft() { + return left != null; + } + + public boolean isRight() { + return right != null; + } + + public String toString() { + StringBuilder builder = new StringBuilder("Either [").append("\n"); + builder.append(" left = ").append(left).append("\n"); + builder.append(" right = ").append(right).append("\n"); + return builder.append("]").toString(); + } +} diff --git a/plugins/plugin-php/che-plugin-php-lang-server/pom.xml b/plugins/plugin-php/che-plugin-php-lang-server/pom.xml index dc39290da36..433d1724200 100644 --- a/plugins/plugin-php/che-plugin-php-lang-server/pom.xml +++ b/plugins/plugin-php/che-plugin-php-lang-server/pom.xml @@ -32,10 +32,6 @@ com.google.inject.extensions guice-multibindings - - io.typefox.lsapi - io.typefox.lsapi.services - org.eclipse.che.core che-core-api-core @@ -60,5 +56,13 @@ org.eclipse.che.plugin che-plugin-php-lang-shared + + org.eclipse.lsp4j + org.eclipse.lsp4j + + + org.eclipse.lsp4j + org.eclipse.lsp4j.jsonrpc + diff --git a/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/languageserver/PhpLanguageServerLauncher.java b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/languageserver/PhpLanguageServerLauncher.java index 76a14ce1d84..eec532b6d93 100644 --- a/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/languageserver/PhpLanguageServerLauncher.java +++ b/plugins/plugin-php/che-plugin-php-lang-server/src/main/java/org/eclipse/che/plugin/php/languageserver/PhpLanguageServerLauncher.java @@ -10,15 +10,15 @@ *******************************************************************************/ package org.eclipse.che.plugin.php.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,20 +35,11 @@ @Singleton public class PhpLanguageServerLauncher extends LanguageServerLauncherTemplate { private static final String LANGUAGE_ID = "php"; - private static final String[] EXTENSIONS = new String[] {"php"}; - private static final String[] MIME_TYPES = new String[] {"text/x-php"}; - + private static final String[] EXTENSIONS = new String[]{"php"}; + private static final String[] MIME_TYPES = new String[]{"text/x-php"}; + private static final LanguageDescription description; private final Path launchScript; - private static final LanguageDescriptionImpl description; - - static { - description = new LanguageDescriptionImpl(); - description.setFileExtensions(asList(EXTENSIONS)); - description.setLanguageId(LANGUAGE_ID); - description.setMimeTypes(asList(MIME_TYPES)); - } - @Inject public PhpLanguageServerLauncher() { this.launchScript = Paths.get(System.getenv("HOME"), "che/ls-php/launch.sh"); @@ -64,10 +55,11 @@ public boolean isAbleToLaunch() { return Files.exists(launchScript); } - 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(); } protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException { @@ -80,4 +72,11 @@ protected Process startLanguageServerProcess(String projectPath) throws Language throw new LanguageServerException("Can't start PHP 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-python/che-plugin-python-lang-server/pom.xml b/plugins/plugin-python/che-plugin-python-lang-server/pom.xml index d784a920385..8d0a36789ed 100644 --- a/plugins/plugin-python/che-plugin-python-lang-server/pom.xml +++ b/plugins/plugin-python/che-plugin-python-lang-server/pom.xml @@ -32,10 +32,6 @@ com.google.inject.extensions guice-multibindings - - io.typefox.lsapi - io.typefox.lsapi.services - javax.inject javax.inject @@ -64,5 +60,13 @@ org.eclipse.che.plugin che-plugin-python-lang-shared + + org.eclipse.lsp4j + org.eclipse.lsp4j + + + org.eclipse.lsp4j + org.eclipse.lsp4j.jsonrpc + diff --git a/plugins/plugin-python/che-plugin-python-lang-server/src/main/java/org/eclipse/che/plugin/python/languageserver/PythonLanguageSeverLauncher.java b/plugins/plugin-python/che-plugin-python-lang-server/src/main/java/org/eclipse/che/plugin/python/languageserver/PythonLanguageSeverLauncher.java index ab268c4813d..113ad214d05 100644 --- a/plugins/plugin-python/che-plugin-python-lang-server/src/main/java/org/eclipse/che/plugin/python/languageserver/PythonLanguageSeverLauncher.java +++ b/plugins/plugin-python/che-plugin-python-lang-server/src/main/java/org/eclipse/che/plugin/python/languageserver/PythonLanguageSeverLauncher.java @@ -10,13 +10,13 @@ *******************************************************************************/ package org.eclipse.che.plugin.python.languageserver; -import io.typefox.lsapi.services.LanguageServer; -import io.typefox.lsapi.services.json.JsonBasedLanguageServer; 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.plugin.python.shared.ProjectAttributes; +import org.eclipse.lsp4j.jsonrpc.Launcher; +import org.eclipse.lsp4j.services.LanguageClient; +import org.eclipse.lsp4j.services.LanguageServer; import javax.inject.Singleton; import java.io.IOException; @@ -32,19 +32,12 @@ @Singleton public class PythonLanguageSeverLauncher extends LanguageServerLauncherTemplate { - private static final String[] EXTENSIONS = new String[] {ProjectAttributes.PYTHON_EXT}; - private static final String[] MIME_TYPES = new String[] {"text/x-python"}; - private static final LanguageDescriptionImpl description; + private static final String[] EXTENSIONS = new String[]{ProjectAttributes.PYTHON_EXT}; + private static final String[] MIME_TYPES = new String[]{"text/x-python"}; + private static final LanguageDescription description; private final Path launchScript; - static { - description = new LanguageDescriptionImpl(); - description.setFileExtensions(asList(EXTENSIONS)); - description.setLanguageId(ProjectAttributes.PYTHON_ID); - description.setMimeTypes(Arrays.asList(MIME_TYPES)); - } - public PythonLanguageSeverLauncher() { launchScript = Paths.get(System.getenv("HOME"), "che/ls-python/launch.sh"); } @@ -73,9 +66,18 @@ protected Process startLanguageServerProcess(String projectPath) throws Language } @Override - protected LanguageServer connectToLanguageServer(Process languageServerProcess) throws LanguageServerException { - 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(); + } + + static { + description = new LanguageDescription(); + description.setFileExtensions(asList(EXTENSIONS)); + description.setLanguageId(ProjectAttributes.PYTHON_ID); + description.setMimeTypes(Arrays.asList(MIME_TYPES)); } } diff --git a/plugins/plugin-web/che-plugin-web-ext-server/pom.xml b/plugins/plugin-web/che-plugin-web-ext-server/pom.xml index c6e2a119123..b82499a70a2 100644 --- a/plugins/plugin-web/che-plugin-web-ext-server/pom.xml +++ b/plugins/plugin-web/che-plugin-web-ext-server/pom.xml @@ -28,10 +28,6 @@ com.google.inject.extensions guice-multibindings - - io.typefox.lsapi - io.typefox.lsapi.services - javax.inject javax.inject @@ -56,6 +52,14 @@ org.eclipse.che.plugin che-plugin-web-ext-shared + + org.eclipse.lsp4j + org.eclipse.lsp4j + + + org.eclipse.lsp4j + org.eclipse.lsp4j.jsonrpc + org.testng testng diff --git a/plugins/plugin-web/che-plugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/typescript/TSLSLauncher.java b/plugins/plugin-web/che-plugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/typescript/TSLSLauncher.java index f62622b0b8f..d4a87f90be8 100644 --- a/plugins/plugin-web/che-plugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/typescript/TSLSLauncher.java +++ b/plugins/plugin-web/che-plugin-web-ext-server/src/main/java/org/eclipse/che/plugin/web/typescript/TSLSLauncher.java @@ -10,14 +10,13 @@ *******************************************************************************/ package org.eclipse.che.plugin.web.typescript; -import io.typefox.lsapi.services.LanguageServer; -import io.typefox.lsapi.services.json.JsonBasedLanguageServer; - 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.plugin.web.shared.Constants; +import org.eclipse.lsp4j.jsonrpc.Launcher; +import org.eclipse.lsp4j.services.LanguageClient; +import org.eclipse.lsp4j.services.LanguageServer; import javax.inject.Singleton; import java.io.IOException; @@ -27,19 +26,20 @@ import static java.util.Arrays.asList; + /** * Launcher for TypeScript Language Server */ @Singleton public class TSLSLauncher extends LanguageServerLauncherTemplate { - private static final String[] EXTENSIONS = new String[] {Constants.TS_EXT}; - private static final String[] MIME_TYPES = new String[] {Constants.TS_MIME_TYPE}; - private static final LanguageDescriptionImpl description; + private static final String[] EXTENSIONS = new String[]{Constants.TS_EXT}; + private static final String[] MIME_TYPES = new String[]{Constants.TS_MIME_TYPE}; + private static final LanguageDescription description; private final Path launchScript; public TSLSLauncher() { - launchScript = Paths.get(System.getenv("HOME"), "che/ls-typescript/launch.sh"); + launchScript = Paths.get(System.getenv("HOME"), "che/ls-typescript/launch.sh"); } @Override @@ -55,10 +55,11 @@ protected Process startLanguageServerProcess(String projectPath) throws Language } @Override - protected LanguageServer connectToLanguageServer(Process languageServerProcess) throws LanguageServerException { - 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 @@ -72,7 +73,7 @@ public boolean isAbleToLaunch() { } static { - description = new LanguageDescriptionImpl(); + description = new LanguageDescription(); description.setFileExtensions(asList(EXTENSIONS)); description.setLanguageId(Constants.TS_LANG); description.setMimeTypes(asList(MIME_TYPES)); diff --git a/pom.xml b/pom.xml index 7b6de292aa9..fc2ced22411 100644 --- a/pom.xml +++ b/pom.xml @@ -257,6 +257,11 @@ che-core-api-languageserver ${che.version} + + org.eclipse.che.core + che-core-api-languageserver-maven-plugin + ${che.version} + org.eclipse.che.core che-core-api-languageserver-shared diff --git a/wsagent/che-core-api-languageserver-maven-plugin/pom.xml b/wsagent/che-core-api-languageserver-maven-plugin/pom.xml new file mode 100644 index 00000000000..b3f15dc26aa --- /dev/null +++ b/wsagent/che-core-api-languageserver-maven-plugin/pom.xml @@ -0,0 +1,84 @@ + + + + 4.0.0 + + che-agent-parent + org.eclipse.che.core + 5.9.0-SNAPSHOT + + che-core-api-languageserver-maven-plugin + maven-plugin + Che Core :: API :: Language Server Maven Plugin + + false + + + + com.google.guava + guava + + + org.apache.maven + maven-plugin-api + + + org.eclipse.lsp4j + org.eclipse.lsp4j.jsonrpc + + + org.reflections + reflections + + + org.apache.maven.plugin-tools + maven-plugin-annotations + provided + + + + + + com.mycila + license-maven-plugin + + + **/generator/** + + + + + org.apache.maven.plugins + maven-plugin-plugin + + + mojo-descriptor + + descriptor + + + + help-goal + + helpmojo + + + + + true + + + + + diff --git a/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ClientDtoGenerator.java b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ClientDtoGenerator.java new file mode 100644 index 00000000000..c4969aecd70 --- /dev/null +++ b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ClientDtoGenerator.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * 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.generator; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; + +/** + * Generates client side dto's from lsp4j message classes and che extensions thereof. + * The classes in question must have a zero-arg constructor and standard getters/setters for all fields. + * + * @author Thomas Mäder + */ +public class ClientDtoGenerator extends DtoGenerator { + public ClientDtoGenerator() { + super(new ClientJsonImpl()); + } + + public static void main(String[] args) throws IOException { + new ClientDtoGenerator().generate(new File(args[0]), "Dtos", args[1], args[2].split(","), new String[]{}); + } + + @Override + protected void writeEnvClassAnnotations(PrintWriter out) { + out.println("@Singleton"); + out.println("@ClientDtoFactoryVisitor"); + out.println("@SuppressWarnings(\"deprecation\")"); + } + + @Override + protected void writeEnvImports(PrintWriter out) { + out.println("import org.eclipse.che.ide.dto.ClientDtoFactoryVisitor;"); + out.println("import org.eclipse.che.ide.dto.DtoFactoryVisitor;"); + out.println("import org.eclipse.che.ide.dto.DtoFactory;"); + out.println("import org.eclipse.che.ide.dto.DtoProvider;"); + out.println("import org.eclipse.che.api.languageserver.util.JsonSerializable;"); + + out.println("import com.google.inject.Singleton;"); + } + +} diff --git a/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ClientJsonImpl.java b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ClientJsonImpl.java new file mode 100644 index 00000000000..33947024ce4 --- /dev/null +++ b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ClientJsonImpl.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * 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.generator; + +import java.io.PrintWriter; + +public class ClientJsonImpl implements JsonImpl { + + @Override + public String element() { + return "JSONValue"; + } + + @Override + public String object() { + return "JSONObject"; + } + + @Override + public String array() { + return "JSONArray"; + } + + @Override + public String nullValue() { + return "JSONNull.getInstance()"; + } + + @Override + public Object string() { + return "JSONString"; + } + + @Override + public Object number() { + return "JSONNumber"; + } + + @Override + public String boolValue(String value) { + return String.format("JSONBoolean.getInstance(%1$s)", value); + } + + @Override + public String arrayValue(String jsonValName) { + return String.format("%1$s.isArray()", jsonValName); + } + + @Override + public Object objectValue(String value) { + return String.format("%1$s.isObject()", value); + } + + @Override + public String asBoolean(String valueName) { + return String.format("%1$s.isBoolean().booleanValue()", valueName); + } + + @Override + public String asDouble(String valueName) { + return String.format("%1$s.isNumber().doubleValue()", valueName); + } + + @Override + public String asString(String valueName) { + return String.format("%1$s.isString().stringValue()", valueName); + } + + @Override + public String parse(String valueName) { + return String.format("JSONParser.parseStrict(%1$s)", valueName); + } + + @Override + public String put() { + return "put"; + } + + public String add(String arrayName, String valueName) { + return String.format("%1$s.set(%1$s.size(), %2$s);", arrayName, valueName); + } + + @Override + public void iterateObject(String indent, PrintWriter out, String objectName, PropertyHandler handler) { + String keyName = objectName + "k"; + out.println(indent + String.format("for(String %1$s : %2$s.keySet()) {", keyName, objectName)); + handler.handle(keyName, String.format("%1$s.get(%2$s)", objectName, keyName)); + out.println(indent + "}"); + } + + @Override + public String isNull(String jsonValName) { + return jsonValName + ".isNull() != null"; + } + + @Override + public void writeImports(PrintWriter out) { + out.println("import com.google.gwt.json.client.JSONParser;"); + out.println("import com.google.gwt.json.client.JSONObject;"); + out.println("import com.google.gwt.json.client.JSONArray;"); + out.println("import com.google.gwt.json.client.JSONString;"); + out.println("import com.google.gwt.json.client.JSONNumber;"); + out.println("import com.google.gwt.json.client.JSONBoolean;"); + out.println("import com.google.gwt.json.client.JSONValue;"); + out.println("import com.google.gwt.json.client.JSONNull;"); + } +} diff --git a/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ConversionGenerator.java b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ConversionGenerator.java new file mode 100644 index 00000000000..5bb85ab27dd --- /dev/null +++ b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ConversionGenerator.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * 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.generator; + +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.lang.reflect.WildcardType; +import java.util.List; + +/** + * Base class for conversion generators. Subclasses are responsible for + * generating conversion code for a single property of a dto. + * + * @author Thomas Mäder + */ +public abstract class ConversionGenerator { + + protected ConversionGenerator() { + } + + protected Type containedType(Type paramType) { + if (paramType == null || !List.class.isAssignableFrom(getRawClass(paramType))) { + return null; + } + if (paramType instanceof ParameterizedType) { + ParameterizedType genericType = (ParameterizedType)paramType; + return getUpperBound(genericType.getActualTypeArguments()[0]); + } + if (paramType instanceof Class) { + Class clazz = (Class)paramType; + Type c = containedType(clazz.getGenericSuperclass()); + if (c != null) { + return c; + } + for (Type intf : clazz.getGenericInterfaces()) { + c = containedType(intf); + if (c != null) { + return c; + } + } + } + return null; + } + + private Type getUpperBound(Type type) { + if (type instanceof WildcardType) { + return ((WildcardType)type).getUpperBounds()[0]; + } + return type; + } + + protected Class getRawClass(Type type) { + if (type instanceof ParameterizedType) { + return getRawClass(((ParameterizedType)type).getRawType()); + } else if (type instanceof WildcardType) { + return getRawClass(((WildcardType)type).getUpperBounds()[0]); + } + return (Class)type; + } + + protected boolean isSimpleNumberType(Class clazz) { + return clazz == double.class || clazz == int.class || clazz == float.class || clazz == long.class; + } + + protected String getterName(Class receiverClass, Method m) { + if (boolean.class == m.getParameterTypes()[0] || Boolean.class == m.getParameterTypes()[0]) { + String root = m.getName().substring(3); + try { + return receiverClass.getMethod("is" + root, new Class[]{}).getName(); + } catch (NoSuchMethodException e) { + try { + return receiverClass.getMethod("get" + root, new Class[]{}).getName(); + } catch (NoSuchMethodException e1) { + StringBuilder b = new StringBuilder(root); + b.setCharAt(0, Character.toLowerCase(root.charAt(0))); + return b.toString(); + } + } + } + return m.getName().replaceFirst("set", "get"); + } + + protected String fieldName(Method setterMethod) { + StringBuilder name = new StringBuilder(setterMethod.getName().substring(3)); + name.setCharAt(0, Character.toLowerCase(name.charAt(0))); + return name.toString(); + } + + +} diff --git a/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/DtoGenerator.java b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/DtoGenerator.java new file mode 100644 index 00000000000..8d374fb7cf7 --- /dev/null +++ b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/DtoGenerator.java @@ -0,0 +1,311 @@ +/******************************************************************************* + * 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.generator; + +import com.google.common.base.Predicate; + +import org.reflections.Reflections; +import org.reflections.scanners.SubTypesScanner; +import org.reflections.util.ClasspathHelper; +import org.reflections.util.ConfigurationBuilder; + +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; +import java.lang.reflect.Method; +import java.net.URL; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * DtoGenerator generates che-style DTO's for lsp4j protocol classes. + * Subclasses specialize this class to generate client-side and server-side implementations. + * + * @author Thomas Mäder + */ +public abstract class DtoGenerator { + + /** + * Standard indent size to use. + */ + public static final String INDENT = " "; + + protected final JsonImpl json; + + public DtoGenerator(JsonImpl json) { + this.json = json; + } + + /** + * Return the simple class name to use for the dto class for the given class. + * + * @param clazz + * @return + */ + public static String dtoName(Class clazz) { + return clazz.getSimpleName() + "Dto"; + } + + static boolean isSetter(Class receiverClass, Method m) { + Method getter = getterFor(receiverClass, m); + return m.getName().startsWith("set") && m.getName().length() > 3 + && Character.isUpperCase(m.getName().charAt(3)) && getter != null && getter.getReturnType() == m.getParameterTypes()[0]; + } + + private static Method getterFor(Class receiverClass, Method m) { + if (m.getParameterTypes().length != 1) { + return null; + } + if (boolean.class == m.getParameterTypes()[0] || Boolean.class == m.getParameterTypes()[0]) { + String root = m.getName().substring(3); + try { + return receiverClass.getMethod("is" + root, new Class[]{}); + } catch (NoSuchMethodException e) { + try { + return receiverClass.getMethod("get" + root, new Class[]{}); + } catch (NoSuchMethodException e1) { + StringBuilder b = new StringBuilder(root); + b.setCharAt(0, Character.toLowerCase(root.charAt(0))); + try { + return receiverClass.getMethod(b.toString(), new Class[]{}); + } catch (NoSuchMethodException e3) { + return null; + } + } + } + } + try { + return receiverClass.getMethod(m.getName().replaceFirst("set", "get"), new Class[]{}); + } catch (NoSuchMethodException e) { + return null; + } + } + + /** + * Generate dto classes. + * + * @param targetFolder + * the base folder to generate code to. This is the package folder root. + * @param targetName + * the simple class name to use for the generated class + * @param targetPackage + * the package name to use for the generated class + * @param sourcePackages + * the source packages to use. THe packages must be on the class path at execution time. + * @throws IOException + */ + public void generate(File targetFolder, String targetName, String targetPackage, String[] sourcePackages, String[] classNames) + throws IOException { + File targetFile = new File(targetFolder, + targetPackage.replace('.', File.separatorChar) + File.separatorChar + targetName + ".java"); + targetFile.getParentFile().mkdirs(); + Set urls = new HashSet<>(); + for (String pkg : sourcePackages) { + urls.addAll(ClasspathHelper.forPackage(pkg)); + } + Reflections reflection = new Reflections(new ConfigurationBuilder().setUrls(urls) + .setScanners(new SubTypesScanner(false)) + .filterInputsBy(new Predicate() { + + @Override + public boolean apply(String input) { + for (String pkg : sourcePackages) { + if (input.startsWith(pkg)) { + return input.indexOf('.', pkg.length() + 1) == + input.lastIndexOf('.'); + } + } + return false; + } + })); + Set> allTypes = reflection.getSubTypesOf(Object.class); + for (String className : classNames) { + try { + allTypes.add(Class.forName(className)); + } catch (ClassNotFoundException e) { + e.printStackTrace(); + } + } + + allTypes = allTypes.stream().filter((cls) -> !cls.isInterface()).collect(Collectors.toSet()); + + try (PrintWriter out = new PrintWriter(targetFile, "utf-8")) { + + out.print("package "); + out.print(targetPackage); + out.println(";"); + + writeEnvImports(out); + + json.writeImports(out); + + out.println("import java.util.Map.Entry;"); + out.println("import java.util.ArrayList;"); + out.println("import java.util.HashMap;"); + out.println("import org.eclipse.lsp4j.jsonrpc.messages.Either;"); + out.println("import org.eclipse.che.api.languageserver.util.EitherUtil;"); + out.println("import org.eclipse.che.api.languageserver.util.JsonUtil;"); + out.println("import org.eclipse.che.api.languageserver.shared.util.JsonDecision;"); + + + for (Class clazz : allTypes) { + out.print("import "); + out.print(clazz.getCanonicalName()); + out.println(";"); + } + + out.println(); + writeEnvClassAnnotations(out); + + out.println(String.format("public class %1$s implements DtoFactoryVisitor {", targetName)); + + for (Class clazz : allTypes) { + writeDTOClass(INDENT, out, clazz, allTypes); + out.println(); + writeDTOProvider(INDENT, out, clazz); + out.println(); + } + + out.println(INDENT + "public void accept(DtoFactory dtoFactory) {"); + for (Class clazz : allTypes) { + out.println(INDENT + INDENT + String.format("dtoFactory.registerProvider(%1$s.class, new %2$s());", + clazz.getSimpleName(), dtoProviderName(clazz))); + } + out.println(INDENT + "}"); + + ToDtoGenerator.generateMakeDto(INDENT, out, allTypes); + + out.println("}"); + out.flush(); + } + } + + /** + * Write environment-specific target class annotations. + * + * @param out + */ + protected abstract void writeEnvClassAnnotations(PrintWriter out); + + /** + * Write environment-specific imports. + * + * @param out + */ + protected abstract void writeEnvImports(PrintWriter out); + + private void writeDTOClass(String indent, PrintWriter out, Class clazz, Set> classes) { + + out.println(indent + String.format("public static class %1$s extends %2$s implements JsonSerializable {", + dtoName(clazz), clazz.getSimpleName())); + + out.println(); + + out.println(indent + INDENT + String.format("public %1$s() {", dtoName(clazz))); + out.println(indent + INDENT + "}"); + out.println(); + + + writeCopyConstructor(indent + INDENT, out, clazz, classes); + out.println(); + + writeToJson(indent + INDENT, out, clazz); + out.println(); + + writeEnvSpecificToJson(indent, out); + + out.println(indent + INDENT + "public String toJson() {"); + out.println(indent + INDENT + INDENT + "return toJsonElement().toString();"); + out.println(indent + INDENT + "}"); + out.println(); + out.println(String.format(indent + INDENT + "public static %1$s fromJson(String json) {", dtoName(clazz))); + out.println(indent + INDENT + INDENT + "if (json == null) {"); + out.println(indent + INDENT + INDENT + INDENT + "return null;"); + out.println(indent + INDENT + INDENT + "}"); + + out.println(indent + INDENT + INDENT + String.format("return fromJson(%1$s);", json.parse("json"))); + out.println(indent + INDENT + "}"); + + out.println(String.format(indent + INDENT + "public static %1$s fromJson(%2$s jsonVal) {", dtoName(clazz), + json.element())); + + out.println(indent + INDENT + INDENT + "if (jsonVal == null) {"); + out.println(indent + INDENT + INDENT + INDENT + "return null;"); + out.println(indent + INDENT + INDENT + "}"); + out.println(indent + INDENT + INDENT + + String.format("%1$s json= %2$s;", json.object(), json.objectValue("jsonVal"))); + + out.println(indent + INDENT + INDENT + String.format("%1$s result= new %1$s();", dtoName(clazz))); + FromJsonGenerator fromJsonGenerator = new FromJsonGenerator(json); + for (Method m : clazz.getMethods()) { + if (isSetter(clazz, m)) { + fromJsonGenerator.generateFromJson(indent + INDENT + INDENT, out, m, "result", "json"); + } + } + out.println(indent + INDENT + INDENT + "return result;"); + + out.println(indent + INDENT + "}"); + + out.println(indent + "}"); + } + + protected void writeEnvSpecificToJson(String indent, PrintWriter out) { + } + + private void writeCopyConstructor(String indent, PrintWriter out, Class clazz, Set> classes) { + out.println(indent + String.format("public %1$s(%2$s o) {", dtoName(clazz), clazz.getName())); + ToDtoGenerator toJsonGenerator = new ToDtoGenerator(classes); + + for (Method m : clazz.getMethods()) { + if (isSetter(clazz, m)) { + toJsonGenerator.generateToDto(indent + INDENT, out, clazz, m, "o"); + } + } + + out.println(indent + "}"); + } + + private void writeToJson(String indent, PrintWriter out, Class clazz) { + out.println(indent + String.format("public %1$s toJsonElement() {", json.element())); + out.println(indent + INDENT + String.format("%1$s result = new %1$s();", json.object())); + + ToJsonGenerator toJsonGenerator = new ToJsonGenerator(json); + + for (Method m : clazz.getMethods()) { + if (isSetter(clazz, m)) { + toJsonGenerator.generateToJson(indent + INDENT, out, clazz, m); + } + } + + out.println(indent + INDENT + "return result;\n"); + out.println(indent + "}"); + } + + private void writeDTOProvider(String indent, PrintWriter out, Class clazz) { + String source = indent + "public static class %1$s implements DtoProvider<%2$s> {\n" + indent + + " public Class getImplClass() {\n" + indent + " return %2$s.class;\n" + indent + + " }\n" + indent + "\n" + indent + " public %2$s newInstance() {\n" + indent + + " return new %2$s();\n" + indent + " }\n" + indent + "\n" + indent + + " public %2$s fromJson(String json) {\n" + indent + " return %2$s.fromJson(json);\n" + indent + + " }\n" + indent + INDENT + "public %2$s fromJson(%3$s json) {\n" + indent + + " return %2$s.fromJson(json);\n" + indent + + " }\n" + indent + INDENT + "public %2$s clone(%2$s dto) {\n" + + indent + INDENT + INDENT + "return %2$s.fromJson(dto.toJson());\n" + indent + + " }\n" + indent + "}"; + + out.println(String.format(source, dtoProviderName(clazz), dtoName(clazz), json.element())); + } + + private String dtoProviderName(Class clazz) { + return clazz.getSimpleName() + "DtoProvider"; + } +} diff --git a/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/EitherUtil.java b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/EitherUtil.java new file mode 100644 index 00000000000..2e4bf002664 --- /dev/null +++ b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/EitherUtil.java @@ -0,0 +1,104 @@ +/******************************************************************************* + * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + *******************************************************************************/ +package org.eclipse.che.api.languageserver.generator; + +import org.eclipse.lsp4j.jsonrpc.messages.Either; + +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.Collection; + +/** + * This class is a backport from org.eclipse.lsp4j.jsonrpc.messages.Either in version 0.2.0-SNAPSHOT remove when moving to 0.2.0 version + * + * @author Thomas Mäder + */ +public class EitherUtil { + static Type getLeftDisjointType(Type type) { + return getDisjointType(type, 0); + } + + static Type getRightDisjointType(Type type) { + return getDisjointType(type, 1); + } + + + private static Type getDisjointType(Type type, int index) { + if (type instanceof ParameterizedType) { + final ParameterizedType parameterizedType = (ParameterizedType)type; + return parameterizedType.getActualTypeArguments()[0]; + } + if (type instanceof Class) { + final Class cls = (Class)type; + return cls.getTypeParameters()[index]; + } + return null; + } + + /** + * Return all disjoint types. + */ + static Collection getAllDisjoinTypes(Type type) { + return collectDisjoinTypes(type, new ArrayList<>()); + } + + private static Collection collectDisjoinTypes(Type type, Collection types) { + if (isEither(type)) { + if (type instanceof ParameterizedType) { + return collectDisjoinTypes((ParameterizedType)type, types); + } + if (type instanceof Class) { + return collectDisjoinTypes((Class)type, types); + } + } + types.add(type); + return types; + } + + private static Collection collectDisjoinTypes(ParameterizedType type, Collection types) { + for (Type typeArgument : type.getActualTypeArguments()) { + collectDisjoinTypes(typeArgument, types); + } + return types; + } + + private static Collection collectDisjoinTypes(Class type, Collection types) { + for (Type typeParameter : type.getTypeParameters()) { + collectDisjoinTypes(typeParameter, types); + } + return types; + } + + /** + * Test whether the given type is Either. + */ + private static boolean isEither(Type type) { + if (type instanceof ParameterizedType) { + return isEither((ParameterizedType)type); + } + if (type instanceof Class) { + return isEither((Class)type); + } + return false; + } + + /** + * Test whether the given type is Either. + */ + private static boolean isEither(ParameterizedType type) { + return isEither(type.getRawType()); + } + + /** + * Test whether the given class is Either. + */ + private static boolean isEither(Class cls) { + return Either.class.isAssignableFrom(cls); + } +} diff --git a/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/FromJsonGenerator.java b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/FromJsonGenerator.java new file mode 100644 index 00000000000..62f5e5749a8 --- /dev/null +++ b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/FromJsonGenerator.java @@ -0,0 +1,175 @@ +/******************************************************************************* + * 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.generator; + +import org.eclipse.lsp4j.jsonrpc.messages.Either; + +import java.io.PrintWriter; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.eclipse.che.api.languageserver.generator.DtoGenerator.INDENT; +import static org.eclipse.che.api.languageserver.generator.DtoGenerator.dtoName; + +/** + * This class generates property conversion code from json properties to dto + * fields. + * + * @author Thomas Mäder + */ +public class FromJsonGenerator extends ConversionGenerator { + + private final JsonImpl json; + + public FromJsonGenerator(JsonImpl json) { + this.json = json; + } + + public void generateFromJson(String indent, PrintWriter out, Method m, String objectName, String jsonName) { + + Type paramType = m.getGenericParameterTypes()[0]; + String fieldName = fieldName(m); + String jsonValName = jsonName + fieldName + "Json"; + String valName = jsonName + fieldName + "Val"; + out.println(indent + String.format("%1$s %2$s = %3$s.get(\"%4$s\");", json.element(), jsonValName, jsonName, fieldName)); + out.println(indent + String.format("if (%1$s != null && !(%2$s)) {", jsonValName, json.isNull(jsonValName))); + generateFromJson(indent + INDENT, out, valName, jsonValName, m.getGenericParameterTypes()[0]); + out.println(String.format(indent + INDENT + "%1$s.%2$s((%3$s)%4$s);", objectName, m.getName(), paramType.getTypeName(), valName)); + out.println(indent + "}"); + } + + private void generateFromJson(String indent, PrintWriter out, String varName, String valueAccess, Type paramType) { + if (List.class.isAssignableFrom(getRawClass(paramType))) { + generateListConversion(indent, out, varName, valueAccess, paramType); + } else if (Map.class.isAssignableFrom(getRawClass(paramType))) { + generateMapConversion(indent, out, varName, valueAccess, paramType); + } else if (Either.class.isAssignableFrom(getRawClass(paramType))) { + generateEitherConversion(indent, out, varName, valueAccess, paramType); + } else { + out.println(indent + String.format("%1$s %2$s = %3$s;", getRawClass(paramType).getName(), varName, + fromJsonConversion(getRawClass(paramType), valueAccess))); + } + } + + private void generateMapConversion(String indent, PrintWriter out, String varName, String jsonValName, Type paramType) { + ParameterizedType genericType = (ParameterizedType)paramType; + Type containedType = genericType.getActualTypeArguments()[1]; + String objectName = varName + "o"; + String containedName = objectName + "X"; + out.println(indent + String.format("HashMap %2$s= new HashMap();", containedType.getTypeName(), varName, + containedType.getTypeName())); + out.println(indent + String.format("%1$s %2$s = %3$s;", json.object(), objectName, json.objectValue(jsonValName))); + + json.iterateObject(indent, out, objectName, (String keyName, String valueName) -> { + generateFromJson(indent + INDENT, out, containedName, valueName, containedType); + out.println(indent + INDENT + String.format("%1$s.put(%2$s, %3$s);", varName, keyName, containedName)); + }); + } + + private void generateListConversion(String indent, PrintWriter out, String varName, String jsonValName, Type paramType) { + Type containedType = containedType(paramType); + out.println(indent + String.format("ArrayList<%1$s> %2$s= new ArrayList<%3$s>();", containedType.getTypeName(), varName, + containedType.getTypeName())); + String arrayName = varName + "a"; + String containedName = arrayName + "X"; + String indexName = arrayName + "i"; + out.println(indent + String.format("%1$s %2$s = %3$s;", json.array(), arrayName, json.arrayValue(jsonValName))); + out.println(indent + String.format("for(int %1$s= 0; %1$s < %2$s.size(); %1$s++) {", indexName, arrayName)); + + generateFromJson(indent + INDENT, out, containedName, arrayName + ".get(" + indexName + ")", containedType); + + out.println(indent + INDENT + String.format("%1$s.add(%2$s);", varName, containedName)); + out.println(indent + "}"); + } + + private String getJsonDecision(Class cls) { + if (cls.isArray() || List.class.isAssignableFrom(cls)) { + return "JsonDecision.LIST"; + } + if (Boolean.class.isAssignableFrom(cls)) { + return "JsonDecision.BOOLEAN"; + } + if (Number.class.isAssignableFrom(cls)) { + return "JsonDecision.NUMBER"; + } + if (Character.class.isAssignableFrom(cls) || String.class.isAssignableFrom(cls) || Enum.class.isAssignableFrom(cls)) { + return "JsonDecision.STRING"; + } + return "JsonDecision.OBJECT"; + } + + private void generateEitherConversion(String indent, PrintWriter out, String varName, String valueAccess, Type paramType) { + String innerName = varName + "e"; + String typesName = innerName + "cls"; + + Collection allDisjoinTypes = EitherUtil.getAllDisjoinTypes(EitherUtil.getLeftDisjointType(paramType)); + Set> leftClasses = allDisjoinTypes.stream().map(t -> getRawClass(t)).collect(Collectors.toSet()); + + out.println(indent + String.format("JsonDecision[] %1$s= new JsonDecision[] {", typesName)); + boolean first = true; + for (Class startClass : leftClasses) { + out.print(indent + INDENT + getJsonDecision(startClass)); + if (first) { + first = false; + } else { + out.print(","); + } + out.println(); + } + out.println(indent + "};"); + + out.println(indent + String.format("%1$s %2$s;", paramType.getTypeName(), varName)); + out.println(indent + String.format("if (EitherUtil.matches(%1$s, %2$s)) {", valueAccess, typesName)); + + generateFromJson(indent + INDENT, out, innerName, valueAccess, EitherUtil.getLeftDisjointType(paramType)); + + out.println(indent + INDENT + String.format("%1$s= Either.forLeft(%2$s);", varName, innerName)); + out.println(indent + "} else {"); + + generateFromJson(indent + INDENT, out, innerName, valueAccess, EitherUtil.getRightDisjointType(paramType)); + out.println(indent + INDENT + String.format("%1$s= Either.forRight(%2$s);", varName, innerName)); + out.println(indent + "}"); + } + + @SuppressWarnings("unchecked") + private String fromJsonConversion(Class t, String valueName) { + if (Enum.class.isAssignableFrom(t)) { + return String.format("%1$s.valueOf(%2$s);", t.getName(), json.asString(valueName)); + } else if (String.class.isAssignableFrom(t)) { + return String.format("%1$s;", json.asString(valueName)); + } else if (Number.class.isAssignableFrom(t)) { + return String.format("(%1$s)%2$s;", primitiveCast((Class)t), json.asDouble(valueName)); + } else if (isSimpleNumberType(t)) { + return String.format("(%1$s)%2$s;", t.getSimpleName(), json.asDouble(valueName)); + } else if (t == boolean.class || Boolean.class.isAssignableFrom(t)) { + return json.asBoolean(valueName); + } else if (t == Object.class) { + return valueName; + } else { + return String.format("%1$s.fromJson((%2$s)%3$s);", dtoName(t), json.object(), valueName); + } + } + + private Object primitiveCast(Class t) { + if (t == Integer.class) { + return "int"; + } else { + return t.getSimpleName().toLowerCase(); + } + } + +} diff --git a/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/JsonImpl.java b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/JsonImpl.java new file mode 100644 index 00000000000..d19c902cb74 --- /dev/null +++ b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/JsonImpl.java @@ -0,0 +1,139 @@ +/******************************************************************************* + * 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.generator; + +import java.io.PrintWriter; + +/** + * Interface that abstracts different implementations of json support. + * + * @author Thomas Mäder + */ +public interface JsonImpl { + + /** + * @return the class name of a general json value. + */ + String element(); + + /** + * @return the class name of a json object. + */ + String object(); + + /** + * @return the class name of a json array. + */ + String array(); + + /** + * @return expression designating the json null value. + */ + String nullValue(); + + /** + * @return the class name of a json string value. + */ + Object string(); + + /** + * @return the class name of a json number value. + */ + Object number(); + + /** + * @return an expression converting the given expression to a json boolean + */ + String boolValue(String value); + + /** + * @return an expression converting the given json element to a json object + */ + Object objectValue(String value); + + /** + * @return an expression converting the given json element to a boolean + */ + String asBoolean(String valueName); + + /** + * @return an expression converting the given json element to a double + */ + String asDouble(String valueName); + + /** + * @return an expression converting the given json element to a String + */ + String asString(String valueName); + + /** + * @return an expression converting the given json element to a json array + */ + String arrayValue(String jsonValName); + + /** + * @return the name of the method on a json object to set a field value + */ + String put(); + + /** + * @param arrayName + * the name of the array + * @param valueName + * the name of the value to add + * @return code that adds a value to json array. + */ + String add(String arrayName, String valueName); + + /** + * Write an iteration over the given json object to the output writer, + * delegating handling of individual properties to the given handler + * + * @param indent + * the base indent to use + * @param out + * where to write text + * @param objectName + * the name of the json object to iterate over + * @param handler + * the handler to delegate property writing to. + */ + void iterateObject(String indent, PrintWriter out, String objectName, PropertyHandler handler); + + /** + * Generate code to check whether the given value is the json null value + * + * @param jsonValName + * @return + */ + String isNull(String jsonValName); + + /** + * @return an expression converting the given string to a json value + */ + String parse(String string); + + /** + * @return write imports for all classes referenced in the implementation of + * this interface + */ + void writeImports(PrintWriter out); + + /** + * An interface to handle the fields in a json object + * + * @author Thomas Mäder + */ + interface PropertyHandler { + void handle(String keyName, String valueName); + } +} diff --git a/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ServerDtoGenerator.java b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ServerDtoGenerator.java new file mode 100644 index 00000000000..5f4de49216a --- /dev/null +++ b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ServerDtoGenerator.java @@ -0,0 +1,74 @@ +/******************************************************************************* + * 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.generator; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.PrintWriter; +import java.nio.file.Files; + + +/** + * Generates server side dto's from lsp4j message classes and che extensions thereof. + * The classes in question must have a zero-arg constructor and standard getters/setters for all fields. + * + * @author Thomas Mäder + */ +public class ServerDtoGenerator extends DtoGenerator { + public ServerDtoGenerator() { + super(new ServerJsonImpl()); + } + + public static void main(String[] args) throws IOException { + new ServerDtoGenerator().generate(new File(args[0]), "Dtos", args[1], args[2].split(","), new String[]{}); + } + + @Override + protected void writeEnvClassAnnotations(PrintWriter out) { + out.println("@SuppressWarnings(value= {\"serial\", \"deprecation\"})"); + } + + @Override + protected void writeEnvImports(PrintWriter out) { + out.println("import org.eclipse.che.dto.server.DtoFactoryVisitor;"); + out.println("import org.eclipse.che.dto.server.DtoFactory;"); + out.println("import org.eclipse.che.dto.server.DtoProvider;"); + out.println("import org.eclipse.che.dto.server.JsonSerializable;"); + out.println("import java.io.Writer;"); + out.println("import java.io.IOException;"); + } + + protected void writeEnvSpecificToJson(String indent, PrintWriter out) { + out.println(indent + INDENT + "public void toJson(Writer w) {"); + out.println(indent + INDENT + INDENT + "try {"); + + out.println(indent + INDENT + INDENT + INDENT + "w.write(toJson());"); + out.println(indent + INDENT + INDENT + "} catch (IOException e) {"); + out.println(indent + INDENT + INDENT + INDENT + "throw new RuntimeException(e);"); + out.println(indent + INDENT + INDENT + "}"); + out.println(indent + INDENT + "}"); + out.println(); + } + + @Override + public void generate(File targetFolder, String targetName, String targetPackage, String[] sourcePackages, String[] classes) + throws IOException { + super.generate(targetFolder, targetName, targetPackage, sourcePackages, classes); + // Create file in META-INF/services/ + File outServiceFile = new File(targetFolder, "META-INF/services/org.eclipse.che.dto.server.DtoFactoryVisitor"); + Files.createDirectories(outServiceFile.toPath().getParent()); + try (BufferedWriter serviceFileWriter = new BufferedWriter(new FileWriter(outServiceFile))) { + serviceFileWriter.write(targetPackage + "." + targetName); + } + } +} diff --git a/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ServerJsonImpl.java b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ServerJsonImpl.java new file mode 100644 index 00000000000..6d7cc5c5d76 --- /dev/null +++ b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ServerJsonImpl.java @@ -0,0 +1,115 @@ +/******************************************************************************* + * 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.generator; + +import java.io.PrintWriter; + +public class ServerJsonImpl implements JsonImpl { + + @Override + public String element() { + return "JsonElement"; + } + + @Override + public String object() { + return "JsonObject"; + } + + @Override + public String array() { + return "JsonArray"; + } + + @Override + public String nullValue() { + return "JsonNull.INSTANCE"; + } + + @Override + public Object string() { + return "JsonPrimitive"; + } + + @Override + public Object number() { + return "JsonPrimitive"; + } + + @Override + public String boolValue(String value) { + return String.format("new JsonPrimitive(%1$s)", value); + } + + @Override + public Object objectValue(String value) { + return String.format("%1$s.getAsJsonObject()", value); + } + + @Override + public String arrayValue(String valueName) { + return String.format("%1$s.getAsJsonArray()", valueName); + } + + @Override + public String asBoolean(String valueName) { + return String.format("%1$s.getAsBoolean()", valueName); + } + + @Override + public String asDouble(String valueName) { + return String.format("%1$s.getAsDouble()", valueName); + } + + @Override + public String asString(String valueName) { + return String.format("%1$s.getAsString()", valueName); + } + + @Override + public String parse(String valueName) { + return String.format("new JsonParser().parse(%1$s)", valueName); + } + + @Override + public String put() { + return "add"; + } + + public String add(String arrayName, String valueName) { + return String.format("%1$s.add(%2$s);", arrayName, valueName); + } + + + @Override + public void iterateObject(String indent, PrintWriter out, String objectName, PropertyHandler handler) { + String entryName = objectName + "e"; + out.println(indent + String.format("for(Entry %1$s : %2$s.entrySet()) {", entryName, objectName)); + handler.handle(String.format("%1$s.getKey()", entryName), String.format("%1$s.getValue()", entryName)); + out.println(indent + "}"); + } + + @Override + public String isNull(String jsonValName) { + return jsonValName + ".isJsonNull()"; + } + + + @Override + public void writeImports(PrintWriter out) { + out.println("import com.google.gson.JsonParser;"); + out.println("import com.google.gson.JsonObject;"); + out.println("import com.google.gson.JsonArray;"); + out.println("import com.google.gson.JsonPrimitive;"); + out.println("import com.google.gson.JsonElement;"); + out.println("import com.google.gson.JsonNull;"); + } +} diff --git a/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ToDtoGenerator.java b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ToDtoGenerator.java new file mode 100644 index 00000000000..862cf9f8acb --- /dev/null +++ b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ToDtoGenerator.java @@ -0,0 +1,142 @@ +/******************************************************************************* + * 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.generator; + +import org.eclipse.lsp4j.jsonrpc.messages.Either; + +import java.io.PrintWriter; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import static org.eclipse.che.api.languageserver.generator.DtoGenerator.INDENT; +import static org.eclipse.che.api.languageserver.generator.DtoGenerator.dtoName; + +; + +/** + * This class generates property conversions from regular lsp4j classes to dto classes. + * Used to convert responses from the backend language servers for che rmi usage. + * + * @author Thomas Mäder + */ +public class ToDtoGenerator extends ConversionGenerator { + + private Set> classes; + + public ToDtoGenerator(Set> classes) { + this.classes = classes; + } + + public static void generateMakeDto(String indent, PrintWriter out, Set> classes) { + out.println(indent + "public static final Object makeDto(Object obj) {"); + for (Class clazz : classes) { + out.println(indent + INDENT + String.format("if (obj instanceof %1$s) {", clazz.getName())); + out.println(indent + INDENT + INDENT + String.format("return new %1$s((%2$s)obj);", dtoName(clazz), clazz.getName())); + out.println(indent + INDENT + "}"); + } + out.println(indent + INDENT + "return obj;"); + out.println(indent + "}"); + } + + public void generateToDto(String indent, PrintWriter out, Class receiverClass, Method m, String objectName) { + String varName = fieldName(m) + "Val"; + String valueAccess = objectName + "." + getterName(receiverClass, m) + "()"; + Type paramType = m.getGenericParameterTypes()[0]; + if (getRawClass(paramType).isPrimitive()) { + generateToDto(indent + INDENT, out, varName, valueAccess, paramType); + out.println(String.format(indent + INDENT + "%1$s((%2$s)%3$s);", m.getName(), paramType.getTypeName(), varName)); + } else { + out.println(indent + String.format("if (%1$s == null) {", valueAccess)); + out.println(indent + INDENT + String.format("%1$s((%2$s)null);", m.getName(), paramType.getTypeName())); + out.println(indent + "} else {"); + generateToDto(indent + INDENT, out, varName, valueAccess, paramType); + out.println(String.format(indent + INDENT + "%1$s((%2$s)%3$s);", m.getName(), paramType.getTypeName(), varName)); + out.println(indent + "}"); + } + } + + private void generateToDto(String indent, PrintWriter out, String varName, String valueAccess, Type paramType) { + Class rawClass = getRawClass(paramType); + if (List.class.isAssignableFrom(rawClass)) { + generateListConversion(indent + INDENT, out, varName, valueAccess, paramType); + } else if (Map.class.isAssignableFrom(rawClass)) { + generateMapConversion(indent + INDENT, out, varName, valueAccess, paramType); + } else if (Either.class.isAssignableFrom(rawClass)) { + generateEitherConversion(indent + INDENT, out, varName, valueAccess, paramType); + } else { + out.println(String.format(indent + "%1$s %2$s = %3$s;", rawClass.getName(), varName, + dtoValueExpression(rawClass, valueAccess))); + } + } + + private void generateEitherConversion(String indent, PrintWriter out, String varName, String valueAccess, + Type paramType) { + String innerName = varName + "e"; + + out.println(indent + String.format("%1$s %2$s;", paramType.getTypeName(), varName)); + out.println(indent + String.format("if (%1$s.getLeft() != null) {", valueAccess)); + generateToDto(indent + INDENT, out, innerName, valueAccess + ".getLeft()", EitherUtil.getLeftDisjointType(paramType)); + out.println(indent + INDENT + String.format("%1$s= Either.forLeft(%2$s);", varName, innerName)); + out.println(indent + "} else {"); + generateToDto(indent + INDENT, out, innerName, valueAccess + ".getRight()", EitherUtil.getRightDisjointType(paramType)); + out.println(indent + INDENT + String.format("%1$s= Either.forRight(%2$s);", varName, innerName)); + out.println(indent + "}"); + } + + + private void generateMapConversion(String indent, PrintWriter out, String varName, String valueAccess, + Type paramType) { + ParameterizedType genericType = (ParameterizedType)paramType; + Type containedType = genericType.getActualTypeArguments()[1]; + Type valueType = genericType.getActualTypeArguments()[1]; + String containedName = varName + "X"; + out.println(indent + String.format("HashMap %2$s= new HashMap();", + containedType.getTypeName(), varName, containedType.getTypeName())); + out.println(String.format(indent + "for (Entry %2$s : %3$s.entrySet()) {", + valueType.getTypeName(), containedName, valueAccess)); + generateToDto(indent + INDENT, out, varName + "Y", containedName + ".getValue()", valueType); + out.println(indent + INDENT + + String.format("%1$s.put(%2$s, %3$s);", varName, containedName + ".getKey()", varName + "Y")); + out.println(indent + "}"); + + } + + private void generateListConversion(String indent, PrintWriter out, String varName, String valueAccess, + Type paramType) { + Type containedType = containedType(paramType); + out.println(indent + String.format("ArrayList<%1$s> %2$s= new ArrayList<%3$s>();", containedType.getTypeName(), varName, + containedType.getTypeName())); + String containedName = varName + "X"; + out.println(String.format(indent + "for (%1$s %2$s : %3$s) {", containedType.getTypeName(), containedName, + valueAccess)); + generateToDto(indent + INDENT, out, varName + "Y", containedName, containedType); + out.println(indent + INDENT + String.format("%1$s.add(%2$s);", varName, varName + "Y")); + out.println(indent + "}"); + } + + + private String dtoValueExpression(Class t, String value) { + if (isDtoClass(t)) { + return String.format("new %1$s(%2$s)", dtoName(t), value); + } else { + return String.format("(%1$s)makeDto(%2$s);", t.getName(), value); + } + } + + private boolean isDtoClass(Class t) { + return classes.contains(t); + } + +} diff --git a/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ToJsonGenerator.java b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ToJsonGenerator.java new file mode 100644 index 00000000000..b8069a45afe --- /dev/null +++ b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/generator/ToJsonGenerator.java @@ -0,0 +1,153 @@ +/******************************************************************************* + * 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.generator; + +import org.eclipse.lsp4j.jsonrpc.messages.Either; + +import java.io.PrintWriter; +import java.lang.reflect.Method; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.List; +import java.util.Map; + +import static org.eclipse.che.api.languageserver.generator.DtoGenerator.INDENT; +import static org.eclipse.che.api.languageserver.generator.DtoGenerator.dtoName; + +; + +/** + * This class generates code to convert dto object fields to json properties. + * + * @author Thomas Mäder + */ +public class ToJsonGenerator extends ConversionGenerator { + private JsonImpl json; + + public ToJsonGenerator(JsonImpl json) { + this.json = json; + } + + public void generateToJson(String indent, PrintWriter out, Class receiverClass, Method m) { + String varName = fieldName(m) + "Val"; + Type paramType = m.getGenericParameterTypes()[0]; + String valueAccess = getterName(receiverClass, m) + "()"; + + if (getRawClass(paramType).isPrimitive()) { + generateToJson(indent, out, varName, getterName(receiverClass, m) + "()", paramType); + out.println( + String.format(indent + INDENT + "result.%1$s(\"%2$s\", %3$s);", json.put(), fieldName(m), varName)); + } else { + out.println(indent + String.format("if (%1$s == null) {", valueAccess)); + out.println(indent + INDENT + String.format("%1$s((%2$s)null);", m.getName(), paramType.getTypeName())); + out.println(indent + "} else {"); + generateToJson(indent + INDENT, out, varName, getterName(receiverClass, m) + "()", paramType); + out.println( + String.format(indent + INDENT + "result.%1$s(\"%2$s\", %3$s);", json.put(), fieldName(m), varName)); + out.println(indent + "}"); + } + } + + private void generateToJson(String indent, PrintWriter out, String varName, String valueAccess, Type paramType) { + if (List.class.isAssignableFrom(getRawClass(paramType))) { + new ListConverter(varName, valueAccess, paramType).generateListConversion(indent, out); + } else if (Map.class.isAssignableFrom(getRawClass(paramType))) { + generateMapConversion(indent, out, varName, valueAccess, paramType); + } else if (Either.class.isAssignableFrom(getRawClass(paramType))) { + generateEitherConversion(indent, out, varName, valueAccess, paramType); + } else { + out.println(String.format(indent + "%1$s %2$s = %3$s;", json.element(), varName, + jsonValueExpression(getRawClass(paramType), valueAccess))); + } + } + + private void generateEitherConversion(String indent, PrintWriter out, String varName, String valueAccess, + Type paramType) { + String innerName = varName + "e"; + + out.println(indent + String.format("%1$s %2$s;", json.element(), varName)); + out.println(indent + String.format("if (%1$s.getLeft() != null) {", valueAccess)); + generateToJson(indent + INDENT, out, innerName, valueAccess + ".getLeft()", EitherUtil.getLeftDisjointType(paramType)); + out.println(indent + INDENT + String.format("%1$s= %2$s;", varName, innerName)); + out.println(indent + "} else {"); + generateToJson(indent + INDENT, out, innerName, valueAccess + ".getRight()", EitherUtil.getRightDisjointType(paramType)); + out.println(indent + INDENT + String.format("%1$s= %2$s;", varName, innerName)); + out.println(indent + "}"); + } + + private void generateMapConversion(String indent, PrintWriter out, String varName, String valueAccess, + Type paramType) { + ParameterizedType genericType = (ParameterizedType)paramType; + Type valueType = genericType.getActualTypeArguments()[1]; + String containedName = varName + "X"; + out.println(String.format(indent + "%1$s %2$s = new %1$s();", json.object(), varName)); + out.println(String.format(indent + "for (Entry %2$s : %3$s.entrySet()) {", + valueType.getTypeName(), containedName, valueAccess)); + generateToJson(indent + INDENT, out, varName + "Y", containedName + ".getValue()", valueType); + out.println(indent + INDENT + String.format("%1$s.%2$s(%3$s.getKey().toString(), %4$s);", varName, json.put(), + containedName, varName + "Y")); + out.println(indent + "}"); + + } + + private String jsonValueExpression(Class paramType, String valueAccess) { + if (paramType.isPrimitive()) { + return String.format("%1$s;", toJsonConversion(paramType, valueAccess)); + } else { + return String.format("%1$s == null ? %2$s : %3$s;", valueAccess, json.nullValue(), + toJsonConversion(paramType, valueAccess)); + } + } + + private String toJsonConversion(Class t, String value) { + if (Enum.class.isAssignableFrom(t)) { + return String.format("new %1$s(%2$s.name())", json.string(), value); + } else if (String.class.isAssignableFrom(t)) { + return String.format("new %1$s(%2$s)", json.string(), value); + } else if (Number.class.isAssignableFrom(t)) { + return String.format("new %1$s(%2$s.doubleValue())", json.number(), value); + } else if (t == boolean.class || Boolean.class.isAssignableFrom(t)) { + return json.boolValue(value); + } else if (isSimpleNumberType(t)) { + return String.format("new %1$s(%2$s)", json.number(), value); + } else if (t == Object.class) { + return String.format("JsonUtil.convertToJson(%1$s)", value); + } else { + return String.format("((%2$s)%1$s).toJsonElement()", value, dtoName(t)); + } + } + + private class ListConverter { + private String varName; + private String valueAccess; + private Type paramType; + + public ListConverter(String varName, String valueAccess, + Type paramType) { + this.varName = varName; + this.valueAccess = valueAccess; + this.paramType = paramType; + } + + private void generateListConversion(String indent, PrintWriter out) { + Type containedType = containedType(paramType); + + String containedName = varName + "X"; + out.println(String.format(indent + "%1$s %2$s = new %1$s();", json.array(), varName)); + out.println(String.format(indent + "for (%1$s %2$s : %3$s) {", containedType.getTypeName(), containedName, + valueAccess)); + generateToJson(indent + INDENT, out, varName + "Y", containedName, containedType); + out.println(indent + INDENT + json.add(varName, varName + "Y")); + out.println(indent + "}"); + } + } + +} diff --git a/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/maven/plugin/DtoGeneratorMojo.java b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/maven/plugin/DtoGeneratorMojo.java new file mode 100644 index 00000000000..ff490cb0cc1 --- /dev/null +++ b/wsagent/che-core-api-languageserver-maven-plugin/src/main/java/org/eclipse/che/api/languageserver/maven/plugin/DtoGeneratorMojo.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * 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.api.languageserver.maven.plugin; + +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.plugins.annotations.ResolutionScope; +import org.eclipse.che.api.languageserver.generator.ClientDtoGenerator; +import org.eclipse.che.api.languageserver.generator.DtoGenerator; +import org.eclipse.che.api.languageserver.generator.ServerDtoGenerator; + +import java.io.File; +import java.io.IOException; + +/** Mojo to run {@link org.eclipse.che.api.languageserver.generator.DtoGenerator}. */ +@Mojo(name = "generate", requiresDependencyResolution = ResolutionScope.COMPILE) +public class DtoGeneratorMojo extends AbstractMojo { + @Parameter(property = "outputDir", required = true) + private String outputDirectory; + + @Parameter(property = "dtoPackages", required = true) + private String[] dtoPackages; + + @Parameter(property = "classes", required = false) + private String[] classes = new String[]{}; + + + @Parameter(property = "genClassName", required = true) + private String genClassName; + + @Parameter(property = "impl", required = true) + private String impl; + + @Override + public void execute() throws MojoExecutionException { + DtoGenerator generator; + if ("client".equals(impl)) { + generator = new ClientDtoGenerator(); + } else { + generator = new ServerDtoGenerator(); + } + + int lastDot = genClassName.lastIndexOf('.'); + String targetClass = genClassName.substring(lastDot + 1); + String targetPackage = genClassName.substring(0, lastDot); + + try { + generator.generate(new File(outputDirectory), targetClass, targetPackage, dtoPackages, classes); + } catch (IOException e) { + throw new MojoExecutionException("Generation failed", e); + } + } +} diff --git a/wsagent/che-core-api-languageserver-shared/pom.xml b/wsagent/che-core-api-languageserver-shared/pom.xml index 8bc32b7ea59..375fdcddc71 100644 --- a/wsagent/che-core-api-languageserver-shared/pom.xml +++ b/wsagent/che-core-api-languageserver-shared/pom.xml @@ -22,21 +22,12 @@ jar Che Core :: API :: Language Server Shared - ${project.build.directory}/generated-sources/dto/ false - com.google.code.gson - gson - - - io.typefox.lsapi - io.typefox.lsapi - - - org.eclipse.che.core - che-core-api-dto + org.eclipse.lsp4j + org.eclipse.lsp4j @@ -47,9 +38,6 @@ src/main/resources - - ${generated.sources.directory} - @@ -58,37 +46,11 @@ **/lsapi/** + **/model/Extended* + **/JsonDecision.java - - org.eclipse.che.core - che-core-api-dto-maven-plugin - ${project.version} - - - process-sources - - generate - - - - - - ${project.groupId} - ${project.artifactId} - ${project.version} - - - - - org.eclipse.che.api.languageserver.shared - - ${dto-generator-out-directory} - org.eclipse.che.api.languageserver.server.dto.DtoServerImpls - server - - maven-compiler-plugin @@ -101,39 +63,6 @@ - - org.codehaus.mojo - build-helper-maven-plugin - - - add-resource - process-sources - - add-resource - - - - - ${dto-generator-out-directory}/META-INF - META-INF - - - - - - add-source - process-sources - - add-source - - - - ${dto-generator-out-directory} - - - - - diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKey.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKey.java index 140d467de1a..5576b8e2c8a 100644 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKey.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/ProjectExtensionKey.java @@ -18,20 +18,15 @@ public class ProjectExtensionKey { public static final String ALL_PROJECT_MARKER = "*"; - private final String project; - private final String extension; + private String project; + private String extension; private ProjectExtensionKey(String project, String extension) { this.project = project; this.extension = extension; } - public String getProject() { - return project; - } - - public String getExtension() { - return extension; + public ProjectExtensionKey() { } public static ProjectExtensionKey createProjectKey(String project, String extension) { @@ -42,13 +37,30 @@ public static ProjectExtensionKey createAllProjectKey(String extension) { return new ProjectExtensionKey(ALL_PROJECT_MARKER, extension); } + public String getProject() { + return project; + } + + public void setProject(String project) { + this.project = project; + } + + public String getExtension() { + return extension; + } + + public void setExtension(String extension) { + this.extension = extension; + } + @Override public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof ProjectExtensionKey)) return false; + if (this == o) + return true; + if (!(o instanceof ProjectExtensionKey)) + return false; ProjectExtensionKey that = (ProjectExtensionKey)o; - return Objects.equals(extension, that.extension) && - Objects.equals(project, that.project); + return Objects.equals(extension, that.extension) && Objects.equals(project, that.project); } @Override diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/event/LanguageServerInitializeEvent.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/event/LanguageServerInitializeEvent.java new file mode 100644 index 00000000000..a1a17e66aef --- /dev/null +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/event/LanguageServerInitializeEvent.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * 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.api.languageserver.shared.event; + +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; +import org.eclipse.lsp4j.ServerCapabilities; + +/** + * @author Anatoliy Bazko + */ +public class LanguageServerInitializeEvent { + + private String projectPath; + private LanguageDescription supportedLanguages; + private ServerCapabilities serverCapabilities; + + public String getProjectPath() { + return projectPath; + } + + public void setProjectPath(String projectPath) { + this.projectPath = projectPath; + } + + public LanguageDescription getSupportedLanguages() { + return supportedLanguages; + } + + public void setSupportedLanguages(LanguageDescription supportedLanguages) { + this.supportedLanguages = supportedLanguages; + } + + public ServerCapabilities getServerCapabilities() { + return serverCapabilities; + } + + public void setServerCapabilities(ServerCapabilities serverCapabilities) { + this.serverCapabilities = serverCapabilities; + } +} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/event/LanguageServerInitializeEventDto.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/event/LanguageServerInitializeEventDto.java deleted file mode 100644 index 2624566a60d..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/event/LanguageServerInitializeEventDto.java +++ /dev/null @@ -1,34 +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.api.languageserver.shared.event; - -import org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.ServerCapabilitiesDTO; -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Anatoliy Bazko - */ -@DTO -public interface LanguageServerInitializeEventDto { - - String getProjectPath(); - - void setProjectPath(String projectPath); - - LanguageDescriptionDTO getSupportedLanguages(); - - void setSupportedLanguages(LanguageDescriptionDTO supportedLanguages); - - ServerCapabilitiesDTO getServerCapabilities(); - - void setServerCapabilities(ServerCapabilitiesDTO serverCapabilities); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CancelParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CancelParamsDTO.java deleted file mode 100644 index b2c3db04f11..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CancelParamsDTO.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.CancelParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface CancelParamsDTO extends CancelParams { - /** - * The request id to cancel. - */ - void setId(final String id); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ClientCapabilitiesDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ClientCapabilitiesDTO.java deleted file mode 100644 index 572afeb4827..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ClientCapabilitiesDTO.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.ClientCapabilities; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface ClientCapabilitiesDTO extends ClientCapabilities { -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionContextDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionContextDTO.java deleted file mode 100644 index 10a44b3b4bc..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionContextDTO.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.CodeActionContext; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * @author Sven Efftinge - */ -@DTO -public interface CodeActionContextDTO extends CodeActionContext { - /** - * An array of diagnostics. Overridden to return the DTO type. - */ - List getDiagnostics(); - - /** - * An array of diagnostics. - */ - void setDiagnostics(final List diagnostics); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionParamsDTO.java deleted file mode 100644 index 0e9fce86c06..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeActionParamsDTO.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.CodeActionParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface CodeActionParamsDTO extends CodeActionParams { - /** - * The document in which the command was invoked. Overridden to return the - * DTO type. - */ - TextDocumentIdentifierDTO getTextDocument(); - - /** - * The document in which the command was invoked. - */ - void setTextDocument(final TextDocumentIdentifierDTO textDocument); - - /** - * The range for which the command was invoked. Overridden to return the DTO - * type. - */ - RangeDTO getRange(); - - /** - * The range for which the command was invoked. - */ - void setRange(final RangeDTO range); - - /** - * Context carrying additional information. Overridden to return the DTO - * type. - */ - CodeActionContextDTO getContext(); - - /** - * Context carrying additional information. - */ - void setContext(final CodeActionContextDTO context); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensDTO.java deleted file mode 100644 index 116b847fbb0..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensDTO.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.CodeLens; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface CodeLensDTO extends CodeLens { - /** - * The range in which this code lens is valid. Should only span a single - * line. Overridden to return the DTO type. - */ - RangeDTO getRange(); - - /** - * The range in which this code lens is valid. Should only span a single - * line. - */ - void setRange(final RangeDTO range); - - /** - * The command this code lens represents. Overridden to return the DTO type. - */ - CommandDTO getCommand(); - - /** - * The command this code lens represents. - */ - void setCommand(final CommandDTO command); - - /** - * An data entry field that is preserved on a code lens item between a code - * lens and a code lens resolve request. - */ - void setData(final Object data); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensOptionsDTO.java deleted file mode 100644 index 0342246676b..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensOptionsDTO.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.CodeLensOptions; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface CodeLensOptionsDTO extends CodeLensOptions { - /** - * Code lens has a resolve provider as well. - */ - void setResolveProvider(final boolean resolveProvider); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensParamsDTO.java deleted file mode 100644 index 8ab8c939b7b..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CodeLensParamsDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.CodeLensParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface CodeLensParamsDTO extends CodeLensParams { - /** - * The document to request code lens for. Overridden to return the DTO type. - */ - TextDocumentIdentifierDTO getTextDocument(); - - /** - * The document to request code lens for. - */ - void setTextDocument(final TextDocumentIdentifierDTO textDocument); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CommandDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CommandDTO.java deleted file mode 100644 index 8917ee3cc37..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CommandDTO.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.Command; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * @author Sven Efftinge - */ -@DTO -public interface CommandDTO extends Command { - /** - * Title of the command, like `save`. - */ - void setTitle(final String title); - - /** - * The identifier of the actual command handler. - */ - void setCommand(final String command); - - /** - * Arguments that the command handler should be invoked with. - */ - void setArguments(final List arguments); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionItemDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionItemDTO.java deleted file mode 100644 index 710b7e838a1..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionItemDTO.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.CompletionItem; -import io.typefox.lsapi.CompletionItemKind; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface CompletionItemDTO extends CompletionItem { - - /** - * The TextDocumentIdentifier for which this completion item was generated. - * Used to select proper language server - */ - TextDocumentIdentifierDTO getTextDocumentIdentifier(); - - void setTextDocumentIdentifier(TextDocumentIdentifierDTO identifier); - - /** - * The label of this completion item. By default also the text that is - * inserted when selecting this completion. - */ - void setLabel(final String label); - - /** - * The kind of this completion item. Based of the kind an icon is chosen by - * the editor. - */ - void setKind(final CompletionItemKind kind); - - /** - * A human-readable string with additional information about this item, like - * type or symbol information. - */ - void setDetail(final String detail); - - /** - * A human-readable string that represents a doc-comment. - */ - void setDocumentation(final String documentation); - - /** - * A string that shoud be used when comparing this item with other items. - * When `falsy` the label is used. - */ - void setSortText(final String sortText); - - /** - * A string that should be used when filtering a set of completion items. - * When `falsy` the label is used. - */ - void setFilterText(final String filterText); - - /** - * A string that should be inserted a document when selecting this - * completion. When `falsy` the label is used. - */ - void setInsertText(final String insertText); - - /** - * An edit which is applied to a document when selecting this completion. - * When an edit is provided the value of insertText is ignored. Overridden - * to return the DTO type. - */ - TextEditDTO getTextEdit(); - - /** - * An edit which is applied to a document when selecting this completion. - * When an edit is provided the value of insertText is ignored. - */ - void setTextEdit(final TextEditDTO textEdit); - - /** - * An data entry field that is preserved on a completion item between a - * completion and a completion resolve request. - */ - void setData(final Object data); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionListDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionListDTO.java deleted file mode 100644 index f8095276e48..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionListDTO.java +++ /dev/null @@ -1,43 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2016 Rogue Wave Software, Inc. - * 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: - * Rogue Wave Software, Inc. - initial API and implementation - *******************************************************************************/ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.CompletionList; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * Represents a collection of completion items to be presented in the editor. - * - * @author Kaloyan Raev - */ -@DTO -public interface CompletionListDTO extends CompletionList { - - /** - * This list it not complete. Further typing should result in recomputing - * this list. - */ - void setIncomplete(boolean incomplete); - - /** - * The completion items. Overridden to return the DTO type. - */ - List getItems(); - - /** - * The completion items. - */ - void setItems(List items); - -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionOptionsDTO.java deleted file mode 100644 index af7cdbb64ad..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/CompletionOptionsDTO.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.CompletionOptions; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * @author Sven Efftinge - */ -@DTO -public interface CompletionOptionsDTO extends CompletionOptions { - /** - * The server provides support to resolve additional information for a - * completion item. - */ - void setResolveProvider(final Boolean resolveProvider); - - /** - * The characters that trigger completion automatically. - */ - void setTriggerCharacters(final List triggerCharacters); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DiagnosticDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DiagnosticDTO.java deleted file mode 100644 index d6d4f97ce80..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DiagnosticDTO.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.Diagnostic; -import io.typefox.lsapi.DiagnosticSeverity; - -import org.eclipse.che.dto.shared.DTO; - -@DTO -public interface DiagnosticDTO extends Diagnostic { - /** - * The range at which the message applies Overridden to return the DTO type. - */ - RangeDTO getRange(); - - /** - * The range at which the message applies - */ - void setRange(final RangeDTO range); - - /** - * The diagnostic's severity. Can be omitted. If omitted it is up to the - * client to interpret diagnostics as error, warning, info or hint. - */ - void setSeverity(final DiagnosticSeverity severity); - - /** - * The diagnostic's code. Can be omitted. - */ - void setCode(final String code); - - /** - * A human-readable string describing the source of this diagnostic, e.g. - * 'typescript' or 'super lint'. - */ - void setSource(final String source); - - /** - * The diagnostic's message. - */ - void setMessage(final String message); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java deleted file mode 100644 index 673638c97da..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeConfigurationParamsDTO.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.DidChangeConfigurationParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface DidChangeConfigurationParamsDTO extends DidChangeConfigurationParams { - void setSettings(final Object settings); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java deleted file mode 100644 index 57c5c3c2098..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeTextDocumentParamsDTO.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.DidChangeTextDocumentParams; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * @author Sven Efftinge - */ -@DTO -public interface DidChangeTextDocumentParamsDTO extends DidChangeTextDocumentParams { - /** - * The document that did change. The version number points to the version - * after all provided content changes have been applied. Overridden to - * return the DTO type. - */ - VersionedTextDocumentIdentifierDTO getTextDocument(); - - /** - * The document that did change. The version number points to the version - * after all provided content changes have been applied. - */ - void setTextDocument(final VersionedTextDocumentIdentifierDTO textDocument); - - /** - * Legacy property to support protocol version 1.0 requests. - */ - void setUri(final String uri); - - /** - * The actual content changes. Overridden to return the DTO type. - */ - List getContentChanges(); - - /** - * The actual content changes. - */ - void setContentChanges(final List contentChanges); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java deleted file mode 100644 index 5b630d802fc..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidChangeWatchedFilesParamsDTO.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.DidChangeWatchedFilesParams; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * @author Sven Efftinge - */ -@DTO -public interface DidChangeWatchedFilesParamsDTO extends DidChangeWatchedFilesParams { - /** - * The actual file events. Overridden to return the DTO type. - */ - List getChanges(); - - /** - * The actual file events. - */ - void setChanges(final List changes); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java deleted file mode 100644 index 2370d6124f9..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidCloseTextDocumentParamsDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.DidCloseTextDocumentParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface DidCloseTextDocumentParamsDTO extends DidCloseTextDocumentParams { - /** - * The document that was closed. Overridden to return the DTO type. - */ - TextDocumentIdentifierDTO getTextDocument(); - - /** - * The document that was closed. - */ - void setTextDocument(final TextDocumentIdentifierDTO textDocument); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java deleted file mode 100644 index b4456ed9590..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidOpenTextDocumentParamsDTO.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.DidOpenTextDocumentParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface DidOpenTextDocumentParamsDTO extends DidOpenTextDocumentParams { - /** - * The document that was opened. Overridden to return the DTO type. - */ - TextDocumentItemDTO getTextDocument(); - - /** - * The document that was opened. - */ - void setTextDocument(final TextDocumentItemDTO textDocument); - - /** - * Legacy property to support protocol version 1.0 requests. - */ - void setText(final String text); - - /** - * The text document's uri. - */ - void setUri(final String uri); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java deleted file mode 100644 index 70f56310f1e..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DidSaveTextDocumentParamsDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.DidSaveTextDocumentParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface DidSaveTextDocumentParamsDTO extends DidSaveTextDocumentParams { - /** - * The document that was closed. Overridden to return the DTO type. - */ - TextDocumentIdentifierDTO getTextDocument(); - - /** - * The document that was closed. - */ - void setTextDocument(final TextDocumentIdentifierDTO textDocument); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java deleted file mode 100644 index d66e9193013..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentFormattingParamsDTO.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.DocumentFormattingParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface DocumentFormattingParamsDTO extends DocumentFormattingParams { - /** - * The document to format. Overridden to return the DTO type. - */ - TextDocumentIdentifierDTO getTextDocument(); - - /** - * The document to format. - */ - void setTextDocument(final TextDocumentIdentifierDTO textDocument); - - /** - * The format options Overridden to return the DTO type. - */ - FormattingOptionsDTO getOptions(); - - /** - * The format options - */ - void setOptions(final FormattingOptionsDTO options); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentHighlightDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentHighlightDTO.java deleted file mode 100644 index 74bfc904395..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentHighlightDTO.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.DocumentHighlight; -import io.typefox.lsapi.DocumentHighlightKind; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface DocumentHighlightDTO extends DocumentHighlight { - /** - * The range this highlight applies to. Overridden to return the DTO type. - */ - RangeDTO getRange(); - - /** - * The range this highlight applies to. - */ - void setRange(final RangeDTO range); - - /** - * The highlight kind, default is KIND_TEXT. - */ - void setKind(final DocumentHighlightKind kind); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java deleted file mode 100644 index a11fe493dcd..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingOptionsDTO.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.DocumentOnTypeFormattingOptions; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * @author Sven Efftinge - */ -@DTO -public interface DocumentOnTypeFormattingOptionsDTO extends DocumentOnTypeFormattingOptions { - /** - * A character on which formatting should be triggered, like `}`. - */ - void setFirstTriggerCharacter(final String firstTriggerCharacter); - - /** - * More trigger characters. - */ - void setMoreTriggerCharacter(final List moreTriggerCharacter); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java deleted file mode 100644 index f3a17ffbd72..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentOnTypeFormattingParamsDTO.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.DocumentOnTypeFormattingParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface DocumentOnTypeFormattingParamsDTO extends DocumentOnTypeFormattingParams { - /** - * The position at which this request was send. Overridden to return the DTO - * type. - */ - PositionDTO getPosition(); - - /** - * The position at which this request was send. - */ - void setPosition(final PositionDTO position); - - /** - * The character that has been typed. - */ - void setCh(final String ch); - - /** - * The document to format. Overridden to return the DTO type. - */ - TextDocumentIdentifierDTO getTextDocument(); - - /** - * The document to format. - */ - void setTextDocument(final TextDocumentIdentifierDTO textDocument); - - /** - * The format options Overridden to return the DTO type. - */ - FormattingOptionsDTO getOptions(); - - /** - * The format options - */ - void setOptions(final FormattingOptionsDTO options); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java deleted file mode 100644 index 90e72955020..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentRangeFormattingParamsDTO.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.DocumentRangeFormattingParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface DocumentRangeFormattingParamsDTO extends DocumentRangeFormattingParams { - /** - * The range to format Overridden to return the DTO type. - */ - RangeDTO getRange(); - - /** - * The range to format - */ - void setRange(final RangeDTO range); - - /** - * The document to format. Overridden to return the DTO type. - */ - TextDocumentIdentifierDTO getTextDocument(); - - /** - * The document to format. - */ - void setTextDocument(final TextDocumentIdentifierDTO textDocument); - - /** - * The format options Overridden to return the DTO type. - */ - FormattingOptionsDTO getOptions(); - - /** - * The format options - */ - void setOptions(final FormattingOptionsDTO options); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java deleted file mode 100644 index 575edae8451..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/DocumentSymbolParamsDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.DocumentSymbolParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface DocumentSymbolParamsDTO extends DocumentSymbolParams { - /** - * The text document. Overridden to return the DTO type. - */ - TextDocumentIdentifierDTO getTextDocument(); - - /** - * The text document. - */ - void setTextDocument(final TextDocumentIdentifierDTO textDocument); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FileEventDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FileEventDTO.java deleted file mode 100644 index d35cf6062fd..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FileEventDTO.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.FileChangeType; -import io.typefox.lsapi.FileEvent; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface FileEventDTO extends FileEvent { - /** - * The file's uri. - */ - void setUri(final String uri); - - /** - * The change type. - */ - void setType(final FileChangeType type); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FormattingOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FormattingOptionsDTO.java deleted file mode 100644 index 2979ac008a5..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/FormattingOptionsDTO.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.FormattingOptions; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.Map; - -/** - * @author Sven Efftinge - */ -@DTO -public interface FormattingOptionsDTO extends FormattingOptions { - /** - * Size of a tab in spaces. - */ - void setTabSize(final int tabSize); - - /** - * Prefer spaces over tabs. - */ - void setInsertSpaces(final boolean insertSpaces); - - /** - * Signature for further properties. - */ - void setProperties(final Map properties); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/HoverDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/HoverDTO.java deleted file mode 100644 index 8d5a7974cac..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/HoverDTO.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.Hover; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * @author Sven Efftinge - */ -@DTO -public interface HoverDTO extends Hover { - /** - * The hover's content Overridden to return the DTO type. - */ - List getContents(); - - /** - * The hover's content - */ - void setContents(final List contents); - - /** - * An optional range Overridden to return the DTO type. - */ - RangeDTO getRange(); - - /** - * An optional range - */ - void setRange(final RangeDTO range); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeErrorDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeErrorDTO.java deleted file mode 100644 index 397641db2f0..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeErrorDTO.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.InitializeError; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface InitializeErrorDTO extends InitializeError { - /** - * Indicates whether the client should retry to send the initialize request - * after showing the message provided in the ResponseError. - */ - void setRetry(final boolean retry); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeResultDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeResultDTO.java deleted file mode 100644 index 9dd579ee379..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/InitializeResultDTO.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * ***************************************************************************** - * Copyright (c) 2012-2016 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.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.InitializeResult; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * @author Anatoliy Bazko - */ -@DTO -public interface InitializeResultDTO extends InitializeResult { - - String getProject(); - - void setProject(String project); - - @Override - ServerCapabilitiesDTO getCapabilities(); - - void setCapabilities(ServerCapabilitiesDTO capabilities); - - List getSupportedLanguages(); - - void setSupportedLanguages(List supportedLanguages); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LanguageDescriptionDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LanguageDescriptionDTO.java deleted file mode 100644 index 7ec434c7862..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LanguageDescriptionDTO.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * @author Sven Efftinge - */ -@DTO -public interface LanguageDescriptionDTO extends LanguageDescription { - /** - * The language id. - */ - void setLanguageId(String id); - - /** - * The optional content types this language is associated with. - */ - void setMimeTypes(List mimeTypes); - - /** - * The fileExtension this language is associated with. At least one extension must be provided. - */ - void setFileExtensions(List fileExtension); - - /** - * The optional highlighting configuration to support client side syntax highlighting. - * The format is client (editor) dependent. - */ - void setHighlightingConfiguration(String grammar); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LocationDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LocationDTO.java deleted file mode 100644 index 5e17997a95f..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/LocationDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.Location; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface LocationDTO extends Location { - void setUri(final String uri); - - /** - * Overridden to return the DTO type. - */ - RangeDTO getRange(); - - void setRange(final RangeDTO range); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MarkedStringDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MarkedStringDTO.java deleted file mode 100644 index 47300dfc0ca..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MarkedStringDTO.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.MarkedString; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface MarkedStringDTO extends MarkedString { - void setLanguage(final String language); - - void setValue(final String value); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageActionItemDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageActionItemDTO.java deleted file mode 100644 index 38ea8ee1505..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageActionItemDTO.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.MessageActionItem; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface MessageActionItemDTO extends MessageActionItem { - /** - * A short title like 'Retry', 'Open Log' etc. - */ - void setTitle(final String title); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageDTO.java deleted file mode 100644 index b63f1fc854e..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageDTO.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.Message; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface MessageDTO extends Message { - void setJsonrpc(final String jsonrpc); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageParamsDTO.java deleted file mode 100644 index 7436cb14a3c..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/MessageParamsDTO.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.MessageParams; -import io.typefox.lsapi.MessageType; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface MessageParamsDTO extends MessageParams { - /** - * The message type. - */ - void setType(final MessageType type); - - /** - * The actual message. - */ - void setMessage(final String message); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/NotificationMessageDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/NotificationMessageDTO.java deleted file mode 100644 index 18ea6c57705..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/NotificationMessageDTO.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.NotificationMessage; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface NotificationMessageDTO extends NotificationMessage { - /** - * The method to be invoked. - */ - void setMethod(final String method); - - /** - * The notification's params. - */ - void setParams(final Object params); - - void setJsonrpc(final String jsonrpc); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ParameterInformationDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ParameterInformationDTO.java deleted file mode 100644 index 7d4ce9d0ed3..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ParameterInformationDTO.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.ParameterInformation; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface ParameterInformationDTO extends ParameterInformation { - /** - * The label of this signature. Will be shown in the UI. - */ - void setLabel(final String label); - - /** - * The human-readable doc-comment of this signature. Will be shown in the UI - * but can be omitted. - */ - void setDocumentation(final String documentation); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PositionDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PositionDTO.java deleted file mode 100644 index f147a092d2d..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PositionDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.Position; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface PositionDTO extends Position { - /** - * Line position in a document (zero-based). - */ - void setLine(final int line); - - /** - * Character offset on a line in a document (zero-based). - */ - void setCharacter(final int character); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java deleted file mode 100644 index 3b5fd84d917..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/PublishDiagnosticsParamsDTO.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.PublishDiagnosticsParams; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * @author Sven Efftinge - */ -@DTO -public interface PublishDiagnosticsParamsDTO extends PublishDiagnosticsParams { - /** - * The URI for which diagnostic information is reported. - */ - void setUri(final String uri); - - /** - * An array of diagnostic information items. Overridden to return the DTO - * type. - */ - List getDiagnostics(); - - /** - * An array of diagnostic information items. - */ - void setDiagnostics(final List diagnostics); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RangeDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RangeDTO.java deleted file mode 100644 index 08513dc468f..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RangeDTO.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.Range; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface RangeDTO extends Range { - /** - * The range's start position Overridden to return the DTO type. - */ - PositionDTO getStart(); - - /** - * The range's start position - */ - void setStart(final PositionDTO start); - - /** - * The range's end position Overridden to return the DTO type. - */ - PositionDTO getEnd(); - - /** - * The range's end position - */ - void setEnd(final PositionDTO end); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceContextDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceContextDTO.java deleted file mode 100644 index 2e2b0204f31..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceContextDTO.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.ReferenceContext; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface ReferenceContextDTO extends ReferenceContext { - /** - * Include the declaration of the current symbol. - */ - void setIncludeDeclaration(final boolean includeDeclaration); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceParamsDTO.java deleted file mode 100644 index 4e99522a6ea..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ReferenceParamsDTO.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.ReferenceParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface ReferenceParamsDTO extends ReferenceParams { - /** - * Overridden to return the DTO type. - */ - ReferenceContextDTO getContext(); - - void setContext(final ReferenceContextDTO context); - - /** - * The text document. Overridden to return the DTO type. - */ - TextDocumentIdentifierDTO getTextDocument(); - - /** - * The text document. - */ - void setTextDocument(final TextDocumentIdentifierDTO textDocument); - - /** - * Legacy property to support protocol version 1.0 requests. - */ - void setUri(final String uri); - - /** - * The position inside the text document. Overridden to return the DTO type. - */ - PositionDTO getPosition(); - - /** - * The position inside the text document. - */ - void setPosition(final PositionDTO position); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RenameParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RenameParamsDTO.java deleted file mode 100644 index 6dd241663ea..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RenameParamsDTO.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.RenameParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface RenameParamsDTO extends RenameParams { - /** - * The document in which to find the symbol. Overridden to return the DTO - * type. - */ - TextDocumentIdentifierDTO getTextDocument(); - - /** - * The document in which to find the symbol. - */ - void setTextDocument(final TextDocumentIdentifierDTO textDocument); - - /** - * The position at which this request was send. Overridden to return the DTO - * type. - */ - PositionDTO getPosition(); - - /** - * The position at which this request was send. - */ - void setPosition(final PositionDTO position); - - /** - * The new name of the symbol. If the given name is not valid the request - * must return a ResponseError with an appropriate message set. - */ - void setNewName(final String newName); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RequestMessageDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RequestMessageDTO.java deleted file mode 100644 index ef978eeca9a..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/RequestMessageDTO.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.RequestMessage; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface RequestMessageDTO extends RequestMessage { - /** - * The request id. - */ - void setId(final String id); - - /** - * The method to be invoked. - */ - void setMethod(final String method); - - /** - * The method's params. - */ - void setParams(final Object params); - - void setJsonrpc(final String jsonrpc); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseErrorDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseErrorDTO.java deleted file mode 100644 index 20d58f38cbe..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseErrorDTO.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.ResponseError; -import io.typefox.lsapi.ResponseErrorCode; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface ResponseErrorDTO extends ResponseError { - /** - * A number indicating the error type that occured. - */ - void setCode(final ResponseErrorCode code); - - /** - * A string providing a short decription of the error. - */ - void setMessage(final String message); - - /** - * A Primitive or Structured value that contains additional information - * about the error. Can be omitted. - */ - void setData(final Object data); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseMessageDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseMessageDTO.java deleted file mode 100644 index 75f4a295330..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ResponseMessageDTO.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.ResponseMessage; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface ResponseMessageDTO extends ResponseMessage { - /** - * The request id. - */ - void setId(final String id); - - /** - * The result of a request. This can be omitted in the case of an error. - */ - void setResult(final Object result); - - /** - * The error object in case a request fails. Overridden to return the DTO - * type. - */ - ResponseErrorDTO getError(); - - /** - * The error object in case a request fails. - */ - void setError(final ResponseErrorDTO error); - - void setJsonrpc(final String jsonrpc); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ServerCapabilitiesDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ServerCapabilitiesDTO.java deleted file mode 100644 index 80a95e3fbd6..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ServerCapabilitiesDTO.java +++ /dev/null @@ -1,118 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.ServerCapabilities; -import io.typefox.lsapi.TextDocumentSyncKind; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface ServerCapabilitiesDTO extends ServerCapabilities { - /** - * Defines how text documents are synced. - */ - void setTextDocumentSync(final TextDocumentSyncKind textDocumentSync); - - /** - * The server provides hover support. - */ - void setHoverProvider(final Boolean hoverProvider); - - /** - * The server provides completion support. Overridden to return the DTO - * type. - */ - CompletionOptionsDTO getCompletionProvider(); - - /** - * The server provides completion support. - */ - void setCompletionProvider(final CompletionOptionsDTO completionProvider); - - /** - * The server provides signature help support. Overridden to return the DTO - * type. - */ - SignatureHelpOptionsDTO getSignatureHelpProvider(); - - /** - * The server provides signature help support. - */ - void setSignatureHelpProvider(final SignatureHelpOptionsDTO signatureHelpProvider); - - /** - * The server provides goto definition support. - */ - void setDefinitionProvider(final Boolean definitionProvider); - - /** - * The server provides find references support. - */ - void setReferencesProvider(final Boolean referencesProvider); - - /** - * The server provides document highlight support. - */ - void setDocumentHighlightProvider(final Boolean documentHighlightProvider); - - /** - * The server provides document symbol support. - */ - void setDocumentSymbolProvider(final Boolean documentSymbolProvider); - - /** - * The server provides workspace symbol support. - */ - void setWorkspaceSymbolProvider(final Boolean workspaceSymbolProvider); - - /** - * The server provides code actions. - */ - void setCodeActionProvider(final Boolean codeActionProvider); - - /** - * The server provides code lens. Overridden to return the DTO type. - */ - CodeLensOptionsDTO getCodeLensProvider(); - - /** - * The server provides code lens. - */ - void setCodeLensProvider(final CodeLensOptionsDTO codeLensProvider); - - /** - * The server provides document formatting. - */ - void setDocumentFormattingProvider(final Boolean documentFormattingProvider); - - /** - * The server provides document range formatting. - */ - void setDocumentRangeFormattingProvider(final Boolean documentRangeFormattingProvider); - - /** - * The server provides document formatting on typing. Overridden to return - * the DTO type. - */ - DocumentOnTypeFormattingOptionsDTO getDocumentOnTypeFormattingProvider(); - - /** - * The server provides document formatting on typing. - */ - void setDocumentOnTypeFormattingProvider( - final DocumentOnTypeFormattingOptionsDTO documentOnTypeFormattingProvider); - - /** - * The server provides rename support. - */ - void setRenameProvider(final Boolean renameProvider); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java deleted file mode 100644 index d658bc7934b..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/ShowMessageRequestParamsDTO.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.MessageType; -import io.typefox.lsapi.ShowMessageRequestParams; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * @author Sven Efftinge - */ -@DTO -public interface ShowMessageRequestParamsDTO extends ShowMessageRequestParams { - /** - * The message action items to present. Overridden to return the DTO type. - */ - List getActions(); - - /** - * The message action items to present. - */ - void setActions(final List actions); - - /** - * The message type. - */ - void setType(final MessageType type); - - /** - * The actual message. - */ - void setMessage(final String message); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpDTO.java deleted file mode 100644 index 9b230cc40ce..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpDTO.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.SignatureHelp; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * @author Sven Efftinge - */ -@DTO -public interface SignatureHelpDTO extends SignatureHelp { - /** - * One or more signatures. Overridden to return the DTO type. - */ - List getSignatures(); - - /** - * One or more signatures. - */ - void setSignatures(final List signatures); - - /** - * The active signature. - */ - void setActiveSignature(final Integer activeSignature); - - /** - * The active parameter of the active signature. - */ - void setActiveParameter(final Integer activeParameter); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java deleted file mode 100644 index 28889cb0458..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureHelpOptionsDTO.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.SignatureHelpOptions; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * @author Sven Efftinge - */ -@DTO -public interface SignatureHelpOptionsDTO extends SignatureHelpOptions { - /** - * The characters that trigger signature help automatically. - */ - void setTriggerCharacters(final List triggerCharacters); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureInformationDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureInformationDTO.java deleted file mode 100644 index 374f8716a08..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SignatureInformationDTO.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.SignatureInformation; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; - -/** - * @author Sven Efftinge - */ -@DTO -public interface SignatureInformationDTO extends SignatureInformation { - /** - * The label of this signature. Will be shown in the UI. - */ - void setLabel(final String label); - - /** - * The human-readable doc-comment of this signature. Will be shown in the UI - * but can be omitted. - */ - void setDocumentation(final String documentation); - - /** - * The parameters of this signature. Overridden to return the DTO type. - */ - List getParameters(); - - /** - * The parameters of this signature. - */ - void setParameters(final List parameters); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SymbolInformationDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SymbolInformationDTO.java deleted file mode 100644 index ce89a16da49..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/SymbolInformationDTO.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.SymbolInformation; -import io.typefox.lsapi.SymbolKind; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface SymbolInformationDTO extends SymbolInformation { - /** - * The name of this symbol. - */ - void setName(final String name); - - /** - * The kind of this symbol. - */ - void setKind(final SymbolKind kind); - - /** - * The location of this symbol. Overridden to return the DTO type. - */ - LocationDTO getLocation(); - - /** - * The location of this symbol. - */ - void setLocation(final LocationDTO location); - - /** - * The name of the symbol containing this symbol. - */ - void setContainerName(final String container); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java deleted file mode 100644 index 371a9c3279c..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentContentChangeEventDTO.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.TextDocumentContentChangeEvent; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface TextDocumentContentChangeEventDTO extends TextDocumentContentChangeEvent { - /** - * The range of the document that changed. Overridden to return the DTO - * type. - */ - RangeDTO getRange(); - - /** - * The range of the document that changed. - */ - void setRange(final RangeDTO range); - - /** - * The length of the range that got replaced. - */ - void setRangeLength(final Integer rangeLength); - - /** - * The new text of the document. - */ - void setText(final String text); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java deleted file mode 100644 index 65636327122..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentIdentifierDTO.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.TextDocumentIdentifier; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface TextDocumentIdentifierDTO extends TextDocumentIdentifier { - /** - * The text document's uri. - */ - void setUri(final String uri); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentItemDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentItemDTO.java deleted file mode 100644 index c8300089898..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentItemDTO.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.TextDocumentItem; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface TextDocumentItemDTO extends TextDocumentItem { - /** - * The text document's uri. - */ - void setUri(final String uri); - - /** - * The text document's language identifier - */ - void setLanguageId(final String languageId); - - /** - * The version number of this document (it will strictly increase after each - * change, including undo/redo). - */ - void setVersion(final int version); - - /** - * The content of the opened text document. - */ - void setText(final String text); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java deleted file mode 100644 index bb36ff1a4ae..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextDocumentPositionParamsDTO.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.TextDocumentPositionParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface TextDocumentPositionParamsDTO extends TextDocumentPositionParams { - /** - * The text document. Overridden to return the DTO type. - */ - TextDocumentIdentifierDTO getTextDocument(); - - /** - * The text document. - */ - void setTextDocument(final TextDocumentIdentifierDTO textDocument); - - /** - * Legacy property to support protocol version 1.0 requests. - */ - void setUri(final String uri); - - /** - * The position inside the text document. Overridden to return the DTO type. - */ - PositionDTO getPosition(); - - /** - * The position inside the text document. - */ - void setPosition(final PositionDTO position); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextEditDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextEditDTO.java deleted file mode 100644 index 6cfe35a24cf..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/TextEditDTO.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.TextEdit; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface TextEditDTO extends TextEdit { - /** - * The range of the text document to be manipulated. To insert text into a - * document create a range where start === end. Overridden to return the DTO - * type. - */ - RangeDTO getRange(); - - /** - * The range of the text document to be manipulated. To insert text into a - * document create a range where start === end. - */ - void setRange(final RangeDTO range); - - /** - * The string to be inserted. For delete operations use an empty string. - */ - void setNewText(final String newText); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java deleted file mode 100644 index b22a2517eeb..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/VersionedTextDocumentIdentifierDTO.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.VersionedTextDocumentIdentifier; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface VersionedTextDocumentIdentifierDTO extends VersionedTextDocumentIdentifier { - /** - * The version number of this document. - */ - void setVersion(final int version); - - /** - * The text document's uri. - */ - void setUri(final String uri); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceEditDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceEditDTO.java deleted file mode 100644 index e614749a48f..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceEditDTO.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.WorkspaceEdit; - -import org.eclipse.che.dto.shared.DTO; - -import java.util.List; -import java.util.Map; - -/** - * @author Sven Efftinge - */ -@DTO -public interface WorkspaceEditDTO extends WorkspaceEdit { - /** - * Holds changes to existing resources. - * Overridden to return the DTO type. - */ - Map> getChanges(); - - /** - * Holds changes to existing resources. - */ - void setChanges(final Map> changes); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java deleted file mode 100644 index 68c89c2f2c1..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/lsapi/WorkspaceSymbolParamsDTO.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2016 TypeFox GmbH (http://www.typefox.io) and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - */ -package org.eclipse.che.api.languageserver.shared.lsapi; - -import io.typefox.lsapi.WorkspaceSymbolParams; - -import org.eclipse.che.dto.shared.DTO; - -/** - * @author Sven Efftinge - */ -@DTO -public interface WorkspaceSymbolParamsDTO extends WorkspaceSymbolParams { - /** - * A non-empty query string - */ - void setQuery(final String query); - - String getFileUri(); - - void setFileUri(String fileUri); -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedCompletionItem.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedCompletionItem.java new file mode 100644 index 00000000000..1a55c86536b --- /dev/null +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedCompletionItem.java @@ -0,0 +1,22 @@ +package org.eclipse.che.api.languageserver.shared.model; + +import org.eclipse.lsp4j.CompletionItem; +import org.eclipse.lsp4j.TextDocumentIdentifier; + +/** + * Extended version of lsp4j {@link CompletionItem} for communication with the IDE. + * + * @author Thomas Mäder + */ +public class ExtendedCompletionItem extends CompletionItem { + + private TextDocumentIdentifier documentIdentifier; + + public TextDocumentIdentifier getTextDocumentIdentifier() { + return documentIdentifier; + } + + public void setTextDocumentIdentifier(TextDocumentIdentifier documentIdentifier) { + this.documentIdentifier = documentIdentifier; + } +} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedCompletionList.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedCompletionList.java new file mode 100644 index 00000000000..1b7664ec614 --- /dev/null +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedCompletionList.java @@ -0,0 +1,39 @@ +package org.eclipse.che.api.languageserver.shared.model; + +import org.eclipse.lsp4j.CompletionList; + +import java.util.List; + +/** + * Version of {@link CompletionList} that holds {@link ExtendedCompletionItem}s + * + * @author Thomas Mäder + */ +public class ExtendedCompletionList { + private boolean inComplete; + private List items; + + public ExtendedCompletionList(boolean incomplete, List items) { + this.inComplete = incomplete; + this.items = items; + } + + public ExtendedCompletionList() { + } + + public List getItems() { + return items; + } + + public void setItems(List items) { + this.items = items; + } + + public boolean isInComplete() { + return inComplete; + } + + public void setInComplete(boolean inComplete) { + this.inComplete = inComplete; + } +} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedInitializeResult.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedInitializeResult.java new file mode 100644 index 00000000000..7646ce7a442 --- /dev/null +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedInitializeResult.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * 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.api.languageserver.shared.model; + +import org.eclipse.lsp4j.ServerCapabilities; + +import java.util.Collections; +import java.util.List; + +/** + * Initialize result per project and language + * + * @author Anatoliy Bazko + * @author Thomas Mäder + */ +public class ExtendedInitializeResult { + + private String project; + private ServerCapabilities capabilities; + private List supportedLanguages; + + public ExtendedInitializeResult(String project, ServerCapabilities serverCapabilities, LanguageDescription languageDescription) { + this.project = project; + this.capabilities = serverCapabilities; + this.supportedLanguages = Collections.singletonList(languageDescription); + } + + public ExtendedInitializeResult() { + } + + public String getProject() { + return project; + } + + public void setProject(String project) { + this.project = project; + } + + public ServerCapabilities getCapabilities() { + return capabilities; + } + + public void setCapabilities(ServerCapabilities capabilities) { + this.capabilities = capabilities; + } + + public List getSupportedLanguages() { + return supportedLanguages; + } + + public void setSupportedLanguages(List supportedLanguages) { + this.supportedLanguages = supportedLanguages; + } +} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedWorkspaceSymbolParams.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedWorkspaceSymbolParams.java new file mode 100644 index 00000000000..c70c9956e1c --- /dev/null +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/ExtendedWorkspaceSymbolParams.java @@ -0,0 +1,21 @@ +package org.eclipse.che.api.languageserver.shared.model; + +import org.eclipse.lsp4j.WorkspaceSymbolParams; + +/** + * Version of workspace symbol params that holds the uri of the file the ide has open. + * + * @author Thomas Mäder + */ +public class ExtendedWorkspaceSymbolParams extends WorkspaceSymbolParams { + + private String fileUri; + + public String getFileUri() { + return fileUri; + } + + public void setFileUri(String fileUri) { + this.fileUri = fileUri; + } +} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/LanguageDescription.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/LanguageDescription.java index 0465dfac6c3..95e475fd0b8 100644 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/LanguageDescription.java +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/LanguageDescription.java @@ -10,30 +10,87 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.shared.model; + import java.util.List; +import java.util.Objects; /** * @author Anatolii Bazko */ -public interface LanguageDescription { +public class LanguageDescription { /** * The language id. */ - String getLanguageId(); - + private String languageId; /** * The optional content types this language is associated with. */ - List getMimeTypes(); - + private List mimeTypes; /** * The fileExtension this language is associated with. At least one extension must be provided. */ - List getFileExtensions(); - + private List fileExtensions; /** * The optional highlighting configuration to support client side syntax highlighting. * The format is client (editor) dependent. */ - String getHighlightingConfiguration(); + private String highlightingConfiguration; + + public String getLanguageId() { + return this.languageId; + } + + public void setLanguageId(final String languageId) { + this.languageId = languageId; + } + + public List getMimeTypes() { + return this.mimeTypes; + } + + public void setMimeTypes(final List mimeTypes) { + this.mimeTypes = mimeTypes; + } + + public List getFileExtensions() { + return this.fileExtensions; + } + + public void setFileExtensions(final List fileExtensions) { + this.fileExtensions = fileExtensions; + } + + public String getHighlightingConfiguration() { + return this.highlightingConfiguration; + } + + public void setHighlightingConfiguration(final String highlightingConfiguration) { + this.highlightingConfiguration = highlightingConfiguration; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + LanguageDescription that = (LanguageDescription)o; + return Objects.equals(languageId, that.languageId) && + Objects.equals(mimeTypes, that.mimeTypes) && + Objects.equals(fileExtensions, that.fileExtensions) && + Objects.equals(highlightingConfiguration, that.highlightingConfiguration); + } + + @Override + public int hashCode() { + return Objects.hash(languageId, mimeTypes, fileExtensions, highlightingConfiguration); + } + + @Override + public String toString() { + return "LanguageDescriptionImpl{" + + "languageId='" + languageId + '\'' + + ", mimeTypes=" + mimeTypes + + ", fileExtensions=" + fileExtensions + + ", highlightingConfiguration='" + highlightingConfiguration + '\'' + + '}'; + } } diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/InitializeResultImpl.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/InitializeResultImpl.java deleted file mode 100644 index 843ada87511..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/InitializeResultImpl.java +++ /dev/null @@ -1,43 +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.api.languageserver.shared.model.impl; - -import io.typefox.lsapi.InitializeResult; -import io.typefox.lsapi.ServerCapabilities; - -import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; - -import java.util.List; - -import static java.util.Collections.singletonList; - -/** - * @author Anatoliy Bazko - */ -public class InitializeResultImpl implements InitializeResult { - - private final ServerCapabilities serverCapabilities; - private final LanguageDescription languageDescription; - - public InitializeResultImpl(ServerCapabilities serverCapabilities, LanguageDescription languageDescription) { - this.serverCapabilities = serverCapabilities; - this.languageDescription = languageDescription; - } - - @Override - public ServerCapabilities getCapabilities() { - return serverCapabilities; - } - - public List getSupportedLanguages() { - return singletonList(languageDescription); - } -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/LanguageDescriptionImpl.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/LanguageDescriptionImpl.java deleted file mode 100644 index 2c672ea6f16..00000000000 --- a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/model/impl/LanguageDescriptionImpl.java +++ /dev/null @@ -1,102 +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.api.languageserver.shared.model.impl; - - -import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; - -import java.util.List; -import java.util.Objects; - -/** - * @author Anatolii Bazko - */ -public class LanguageDescriptionImpl implements LanguageDescription { - /** - * The language id. - */ - private String languageId; - /** - * The optional content types this language is associated with. - */ - private List mimeTypes; - /** - * The fileExtension this language is associated with. At least one extension must be provided. - */ - private List fileExtensions; - /** - * The optional highlighting configuration to support client side syntax highlighting. - * The format is client (editor) dependent. - */ - private String highlightingConfiguration; - - @Override - public String getLanguageId() { - return this.languageId; - } - - public void setLanguageId(final String languageId) { - this.languageId = languageId; - } - - @Override - public List getMimeTypes() { - return this.mimeTypes; - } - - public void setMimeTypes(final List mimeTypes) { - this.mimeTypes = mimeTypes; - } - - @Override - public List getFileExtensions() { - return this.fileExtensions; - } - - public void setFileExtensions(final List fileExtensions) { - this.fileExtensions = fileExtensions; - } - - @Override - public String getHighlightingConfiguration() { - return this.highlightingConfiguration; - } - - public void setHighlightingConfiguration(final String highlightingConfiguration) { - this.highlightingConfiguration = highlightingConfiguration; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - LanguageDescriptionImpl that = (LanguageDescriptionImpl)o; - return Objects.equals(languageId, that.languageId) && - Objects.equals(mimeTypes, that.mimeTypes) && - Objects.equals(fileExtensions, that.fileExtensions) && - Objects.equals(highlightingConfiguration, that.highlightingConfiguration); - } - - @Override - public int hashCode() { - return Objects.hash(languageId, mimeTypes, fileExtensions, highlightingConfiguration); - } - - @Override - public String toString() { - return "LanguageDescriptionImpl{" + - "languageId='" + languageId + '\'' + - ", mimeTypes=" + mimeTypes + - ", fileExtensions=" + fileExtensions + - ", highlightingConfiguration='" + highlightingConfiguration + '\'' + - '}'; - } -} diff --git a/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/util/JsonDecision.java b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/util/JsonDecision.java new file mode 100644 index 00000000000..9a4ad659524 --- /dev/null +++ b/wsagent/che-core-api-languageserver-shared/src/main/java/org/eclipse/che/api/languageserver/shared/util/JsonDecision.java @@ -0,0 +1,5 @@ +package org.eclipse.che.api.languageserver.shared.util; + +public enum JsonDecision { + LIST, BOOLEAN, NUMBER, STRING, OBJECT +} diff --git a/wsagent/che-core-api-languageserver/pom.xml b/wsagent/che-core-api-languageserver/pom.xml index acca5ab13f3..1d690303391 100644 --- a/wsagent/che-core-api-languageserver/pom.xml +++ b/wsagent/che-core-api-languageserver/pom.xml @@ -21,6 +21,9 @@ che-core-api-languageserver jar Che Core :: API :: Language Server + + ${project.build.directory}/generated-sources/dto/ + com.google.code.gson @@ -38,14 +41,6 @@ com.google.inject.extensions guice-multibindings - - io.typefox.lsapi - io.typefox.lsapi - - - io.typefox.lsapi - io.typefox.lsapi.services - javax.annotation javax.annotation-api @@ -82,6 +77,10 @@ org.eclipse.che.core che-core-commons-annotations + + org.eclipse.lsp4j + org.eclipse.lsp4j + org.everrest everrest-websockets @@ -90,6 +89,11 @@ org.slf4j slf4j-api + + ch.qos.logback + logback-classic + test + org.hamcrest hamcrest-core @@ -119,6 +123,9 @@ src/main/resources + + ${generated.sources.directory} + @@ -128,5 +135,81 @@ src/test/resources + + + com.mycila + license-maven-plugin + + + **/EitherUtil.java + **/JsonUtil.java + **/DtoConversionTest.java + + + + + org.eclipse.che.core + che-core-api-languageserver-maven-plugin + ${project.version} + + + process-sources + + generate + + + + + + ${project.groupId} + ${project.artifactId} + ${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.server.dto.DtoServerImpls + server + + + + org.codehaus.mojo + build-helper-maven-plugin + + + add-resource + process-sources + + add-resource + + + + + ${dto-generator-out-directory}/META-INF + META-INF + + + + + + add-source + process-sources + + add-source + + + + ${dto-generator-out-directory} + + + + + + diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/DtoConverter.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/DtoConverter.java deleted file mode 100644 index d4a28b10cfa..00000000000 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/DtoConverter.java +++ /dev/null @@ -1,120 +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.api.languageserver; - -import io.typefox.lsapi.CodeLensOptions; -import io.typefox.lsapi.CompletionOptions; -import io.typefox.lsapi.DocumentOnTypeFormattingOptions; -import io.typefox.lsapi.InitializeResult; -import io.typefox.lsapi.ServerCapabilities; -import io.typefox.lsapi.SignatureHelpOptions; - -import org.eclipse.che.api.languageserver.shared.lsapi.CodeLensOptionsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.CompletionOptionsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.DocumentOnTypeFormattingOptionsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.InitializeResultDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.ServerCapabilitiesDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.SignatureHelpOptionsDTO; -import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; - -import static org.eclipse.che.dto.server.DtoFactory.newDto; - -/** - * @author Anatoliy Bazko - */ -public class DtoConverter { - - public static InitializeResultDTO asDto(InitializeResult initializeResult) { - InitializeResultDTO initializeResultDTO = newDto(InitializeResultDTO.class); - initializeResultDTO.setCapabilities(asDto(initializeResult.getCapabilities())); - return initializeResultDTO; - } - - public static LanguageDescriptionDTO asDto(LanguageDescription languageDescription) { - LanguageDescriptionDTO languageDescriptionDTO = newDto(LanguageDescriptionDTO.class); - languageDescriptionDTO.setFileExtensions(languageDescription.getFileExtensions()); - languageDescriptionDTO.setHighlightingConfiguration(languageDescription.getHighlightingConfiguration()); - languageDescriptionDTO.setLanguageId(languageDescription.getLanguageId()); - languageDescriptionDTO.setMimeTypes(languageDescription.getMimeTypes()); - return languageDescriptionDTO; - } - - public static ServerCapabilitiesDTO asDto(ServerCapabilities capabilities) { - ServerCapabilitiesDTO serverCapabilitiesDTO = newDto(ServerCapabilitiesDTO.class); - - serverCapabilitiesDTO.setCodeActionProvider(capabilities.isCodeActionProvider()); - - CodeLensOptions codeLensProvider = capabilities.getCodeLensProvider(); - serverCapabilitiesDTO.setCodeLensProvider(codeLensProvider == null - ? null - : asDto(codeLensProvider)); - - CompletionOptions completionProvider = capabilities.getCompletionProvider(); - serverCapabilitiesDTO.setCompletionProvider(completionProvider == null - ? null - : asDto(completionProvider)); - - serverCapabilitiesDTO.setDefinitionProvider(capabilities.isDefinitionProvider()); - serverCapabilitiesDTO.setDocumentFormattingProvider(capabilities.isDocumentFormattingProvider()); - - DocumentOnTypeFormattingOptions documentOnTypeFormattingProvider = capabilities.getDocumentOnTypeFormattingProvider(); - serverCapabilitiesDTO.setDocumentOnTypeFormattingProvider(documentOnTypeFormattingProvider == null - ? null - : asDto(documentOnTypeFormattingProvider)); - - serverCapabilitiesDTO.setDocumentHighlightProvider(capabilities.isDocumentHighlightProvider()); - serverCapabilitiesDTO.setDocumentRangeFormattingProvider(capabilities.isDocumentRangeFormattingProvider()); - serverCapabilitiesDTO.setDocumentSymbolProvider(capabilities.isDocumentSymbolProvider()); - serverCapabilitiesDTO.setHoverProvider(capabilities.isHoverProvider()); - serverCapabilitiesDTO.setReferencesProvider(capabilities.isReferencesProvider()); - serverCapabilitiesDTO.setRenameProvider(capabilities.isRenameProvider()); - - SignatureHelpOptions signatureHelpProvider = capabilities.getSignatureHelpProvider(); - serverCapabilitiesDTO.setSignatureHelpProvider(signatureHelpProvider == null - ? null - : asDto(signatureHelpProvider)); - - serverCapabilitiesDTO.setTextDocumentSync(capabilities.getTextDocumentSync()); - serverCapabilitiesDTO.setWorkspaceSymbolProvider(capabilities.isWorkspaceSymbolProvider()); - - return serverCapabilitiesDTO; - } - - public static SignatureHelpOptionsDTO asDto(SignatureHelpOptions signatureHelpOptions) { - SignatureHelpOptionsDTO signatureHelpOptionsDTO = newDto(SignatureHelpOptionsDTO.class); - signatureHelpOptionsDTO.setTriggerCharacters(signatureHelpOptions.getTriggerCharacters()); - return signatureHelpOptionsDTO; - } - - public static DocumentOnTypeFormattingOptionsDTO asDto(DocumentOnTypeFormattingOptions documentOnTypeFormattingOptions) { - DocumentOnTypeFormattingOptionsDTO formattingOptionsDTO = newDto(DocumentOnTypeFormattingOptionsDTO.class); - formattingOptionsDTO.setFirstTriggerCharacter(documentOnTypeFormattingOptions.getFirstTriggerCharacter()); - formattingOptionsDTO.setMoreTriggerCharacter(documentOnTypeFormattingOptions.getMoreTriggerCharacter()); - return formattingOptionsDTO; - } - - public static CompletionOptionsDTO asDto(CompletionOptions completionOptions) { - CompletionOptionsDTO completionOptionsDTO = newDto(CompletionOptionsDTO.class); - completionOptionsDTO.setTriggerCharacters(completionOptions.getTriggerCharacters()); - completionOptionsDTO.setResolveProvider(completionOptions.getResolveProvider()); - return completionOptionsDTO; - } - - public static CodeLensOptionsDTO asDto(CodeLensOptions codeLensOptions) { - CodeLensOptionsDTO codeLensOptionsDTO = newDto(CodeLensOptionsDTO.class); - codeLensOptionsDTO.setResolveProvider(codeLensOptions.getResolveProvider()); - return codeLensOptionsDTO; - } - - private DtoConverter() { } - -} diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/exception/LanguageServerException.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/exception/LanguageServerException.java index 185517d4e87..19ab7a3ed8b 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/exception/LanguageServerException.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/exception/LanguageServerException.java @@ -15,6 +15,7 @@ /** * @author Anatoliy Bazko */ +@SuppressWarnings("serial") public class LanguageServerException extends ServerException { public LanguageServerException(String message) { super(message); diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncher.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncher.java index 54d48c4450f..b8b2e17ae85 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncher.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncher.java @@ -10,10 +10,10 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.launcher; -import io.typefox.lsapi.services.LanguageServer; - import org.eclipse.che.api.languageserver.exception.LanguageServerException; import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; +import org.eclipse.lsp4j.services.LanguageClient; +import org.eclipse.lsp4j.services.LanguageServer; /** * @author Anatoliy Bazko @@ -23,7 +23,7 @@ public interface LanguageServerLauncher { /** * Starts {@link io.typefox.lsapi.services.LanguageServer}. */ - LanguageServer launch(String projectPath) throws LanguageServerException; + LanguageServer launch(String projectPath, LanguageClient client) throws LanguageServerException; /** * Gets supported languages. diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncherTemplate.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncherTemplate.java index 70371d79d46..57eb429f84a 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncherTemplate.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/launcher/LanguageServerLauncherTemplate.java @@ -10,9 +10,9 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.launcher; -import io.typefox.lsapi.services.LanguageServer; - import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.lsp4j.services.LanguageClient; +import org.eclipse.lsp4j.services.LanguageServer; /** * @author Anatolii Bazko @@ -20,12 +20,13 @@ public abstract class LanguageServerLauncherTemplate implements LanguageServerLauncher { @Override - public final LanguageServer launch(String projectPath) throws LanguageServerException { + public final LanguageServer launch(String projectPath, LanguageClient client) throws LanguageServerException { Process languageServerProcess = startLanguageServerProcess(projectPath); - return connectToLanguageServer(languageServerProcess); + return connectToLanguageServer(languageServerProcess, client); } abstract protected Process startLanguageServerProcess(String projectPath) throws LanguageServerException; - abstract protected LanguageServer connectToLanguageServer(Process languageServerProcess) throws LanguageServerException; + abstract protected LanguageServer connectToLanguageServer(Process languageServerProcess, LanguageClient client) + throws LanguageServerException; } diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/InitializeEventMessenger.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/InitializeEventMessenger.java index df39099a11a..c6559452937 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/InitializeEventMessenger.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/InitializeEventMessenger.java @@ -10,17 +10,14 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.messager; -import io.typefox.lsapi.ServerCapabilities; -import io.typefox.lsapi.services.LanguageServer; - -import com.google.gson.Gson; - -import org.eclipse.che.api.languageserver.DtoConverter; import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; import org.eclipse.che.api.languageserver.registry.ServerInitializer; import org.eclipse.che.api.languageserver.registry.ServerInitializerObserver; -import org.eclipse.che.api.languageserver.shared.event.LanguageServerInitializeEventDto; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.LanguageServerInitializeEventDto; import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; +import org.eclipse.lsp4j.ServerCapabilities; +import org.eclipse.lsp4j.services.LanguageServer; import org.everrest.websockets.WSConnectionContext; import org.everrest.websockets.message.ChannelBroadcastMessage; import org.slf4j.Logger; @@ -33,8 +30,6 @@ import javax.websocket.EncodeException; import java.io.IOException; -import static org.eclipse.che.dto.server.DtoFactory.newDto; - /** * @author Anatolii Bazko */ @@ -55,9 +50,9 @@ public void onServerInitialized(LanguageServer server, LanguageDescription languageDescription, String projectPath) { - LanguageServerInitializeEventDto initializeEventDto = newDto(LanguageServerInitializeEventDto.class); - initializeEventDto.setSupportedLanguages(DtoConverter.asDto(languageDescription)); - initializeEventDto.setServerCapabilities(DtoConverter.asDto(serverCapabilities)); + LanguageServerInitializeEventDto initializeEventDto = new DtoServerImpls.LanguageServerInitializeEventDto(); + initializeEventDto.setSupportedLanguages(new DtoServerImpls.LanguageDescriptionDto(languageDescription)); + initializeEventDto.setServerCapabilities(new DtoServerImpls.ServerCapabilitiesDto(serverCapabilities)); initializeEventDto.setProjectPath(projectPath.substring(LanguageServerRegistryImpl.PROJECT_FOLDER_PATH.length())); send(initializeEventDto); @@ -77,7 +72,7 @@ protected void send(final LanguageServerInitializeEventDto message) { try { final ChannelBroadcastMessage bm = new ChannelBroadcastMessage(); bm.setChannel("languageserver"); - bm.setBody(new Gson().toJson(message)); + bm.setBody(message.toJson()); WSConnectionContext.sendMessage(bm); } catch (EncodeException | IOException e) { LOG.error(e.getMessage(), e); diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/PublishDiagnosticsParamsMessenger.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/PublishDiagnosticsParamsMessenger.java index 5c434f5e814..de033fd7d5b 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/PublishDiagnosticsParamsMessenger.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/PublishDiagnosticsParamsMessenger.java @@ -10,13 +10,10 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.messager; -import io.typefox.lsapi.PublishDiagnosticsParams; -import io.typefox.lsapi.impl.PublishDiagnosticsParamsImpl; - -import com.google.gson.Gson; - import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.core.notification.EventSubscriber; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls; +import org.eclipse.lsp4j.PublishDiagnosticsParams; import org.everrest.websockets.WSConnectionContext; import org.everrest.websockets.message.ChannelBroadcastMessage; import org.slf4j.Logger; @@ -42,12 +39,10 @@ public PublishDiagnosticsParamsMessenger(EventService eventService) { public void onEvent(final PublishDiagnosticsParams event) { try { - if (event instanceof PublishDiagnosticsParamsImpl && event.getUri().startsWith("file:///projects")) { - ((PublishDiagnosticsParamsImpl)event).setUri(event.getUri().substring(16)); - } + event.setUri(event.getUri().substring(16)); final ChannelBroadcastMessage bm = new ChannelBroadcastMessage(); bm.setChannel("languageserver/textDocument/publishDiagnostics"); - bm.setBody(new Gson().toJson(event)); + bm.setBody(new DtoServerImpls.PublishDiagnosticsParamsDto(event).toJson()); WSConnectionContext.sendMessage(bm); } catch (EncodeException | IOException e) { LOG.error(e.getMessage(), e); diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/ShowMessageMessenger.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/ShowMessageMessenger.java index 572f339d582..b4863613533 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/ShowMessageMessenger.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/messager/ShowMessageMessenger.java @@ -10,32 +10,30 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.messager; -import java.io.IOException; - -import javax.annotation.PostConstruct; -import javax.annotation.PreDestroy; -import javax.inject.Inject; -import javax.inject.Singleton; -import javax.websocket.EncodeException; - import org.eclipse.che.api.core.notification.EventService; import org.eclipse.che.api.core.notification.EventSubscriber; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls; +import org.eclipse.lsp4j.MessageParams; import org.everrest.websockets.WSConnectionContext; import org.everrest.websockets.message.ChannelBroadcastMessage; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.gson.Gson; - -import io.typefox.lsapi.MessageParams; +import javax.annotation.PostConstruct; +import javax.annotation.PreDestroy; +import javax.inject.Inject; +import javax.inject.Singleton; +import javax.websocket.EncodeException; +import java.io.IOException; /** * {@link EventSubscriber} for incoming window/showMessage notifications. + * * @author xcoulon */ @Singleton public class ShowMessageMessenger implements EventSubscriber { - + private final static Logger LOG = LoggerFactory.getLogger(ShowMessageMessenger.class); private final EventService eventService; @@ -49,7 +47,7 @@ public void onEvent(final MessageParams event) { try { final ChannelBroadcastMessage bm = new ChannelBroadcastMessage(); bm.setChannel("languageserver/window/showMessage"); - bm.setBody(new Gson().toJson(event)); + bm.setBody(new DtoServerImpls.MessageParamsDto(event).toJson()); WSConnectionContext.sendMessage(bm); } catch (EncodeException | IOException e) { LOG.error(e.getMessage(), e); diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerDescription.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerDescription.java index 0409d266ca6..acd7cc72ab7 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerDescription.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerDescription.java @@ -10,9 +10,8 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.registry; -import io.typefox.lsapi.InitializeResult; - import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; +import org.eclipse.lsp4j.InitializeResult; /** diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistry.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistry.java index 8456eee7bd2..e4274906a29 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistry.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistry.java @@ -10,12 +10,11 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.registry; -import io.typefox.lsapi.services.LanguageServer; - import org.eclipse.che.api.languageserver.exception.LanguageServerException; import org.eclipse.che.api.languageserver.shared.ProjectExtensionKey; import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import org.eclipse.che.commons.annotation.Nullable; +import org.eclipse.lsp4j.services.LanguageServer; import java.util.List; import java.util.Map; diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImpl.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImpl.java index fae70ac8fb6..8e96f72336e 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImpl.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImpl.java @@ -10,9 +10,6 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.registry; -import io.typefox.lsapi.ServerCapabilities; -import io.typefox.lsapi.services.LanguageServer; - import com.google.inject.Inject; import com.google.inject.Provider; import com.google.inject.Singleton; @@ -26,6 +23,8 @@ import org.eclipse.che.api.project.server.ProjectManager; import org.eclipse.che.api.project.server.VirtualFileEntry; import org.eclipse.che.commons.annotation.Nullable; +import org.eclipse.lsp4j.ServerCapabilities; +import org.eclipse.lsp4j.services.LanguageServer; import java.net.URI; import java.util.ArrayList; diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializer.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializer.java index 1da97f1203b..2d7b9c89d9a 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializer.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializer.java @@ -10,10 +10,9 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.registry; -import io.typefox.lsapi.services.LanguageServer; - import org.eclipse.che.api.languageserver.exception.LanguageServerException; import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; +import org.eclipse.lsp4j.services.LanguageServer; import java.util.Map; diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImpl.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImpl.java index 5e9322a9424..8d8832cdaf7 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImpl.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImpl.java @@ -10,12 +10,6 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.registry; -import io.typefox.lsapi.InitializeResult; -import io.typefox.lsapi.ServerCapabilities; -import io.typefox.lsapi.impl.ClientCapabilitiesImpl; -import io.typefox.lsapi.impl.InitializeParamsImpl; -import io.typefox.lsapi.services.LanguageServer; - import com.google.inject.Inject; import com.google.inject.Singleton; @@ -24,6 +18,15 @@ import org.eclipse.che.api.languageserver.messager.PublishDiagnosticsParamsMessenger; import org.eclipse.che.api.languageserver.messager.ShowMessageMessenger; import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; +import org.eclipse.lsp4j.ClientCapabilities; +import org.eclipse.lsp4j.InitializeParams; +import org.eclipse.lsp4j.InitializeResult; +import org.eclipse.lsp4j.MessageParams; +import org.eclipse.lsp4j.PublishDiagnosticsParams; +import org.eclipse.lsp4j.ServerCapabilities; +import org.eclipse.lsp4j.ShowMessageRequestParams; +import org.eclipse.lsp4j.services.LanguageClient; +import org.eclipse.lsp4j.services.LanguageServer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -36,7 +39,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ExecutionException; -import java.util.stream.Collectors; /** * @author Anatoliy Bazko @@ -48,21 +50,47 @@ public class ServerInitializerImpl implements ServerInitializer { private static final int PROCESS_ID = getProcessId(); private static final String CLIENT_NAME = "EclipseChe"; - private final List observers; - private final PublishDiagnosticsParamsMessenger publishDiagnosticsParamsMessenger; - private final ShowMessageMessenger showMessageMessenger; - - private final ConcurrentHashMap languageIdToServers; + private final List observers; + + private final ConcurrentHashMap languageIdToServers; private final ConcurrentHashMap serversToInitResult; + private LanguageClient languageClient; + @Inject public ServerInitializerImpl(final PublishDiagnosticsParamsMessenger publishDiagnosticsParamsMessenger, - final ShowMessageMessenger showMessageMessenger) { + final ShowMessageMessenger showMessageMessenger) { this.observers = new ArrayList<>(); this.languageIdToServers = new ConcurrentHashMap<>(); this.serversToInitResult = new ConcurrentHashMap<>(); - this.publishDiagnosticsParamsMessenger = publishDiagnosticsParamsMessenger; - this.showMessageMessenger = showMessageMessenger; + languageClient = new LanguageClient() { + + @Override + public void telemetryEvent(Object object) { + // TODO Auto-generated method stub + + } + + @Override + public CompletableFuture showMessageRequest(ShowMessageRequestParams requestParams) { + return CompletableFuture.completedFuture(null); + } + + @Override + public void showMessage(MessageParams messageParams) { + showMessageMessenger.onEvent(messageParams); + } + + @Override + public void publishDiagnostics(PublishDiagnosticsParams diagnostics) { + publishDiagnosticsParamsMessenger.onEvent(diagnostics); + } + + @Override + public void logMessage(MessageParams message) { + LOG.error(message.getType() + " " + message.getMessage()); + } + }; } private static int getProcessId() { @@ -102,7 +130,8 @@ public LanguageServer initialize(LanguageServerLauncher launcher, String project server = doInitialize(launcher, projectPath); languageIdToServers.put(languageId, server); } - onServerInitialized(server, serversToInitResult.get(server).getInitializeResult().getCapabilities(), launcher.getLanguageDescription(), projectPath); + onServerInitialized(server, serversToInitResult.get(server).getInitializeResult().getCapabilities(), + launcher.getLanguageDescription(), projectPath); return server; } } @@ -114,11 +143,11 @@ public Map getInitializedServers() { protected LanguageServer doInitialize(LanguageServerLauncher launcher, String projectPath) throws LanguageServerException { String languageId = launcher.getLanguageDescription().getLanguageId(); - InitializeParamsImpl initializeParams = prepareInitializeParams(projectPath); + InitializeParams initializeParams = prepareInitializeParams(projectPath); LanguageServer server; try { - server = launcher.launch(projectPath); + server = launcher.launch(projectPath, languageClient); } catch (LanguageServerException e) { throw new LanguageServerException( "Can't initialize Language Server " + languageId + " on " + projectPath + ". " + e.getMessage(), e); @@ -141,21 +170,17 @@ protected LanguageServer doInitialize(LanguageServerLauncher launcher, String pr } protected void registerCallbacks(LanguageServer server) { - server.getTextDocumentService().onPublishDiagnostics(publishDiagnosticsParamsMessenger::onEvent); - server.getWindowService().onLogMessage(messageParams -> LOG.error(messageParams.getType() + " " + messageParams.getMessage())); - server.getWindowService().onShowMessage(showMessageMessenger::onEvent); - server.onTelemetryEvent(o -> LOG.error(o.toString())); - + if (server instanceof ServerInitializerObserver) { - addObserver((ServerInitializerObserver) server); + addObserver((ServerInitializerObserver)server); } } - protected InitializeParamsImpl prepareInitializeParams(String projectPath) { - InitializeParamsImpl initializeParams = new InitializeParamsImpl(); + protected InitializeParams prepareInitializeParams(String projectPath) { + InitializeParams initializeParams = new InitializeParams(); initializeParams.setProcessId(PROCESS_ID); initializeParams.setRootPath(projectPath); - initializeParams.setCapabilities(new ClientCapabilitiesImpl()); + initializeParams.setCapabilities(new ClientCapabilities()); initializeParams.setClientName(CLIENT_NAME); return initializeParams; } diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObserver.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObserver.java index d18f860f610..4ae6f1581b7 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObserver.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/registry/ServerInitializerObserver.java @@ -10,10 +10,9 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.registry; -import io.typefox.lsapi.ServerCapabilities; -import io.typefox.lsapi.services.LanguageServer; - import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; +import org.eclipse.lsp4j.ServerCapabilities; +import org.eclipse.lsp4j.services.LanguageServer; /** * @author Anatoliy Bazko @@ -24,9 +23,9 @@ public interface ServerInitializerObserver { * Notifies observers when server is initialized and ready to use. * * @param server - * the {@link LanguageServer} + * the {@link LanguageServer} * @param capabilities - * the supported capabilities by server + * the supported capabilities by server * @param languageDescription * @param projectPath */ diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/LanguageRegistryService.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/LanguageRegistryService.java index 4edd00abcb7..b7891736f86 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/LanguageRegistryService.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/LanguageRegistryService.java @@ -13,14 +13,15 @@ import com.google.inject.Inject; import com.google.inject.Singleton; -import org.eclipse.che.api.languageserver.DtoConverter; import org.eclipse.che.api.languageserver.exception.LanguageServerException; import org.eclipse.che.api.languageserver.registry.LanguageServerDescription; import org.eclipse.che.api.languageserver.registry.LanguageServerRegistry; import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.ExtendedInitializeResultDto; import org.eclipse.che.api.languageserver.shared.ProjectExtensionKey; -import org.eclipse.che.api.languageserver.shared.lsapi.InitializeResultDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.LanguageDescriptionDTO; +import org.eclipse.che.api.languageserver.shared.model.ExtendedInitializeResult; +import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -32,57 +33,51 @@ import java.util.List; import static java.util.stream.Collectors.toList; -import static org.eclipse.che.api.languageserver.DtoConverter.asDto; -import static org.eclipse.che.dto.server.DtoFactory.newDto; @Singleton @Path("languageserver") public class LanguageRegistryService { - private final LanguageServerRegistry registry; + private final LanguageServerRegistry registry; - @Inject - public LanguageRegistryService(LanguageServerRegistry registry) { - this.registry = registry; - } + @Inject + public LanguageRegistryService(LanguageServerRegistry registry) { + this.registry = registry; + } - @GET - @Produces(MediaType.APPLICATION_JSON) - @Path("supported") - public List getSupportedLanguages() { - return registry.getSupportedLanguages() - .stream() - .map(DtoConverter::asDto) - .collect(toList()); - } + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("supported") + public List getSupportedLanguages() { + return registry.getSupportedLanguages(); + } - @GET - @Produces(MediaType.APPLICATION_JSON) - @Path("registered") - public List getRegisteredLanguages() { - return registry.getInitializedLanguages() - .entrySet() - .stream() - .map(entry -> { - ProjectExtensionKey projectExtensionKey = entry.getKey(); - LanguageServerDescription serverDescription = entry.getValue(); + @GET + @Produces(MediaType.APPLICATION_JSON) + @Path("registered") + public List getRegisteredLanguages() { + return registry.getInitializedLanguages() + .entrySet() + .stream() + .map(entry -> { + ProjectExtensionKey projectExtensionKey = entry.getKey(); + LanguageServerDescription serverDescription = entry.getValue(); - List languageDescriptionDTOs - = Collections.singletonList(asDto(serverDescription.getLanguageDescription())); - InitializeResultDTO dto = newDto(InitializeResultDTO.class); - dto.setProject(projectExtensionKey.getProject().substring(LanguageServerRegistryImpl.PROJECT_FOLDER_PATH.length())); - dto.setSupportedLanguages(languageDescriptionDTOs); - dto.setCapabilities(asDto(serverDescription.getInitializeResult().getCapabilities())); - return dto; - }) - .collect(toList()); + ExtendedInitializeResult dto = new ExtendedInitializeResult(); + dto.setProject( + projectExtensionKey.getProject().substring(LanguageServerRegistryImpl.PROJECT_FOLDER_PATH.length())); + dto.setSupportedLanguages(Collections.singletonList(serverDescription.getLanguageDescription())); + dto.setCapabilities(serverDescription.getInitializeResult().getCapabilities()); + return new DtoServerImpls.ExtendedInitializeResultDto(dto); + }) + .collect(toList()); - } + } - @POST + @POST @Path("initialize") - public void initialize(@QueryParam("path") String path) throws LanguageServerException { + public void initialize(@QueryParam("path") String path) throws LanguageServerException { //in most cases starts new LS if not already started registry.findServer(TextDocumentService.prefixURI(path)); } diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/TextDocumentService.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/TextDocumentService.java index 8bd75c7d674..681d6c23fa4 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/TextDocumentService.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/TextDocumentService.java @@ -10,52 +10,49 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.service; -import static java.util.Collections.emptyList; - -import java.util.List; -import java.util.concurrent.ExecutionException; +import com.google.inject.Singleton; +import org.eclipse.che.api.languageserver.exception.LanguageServerException; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistry; +import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.CompletionItemDto; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.CompletionListDto; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.ExtendedCompletionItemDto; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.HoverDto; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.LocationDto; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.SignatureHelpDto; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.SymbolInformationDto; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.TextEditDto; +import org.eclipse.lsp4j.CompletionList; +import org.eclipse.lsp4j.DidChangeTextDocumentParams; +import org.eclipse.lsp4j.DidCloseTextDocumentParams; +import org.eclipse.lsp4j.DidOpenTextDocumentParams; +import org.eclipse.lsp4j.DidSaveTextDocumentParams; +import org.eclipse.lsp4j.DocumentFormattingParams; +import org.eclipse.lsp4j.DocumentHighlight; +import org.eclipse.lsp4j.DocumentOnTypeFormattingParams; +import org.eclipse.lsp4j.DocumentRangeFormattingParams; +import org.eclipse.lsp4j.DocumentSymbolParams; +import org.eclipse.lsp4j.Location; +import org.eclipse.lsp4j.ReferenceParams; +import org.eclipse.lsp4j.TextDocumentPositionParams; +import org.eclipse.lsp4j.services.LanguageServer; + +import javax.inject.Inject; import javax.ws.rs.Consumes; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; - -import org.eclipse.che.api.languageserver.exception.LanguageServerException; -import org.eclipse.che.api.languageserver.registry.LanguageServerRegistry; -import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; -import org.eclipse.che.api.languageserver.shared.lsapi.CodeActionParamsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.CompletionItemDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.DidChangeTextDocumentParamsDTO; -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.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.DocumentSymbolParamsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.ReferenceParamsDTO; -import org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO; - -import com.google.inject.Inject; -import com.google.inject.Singleton; - -import io.typefox.lsapi.Command; -import io.typefox.lsapi.CompletionItem; -import io.typefox.lsapi.CompletionList; -import io.typefox.lsapi.DocumentHighlight; -import io.typefox.lsapi.Hover; -import io.typefox.lsapi.Location; -import io.typefox.lsapi.SignatureHelp; -import io.typefox.lsapi.SymbolInformation; -import io.typefox.lsapi.TextEdit; -import io.typefox.lsapi.impl.LocationImpl; -import io.typefox.lsapi.services.LanguageServer; +import java.util.Collections; +import java.util.List; +import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; /** - * REST API for the textDocument/* services defined in - * https://github.com/Microsoft/vscode-languageserver-protocol Dispatches onto - * the {@link LanguageServerRegistryImpl}. + * REST API for the textDoc + *

    + * Dispatches onto the {@link LanguageServerRegistryImpl}. */ @Singleton @Path("languageserver/textDocument") @@ -81,119 +78,122 @@ static String removePrefixUri(String uri) { return uri; } + @SuppressWarnings("deprecation") @POST @Path("completion") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public CompletionList completion(TextDocumentPositionParamsDTO textDocumentPositionParams) - throws InterruptedException, ExecutionException, LanguageServerException { + public CompletionListDto completion(TextDocumentPositionParams textDocumentPositionParams) + throws InterruptedException, ExecutionException, LanguageServerException { textDocumentPositionParams.getTextDocument().setUri(prefixURI(textDocumentPositionParams.getTextDocument().getUri())); textDocumentPositionParams.setUri(prefixURI(textDocumentPositionParams.getUri())); LanguageServer server = getServer(textDocumentPositionParams.getTextDocument().getUri()); if (server == null) { return null; } - return server.getTextDocumentService().completion(textDocumentPositionParams).get(); + CompletionList result = server.getTextDocumentService().completion(textDocumentPositionParams).get(); + + return new CompletionListDto(result); } @POST @Path("documentSymbol") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public List documentSymbol(DocumentSymbolParamsDTO documentSymbolParams) - throws ExecutionException, InterruptedException, LanguageServerException { + public List documentSymbol(DocumentSymbolParams documentSymbolParams) + throws ExecutionException, InterruptedException, LanguageServerException { documentSymbolParams.getTextDocument().setUri(prefixURI(documentSymbolParams.getTextDocument().getUri())); LanguageServer server = getServer(documentSymbolParams.getTextDocument().getUri()); if (server == null) { - return emptyList(); + return Collections.emptyList(); } - return server.getTextDocumentService().documentSymbol(documentSymbolParams).get(); + return server.getTextDocumentService().documentSymbol(documentSymbolParams).get().stream().map(o -> new SymbolInformationDto(o)) + .collect(Collectors.toList()); } @POST @Path("references") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public List references(ReferenceParamsDTO params) - throws ExecutionException, InterruptedException, LanguageServerException { + public List references(ReferenceParams params) + throws ExecutionException, InterruptedException, LanguageServerException { params.getTextDocument().setUri(prefixURI(params.getTextDocument().getUri())); LanguageServer server = getServer(params.getTextDocument().getUri()); if (server == null) { - return emptyList(); + return Collections.emptyList(); } List locations = server.getTextDocumentService().references(params).get(); locations.forEach(o -> { - if (o instanceof LocationImpl) { - ((LocationImpl) o).setUri(removePrefixUri(o.getUri())); - } + o.setUri(removePrefixUri(o.getUri())); }); - return locations; + return locations.stream().map(o -> new LocationDto(o)).collect(Collectors.toList()); } @POST @Path("definition") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public List definition(TextDocumentPositionParamsDTO params) - throws ExecutionException, InterruptedException, LanguageServerException { + public List definition(TextDocumentPositionParams params) + throws ExecutionException, InterruptedException, LanguageServerException { params.getTextDocument().setUri(prefixURI(params.getTextDocument().getUri())); LanguageServer server = getServer(params.getTextDocument().getUri()); if (server == null) { - return emptyList(); + return Collections.emptyList(); } List locations = server.getTextDocumentService().definition(params).get(); locations.forEach(o -> { - if (o instanceof LocationImpl) { - ((LocationImpl) o).setUri(removePrefixUri(o.getUri())); - } + o.setUri(removePrefixUri(o.getUri())); }); - return locations; + return locations.stream().map(o -> new LocationDto(o)).collect(Collectors.toList()); } + @POST @Path("completionItem/resolve") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public CompletionItem resolveCompletionItem(CompletionItemDTO unresolved) - throws InterruptedException, ExecutionException, LanguageServerException { + public CompletionItemDto resolveCompletionItem(ExtendedCompletionItemDto unresolved) + throws InterruptedException, ExecutionException, LanguageServerException { LanguageServer server = getServer(prefixURI(unresolved.getTextDocumentIdentifier().getUri())); if (server != null) { - return server.getTextDocumentService().resolveCompletionItem(unresolved).get(); + return new CompletionItemDto(server.getTextDocumentService().resolveCompletionItem(unresolved).get()); } else { - return unresolved; + return new CompletionItemDto(unresolved); } } + @SuppressWarnings("deprecation") @POST @Path("hover") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public Hover hover(TextDocumentPositionParamsDTO positionParams) - throws LanguageServerException, ExecutionException, InterruptedException { + public HoverDto hover(TextDocumentPositionParams positionParams) + throws LanguageServerException, ExecutionException, InterruptedException { positionParams.getTextDocument().setUri(prefixURI(positionParams.getTextDocument().getUri())); - positionParams.setUri(positionParams.getTextDocument().getUri()); + positionParams.setUri(prefixURI(positionParams.getUri())); LanguageServer server = getServer(positionParams.getTextDocument().getUri()); if (server != null) { - return server.getTextDocumentService().hover(positionParams).get(); + return new HoverDto(server.getTextDocumentService().hover(positionParams).get()); } else { return null; } } + @SuppressWarnings("deprecation") @POST @Path("signatureHelp") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public SignatureHelp signatureHelp(TextDocumentPositionParamsDTO positionParams) - throws LanguageServerException, ExecutionException, InterruptedException { + public SignatureHelpDto signatureHelp(TextDocumentPositionParams positionParams) + throws LanguageServerException, ExecutionException, InterruptedException { positionParams.getTextDocument().setUri(prefixURI(positionParams.getTextDocument().getUri())); positionParams.setUri(prefixURI(positionParams.getUri())); LanguageServer server = getServer(positionParams.getTextDocument().getUri()); if (server != null) { - return server.getTextDocumentService().signatureHelp(positionParams).get(); + return new SignatureHelpDto(server.getTextDocumentService().signatureHelp(positionParams).get()); } else { return null; } @@ -203,14 +203,14 @@ public SignatureHelp signatureHelp(TextDocumentPositionParamsDTO positionParams) @Path("formatting") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public List formatting(DocumentFormattingParamsDTO params) - throws InterruptedException, ExecutionException, LanguageServerException { + public List formatting(DocumentFormattingParams params) + throws InterruptedException, ExecutionException, LanguageServerException { params.getTextDocument().setUri(prefixURI(params.getTextDocument().getUri())); LanguageServer server = getServer(params.getTextDocument().getUri()); if (server == null) { - return emptyList(); + return Collections.emptyList(); } - return server.getTextDocumentService().formatting(params).get(); + return server.getTextDocumentService().formatting(params).get().stream().map(o -> new TextEditDto(o)).collect(Collectors.toList()); } @@ -218,14 +218,15 @@ public List formatting(DocumentFormattingParamsDTO params) @Path("rangeFormatting") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public List rangeFormatting(DocumentRangeFormattingParamsDTO params) - throws InterruptedException, ExecutionException, LanguageServerException { + public List rangeFormatting(DocumentRangeFormattingParams params) + throws InterruptedException, ExecutionException, LanguageServerException { params.getTextDocument().setUri(prefixURI(params.getTextDocument().getUri())); LanguageServer server = getServer(params.getTextDocument().getUri()); if (server == null) { - return emptyList(); + return Collections.emptyList(); } - return server.getTextDocumentService().rangeFormatting(params).get(); + return server.getTextDocumentService().rangeFormatting(params).get().stream().map(o -> new TextEditDto(o)) + .collect(Collectors.toList()); } @@ -233,21 +234,23 @@ public List rangeFormatting(DocumentRangeFormattingParamsDTO @Path("onTypeFormatting") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public List onTypeFormatting(DocumentOnTypeFormattingParamsDTO params) - throws InterruptedException, ExecutionException, LanguageServerException { + public List onTypeFormatting(DocumentOnTypeFormattingParams params) + throws InterruptedException, ExecutionException, LanguageServerException { params.getTextDocument().setUri(prefixURI(params.getTextDocument().getUri())); LanguageServer server = getServer(params.getTextDocument().getUri()); if (server == null) { - return emptyList(); + return Collections.emptyList(); } - return server.getTextDocumentService().onTypeFormatting(params).get(); + return server.getTextDocumentService().onTypeFormatting(params).get().stream().map(o -> new TextEditDto(o)) + .collect(Collectors.toList()); } + @SuppressWarnings("deprecation") @POST @Path("didChange") @Consumes(MediaType.APPLICATION_JSON) - public void didChange(DidChangeTextDocumentParamsDTO change) throws LanguageServerException { + public void didChange(DidChangeTextDocumentParams change) throws LanguageServerException { change.getTextDocument().setUri(prefixURI(change.getTextDocument().getUri())); change.setUri(prefixURI(change.getUri())); LanguageServer server = getServer(change.getTextDocument().getUri()); @@ -259,9 +262,8 @@ public void didChange(DidChangeTextDocumentParamsDTO change) throws LanguageServ @POST @Path("didOpen") @Consumes(MediaType.APPLICATION_JSON) - public void didOpen(DidOpenTextDocumentParamsDTO openEvent) throws LanguageServerException { + public void didOpen(DidOpenTextDocumentParams openEvent) throws LanguageServerException { openEvent.getTextDocument().setUri(prefixURI(openEvent.getTextDocument().getUri())); - openEvent.setUri(prefixURI(openEvent.getUri())); LanguageServer server = getServer(openEvent.getTextDocument().getUri()); if (server != null) { server.getTextDocumentService().didOpen(openEvent); @@ -271,7 +273,7 @@ public void didOpen(DidOpenTextDocumentParamsDTO openEvent) throws LanguageServe @POST @Path("didClose") @Consumes(MediaType.APPLICATION_JSON) - public void didClose(DidCloseTextDocumentParamsDTO closeEvent) throws LanguageServerException { + public void didClose(DidCloseTextDocumentParams closeEvent) throws LanguageServerException { closeEvent.getTextDocument().setUri(prefixURI(closeEvent.getTextDocument().getUri())); LanguageServer server = getServer(closeEvent.getTextDocument().getUri()); if (server != null) { @@ -282,7 +284,7 @@ public void didClose(DidCloseTextDocumentParamsDTO closeEvent) throws LanguageSe @POST @Path("didSave") @Consumes(MediaType.APPLICATION_JSON) - public void didSave(DidSaveTextDocumentParamsDTO saveEvent) throws LanguageServerException { + public void didSave(DidSaveTextDocumentParams saveEvent) throws LanguageServerException { saveEvent.getTextDocument().setUri(prefixURI(saveEvent.getTextDocument().getUri())); LanguageServer server = getServer(saveEvent.getTextDocument().getUri()); if (server != null) { @@ -293,30 +295,16 @@ public void didSave(DidSaveTextDocumentParamsDTO saveEvent) throws LanguageServe @POST @Path("documentHighlight") @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public DocumentHighlight documentHighlight(TextDocumentPositionParamsDTO positionParams) - throws LanguageServerException, InterruptedException, ExecutionException { + public DocumentHighlight documentHighlight(TextDocumentPositionParams positionParams) + throws LanguageServerException, InterruptedException, ExecutionException { positionParams.getTextDocument().setUri(prefixURI(positionParams.getTextDocument().getUri())); LanguageServer server = getServer(positionParams.getTextDocument().getUri()); if (server != null) { - return server.getTextDocumentService().documentHighlight(positionParams).get(); + return server.getTextDocumentService().documentHighlight(positionParams).get().get(0); } return null; } - @POST - @Path("codeAction") - @Consumes(MediaType.APPLICATION_JSON) - @Produces(MediaType.APPLICATION_JSON) - public List codeAction(CodeActionParamsDTO params) - throws LanguageServerException, InterruptedException, ExecutionException { - params.getTextDocument().setUri(prefixURI(params.getTextDocument().getUri())); - LanguageServer server = getServer(params.getTextDocument().getUri()); - if (server != null) { - return server.getTextDocumentService().codeAction(params).get(); - } - return null; - } private LanguageServer getServer(String uri) throws LanguageServerException { return languageServerRegistry.findServer(uri); diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/WorkspaceService.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/WorkspaceService.java index 90756ad81cc..fe85291d7c0 100644 --- a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/WorkspaceService.java +++ b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/service/WorkspaceService.java @@ -10,18 +10,17 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.service; -import io.typefox.lsapi.Location; -import io.typefox.lsapi.SymbolInformation; -import io.typefox.lsapi.impl.LocationImpl; -import io.typefox.lsapi.services.LanguageServer; - import com.google.inject.Inject; import com.google.inject.Singleton; import org.eclipse.che.api.languageserver.exception.LanguageServerException; import org.eclipse.che.api.languageserver.registry.LanguageServerRegistry; import org.eclipse.che.api.languageserver.registry.LanguageServerRegistryImpl; -import org.eclipse.che.api.languageserver.shared.lsapi.WorkspaceSymbolParamsDTO; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.SymbolInformationDto; +import org.eclipse.che.api.languageserver.shared.model.ExtendedWorkspaceSymbolParams; +import org.eclipse.lsp4j.Location; +import org.eclipse.lsp4j.SymbolInformation; +import org.eclipse.lsp4j.services.LanguageServer; import javax.ws.rs.Consumes; import javax.ws.rs.POST; @@ -30,6 +29,7 @@ import javax.ws.rs.core.MediaType; import java.util.List; import java.util.concurrent.ExecutionException; +import java.util.stream.Collectors; import static java.util.Collections.emptyList; @@ -53,9 +53,10 @@ public WorkspaceService(LanguageServerRegistry registry) { @Path("symbol") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) - public List documentSymbol(WorkspaceSymbolParamsDTO workspaceSymbolParams) throws ExecutionException, - InterruptedException, - LanguageServerException { + public List documentSymbol(ExtendedWorkspaceSymbolParams workspaceSymbolParams) + throws ExecutionException, + InterruptedException, + LanguageServerException { LanguageServer server = getServer(TextDocumentService.prefixURI(workspaceSymbolParams.getFileUri())); if (server == null) { return emptyList(); @@ -64,11 +65,9 @@ public List documentSymbol(WorkspaceSymbolParamsDTO List informations = server.getWorkspaceService().symbol(workspaceSymbolParams).get(); informations.forEach(o -> { Location location = o.getLocation(); - if (location instanceof LocationImpl) { - ((LocationImpl)location).setUri(TextDocumentService.removePrefixUri(location.getUri())); - } + location.setUri(TextDocumentService.removePrefixUri(location.getUri())); }); - return informations; + return informations.stream().map(o -> new SymbolInformationDto(o)).collect(Collectors.toList()); } private LanguageServer getServer(String uri) throws LanguageServerException { diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/util/EitherUtil.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/util/EitherUtil.java new file mode 100644 index 00000000000..87f6b0ef41f --- /dev/null +++ b/wsagent/che-core-api-languageserver/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.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +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(JsonElement element, JsonDecision[] decisions) { + for (JsonDecision cls : decisions) { + if (matches(element, cls)) { + return true; + } + } + return false; + } + + private static boolean matches(JsonElement element, JsonDecision decision) { + if (decision == JsonDecision.LIST) { + return element.isJsonArray(); + } + if (decision == JsonDecision.BOOLEAN) { + return element.isJsonPrimitive() && ((JsonPrimitive)element).isBoolean(); + } + if (decision == JsonDecision.NUMBER) { + return element.isJsonPrimitive() && ((JsonPrimitive)element).isNumber(); + } + if (decision == JsonDecision.STRING) { + return element.isJsonPrimitive() && ((JsonPrimitive)element).isString(); + } + return element.isJsonObject(); + } +} diff --git a/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/util/JsonUtil.java b/wsagent/che-core-api-languageserver/src/main/java/org/eclipse/che/api/languageserver/util/JsonUtil.java new file mode 100644 index 00000000000..76e8c258d66 --- /dev/null +++ b/wsagent/che-core-api-languageserver/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.gson.JsonElement; +import com.google.gson.JsonPrimitive; + +import org.eclipse.che.dto.server.JsonSerializable; + +/** + * Utility to convert stuff that is not statically typed in lsp4j (java.lang.Object) + * + * @author Thomas Mäder + */ +public class JsonUtil { + public static JsonElement convertToJson(Object value) { + Class t = value.getClass(); + if (Enum.class.isAssignableFrom(t)) { + return new JsonPrimitive(((Enum)value).name()); + } else if (String.class.isAssignableFrom(t)) { + return new JsonPrimitive((String)value); + } else if (Number.class.isAssignableFrom(t)) { + return new JsonPrimitive(((Number)value).doubleValue()); + } else if (Boolean.class.isAssignableFrom(t)) { + return new JsonPrimitive((boolean)value); + } else if (JsonSerializable.class.isAssignableFrom(t)) { + return ((JsonSerializable)value).toJsonElement(); + } else if (value instanceof JsonElement) { + return (JsonElement)value; + } + throw new RuntimeException("Unexpected runtime value: " + value); + } + +} diff --git a/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/dto/DtoConversionTest.java b/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/dto/DtoConversionTest.java new file mode 100644 index 00000000000..ad9caed4cec --- /dev/null +++ b/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/dto/DtoConversionTest.java @@ -0,0 +1,149 @@ +/******************************************************************************* + * 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.dto; + +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.ExtendedCompletionItemDto; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.ExtendedCompletionListDto; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.HoverDto; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.ParameterInformationDto; +import org.eclipse.che.api.languageserver.server.dto.DtoServerImpls.WorkspaceEditDto; +import org.eclipse.che.api.languageserver.shared.model.ExtendedCompletionItem; +import org.eclipse.che.api.languageserver.shared.model.ExtendedCompletionList; +import org.eclipse.lsp4j.Hover; +import org.eclipse.lsp4j.ParameterInformation; +import org.eclipse.lsp4j.Position; +import org.eclipse.lsp4j.Range; +import org.eclipse.lsp4j.TextEdit; +import org.eclipse.lsp4j.WorkspaceEdit; +import org.testng.Assert; +import org.testng.annotations.Test; + +import java.lang.reflect.Array; +import java.lang.reflect.Field; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +public class DtoConversionTest { + + @Test + public void testListConversion() { + ExtendedCompletionList ecl = new ExtendedCompletionList(); + ecl.setInComplete(true); + List items = new ArrayList<>(); + ExtendedCompletionItem item = new ExtendedCompletionItemDto(); + item.setTextEdit(new TextEdit(new Range(new Position(1, 2), new Position(3, 4)), "changed text")); + + // cannot unmarshal object type stuff from json. So need to set json + // element for equality test to work. + item.setData(new ParameterInformationDto(new ParameterInformation("the label", "the doc")).toJsonElement()); + items.add(item); + ecl.setItems(items); + + ExtendedCompletionListDto originalDto = new ExtendedCompletionListDto(ecl); + Assert.assertTrue(reflectionEquals(originalDto, ecl)); + String jsonString = originalDto.toJson(); + ExtendedCompletionListDto convertedDto = ExtendedCompletionListDto.fromJson(jsonString); + Assert.assertTrue(reflectionEquals(originalDto, convertedDto)); + } + + @Test + public void testMapConversion() { + Map> changes = Collections.singletonMap("anURL", + Arrays.asList(new TextEdit( + new Range(new Position(0, 1), new Position(3, 4)), + "blabla"))); + WorkspaceEdit edit = new WorkspaceEdit(); + edit.setChanges(changes); + + WorkspaceEditDto originalDto = new WorkspaceEditDto(edit); + Assert.assertTrue(reflectionEquals(originalDto, edit)); + String jsonString = originalDto.toJson(); + WorkspaceEditDto convertedDto = WorkspaceEditDto.fromJson(jsonString); + Assert.assertTrue(reflectionEquals(originalDto, convertedDto)); + } + + @Test + public void testEitherConversion() { + List entries = Arrays.asList("foobar", "bar"); + Hover hover = new Hover(entries, new Range(new Position(0, 1), new Position(2, 3))); + + HoverDto originalDto = new HoverDto(hover); + Assert.assertTrue(reflectionEquals(originalDto, hover)); + String jsonString = originalDto.toJson(); + HoverDto convertedDto = HoverDto.fromJson(jsonString); + Assert.assertTrue(reflectionEquals(originalDto, convertedDto)); + } + + /* + * This method compares objects reflectively. This probably won't work in general, because of ordering problems in collections + */ + private boolean reflectionEquals(Object left, Object right) { + Class leftClass = left.getClass(); + Class rightClass = right.getClass(); + return reflectionEquals(left, right, leftClass, rightClass); + } + + private boolean reflectionEquals(Object left, Object right, Class leftClass, Class rightClass) { + if (left == right) { + return true; + } + if (left == null || right == null) { + return false; + } + + if (leftClass.isPrimitive() || rightClass.isPrimitive()) { + return left.equals(right); + } + if (leftClass.isArray()) { + if (!rightClass.isArray()) { + return false; + } + return compareArrays(left, right); + } + while (leftClass != null) { + Field[] fields = leftClass.getDeclaredFields(); + Field.setAccessible(fields, true); + for (Field field : fields) { + try { + if (!field.isSynthetic() && !Modifier.isStatic(field.getModifiers())) { + if (!reflectionEquals(field.get(left), field.get(right), field.getType(), field.getType())) { + return false; + } + } + } catch (IllegalArgumentException e) { + return false; + } catch (IllegalAccessException e) { + throw new RuntimeException("should not happen", e); + } + } + leftClass = leftClass.getSuperclass(); + } + return true; + } + + private boolean compareArrays(Object left, Object right) { + int size = Array.getLength(left); + if (size != Array.getLength(right)) { + return false; + } + for (int i = 0; i < size; i++) { + if (!reflectionEquals(Array.get(left, i), Array.get(right, i), left.getClass().getComponentType(), + right.getClass().getComponentType())) { + return false; + } + } + return true; + } +} diff --git a/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImplTest.java b/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImplTest.java index cbe34f7e329..d211e366855 100644 --- a/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImplTest.java +++ b/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/LanguageServerRegistryImplTest.java @@ -10,15 +10,13 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.registry; -import io.typefox.lsapi.InitializeParams; -import io.typefox.lsapi.InitializeResult; -import io.typefox.lsapi.ServerCapabilities; -import io.typefox.lsapi.services.LanguageServer; -import io.typefox.lsapi.services.TextDocumentService; -import io.typefox.lsapi.services.WindowService; - import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; +import org.eclipse.lsp4j.InitializeParams; +import org.eclipse.lsp4j.InitializeResult; +import org.eclipse.lsp4j.ServerCapabilities; +import org.eclipse.lsp4j.services.LanguageServer; +import org.eclipse.lsp4j.services.TextDocumentService; import org.mockito.Mock; import org.mockito.testng.MockitoTestNGListener; import org.testng.annotations.BeforeMethod; @@ -39,6 +37,7 @@ import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertNotNull; + /** * @author Anatoliy Bazko */ @@ -78,7 +77,6 @@ public void setUp() throws Exception { when(languageDescription.getMimeTypes()).thenReturn(Collections.singletonList("plain/text")); when(languageServer.getTextDocumentService()).thenReturn(mock(TextDocumentService.class)); - when(languageServer.getWindowService()).thenReturn(mock(WindowService.class)); when(languageServer.initialize(any(InitializeParams.class))).thenReturn(completableFuture); registry = spy(new LanguageServerRegistryImpl(Collections.singleton(languageServerLauncher), diff --git a/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImplTest.java b/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImplTest.java index b31634c7976..692c8d1ca12 100644 --- a/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImplTest.java +++ b/wsagent/che-core-api-languageserver/src/test/java/org/eclipse/che/api/languageserver/registry/ServerInitializerImplTest.java @@ -10,15 +10,14 @@ *******************************************************************************/ package org.eclipse.che.api.languageserver.registry; -import io.typefox.lsapi.InitializeParams; -import io.typefox.lsapi.InitializeResult; -import io.typefox.lsapi.ServerCapabilities; -import io.typefox.lsapi.services.LanguageServer; - import org.eclipse.che.api.languageserver.launcher.LanguageServerLauncher; import org.eclipse.che.api.languageserver.messager.PublishDiagnosticsParamsMessenger; import org.eclipse.che.api.languageserver.messager.ShowMessageMessenger; import org.eclipse.che.api.languageserver.shared.model.LanguageDescription; +import org.eclipse.lsp4j.InitializeParams; +import org.eclipse.lsp4j.InitializeResult; +import org.eclipse.lsp4j.ServerCapabilities; +import org.eclipse.lsp4j.services.LanguageServer; import org.mockito.Mock; import org.mockito.testng.MockitoTestNGListener; import org.testng.annotations.BeforeMethod; @@ -48,7 +47,7 @@ public class ServerInitializerImplTest { @Mock private PublishDiagnosticsParamsMessenger publishDiagnosticsParamsMessenger; @Mock - private ShowMessageMessenger showMessageParamsMessenger; + private ShowMessageMessenger showMessageParamsMessenger; @Mock private LanguageDescription languageDescription; @Mock @@ -72,7 +71,7 @@ public void initializerShouldNotifyObservers() throws Exception { when(completableFuture.get()).thenReturn(mock(InitializeResult.class)); when(launcher.getLanguageDescription()).thenReturn(languageDescription); - when(launcher.launch(anyString())).thenReturn(server); + when(launcher.launch(anyString(), any())).thenReturn(server); doNothing().when(initializer).registerCallbacks(server); initializer.addObserver(observer); diff --git a/wsagent/pom.xml b/wsagent/pom.xml index ffde5658e69..fdee06885a7 100644 --- a/wsagent/pom.xml +++ b/wsagent/pom.xml @@ -37,6 +37,7 @@ che-core-api-debug-shared che-core-api-languageserver che-core-api-languageserver-shared + che-core-api-languageserver-maven-plugin che-core-api-testing che-core-api-testing-shared wsagent-local