Search in sources :

Example 1 with BadLocationException

use of org.springframework.ide.vscode.commons.util.BadLocationException in project sts4 by spring-projects.

the class BoshDefintionFinder method toLocation.

protected Optional<Location> toLocation(TextDocument doc, Node node) {
    int start = node.getStartMark().getIndex();
    int end = node.getEndMark().getIndex();
    try {
        return Optional.of(new Location(doc.getUri(), doc.toRange(start, end - start)));
    } catch (BadLocationException e) {
        Log.log(e);
        return Optional.empty();
    }
}
Also used : BadLocationException(org.springframework.ide.vscode.commons.util.BadLocationException) Location(org.eclipse.lsp4j.Location)

Example 2 with BadLocationException

use of org.springframework.ide.vscode.commons.util.BadLocationException in project sts4 by spring-projects.

the class ListLineTracker method getLineInformationOfOffset.

@Override
public final IRegion getLineInformationOfOffset(int position) throws BadLocationException {
    if (position > fTextLength)
        throw new BadLocationException();
    if (position == fTextLength) {
        int size = fLines.size();
        if (size == 0)
            return new Region(0, 0);
        Line l = fLines.get(size - 1);
        return (l.delimiter != null ? new Line(fTextLength, 0) : new Line(fTextLength - l.length, l.length));
    }
    return getLineInformation(findLine(position));
}
Also used : Region(org.springframework.ide.vscode.commons.util.text.Region) IRegion(org.springframework.ide.vscode.commons.util.text.IRegion) BadLocationException(org.springframework.ide.vscode.commons.util.BadLocationException)

Example 3 with BadLocationException

use of org.springframework.ide.vscode.commons.util.BadLocationException in project sts4 by spring-projects.

the class ListLineTracker method getLineDelimiter.

@Override
public final String getLineDelimiter(int line) throws BadLocationException {
    int lines = fLines.size();
    if (line < 0 || line > lines)
        throw new BadLocationException();
    if (lines == 0)
        return null;
    if (line == lines)
        return null;
    Line l = fLines.get(line);
    return l.delimiter;
}
Also used : BadLocationException(org.springframework.ide.vscode.commons.util.BadLocationException)

Example 4 with BadLocationException

use of org.springframework.ide.vscode.commons.util.BadLocationException in project sts4 by spring-projects.

the class ListLineTracker method getLineNumberOfOffset.

@Override
public final int getLineNumberOfOffset(int position) throws BadLocationException {
    if (position < 0 || position > fTextLength)
        throw new BadLocationException();
    if (position == fTextLength) {
        int lastLine = fLines.size() - 1;
        if (lastLine < 0)
            return 0;
        Line l = fLines.get(lastLine);
        return (l.delimiter != null ? lastLine + 1 : lastLine);
    }
    return findLine(position);
}
Also used : BadLocationException(org.springframework.ide.vscode.commons.util.BadLocationException)

Example 5 with BadLocationException

use of org.springframework.ide.vscode.commons.util.BadLocationException in project sts4 by spring-projects.

the class ConcourseDefinitionFinder method toLocation.

Optional<Location> toLocation(TextDocument doc, Node node) {
    int start = node.getStartMark().getIndex();
    int end = node.getEndMark().getIndex();
    try {
        return Optional.of(new Location(doc.getUri(), doc.toRange(start, end - start)));
    } catch (BadLocationException e) {
        Log.log(e);
        return Optional.empty();
    }
}
Also used : BadLocationException(org.springframework.ide.vscode.commons.util.BadLocationException) Location(org.eclipse.lsp4j.Location)

Aggregations

BadLocationException (org.springframework.ide.vscode.commons.util.BadLocationException)23 Range (org.eclipse.lsp4j.Range)10 IMethodBinding (org.eclipse.jdt.core.dom.IMethodBinding)9 Location (org.eclipse.lsp4j.Location)5 ASTNode (org.eclipse.jdt.core.dom.ASTNode)4 SimpleName (org.eclipse.jdt.core.dom.SimpleName)4 TextDocument (org.springframework.ide.vscode.commons.util.text.TextDocument)3 ImmutableList (com.google.common.collect.ImmutableList)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 QualifiedName (org.eclipse.jdt.core.dom.QualifiedName)2 StringLiteral (org.eclipse.jdt.core.dom.StringLiteral)2 JsonArray (com.google.gson.JsonArray)1 JsonElement (com.google.gson.JsonElement)1 JsonObject (com.google.gson.JsonObject)1 File (java.io.File)1 Paths (java.nio.file.Paths)1 Collection (java.util.Collection)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1