Search in sources :

Example 31 with TextPosition

use of org.eclipse.che.ide.api.editor.text.TextPosition in project che by eclipse.

the class CloseCStyleCommentChangeInterceptorTest method testAddWithComment.

@Ignore
@Test
public void testAddWithComment() {
    doReturn("/*").when(document).getLineContent(0);
    doReturn("/*").when(document).getLineContent(1);
    doReturn(" *").when(document).getLineContent(2);
    final TextChange input = new TextChange.Builder().from(new TextPosition(1, 2)).to(new TextPosition(2, 2)).insert("\n *").build();
    final TextChange output = interceptor.processChange(input, document);
    assertNull(output);
}
Also used : TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) TextChange(org.eclipse.che.ide.api.editor.changeintercept.TextChange) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 32 with TextPosition

use of org.eclipse.che.ide.api.editor.text.TextPosition in project che by eclipse.

the class JavaDebuggerFileHandler method scrollEditorToExecutionPoint.

private void scrollEditorToExecutionPoint(TextEditor editor, int lineNumber) {
    Document document = editor.getDocument();
    if (document != null) {
        TextPosition newPosition = new TextPosition(lineNumber, 0);
        document.setCursorPosition(newPosition);
    }
}
Also used : TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) Document(org.eclipse.che.ide.api.editor.document.Document)

Example 33 with TextPosition

use of org.eclipse.che.ide.api.editor.text.TextPosition in project che by eclipse.

the class SemanticHighlightRenderer method reconcile.

public void reconcile(List<HighlightedPosition> positions) {
    for (HasTextMarkers.MarkerRegistration marker : markers) {
        marker.clearMark();
    }
    markers.clear();
    for (HighlightedPosition position : positions) {
        final TextPosition from = this.document.getPositionFromIndex(position.getOffset());
        final TextPosition to = this.document.getPositionFromIndex(position.getOffset() + position.getLength());
        HasTextMarkers.MarkerRegistration registration = editor.addMarker(new TextRange(from, to), styleMap.get(position.getType()));
        if (registration != null) {
            markers.add(registration);
        }
    }
}
Also used : HasTextMarkers(org.eclipse.che.ide.api.editor.texteditor.HasTextMarkers) HighlightedPosition(org.eclipse.che.ide.ext.java.shared.dto.HighlightedPosition) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) TextRange(org.eclipse.che.ide.api.editor.text.TextRange)

Example 34 with TextPosition

use of org.eclipse.che.ide.api.editor.text.TextPosition in project che by eclipse.

the class EditorGroupSynchronizationImpl method updateContent.

private void updateContent(String newContent, String oldStamp, VirtualFile virtualFile) {
    final DocumentHandle documentHandle = getDocumentHandleFor(groupLeaderEditor);
    if (documentHandle == null) {
        return;
    }
    final Document document = documentHandle.getDocument();
    final String oldContent = document.getContents();
    final TextPosition cursorPosition = document.getCursorPosition();
    if (!(virtualFile instanceof File)) {
        replaceContent(document, newContent, oldContent, cursorPosition);
        return;
    }
    final File file = (File) virtualFile;
    final String newStamp = file.getModificationStamp();
    if (oldStamp == null && !Objects.equals(newContent, oldContent)) {
        replaceContent(document, newContent, oldContent, cursorPosition);
        return;
    }
    if (!Objects.equals(oldStamp, newStamp)) {
        replaceContent(document, newContent, oldContent, cursorPosition);
        notificationManager.notify("External operation", "File '" + file.getName() + "' is updated", SUCCESS, EMERGE_MODE);
    }
}
Also used : DocumentHandle(org.eclipse.che.ide.api.editor.document.DocumentHandle) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) Document(org.eclipse.che.ide.api.editor.document.Document) File(org.eclipse.che.ide.api.resources.File) VirtualFile(org.eclipse.che.ide.api.resources.VirtualFile)

Aggregations

TextPosition (org.eclipse.che.ide.api.editor.text.TextPosition)34 Position (org.eclipse.che.ide.api.editor.text.Position)9 TextChange (org.eclipse.che.ide.api.editor.changeintercept.TextChange)8 TextRange (org.eclipse.che.ide.api.editor.text.TextRange)7 Test (org.junit.Test)7 Document (org.eclipse.che.ide.api.editor.document.Document)6 RangeDTO (org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO)5 Ignore (org.junit.Ignore)4 Annotation (org.eclipse.che.ide.api.editor.text.annotation.Annotation)3 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)3 Element (elemental.dom.Element)2 ArrayList (java.util.ArrayList)2 PositionDTO (org.eclipse.che.api.languageserver.shared.lsapi.PositionDTO)2 SymbolInformationDTO (org.eclipse.che.api.languageserver.shared.lsapi.SymbolInformationDTO)2 DocumentHandle (org.eclipse.che.ide.api.editor.document.DocumentHandle)2 TypedPosition (org.eclipse.che.ide.api.editor.text.TypedPosition)2 File (org.eclipse.che.ide.api.resources.File)2 Match (org.eclipse.che.plugin.languageserver.ide.filters.Match)2 Optional (com.google.common.base.Optional)1 Timer (com.google.gwt.user.client.Timer)1