Search in sources :

Example 1 with ProblemLocation

use of org.eclipse.jdt.ls.core.internal.corrections.ProblemLocation in project eclipse.jdt.ls by eclipse.

the class CodeActionHandler method getProblemLocations.

private IProblemLocation[] getProblemLocations(ICompilationUnit unit, List<Diagnostic> diagnostics) {
    IProblemLocation[] locations = new IProblemLocation[diagnostics.size()];
    for (int i = 0; i < diagnostics.size(); i++) {
        Diagnostic diagnostic = diagnostics.get(i);
        int problemId = getProblemId(diagnostic);
        int start = DiagnosticsHelper.getStartOffset(unit, diagnostic.getRange());
        int end = DiagnosticsHelper.getEndOffset(unit, diagnostic.getRange());
        boolean isError = diagnostic.getSeverity() == DiagnosticSeverity.Error;
        locations[i] = new ProblemLocation(start, end - start, problemId, isError);
    }
    return locations;
}
Also used : Diagnostic(org.eclipse.lsp4j.Diagnostic) IProblemLocation(org.eclipse.jdt.ls.core.internal.corrections.IProblemLocation) ProblemLocation(org.eclipse.jdt.ls.core.internal.corrections.ProblemLocation) IProblemLocation(org.eclipse.jdt.ls.core.internal.corrections.IProblemLocation)

Example 2 with ProblemLocation

use of org.eclipse.jdt.ls.core.internal.corrections.ProblemLocation in project eclipse.jdt.ls by eclipse.

the class PotentialProgrammingProblemsFix method createCleanUp.

public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean addSerialVersionIds) {
    IProblem[] problems = compilationUnit.getProblems();
    IProblemLocation[] locations = new IProblemLocation[problems.length];
    for (int i = 0; i < problems.length; i++) {
        // locations[i]= new ProblemLocation(problems[i]);
        boolean isError = problems[i].isError();
        int problemId = problems[i].getID();
        int length = problems[i].getSourceEnd() - problems[i].getSourceStart();
        int offset = problems[i].getSourceStart();
        locations[i] = new ProblemLocation(offset, length, problemId, isError);
    }
    return createCleanUp(compilationUnit, locations, addSerialVersionIds);
}
Also used : IProblemLocation(org.eclipse.jdt.ls.core.internal.corrections.IProblemLocation) ProblemLocation(org.eclipse.jdt.ls.core.internal.corrections.ProblemLocation) IProblemLocation(org.eclipse.jdt.ls.core.internal.corrections.IProblemLocation) IProblem(org.eclipse.jdt.core.compiler.IProblem)

Aggregations

IProblemLocation (org.eclipse.jdt.ls.core.internal.corrections.IProblemLocation)2 ProblemLocation (org.eclipse.jdt.ls.core.internal.corrections.ProblemLocation)2 IProblem (org.eclipse.jdt.core.compiler.IProblem)1 Diagnostic (org.eclipse.lsp4j.Diagnostic)1