Search in sources :

Example 11 with TextPosition

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

the class OpenLocationPresenter method onLocationSelected.

@Override
public void onLocationSelected(LocationDTO location) {
    RangeDTO range = location.getRange();
    helper.openFile(location.getUri(), new TextRange(new TextPosition(range.getStart().getLine(), range.getStart().getCharacter()), new TextPosition(range.getEnd().getLine(), range.getEnd().getCharacter())));
}
Also used : TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) TextRange(org.eclipse.che.ide.api.editor.text.TextRange) RangeDTO(org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO)

Example 12 with TextPosition

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

the class SymbolEntry method runOpen.

private boolean runOpen() {
    editor.getDocument().setCursorPosition(new TextPosition(range.getFrom().getLine(), range.getFrom().getCharacter()));
    editor.setFocus();
    return true;
}
Also used : TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition)

Example 13 with TextPosition

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

the class FindSymbolAction method toSymbolEntries.

private List<SymbolEntry> toSymbolEntries(List<SymbolInformationDTO> types, String value) {
    List<SymbolEntry> result = new ArrayList<>();
    for (SymbolInformationDTO element : types) {
        if (!SUPPORTED_OPEN_TYPES.contains(symbolKindHelper.from(element.getKind()))) {
            continue;
        }
        List<Match> matches = fuzzyMatches.fuzzyMatch(value, element.getName());
        if (matches != null) {
            LocationDTO location = element.getLocation();
            if (location != null && location.getUri() != null) {
                String filePath = location.getUri();
                RangeDTO locationRange = location.getRange();
                TextRange range = null;
                if (locationRange != null) {
                    range = new TextRange(new TextPosition(locationRange.getStart().getLine(), locationRange.getStart().getCharacter()), new TextPosition(locationRange.getEnd().getLine(), locationRange.getEnd().getCharacter()));
                }
                result.add(new SymbolEntry(element.getName(), "", filePath, filePath, symbolKindHelper.from(element.getKind()), range, symbolKindHelper.getIcon(element.getKind()), editorHelper, matches));
            }
        }
    }
    //TODO add sorting
    return result;
}
Also used : SymbolInformationDTO(org.eclipse.che.api.languageserver.shared.lsapi.SymbolInformationDTO) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) ArrayList(java.util.ArrayList) TextRange(org.eclipse.che.ide.api.editor.text.TextRange) LocationDTO(org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO) RangeDTO(org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO) Match(org.eclipse.che.plugin.languageserver.ide.filters.Match)

Example 14 with TextPosition

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

the class OrionCursorModel method dispatchCursorChange.

private void dispatchCursorChange(final boolean isExplicitChange) {
    final TextPosition position = this.document.getCursorPosition();
    cursorHandlerManager.dispatch(new Dispatcher<CursorHandler>() {

        @Override
        public void dispatch(CursorHandler listener) {
            listener.onCursorChange(position.getLine(), position.getCharacter(), isExplicitChange);
        }
    });
}
Also used : TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition)

Example 15 with TextPosition

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

the class OrionCursorModel method getCursorPosition.

@Override
public Position getCursorPosition() {
    TextPosition position = document.getCursorPosition();
    int offset = document.getIndexFromPosition(position);
    return new Position(offset);
}
Also used : TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) Position(org.eclipse.che.ide.api.editor.text.Position) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition)

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