Java Code Examples for org.eclipse.jdt.core.compiler.IProblem#getID()
The following examples show how to use
org.eclipse.jdt.core.compiler.IProblem#getID() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntroduceParameterObjectProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
@Override protected boolean shouldReport(IProblem problem, CompilationUnit cu) { if (!super.shouldReport(problem, cu)) return false; ASTNode node= ASTNodeSearchUtil.getAstNode(cu, problem.getSourceStart(), problem.getSourceEnd() - problem.getSourceStart() + 1); if (node instanceof Type) { Type type= (Type) node; if (problem.getID() == IProblem.UndefinedType && getClassName().equals(ASTNodes.getTypeName(type))) { return false; } } if (node instanceof Name) { Name name= (Name) node; if (problem.getID() == IProblem.ImportNotFound && getPackage().indexOf(name.getFullyQualifiedName()) != -1) return false; if (problem.getID() == IProblem.MissingTypeInMethod) { StructuralPropertyDescriptor locationInParent= name.getLocationInParent(); String[] arguments= problem.getArguments(); if ((locationInParent == MethodInvocation.NAME_PROPERTY || locationInParent == SuperMethodInvocation.NAME_PROPERTY) && arguments.length > 3 && arguments[3].endsWith(getClassName())) return false; } } return true; }
Example 2
Source File: LinkedNodeFinder.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static int getProblemKind(IProblem problem) { switch (problem.getID()) { case IProblem.UndefinedField: return FIELD; case IProblem.UndefinedMethod: return METHOD; case IProblem.UndefinedLabel: return LABEL; case IProblem.UndefinedName: case IProblem.UnresolvedVariable: return NAME; case IProblem.UndefinedType: return TYPE; } return 0; }
Example 3
Source File: RefactoringAnalyzeUtil.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static boolean isCorresponding(IProblem oldProblem, IProblem iProblem) { if (oldProblem.getID() != iProblem.getID()) { return false; } if (!oldProblem.getMessage().equals(iProblem.getMessage())) { return false; } return true; }
Example 4
Source File: BaseDiagnosticsHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
public boolean isSyntaxLikeError(IProblem problem) { //Syntax issues are always reported if ((problem.getID() & IProblem.Syntax) != 0) { return true; } if (!isDefaultProject && problem.getID() == IProblem.PackageIsNotExpectedPackage) { return false; } //Type and Import issues are never reported if ((problem.getID() & IProblem.TypeRelated) != 0 || // (problem.getID() & IProblem.ImportRelated) != 0) { return false; } //For the rest, we need to cherry pick what is ignored or not switch (problem.getID()) { case IProblem.AbstractMethodMustBeImplemented: case IProblem.AmbiguousMethod: case IProblem.DanglingReference: case IProblem.MethodMustOverrideOrImplement: case IProblem.MissingReturnType: case IProblem.MissingTypeInConstructor: case IProblem.MissingTypeInLambda: case IProblem.MissingTypeInMethod: case IProblem.UndefinedConstructor: case IProblem.UndefinedField: case IProblem.UndefinedMethod: case IProblem.UndefinedName: case IProblem.UnresolvedVariable: return false; default: //We log problems for troubleshooting purposes String error = getError(problem); JavaLanguageServerPlugin.logInfo(problem.getMessage() + " is of type " + error); } return true; }
Example 5
Source File: BaseDiagnosticsHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
private static DiagnosticSeverity convertSeverity(IProblem problem) { if (problem.isError()) { return DiagnosticSeverity.Error; } if (problem.isWarning() && (problem.getID() != IProblem.Task)) { return DiagnosticSeverity.Warning; } return DiagnosticSeverity.Information; }
Example 6
Source File: ChangeSignatureProcessor.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Evaluates if a problem needs to be reported. * @param problem the problem * @param cu the AST containing the new source * @return return <code>true</code> if the problem needs to be reported */ protected boolean shouldReport(IProblem problem, CompilationUnit cu) { if (! problem.isError()) return false; if (problem.getID() == IProblem.UndefinedType) //reported when trying to import return false; return true; }
Example 7
Source File: RefactoringAnalyzeUtil.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static boolean isCorresponding(IProblem oldProblem, IProblem iProblem) { if (oldProblem.getID() != iProblem.getID()) return false; if (! oldProblem.getMessage().equals(iProblem.getMessage())) return false; return true; }
Example 8
Source File: CompilationUnitDocumentProvider.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void acceptProblem(IProblem problem) { if (fIsHandlingTemporaryProblems || problem.getID() == JavaSpellingReconcileStrategy.SPELLING_PROBLEM_ID) { ProblemRequestorState state= fProblemRequestorState.get(); if (state != null) state.fReportedProblems.add(problem); } }
Example 9
Source File: ProblemHover.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static boolean hasProblem(IProblem[] problems, IProblemLocation location) { for (int i= 0; i < problems.length; i++) { IProblem problem= problems[i]; if (problem.getID() == location.getProblemId() && problem.getSourceStart() == location.getOffset()) return true; } return false; }
Example 10
Source File: ProblemLocation.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public ProblemLocation(IProblem problem) { fId= problem.getID(); fArguments= problem.getArguments(); fOffset= problem.getSourceStart(); fLength= problem.getSourceEnd() - fOffset + 1; fIsError= problem.isError(); fMarkerType= problem instanceof CategorizedProblem ? ((CategorizedProblem) problem).getMarkerType() : IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER; }
Example 11
Source File: CorrectionMarkerResolutionGenerator.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private static boolean hasProblem(IProblem[] problems, IProblemLocation location) { for (int i= 0; i < problems.length; i++) { IProblem problem= problems[i]; if (problem.getID() == location.getProblemId() && problem.getSourceStart() == location.getOffset()) return true; } return false; }
Example 12
Source File: JRJdtCompiler.java From jasperreports with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void acceptResult(CompilationResult result) { String className = ((CompilationUnit) result.getCompilationUnit()).className; int classIdx; for (classIdx = 0; classIdx < units.length; ++classIdx) { if (className.equals(units[classIdx].getName())) { break; } } if (result.hasErrors()) { //IProblem[] problems = result.getErrors(); IProblem[] problems = getJavaCompilationErrors(result); unitResults[classIdx].problems = problems; String sourceCode = units[classIdx].getSourceCode(); for (int i = 0; i < problems.length; i++) { IProblem problem = problems[i]; if (IProblem.UndefinedMethod == problem.getID()) { if ( problem.getSourceStart() >= 0 && problem.getSourceEnd() >= 0 ) { String methodName = sourceCode.substring( problem.getSourceStart(), problem.getSourceEnd() + 1 ); Method method = FunctionsUtil.getInstance(jasperReportsContext).getMethod4Function(methodName); if (method != null) { unitResults[classIdx].addMissingMethod(method); //continue; } } } } } else { ClassFile[] resultClassFiles = result.getClassFiles(); for (int i = 0; i < resultClassFiles.length; i++) { units[classIdx].setCompileData(resultClassFiles[i].getBytes()); } } }
Example 13
Source File: SelfEncapsulateFieldRefactoring.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private boolean isIgnorableProblem(IProblem problem) { if (problem.getID() == IProblem.NotVisibleField) { return true; } return false; }
Example 14
Source File: BaseDocumentLifeCycleHandler.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 4 votes |
private ICompilationUnit checkPackageDeclaration(String uri, ICompilationUnit unit) { if (unit.getResource() != null && unit.getJavaProject() != null && unit.getJavaProject().getProject().getName().equals(ProjectsManager.DEFAULT_PROJECT_NAME)) { try { CompilationUnit astRoot = CoreASTProvider.getInstance().getAST(unit, CoreASTProvider.WAIT_YES, new NullProgressMonitor()); IProblem[] problems = astRoot.getProblems(); for (IProblem problem : problems) { if (problem.getID() == IProblem.PackageIsNotExpectedPackage) { IResource file = unit.getResource(); boolean toRemove = file.isLinked(); if (toRemove) { IPath path = file.getParent().getProjectRelativePath(); if (path.segmentCount() > 0 && JDTUtils.SRC.equals(path.segments()[0])) { String packageNameResource = path.removeFirstSegments(1).toString().replace(JDTUtils.PATH_SEPARATOR, JDTUtils.PERIOD); path = file.getLocation(); if (path != null && path.segmentCount() > 0) { path = path.removeLastSegments(1); String pathStr = path.toString().replace(JDTUtils.PATH_SEPARATOR, JDTUtils.PERIOD); if (pathStr.endsWith(packageNameResource)) { toRemove = false; } } } } if (toRemove) { file.delete(true, new NullProgressMonitor()); if (unit.equals(sharedASTProvider.getActiveJavaElement())) { sharedASTProvider.disposeAST(); } unit.discardWorkingCopy(); unit = JDTUtils.resolveCompilationUnit(uri); unit.becomeWorkingCopy(new NullProgressMonitor()); triggerValidation(unit); } break; } } } catch (CoreException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } } return unit; }
Example 15
Source File: SelfEncapsulateFieldRefactoring.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 4 votes |
private boolean isIgnorableProblem(IProblem problem) { if (problem.getID() == IProblem.NotVisibleField) return true; return false; }