Search in sources :

Example 11 with TextEditor

use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.

the class AbstractTextEditorProvider method getEditor.

@Override
public TextEditor getEditor() {
    if (editorBuilder == null) {
        Log.debug(AbstractTextEditorProvider.class, "No builder registered for default editor type - giving up.");
        return null;
    }
    final TextEditor editor = editorBuilder.buildEditor();
    editor.initialize(getEditorConfiguration());
    return editor;
}
Also used : TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor)

Example 12 with TextEditor

use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.

the class FindDefinitionAction method updateInPerspective.

@Override
public void updateInPerspective(@NotNull ActionEvent event) {
    EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
    if (activeEditor instanceof TextEditor) {
        TextEditorConfiguration configuration = ((TextEditor) activeEditor).getConfiguration();
        if (configuration instanceof LanguageServerEditorConfiguration) {
            ServerCapabilities capabilities = ((LanguageServerEditorConfiguration) configuration).getServerCapabilities();
            event.getPresentation().setEnabledAndVisible(capabilities.isDefinitionProvider() != null && capabilities.isDefinitionProvider());
            return;
        }
    }
    event.getPresentation().setEnabledAndVisible(false);
}
Also used : TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) LanguageServerEditorConfiguration(org.eclipse.che.plugin.languageserver.ide.editor.LanguageServerEditorConfiguration) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) TextEditorConfiguration(org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration) ServerCapabilities(io.typefox.lsapi.ServerCapabilities)

Example 13 with TextEditor

use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.

the class FindReferencesAction method updateInPerspective.

@Override
public void updateInPerspective(@NotNull ActionEvent event) {
    EditorPartPresenter activeEditor = editorAgent.getActiveEditor();
    if (activeEditor instanceof TextEditor) {
        TextEditorConfiguration configuration = ((TextEditor) activeEditor).getConfiguration();
        if (configuration instanceof LanguageServerEditorConfiguration) {
            ServerCapabilities capabilities = ((LanguageServerEditorConfiguration) configuration).getServerCapabilities();
            event.getPresentation().setEnabledAndVisible(capabilities.isReferencesProvider() != null && capabilities.isReferencesProvider());
            return;
        }
    }
    event.getPresentation().setEnabledAndVisible(false);
}
Also used : TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) LanguageServerEditorConfiguration(org.eclipse.che.plugin.languageserver.ide.editor.LanguageServerEditorConfiguration) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) TextEditorConfiguration(org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration) ServerCapabilities(io.typefox.lsapi.ServerCapabilities)

Example 14 with TextEditor

use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.

the class PublishDiagnosticsProcessor method processDiagnostics.

public void processDiagnostics(PublishDiagnosticsParamsDTO diagnosticsMessage) {
    EditorPartPresenter openedEditor = editorAgent.getOpenedEditor(new Path(diagnosticsMessage.getUri()));
    //TODO add markers
    if (openedEditor == null) {
        return;
    }
    if (openedEditor instanceof TextEditor) {
        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()) {
                    collector.acceptDiagnostic(diagnostic);
                }
            } finally {
                collector.endReporting();
            }
        }
    }
}
Also used : Path(org.eclipse.che.ide.resource.Path) TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor) DiagnosticDTO(org.eclipse.che.api.languageserver.shared.lsapi.DiagnosticDTO) AnnotationModel(org.eclipse.che.ide.api.editor.annotation.AnnotationModel) EditorPartPresenter(org.eclipse.che.ide.api.editor.EditorPartPresenter) TextEditorConfiguration(org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration)

Example 15 with TextEditor

use of org.eclipse.che.ide.api.editor.texteditor.TextEditor in project che by eclipse.

the class LanguageServerEditorProvider method createEditor.

private TextEditor createEditor(TextEditorConfiguration configuration) {
    if (editorBuilder == null) {
        Log.debug(AbstractTextEditorProvider.class, "No builder registered for default editor type - giving up.");
        return null;
    }
    final TextEditor editor = editorBuilder.buildEditor();
    editor.initialize(configuration);
    return editor;
}
Also used : TextEditor(org.eclipse.che.ide.api.editor.texteditor.TextEditor)

Aggregations

TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)33 EditorPartPresenter (org.eclipse.che.ide.api.editor.EditorPartPresenter)21 Project (org.eclipse.che.ide.api.resources.Project)8 Resource (org.eclipse.che.ide.api.resources.Resource)8 OperationException (org.eclipse.che.api.promises.client.OperationException)7 VirtualFile (org.eclipse.che.ide.api.resources.VirtualFile)7 Operation (org.eclipse.che.api.promises.client.Operation)6 Document (org.eclipse.che.ide.api.editor.document.Document)5 TextEditorConfiguration (org.eclipse.che.ide.api.editor.editorconfig.TextEditorConfiguration)5 LanguageServerEditorConfiguration (org.eclipse.che.plugin.languageserver.ide.editor.LanguageServerEditorConfiguration)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 PromiseError (org.eclipse.che.api.promises.client.PromiseError)4 File (org.eclipse.che.ide.api.resources.File)4 Optional (com.google.common.base.Optional)3 ServerCapabilities (io.typefox.lsapi.ServerCapabilities)3 TextDocumentPositionParamsDTO (org.eclipse.che.api.languageserver.shared.lsapi.TextDocumentPositionParamsDTO)3 Collections.singletonList (java.util.Collections.singletonList)2 FunctionException (org.eclipse.che.api.promises.client.FunctionException)2 JsPromise (org.eclipse.che.api.promises.client.js.JsPromise)2