Example usage for org.eclipse.jdt.internal.compiler.problem DefaultProblem getSourceEnd

List of usage examples for org.eclipse.jdt.internal.compiler.problem DefaultProblem getSourceEnd

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.problem DefaultProblem getSourceEnd.

Prototype

@Override
    public int getSourceEnd() 

Source Link

Usage

From source file:org.jboss.tools.vscode.java.internal.handlers.DiagnosticsHandler.java

License:Open Source License

private Range convertRange(IProblem problem) {
    Range range = new Range();
    Position start = new Position();
    Position end = new Position();

    start.setLine(Double.valueOf(problem.getSourceLineNumber() - 1));// VSCode is 0-based
    end.setLine(Double.valueOf(problem.getSourceLineNumber() - 1));
    if (problem instanceof DefaultProblem) {
        DefaultProblem dProblem = (DefaultProblem) problem;
        start.setCharacter(Double.valueOf(dProblem.getSourceColumnNumber() - 1));
        int offset = 0;
        if (dProblem.getSourceStart() != -1 && dProblem.getSourceEnd() != -1) {
            offset = dProblem.getSourceEnd() - dProblem.getSourceStart() + 1;
        }//from  www . j av a 2s.com
        end.setCharacter(Double.valueOf(dProblem.getSourceColumnNumber() - 1 + offset));
    }
    return range.withEnd(end).withStart(start);
}