List of usage examples for org.eclipse.jdt.core.compiler IProblem ImportNotFound
int ImportNotFound
To view the source code for org.eclipse.jdt.core.compiler IProblem ImportNotFound.
Click Source Link
From source file:com.facebook.nuclide.debugger.EvaluationManager.java
License:Open Source License
private String checkUnitForProblems(CompilationUnit unit) { final IProblem[] problems = unit.getProblems(); final StringBuilder errors = new StringBuilder(); int realProblemCount = 0; if (problems.length > 0) { for (IProblem problem : problems) { if (!problem.isError()) { // Ignore anything that's not error severity. continue; }//from w w w .ja v a 2s . c o m int problemId = problem.getID(); // These problems do not need to stop the parse. // NOTE: List taken from Eclipse reference impl. if (problemId == IProblem.VoidMethodReturnsValue || problemId == IProblem.NotVisibleMethod || problemId == IProblem.NotVisibleConstructor || problemId == IProblem.NotVisibleField || problemId == IProblem.NotVisibleType || problemId == IProblem.ImportNotFound || problemId == IProblem.UndefinedType || problemId == IProblem.BodyForAbstractMethod) { continue; } realProblemCount++; if (realProblemCount == 1) { errors.append("Unable to evaluate expression: "); } errors.append(problem.getMessage()); errors.append("\n"); } // We couldn't parse the specified expression. // Throw the error messages back to the debugger frontend. if (realProblemCount > 0) { return errors.toString().trim(); } } return null; }
From source file:com.liferay.ide.gradle.ui.quickfix.QuickFixGradleDep.java
License:Open Source License
@Override public boolean hasCorrections(ICompilationUnit unit, int problemId) { switch (problemId) { case IProblem.ImportNotFound: case IProblem.UndefinedType: return true; default://from ww w .jav a2s . com return false; } }
From source file:com.liferay.ide.gradle.ui.quickfix.QuickFixGradleDep.java
License:Open Source License
private void process(IInvocationContext context, IProblemLocation problem, List<IJavaCompletionProposal> proposals) { int id = problem.getProblemId(); if (id == 0) { return;/*from w w w.ja va 2 s . com*/ } switch (id) { case IProblem.ImportNotFound: importNotFoundProposal(context, problem, proposals); break; case IProblem.UndefinedType: undefinedType(context, problem, proposals); break; default: ; } }
From source file:com.siteview.mde.internal.ui.correction.java.QuickFixProcessor.java
License:Open Source License
public IJavaCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) throws CoreException { ArrayList results = new ArrayList(); for (int i = 0; i < locations.length; i++) { int id = locations[i].getProblemId(); switch (id) { case IProblem.ForbiddenReference: handleAccessRestrictionProblem(context, locations[i], results); case IProblem.ImportNotFound: handleImportNotFound(context, locations[i], results); }//from w w w . ja v a2 s . c om } return (IJavaCompletionProposal[]) results.toArray(new IJavaCompletionProposal[results.size()]); }
From source file:com.siteview.mde.internal.ui.correction.java.QuickFixProcessor.java
License:Open Source License
public boolean hasCorrections(ICompilationUnit unit, int problemId) { switch (problemId) { case IProblem.ForbiddenReference: case IProblem.ImportNotFound: IJavaElement parent = unit.getParent(); if (parent != null) { IJavaProject project = parent.getJavaProject(); if (project != null) return WorkspaceModelManager.isPluginProject(project.getProject()); }/* w w w.j a va 2 s .com*/ } return false; }
From source file:edu.uci.ics.sourcerer.extractor.ast.FeatureExtractor.java
License:Open Source License
@SuppressWarnings("unchecked") private boolean checkForMissingTypes(CompilationUnit unit, SourceExtractionReport report, IMissingTypeWriter writer) {/* www. j ava2 s .c o m*/ Set<String> onDemandImports = Helper.newHashSet(); Map<String, String> singleTypeImports = Helper.newHashMap(); Set<String> simpleNames = Helper.newHashSet(); boolean hasSecondOrder = false; // Check for the classpath problem for (IProblem problem : unit.getProblems()) { if (problem.isError()) { if (problem.getID() == IProblem.IsClassPathCorrect) { writer.writeMissingType(problem.getArguments()[0]); report.reportMissingSecondOrder(); hasSecondOrder = true; } else if (problem.getID() == IProblem.ImportNotFound) { String prefix = problem.getArguments()[0]; // Go and find all the imports with this prefix boolean found = false; for (ImportDeclaration imp : (List<ImportDeclaration>) unit.imports()) { String fqn = imp.getName().getFullyQualifiedName(); if (fqn.startsWith(prefix)) { if (imp.isOnDemand()) { onDemandImports.add(fqn); } else { String simpleName = fqn.substring(fqn.lastIndexOf('.') + 1); String oldFqn = singleTypeImports.get(simpleName); if (oldFqn != null && !oldFqn.equals(fqn)) { logger.log(Level.SEVERE, "Two fqns with the same simple name: " + fqn + " and " + oldFqn); } else { singleTypeImports.put(simpleName, fqn); } } // writer.writeMissingType(imp.getName().getFullyQualifiedName()); found = true; } } if (!found) { logger.log(Level.SEVERE, "Unable to find import matching: " + prefix); writer.writeMissingType(prefix); } report.reportMissingType(); } else if (problem.getID() == IProblem.UndefinedType) { simpleNames.add(problem.getArguments()[0]); report.reportMissingType(); } } } for (String imp : onDemandImports) { writer.writeMissingType(imp); } for (String imp : singleTypeImports.values()) { writer.writeMissingType(imp); } for (String simpleName : simpleNames) { if (!singleTypeImports.containsKey(simpleName)) { for (String imp : onDemandImports) { writer.writeMissingType(imp + "." + simpleName); } } } return hasSecondOrder; }
From source file:edu.washington.cs.cupid.scripting.java.quickfix.ClasspathProcessor.java
License:Open Source License
@Override public IJavaCompletionProposal[] getCorrections(final IInvocationContext context, final IProblemLocation[] locations) throws CoreException { List<IJavaCompletionProposal> proposals = Lists.newArrayList(); for (IProblemLocation location : locations) { switch (location.getProblemId()) { case IProblem.ImportNotFound: proposals.addAll(buildImportNotFoundProposals(context, location)); break; case IProblem.MissingTypeInMethod: proposals.addAll(buildMissingTypeProposals(context, location)); break; case IProblem.UndefinedType: proposals.addAll(buildMissingBundleProposals(context, location)); break; default://from w ww .ja v a 2 s.c om // NO OP } } return proposals.toArray(new IJavaCompletionProposal[] {}); }
From source file:fede.workspace.dependencies.eclipse.java.fix.DependencyQuickFixProcessor.java
License:Apache License
public boolean hasCorrections(ICompilationUnit unit, int problemId) { if (problemId == IProblem.ImportNotFound || problemId == IProblem.UndefinedType) return true; return false; }
From source file:org.apache.felix.sigil.eclipse.ui.internal.quickfix.ImportQuickFixProcessor.java
License:Apache License
public boolean hasCorrections(ICompilationUnit unit, int problemId) { switch (problemId) { case IProblem.ForbiddenReference: case IProblem.ImportNotFound: case IProblem.IsClassPathCorrect: case IProblem.UndefinedType: case IProblem.UndefinedName: return true; default:/*from w w w. j a v a 2 s. c o m*/ return false; } }
From source file:org.apache.felix.sigil.eclipse.ui.internal.quickfix.ImportQuickFixProcessor.java
License:Apache License
public IJavaCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) throws CoreException { try {//from w w w.ja v a 2 s. c om HashMap<Object, IJavaCompletionProposal> results = new HashMap<Object, IJavaCompletionProposal>(); ISigilProjectModel project = findProject(context); if (project != null) { for (int i = 0; i < locations.length; i++) { switch (locations[i].getProblemId()) { case IProblem.ForbiddenReference: handleImportNotFound(project, context, locations[i], results); break; case IProblem.ImportNotFound: handleImportNotFound(project, context, locations[i], results); break; case IProblem.IsClassPathCorrect: handleIsClassPathCorrect(project, context, locations[i], results); break; case IProblem.UndefinedType: handleUndefinedType(project, context, locations[i], results); break; case IProblem.UndefinedName: handleUndefinedName(project, context, locations[i], results); break; } } } return (IJavaCompletionProposal[]) results.values() .toArray(new IJavaCompletionProposal[results.size()]); } catch (RuntimeException e) { e.printStackTrace(); throw e; } }