use of org.eclipse.jdt.core.compiler.IProblem in project eclipse.jdt.ls by eclipse.
the class DiagnosticsHandler method toDiagnosticsArray.
public static List<Diagnostic> toDiagnosticsArray(IOpenable openable, List<IProblem> problems) {
List<Diagnostic> array = new ArrayList<>(problems.size());
for (IProblem problem : problems) {
Diagnostic diag = new Diagnostic();
diag.setSource(JavaLanguageServerPlugin.SERVER_SOURCE_ID);
diag.setMessage(problem.getMessage());
diag.setCode(Integer.toString(problem.getID()));
diag.setSeverity(convertSeverity(problem));
diag.setRange(convertRange(openable, problem));
array.add(diag);
}
return array;
}
use of org.eclipse.jdt.core.compiler.IProblem in project eclipse.jdt.ls by eclipse.
the class ExtractConstantRefactoring method checkSource.
private void checkSource(SubProgressMonitor monitor, RefactoringStatus result) throws CoreException {
String newCuSource = fChange.getPreviewContent(new NullProgressMonitor());
CompilationUnit newCUNode = new RefactoringASTParser(IASTSharedValues.SHARED_AST_LEVEL).parse(newCuSource, fCu, true, true, monitor);
IProblem[] newProblems = RefactoringAnalyzeUtil.getIntroducedCompileProblems(newCUNode, fCuRewrite.getRoot());
for (int i = 0; i < newProblems.length; i++) {
IProblem problem = newProblems[i];
if (problem.isError()) {
result.addEntry(new RefactoringStatusEntry((problem.isError() ? RefactoringStatus.ERROR : RefactoringStatus.WARNING), problem.getMessage(), new JavaStringStatusContext(newCuSource, SourceRangeFactory.create(problem))));
}
}
}
use of org.eclipse.jdt.core.compiler.IProblem 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);
}
use of org.eclipse.jdt.core.compiler.IProblem in project eclipse.jdt.ls by eclipse.
the class ExtractTempRefactoring method checkNewSource.
private void checkNewSource(SubProgressMonitor monitor, RefactoringStatus result) throws CoreException {
String newCuSource = fChange.getPreviewContent(new NullProgressMonitor());
CompilationUnit newCUNode = new RefactoringASTParser(IASTSharedValues.SHARED_AST_LEVEL).parse(newCuSource, fCu, true, true, monitor);
IProblem[] newProblems = RefactoringAnalyzeUtil.getIntroducedCompileProblems(newCUNode, fCompilationUnitNode);
for (int i = 0; i < newProblems.length; i++) {
IProblem problem = newProblems[i];
if (problem.isError()) {
result.addEntry(new RefactoringStatusEntry((problem.isError() ? RefactoringStatus.ERROR : RefactoringStatus.WARNING), problem.getMessage(), new JavaStringStatusContext(newCuSource, SourceRangeFactory.create(problem))));
}
}
}
use of org.eclipse.jdt.core.compiler.IProblem in project eclipse.jdt.ls by eclipse.
the class LinkedNodeFinder method getNameNodeProblemKind.
private static int getNameNodeProblemKind(IProblem[] problems, SimpleName nameNode) {
int nameOffset = nameNode.getStartPosition();
int nameInclEnd = nameOffset + nameNode.getLength() - 1;
for (int i = 0; i < problems.length; i++) {
IProblem curr = problems[i];
if (curr.getSourceStart() == nameOffset && curr.getSourceEnd() == nameInclEnd) {
int kind = getProblemKind(curr);
if (kind != 0) {
return kind;
}
}
}
return 0;
}
Aggregations