Skip to content

Commit

Permalink
CHE-1287: Support for Language Server Protocol (eclipse-che#2452)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anatoliy Bazko authored Sep 16, 2016
1 parent 2662624 commit 51ca5b1
Show file tree
Hide file tree
Showing 243 changed files with 13,110 additions and 58 deletions.
16 changes: 16 additions & 0 deletions assembly/assembly-ide-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-cpp-lang-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-csharp-lang-ide</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-csharp-lang-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-debugger-ide</artifactId>
Expand Down Expand Up @@ -148,6 +156,14 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-java-plain-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-languageserver-ide</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-languageserver-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-machine-ext-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@

<inherits name='org.eclipse.che.plugin.product.info.ProductInfo'/>
<inherits name='org.eclipse.che.plugin.cpp.Cpp'/>
<inherits name='org.eclipse.che.plugin.csharp.CSharp'/>
<inherits name='org.eclipse.che.plugin.python.Python'/>
<inherits name='org.eclipse.che.plugin.java.plain.PlainJava'/>
<inherits name='org.eclipse.che.plugin.nodejs.NodeJs'/>
<inherits name='org.eclipse.che.plugin.docker.client.dto.Dto'/>
<inherits name='org.eclipse.che.plugin.languageserver.LanguageServer'/>

<inherits name='org.eclipse.che.api.core.Core'/>
<inherits name='org.eclipse.che.api.core.model.Model'/>
Expand Down
16 changes: 16 additions & 0 deletions assembly/assembly-wsagent-war/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,14 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-cpp-lang-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-csharp-lang-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-csharp-lang-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-gdb-server</artifactId>
Expand Down Expand Up @@ -136,6 +144,14 @@
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-java-plain-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-languageserver-server</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-languageserver-shared</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.che.plugin</groupId>
<artifactId>che-plugin-maven-generator-archetype</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ protected void configure() {
install(new org.eclipse.che.api.core.util.FileCleaner.FileCleanerModule());
install(new org.eclipse.che.plugin.docker.machine.local.LocalDockerModule());
install(new org.eclipse.che.api.machine.server.MachineModule());
install(new org.eclipse.che.api.agent.server.AgentModule());
install(new org.eclipse.che.plugin.docker.machine.ext.DockerExtServerModule());
install(new org.eclipse.che.plugin.docker.machine.ext.DockerTerminalModule());
install(new org.eclipse.che.swagger.deploy.DocsModule());
Expand Down
Empty file modified che.sh
100755 → 100644
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@
*******************************************************************************/
package org.eclipse.che.dto.generator;

import com.google.common.base.Preconditions;
import com.google.common.primitives.Primitives;

import org.eclipse.che.dto.server.JsonSerializable;
import org.eclipse.che.dto.shared.DelegateRule;
import org.eclipse.che.dto.shared.DTOImpl;
import org.eclipse.che.dto.shared.DelegateRule;
import org.eclipse.che.dto.shared.DelegateTo;
import org.eclipse.che.dto.shared.JsonArray;
import org.eclipse.che.dto.shared.JsonStringMap;
import org.eclipse.che.dto.shared.SerializationIndex;

import com.google.common.base.Preconditions;
import com.google.common.primitives.Primitives;

import java.lang.reflect.Method;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
Expand Down Expand Up @@ -493,6 +493,14 @@ private void emitDeserializeFieldForMethod(Method getter, StringBuilder builder)
emitDeserializerImpl(expandedTypes, 0, builder, fieldNameIn, fieldNameOut, baseIndentation);
builder.append(" dto.").append(getSetterName(fieldName)).append("(").append(fieldNameOut).append(");\n");
builder.append(" }\n");
Type type = expandedTypes.get(0);

Class<?> aClass = getRawClass(type);
if(Boolean.class.equals(aClass)){
builder.append(" else {\n");
builder.append(" dto.").append(getSetterName(fieldName)).append("(").append("false").append(");\n");
builder.append(" }\n");
}
}

private void emitDeserializeFieldForMethodCompact(Method method, final StringBuilder builder) {
Expand Down Expand Up @@ -946,7 +954,7 @@ private String getFqParameterizedName(Type type) {
sb.append('>');
return sb.toString();
} else {
throw new IllegalArgumentException("We do not handle this type");
throw new IllegalArgumentException("We do not handle the type '" + type == null ? null : type.getTypeName() + "'.");
}
}

Expand Down Expand Up @@ -974,4 +982,4 @@ private String getImplNameForDto(Class<?> dtoInterface) {
}
return dtoInterface.getCanonicalName();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
* GinMapBinder.newMapBinder(binder(), String.class, WsAgentComponent.class);
* mapBinder.addBinding("component key").to(YourComponent.class);
* </pre>
* <b>Note:</b> Ws Agent Component start order will be calculated upon component key.
* All keys will be sorted in alphabet order.
*
* @author Artem Zatsarynnyi
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*******************************************************************************
* 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.ide.api.editor;

import org.eclipse.che.api.promises.client.Promise;
import org.eclipse.che.ide.api.resources.VirtualFile;

/**
* Extension interface for {@link EditorProvider}
* Add ability to create editor asynchronously.
* {@link EditorAgent} should use this interface to crate editor instance
*
* @author Evgen Vidolob
*/
public interface AsyncEditorProvider {

/**
* Create promise for creating new editor instance.
*
* @param file
* the file for which editor should crated
* @return
* promise
*
*/
Promise<EditorPartPresenter> createEditor(VirtualFile file);
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ public DocumentHandle getDocumentHandle() {
return this;
}

@Override
public void replace(int startLine, int startChar, int endLine, int endChar, String text) {
// does nothing by default
}

@Override
public void setFile(VirtualFile fileNode) {
this.file = fileNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,22 @@ public interface Document extends ReadOnlyDocument {
*/
void replace(int offset, int length, String text);

/**
* Replaces the text range with the given replacement contents.
*
* @param startLine
* start line of the range
* @param startChar
* start char of the range
* @param endLine
* end line of the range
* @param endChar
* end char of the range
* @param text
* the replacement text
*/
void replace(int startLine, int startChar, int endLine, int endChar, String text);

void setFile(VirtualFile file);

VirtualFile getFile();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
package org.eclipse.che.ide.api.editor.formatter;

import org.eclipse.che.ide.api.editor.document.Document;
import org.eclipse.che.ide.api.editor.texteditor.TextEditor;

/**
* The interface of a document content formatter. The formatter formats ranges within documents.
Expand All @@ -24,4 +25,7 @@ public interface ContentFormatter {
* the document to be formatted
*/
void format(Document document);

void install(TextEditor editor);

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import com.google.web.bindery.event.shared.EventBus;

import org.eclipse.che.ide.api.editor.events.DocumentReadyEvent;
import org.eclipse.che.ide.api.editor.formatter.ContentFormatter;
import org.eclipse.che.ide.api.editor.text.TypedRegion;
import org.eclipse.che.ide.api.editor.annotation.AnnotationModel;
import org.eclipse.che.ide.api.editor.annotation.HasAnnotationRendering;
Expand Down Expand Up @@ -101,11 +102,20 @@ public void initialize(final DocumentHandle documentHandle, final TextEditorInit
configureCodeAssist(documentHandle);
configureChangeInterceptors(documentHandle);
addQuickAssistKeyBinding();
configureFormatter(textEditor);
}
};
new DocReadyWrapper<TextEditorInit<T>>(generalEventBus, this.textEditor.getEditorHandle(), init, this);
}

private void configureFormatter(TextEditorPresenter<T> textEditor) {
ContentFormatter formatter = configuration.getContentFormatter();
if (formatter != null) {
formatter.install(textEditor);
}

}

public void uninstall() {
Reconciler reconciler = configuration.getReconciler();
if (reconciler != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.eclipse.che.ide.Resources;
import org.eclipse.che.ide.api.action.AbstractPerspectiveAction;
import org.eclipse.che.ide.api.action.ActionEvent;
import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.editor.EditorAgent;
import org.eclipse.che.ide.api.editor.EditorPartPresenter;
import org.eclipse.che.ide.api.editor.texteditor.HandlesTextOperations;
Expand All @@ -35,20 +34,17 @@
*/
public class FormatterAction extends AbstractPerspectiveAction {

private final AppContext appContext;
private final EditorAgent editorAgent;

@Inject
public FormatterAction(AppContext appContext,
EditorAgent editorAgent,
public FormatterAction(EditorAgent editorAgent,
CoreLocalizationConstant localization,
Resources resources) {
super(singletonList(PROJECT_PERSPECTIVE_ID),
localization.formatName(),
localization.formatDescription(),
null,
resources.format());
this.appContext = appContext;
this.editorAgent = editorAgent;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@

import java.util.Iterator;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;

/**
* Performs initial application startup.
Expand Down Expand Up @@ -116,7 +118,9 @@ public void apply(WorkspaceDto ws) throws OperationException {

wsAgentStateControllerProvider.get().initialize(devMachine);
wsAgentURLModifier.initialize(devMachine);
startWsAgentComponents(components.values().iterator());
SortedMap<String, Provider<WsAgentComponent>> sortedComponents = new TreeMap<>();
sortedComponents.putAll(components);
startWsAgentComponents(sortedComponents.values().iterator());
}
}).catchError(new Operation<PromiseError>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*******************************************************************************
* 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.ide.client;

import com.google.gwt.core.client.Callback;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;

import org.eclipse.che.ide.api.app.AppContext;
import org.eclipse.che.ide.api.component.WsAgentComponent;
import org.eclipse.che.ide.statepersistance.AppStateManager;

/**
* @author Evgen Vidolob
*/
@Singleton
public class WorkspaceStateRestorer implements WsAgentComponent {

private final Provider<AppStateManager> managerProvider;
private final Provider<AppContext> appContextProvider;

@Inject
public WorkspaceStateRestorer(Provider<AppStateManager> managerProvider, Provider<AppContext> appContextProvider) {
this.managerProvider = managerProvider;
this.appContextProvider = appContextProvider;
}

@Override
public void start(Callback<WsAgentComponent, Exception> callback) {
managerProvider.get().restoreWorkspaceState(appContextProvider.get().getWorkspaceId());
callback.onSuccess(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,6 @@ public void apply(Project[] projects) throws OperationException {
AppContextImpl.this.projects = projects;
java.util.Arrays.sort(AppContextImpl.this.projects, ResourcePathComparator.getInstance());
eventBus.fireEvent(new WorkspaceReadyEvent(projects));
appStateManager.get().restoreWorkspaceState(getWorkspaceId());
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
import org.eclipse.che.ide.api.workspace.WorkspaceServiceClient;
import org.eclipse.che.ide.api.workspace.WorkspaceServiceClientImpl;
import org.eclipse.che.ide.client.StartUpActionsProcessor;
import org.eclipse.che.ide.client.WorkspaceStateRestorer;
import org.eclipse.che.ide.context.AppContextImpl;
import org.eclipse.che.ide.editor.EditorAgentImpl;
import org.eclipse.che.ide.editor.EditorRegistryImpl;
Expand Down Expand Up @@ -431,6 +432,7 @@ private void configureComponents() {
GinMapBinder.newMapBinder(binder(), String.class, WsAgentComponent.class);
wsAgentComponentsBinder.addBinding("Project types").to(ProjectTypeComponent.class);
wsAgentComponentsBinder.addBinding("Start-up actions processor").to(StartUpActionsProcessor.class);
wsAgentComponentsBinder.addBinding("ZZ Restore Workspace State").to(WorkspaceStateRestorer.class);
}

private void configureProjectWizard() {
Expand Down
Loading

0 comments on commit 51ca5b1

Please sign in to comment.