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);
}
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);
}
}
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);
}
}
}
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);
}
}
Aggregations