-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#1809 fix some bugs with symbol navigation
- Loading branch information
Evgen Vidolob
committed
Sep 7, 2016
1 parent
9da8efd
commit 8a2e7b7
Showing
8 changed files
with
174 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
ide/che-core-ide-app/src/main/java/org/eclipse/che/ide/client/WorkspaceStateRestorer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
...c/main/java/org/eclipse/che/plugin/languageserver/ide/LanguageServerFileTypeRegister.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/******************************************************************************* | ||
* 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.plugin.languageserver.ide; | ||
|
||
import com.google.gwt.core.client.Callback; | ||
import com.google.inject.Inject; | ||
import com.google.inject.Singleton; | ||
|
||
import org.eclipse.che.api.promises.client.Operation; | ||
import org.eclipse.che.api.promises.client.OperationException; | ||
import org.eclipse.che.api.promises.client.Promise; | ||
import org.eclipse.che.api.promises.client.PromiseError; | ||
import org.eclipse.che.ide.api.component.WsAgentComponent; | ||
import org.eclipse.che.ide.api.editor.EditorRegistry; | ||
import org.eclipse.che.ide.api.filetypes.FileType; | ||
import org.eclipse.che.ide.api.filetypes.FileTypeRegistry; | ||
import org.eclipse.che.ide.editor.orion.client.OrionContentTypeRegistrant; | ||
import org.eclipse.che.ide.editor.orion.client.jso.OrionContentTypeOverlay; | ||
import org.eclipse.che.ide.editor.orion.client.jso.OrionHighlightingConfigurationOverlay; | ||
import org.eclipse.che.plugin.languageserver.ide.editor.LanguageServerEditorProvider; | ||
import org.eclipse.che.plugin.languageserver.ide.service.LanguageServerRegistryServiceClient; | ||
import org.eclipse.che.plugin.languageserver.shared.lsapi.LanguageDescriptionDTO; | ||
|
||
import java.util.List; | ||
|
||
import static com.google.common.collect.Lists.newArrayList; | ||
|
||
/** | ||
* @author Evgen Vidolob | ||
*/ | ||
@Singleton | ||
public class LanguageServerFileTypeRegister implements WsAgentComponent { | ||
|
||
|
||
private final LanguageServerRegistryServiceClient serverLanguageRegistry; | ||
private final FileTypeRegistry fileTypeRegistry; | ||
private final LanguageServerResources resources; | ||
private final EditorRegistry editorRegistry; | ||
private final OrionContentTypeRegistrant contentTypeRegistrant; | ||
private final LanguageServerEditorProvider editorProvider; | ||
|
||
@Inject | ||
public LanguageServerFileTypeRegister(LanguageServerRegistryServiceClient serverLanguageRegistry, | ||
FileTypeRegistry fileTypeRegistry, | ||
LanguageServerResources resources, | ||
EditorRegistry editorRegistry, | ||
OrionContentTypeRegistrant contentTypeRegistrant, | ||
LanguageServerEditorProvider editorProvider) { | ||
this.serverLanguageRegistry = serverLanguageRegistry; | ||
this.fileTypeRegistry = fileTypeRegistry; | ||
this.resources = resources; | ||
this.editorRegistry = editorRegistry; | ||
this.contentTypeRegistrant = contentTypeRegistrant; | ||
this.editorProvider = editorProvider; | ||
} | ||
|
||
@Override | ||
public void start(final Callback<WsAgentComponent, Exception> callback) { | ||
Promise<List<LanguageDescriptionDTO>> registeredLanguages = serverLanguageRegistry.getSupportedLanguages(); | ||
registeredLanguages.then(new Operation<List<LanguageDescriptionDTO>>() { | ||
@Override | ||
public void apply(List<LanguageDescriptionDTO> langs) throws OperationException { | ||
if (!langs.isEmpty()) { | ||
for (LanguageDescriptionDTO lang : langs) { | ||
String primaryExtension = lang.getFileExtensions().get(0); | ||
for (String ext : lang.getFileExtensions()) { | ||
final FileType fileType = new FileType(resources.file(), ext); | ||
fileTypeRegistry.registerFileType(fileType); | ||
editorRegistry.registerDefaultEditor(fileType, editorProvider); | ||
} | ||
List<String> mimeTypes = lang.getMimeTypes(); | ||
if (mimeTypes.isEmpty()) { | ||
mimeTypes = newArrayList("text/x-" + lang.getLanguageId()); | ||
} | ||
for (String contentTypeId : mimeTypes) { | ||
|
||
OrionContentTypeOverlay contentType = OrionContentTypeOverlay.create(); | ||
contentType.setId(contentTypeId); | ||
contentType.setName(lang.getLanguageId()); | ||
contentType.setExtension(primaryExtension); | ||
contentType.setExtends("text/plain"); | ||
|
||
// highlighting | ||
OrionHighlightingConfigurationOverlay config = OrionHighlightingConfigurationOverlay | ||
.create(); | ||
config.setId(lang.getLanguageId() + ".highlighting"); | ||
config.setContentTypes(contentTypeId); | ||
config.setPatterns(lang.getHighlightingConfiguration()); | ||
|
||
contentTypeRegistrant.registerFileType(contentType, config); | ||
} | ||
} | ||
} | ||
callback.onSuccess(LanguageServerFileTypeRegister.this); | ||
} | ||
}).catchError(new Operation<PromiseError>() { | ||
@Override | ||
public void apply(PromiseError arg) throws OperationException { | ||
callback.onFailure(new Exception(arg.getMessage(), arg.getCause())); | ||
} | ||
}); | ||
} | ||
} |
Oops, something went wrong.