Search in sources :

Example 1 with TextRange

use of org.eclipse.che.ide.api.editor.text.TextRange 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 2 with TextRange

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

the class GoToSymbolAction method sortNormal.

private int sortNormal(String value, SymbolEntry a, SymbolEntry b) {
    String aName = a.getLabel().toLowerCase();
    String bName = b.getLabel().toLowerCase();
    int r = aName.compareTo(bName);
    if (r != 0) {
        return r;
    }
    TextRange aRange = a.getRange();
    TextRange bRange = b.getRange();
    return aRange.getFrom().getLine() - bRange.getFrom().getLine();
}
Also used : TextRange(org.eclipse.che.ide.api.editor.text.TextRange)

Example 3 with TextRange

use of org.eclipse.che.ide.api.editor.text.TextRange 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 4 with TextRange

use of org.eclipse.che.ide.api.editor.text.TextRange 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 5 with TextRange

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

the class InlineAnnotationRenderer method addAnnotationItem.

/**
     * Add an inline annotation.
     *
     * @param annotationModel the annotation model
     * @param annotation the annotation to add
     * @param decorations the available decorations
     */
private void addAnnotationItem(AnnotationModel annotationModel, Annotation annotation, Map<String, String> decorations) {
    if (this.hasTextMarkers != null) {
        final String className = decorations.get(annotation.getType());
        if (className == null) {
            return;
        }
        final Position position = annotationModel.getPosition(annotation);
        if (position == null) {
            Log.warn(InlineAnnotationRenderer.class, "Can't add annotation with no position");
            return;
        }
        final TextPosition from = this.document.getPositionFromIndex(position.getOffset());
        final TextPosition to = this.document.getPositionFromIndex(position.getOffset() + position.getLength());
        final MarkerRegistration registration = this.hasTextMarkers.addMarker(new TextRange(from, to), className);
        if (registration != null) {
            this.markers.put(annotation, registration);
        }
    }
}
Also used : MarkerRegistration(org.eclipse.che.ide.api.editor.texteditor.HasTextMarkers.MarkerRegistration) 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) TextRange(org.eclipse.che.ide.api.editor.text.TextRange)

Aggregations

TextRange (org.eclipse.che.ide.api.editor.text.TextRange)9 TextPosition (org.eclipse.che.ide.api.editor.text.TextPosition)7 RangeDTO (org.eclipse.che.api.languageserver.shared.lsapi.RangeDTO)3 ArrayList (java.util.ArrayList)2 SymbolInformationDTO (org.eclipse.che.api.languageserver.shared.lsapi.SymbolInformationDTO)2 Match (org.eclipse.che.plugin.languageserver.ide.filters.Match)2 LocationDTO (org.eclipse.che.api.languageserver.shared.lsapi.LocationDTO)1 Position (org.eclipse.che.ide.api.editor.text.Position)1 HasTextMarkers (org.eclipse.che.ide.api.editor.texteditor.HasTextMarkers)1 MarkerRegistration (org.eclipse.che.ide.api.editor.texteditor.HasTextMarkers.MarkerRegistration)1 TextEditor (org.eclipse.che.ide.api.editor.texteditor.TextEditor)1 OrionSelectionOverlay (org.eclipse.che.ide.editor.orion.client.jso.OrionSelectionOverlay)1 HighlightedPosition (org.eclipse.che.ide.ext.java.shared.dto.HighlightedPosition)1