List of usage examples for org.eclipse.jdt.core.compiler IProblem UndefinedType
int UndefinedType
To view the source code for org.eclipse.jdt.core.compiler IProblem UndefinedType.
Click Source Link
From source file:ch.powerunit.poweruniteclipse.PowerunitQuickFixProcessor.java
License:Open Source License
@Override public boolean hasCorrections(ICompilationUnit unit, int problemId) { return problemId == IProblem.UndefinedType; }
From source file:ch.powerunit.poweruniteclipse.PowerunitQuickFixProcessor.java
License:Open Source License
@Override public IJavaCompletionProposal[] getCorrections(final IInvocationContext context, IProblemLocation[] locations) {/*from w ww. j ava 2 s.c o m*/ ArrayList<IJavaCompletionProposal> res = null; for (int i = 0; i < locations.length; i++) { IProblemLocation problem = locations[i]; int id = problem.getProblemId(); if (IProblem.UndefinedType == id) { res = getAddPowerunitToBuildPathProposals(context, problem, res); } } if (res == null || res.isEmpty()) { return null; } return res.toArray(new IJavaCompletionProposal[res.size()]); }
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 . jav a 2 s .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 w ww .j ava 2s . c o m*/ 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 . j ava2s . co m*/ } switch (id) { case IProblem.ImportNotFound: importNotFoundProposal(context, problem, proposals); break; case IProblem.UndefinedType: undefinedType(context, problem, proposals); break; default: ; } }
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) {//from w w w . j a v a 2 s.co 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 boolean hasCorrections(final ICompilationUnit unit, final int problemId) { try {/*from w w w. j a v a2 s .co m*/ IResource resource = unit.getCorrespondingResource(); if (resource.getProject() == CupidScriptingPlugin.getDefault().getCupidProject()) { return problemId == IProblem.UndefinedType || problemId == IProblem.IsClassPathCorrect || problemId == IProblem.MissingTypeInMethod; } else { return false; } } catch (Exception ex) { return false; } }
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 w w . j ava2 s.co m // 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:fede.workspace.dependencies.eclipse.java.fix.DependencyQuickFixProcessor.java
License:Apache License
public IJavaCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) throws CoreException { List<IJavaCompletionProposal> ret = new ArrayList<IJavaCompletionProposal>(); CompilationUnit astroot = context.getASTRoot(); IResource r = context.getCompilationUnit().getResource(); IProject p = r.getProject();/*from w ww.j a v a 2s. co m*/ IJavaProject jp = JavaCore.create(p); Item itemSource = WSPlugin.getItemFromResource(p); if (itemSource != null) { Object manager = itemSource.getType().getItemManager(); if (manager instanceof IFixManager) { IFixManager fixmanager = (IFixManager) manager; for (IProblemLocation problem : locations) { ASTNode coveredNode = problem.getCoveredNode(astroot); String[] arguments = problem.getProblemArguments(); switch (problem.getProblemId()) { case IProblem.IsClassPathCorrect: if (arguments.length == 1) { String qualifiedType = arguments[0]; String packageName = Signature.getQualifier(qualifiedType); String typeName = Signature.getSimpleName(qualifiedType); fixmanager.resolve(jp, itemSource, packageName, typeName, false, ret); } continue; case IProblem.UndefinedType: if (coveredNode instanceof SimpleName) { fixmanager.resolve(jp, itemSource, ((SimpleName) coveredNode).getIdentifier(), null, false, ret); } break; default: break; } ASTNode selectedNode = problem.getCoveringNode(context.getASTRoot()); if (selectedNode == null) continue; ImportDeclaration importDeclaration = (ImportDeclaration) ASTNodes.getParent(selectedNode, ASTNode.IMPORT_DECLARATION); if (importDeclaration == null) { continue; } String name = ASTNodes.asString(importDeclaration.getName()); String packageName; String typeName = null; if (importDeclaration.isOnDemand()) { packageName = name; } else { packageName = Signature.getQualifier(name); typeName = Signature.getSimpleName(name); } fixmanager.resolve(jp, itemSource, packageName, typeName, problem.getProblemId() == IProblem.UndefinedType, ret); } } } return (IJavaCompletionProposal[]) ret.toArray(new IJavaCompletionProposal[ret.size()]); }