use of org.eclipse.jdt.core.compiler.IProblem in project che 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]);
}
return createCleanUp(compilationUnit, locations, addSerialVersionIds);
}
use of org.eclipse.jdt.core.compiler.IProblem in project che by eclipse.
the class ASTNodes method getProblems.
public static IProblem[] getProblems(ASTNode node, int scope, int severity) {
ASTNode root = node.getRoot();
if (!(root instanceof CompilationUnit))
return EMPTY_PROBLEMS;
IProblem[] problems = ((CompilationUnit) root).getProblems();
if (root == node)
return problems;
final int iterations = computeIterations(scope);
List<IProblem> result = new ArrayList<IProblem>(5);
for (int i = 0; i < problems.length; i++) {
IProblem problem = problems[i];
boolean consider = false;
if ((severity & PROBLEMS) == PROBLEMS)
consider = true;
else if ((severity & WARNING) != 0)
consider = problem.isWarning();
else if ((severity & ERROR) != 0)
consider = problem.isError();
if (consider) {
ASTNode temp = node;
int count = iterations;
do {
int nodeOffset = temp.getStartPosition();
int problemOffset = problem.getSourceStart();
if (nodeOffset <= problemOffset && problemOffset < nodeOffset + temp.getLength()) {
result.add(problem);
count = 0;
} else {
count--;
}
} while ((temp = temp.getParent()) != null && count > 0);
}
}
return result.toArray(new IProblem[result.size()]);
}
use of org.eclipse.jdt.core.compiler.IProblem in project che by eclipse.
the class RenameAnalyzeUtil method analyzeCompileErrors.
private static RefactoringStatus analyzeCompileErrors(String newCuSource, CompilationUnit newCUNode, CompilationUnit oldCUNode) {
RefactoringStatus result = new RefactoringStatus();
IProblem[] newProblems = RefactoringAnalyzeUtil.getIntroducedCompileProblems(newCUNode, oldCUNode);
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))));
}
return result;
}
use of org.eclipse.jdt.core.compiler.IProblem in project che by eclipse.
the class StringCleanUp method computeNumberOfFixes.
/**
* {@inheritDoc}
*/
@Override
public int computeNumberOfFixes(CompilationUnit compilationUnit) {
try {
ICompilationUnit cu = (ICompilationUnit) compilationUnit.getJavaElement();
if (!cu.isStructureKnown())
//[clean up] 'Remove unnecessary $NLS-TAGS$' removes necessary ones in case of syntax errors: https://bugs.eclipse.org/bugs/show_bug.cgi?id=285814 :
return 0;
} catch (JavaModelException e) {
return 0;
}
int result = 0;
IProblem[] problems = compilationUnit.getProblems();
if (isEnabled(CleanUpConstants.ADD_MISSING_NLS_TAGS))
result += getNumberOfProblems(problems, IProblem.NonExternalizedStringLiteral);
if (isEnabled(CleanUpConstants.REMOVE_UNNECESSARY_NLS_TAGS))
result += getNumberOfProblems(problems, IProblem.UnnecessaryNLSTag);
return result;
}
use of org.eclipse.jdt.core.compiler.IProblem in project che by eclipse.
the class JavaReconciler method convertProblem.
private Problem convertProblem(IProblem problem) {
Problem result = DtoFactory.getInstance().createDto(Problem.class);
result.setArguments(Arrays.asList(problem.getArguments()));
result.setID(problem.getID());
result.setMessage(problem.getMessage());
result.setOriginatingFileName(new String(problem.getOriginatingFileName()));
result.setError(problem.isError());
result.setWarning(problem.isWarning());
result.setSourceEnd(problem.getSourceEnd());
result.setSourceStart(problem.getSourceStart());
result.setSourceLineNumber(problem.getSourceLineNumber());
return result;
}
Aggregations