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

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

Introduction

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

Prototype

@Override
    public int getSourceStart() 

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;
        }//  ww w. j  av a  2s  .  co  m
        end.setCharacter(Double.valueOf(dProblem.getSourceColumnNumber() - 1 + offset));
    }
    return range.withEnd(end).withStart(start);
}