use of org.eclipse.jdt.core.compiler.IProblem in project che by eclipse.
the class UnresolvedTypesQuickFixTest method testParameterizedType2.
@Test
@Ignore
public void testParameterizedType2() throws Exception {
IPackageFragment pack1 = fSourceFolder.createPackageFragment("test1", false, null);
StringBuffer buf = new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.util.Map;\n");
buf.append("public class E<T> {\n");
buf.append(" static class SomeType<S1, S2> { }\n");
buf.append(" void foo() {\n");
buf.append(" SomeType<String, String> list= new XXY<String, String>() { };\n");
buf.append(" }\n");
buf.append("}\n");
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
CompilationUnit astRoot = getASTRoot(cu);
IProblem[] problems = astRoot.getProblems();
assertNumberOfProblems(2, problems);
ArrayList proposals = collectCorrections(cu, problems[0], null);
proposals.addAll(collectCorrections(cu, problems[1], null));
assertCorrectLabels(proposals);
String[] expected = new String[3];
buf = new StringBuffer();
buf.append("package test1;\n");
buf.append("import java.util.Map;\n");
buf.append("public class E<T> {\n");
buf.append(" static class SomeType<S1, S2> { }\n");
buf.append(" void foo() {\n");
buf.append(" SomeType<String, String> list= new SomeType<String, String>() { };\n");
buf.append(" }\n");
buf.append("}\n");
expected[0] = buf.toString();
buf = new StringBuffer();
buf.append("package test1;\n");
buf.append("\n");
buf.append("import test1.E.SomeType;\n");
buf.append("\n");
buf.append("public class XXY<T1, T2> extends SomeType<String, String> {\n");
buf.append("\n");
buf.append("}\n");
expected[1] = buf.toString();
buf = new StringBuffer();
buf.append("package test1;\n");
buf.append("\n");
buf.append("public interface XXY<T1, T2> {\n");
buf.append("\n");
buf.append("}\n");
expected[2] = buf.toString();
assertExpectedExistInProposals(proposals, expected);
}
use of org.eclipse.jdt.core.compiler.IProblem in project che by eclipse.
the class CodeStyleFix method createCleanUp.
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean addThisQualifier, boolean changeNonStaticAccessToStatic, boolean qualifyStaticFieldAccess, boolean changeIndirectStaticAccessToDirect, boolean qualifyMethodAccess, boolean qualifyStaticMethodAccess, boolean removeFieldQualifier, boolean removeMethodQualifier) {
if (!addThisQualifier && !changeNonStaticAccessToStatic && !qualifyStaticFieldAccess && !changeIndirectStaticAccessToDirect && !qualifyMethodAccess && !qualifyStaticMethodAccess && !removeFieldQualifier && !removeMethodQualifier)
return null;
List<CompilationUnitRewriteOperation> operations = new ArrayList<CompilationUnitRewriteOperation>();
if (addThisQualifier || qualifyStaticFieldAccess || qualifyMethodAccess || qualifyStaticMethodAccess) {
CodeStyleVisitor codeStyleVisitor = new CodeStyleVisitor(compilationUnit, addThisQualifier, qualifyStaticFieldAccess, qualifyMethodAccess, qualifyStaticMethodAccess, operations);
compilationUnit.accept(codeStyleVisitor);
}
IProblem[] problems = compilationUnit.getProblems();
IProblemLocation[] locations = new IProblemLocation[problems.length];
for (int i = 0; i < problems.length; i++) {
locations[i] = new ProblemLocation(problems[i]);
}
addToStaticAccessOperations(compilationUnit, locations, changeNonStaticAccessToStatic, changeIndirectStaticAccessToDirect, operations);
if (removeFieldQualifier || removeMethodQualifier) {
ThisQualifierVisitor visitor = new ThisQualifierVisitor(removeFieldQualifier, removeMethodQualifier, compilationUnit, operations);
compilationUnit.accept(visitor);
}
if (operations.isEmpty())
return null;
CompilationUnitRewriteOperation[] operationsArray = operations.toArray(new CompilationUnitRewriteOperation[operations.size()]);
return new CodeStyleFix(FixMessages.CodeStyleFix_change_name, compilationUnit, operationsArray);
}
use of org.eclipse.jdt.core.compiler.IProblem in project che by eclipse.
the class StringFix method createCleanUp.
public static ICleanUpFix createCleanUp(CompilationUnit compilationUnit, boolean addNLSTag, boolean removeNLSTag) throws CoreException, JavaModelException {
if (!addNLSTag && !removeNLSTag)
return null;
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, addNLSTag, removeNLSTag, locations);
}
use of org.eclipse.jdt.core.compiler.IProblem in project che by eclipse.
the class Java50Fix method hasFatalError.
private static boolean hasFatalError(CompilationUnit compilationUnit) {
try {
if (!((ICompilationUnit) compilationUnit.getJavaElement()).isStructureKnown())
return true;
} catch (JavaModelException e) {
JavaPlugin.log(e);
return true;
}
IProblem[] problems = compilationUnit.getProblems();
for (int i = 0; i < problems.length; i++) {
if (problems[i].isError()) {
if (!(problems[i] instanceof CategorizedProblem))
return true;
CategorizedProblem categorizedProblem = (CategorizedProblem) problems[i];
int categoryID = categorizedProblem.getCategoryID();
if (categoryID == CategorizedProblem.CAT_BUILDPATH)
return true;
if (categoryID == CategorizedProblem.CAT_SYNTAX)
return true;
if (categoryID == CategorizedProblem.CAT_IMPORT)
return true;
if (categoryID == CategorizedProblem.CAT_TYPE)
return true;
if (categoryID == CategorizedProblem.CAT_MEMBER)
return true;
if (categoryID == CategorizedProblem.CAT_INTERNAL)
return true;
}
}
return false;
}
use of org.eclipse.jdt.core.compiler.IProblem in project che by eclipse.
the class ChangeSignatureProcessor method checkCompilationofDeclaringCu.
private RefactoringStatus checkCompilationofDeclaringCu() throws CoreException {
ICompilationUnit cu = getCu();
TextChange change = fChangeManager.get(cu);
String newCuSource = change.getPreviewContent(new NullProgressMonitor());
CompilationUnit newCUNode = new RefactoringASTParser(ASTProvider.SHARED_AST_LEVEL).parse(newCuSource, cu, true, false, null);
IProblem[] problems = RefactoringAnalyzeUtil.getIntroducedCompileProblems(newCUNode, fBaseCuRewrite.getRoot());
RefactoringStatus result = new RefactoringStatus();
for (int i = 0; i < problems.length; i++) {
IProblem problem = problems[i];
if (shouldReport(problem, newCUNode))
result.addEntry(new RefactoringStatusEntry((problem.isError() ? RefactoringStatus.ERROR : RefactoringStatus.WARNING), problem.getMessage(), new JavaStringStatusContext(newCuSource, SourceRangeFactory.create(problem))));
}
return result;
}
Aggregations