List of usage examples for org.eclipse.jdt.core.compiler IProblem Syntax
int Syntax
To view the source code for org.eclipse.jdt.core.compiler IProblem Syntax.
Click Source Link
From source file:astview.ProblemNode.java
License:Open Source License
private String getErrorLabel() { int id = fProblem.getID(); StringBuffer buf = new StringBuffer(); if ((id & IProblem.TypeRelated) != 0) { buf.append("TypeRelated + "); //$NON-NLS-1$ }/*from w w w .j a v a 2 s. co m*/ if ((id & IProblem.FieldRelated) != 0) { buf.append("FieldRelated + "); //$NON-NLS-1$ } if ((id & IProblem.ConstructorRelated) != 0) { buf.append("ConstructorRelated + "); //$NON-NLS-1$ } if ((id & IProblem.MethodRelated) != 0) { buf.append("MethodRelated + "); //$NON-NLS-1$ } if ((id & IProblem.ImportRelated) != 0) { buf.append("ImportRelated + "); //$NON-NLS-1$ } if ((id & IProblem.Internal) != 0) { buf.append("Internal + "); //$NON-NLS-1$ } if ((id & IProblem.Syntax) != 0) { buf.append("Syntax + "); //$NON-NLS-1$ } if ((id & IProblem.Javadoc) != 0) { buf.append("Javadoc + "); //$NON-NLS-1$ } buf.append(id & IProblem.IgnoreCategoriesMask); buf.append(" = 0x").append(Integer.toHexString(id)).append(" = ").append(id); return buf.toString(); }
From source file:com.codenvy.ide.ext.java.server.internal.codeassist.SelectionEngine.java
License:Open Source License
/** * The SelectionEngine is responsible for computing the selected object. * * It requires a searchable name environment, which supports some * specific search APIs, and a requestor to feed back the results to a UI. * * @param nameEnvironment org.eclipse.jdt.internal.core.SearchableEnvironment * used to resolve type/package references and search for types/packages * based on partial names./*from ww w. j ava 2s . c o m*/ * * @param requestor org.eclipse.jdt.internal.codeassist.ISelectionRequestor * since the engine might produce answers of various forms, the engine * is associated with a requestor able to accept all possible completions. * * @param settings java.util.Map * set of options used to configure the code assist engine. */ public SelectionEngine(SearchableEnvironment nameEnvironment, ISelectionRequestor requestor, Map settings, WorkingCopyOwner owner, IndexManager indexManager, JavaProject javaProject) { super(settings); this.requestor = requestor; this.indexManager = indexManager; this.javaProject = javaProject; this.nameEnvironment = nameEnvironment; ProblemReporter problemReporter = new ProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(), this.compilerOptions, new DefaultProblemFactory(Locale.getDefault())) { public CategorizedProblem createProblem(char[] fileName, int problemId, String[] problemArguments, String[] messageArguments, int severity, int problemStartPosition, int problemEndPosition, int lineNumber, int columnNumber) { CategorizedProblem pb = super.createProblem(fileName, problemId, problemArguments, messageArguments, severity, problemStartPosition, problemEndPosition, lineNumber, columnNumber); if (SelectionEngine.this.problem == null && pb.isError() && (pb.getID() & IProblem.Syntax) == 0) { SelectionEngine.this.problem = pb; } return pb; } }; this.lookupEnvironment = new LookupEnvironment(this, this.compilerOptions, problemReporter, nameEnvironment); this.parser = new SelectionParser(problemReporter); this.owner = owner; }
From source file:com.codenvy.ide.ext.java.server.internal.core.CompilationUnitStructureRequestor.java
License:Open Source License
public void acceptProblem(CategorizedProblem problem) { if ((problem.getID() & IProblem.Syntax) != 0) { this.hasSyntaxErrors = true; } }
From source file:fromastview.ProblemNode.java
License:Open Source License
private String getErrorLabel() { int id = fProblem.getID(); StringBuffer buf = new StringBuffer(); if ((id & IProblem.TypeRelated) != 0) { buf.append("TypeRelated + "); }/* ww w.j ava 2 s.c o m*/ if ((id & IProblem.FieldRelated) != 0) { buf.append("FieldRelated + "); } if ((id & IProblem.ConstructorRelated) != 0) { buf.append("ConstructorRelated + "); } if ((id & IProblem.MethodRelated) != 0) { buf.append("MethodRelated + "); } if ((id & IProblem.ImportRelated) != 0) { buf.append("ImportRelated + "); } if ((id & IProblem.Internal) != 0) { buf.append("Internal + "); } if ((id & IProblem.Syntax) != 0) { buf.append("Syntax + "); } if ((id & IProblem.Javadoc) != 0) { buf.append("Javadoc + "); } buf.append(id & IProblem.IgnoreCategoriesMask); buf.append(" = 0x").append(Integer.toHexString(id)).append(" = ").append(id); return buf.toString(); }
From source file:org.eclipse.ajdt.internal.ui.editor.actions.AJOrganizeImportsOperation.java
License:Open Source License
protected boolean collectReferences(CompilationUnit astRoot, List<SimpleName> typeReferences, List<SimpleName> staticReferences, Set<String> oldSingleImports, Set<String> oldDemandImports) { AJProjectModelFacade model = AJProjectModelFactory.getInstance().getModelForJavaElement(fCompilationUnit); IProblem[] problems = astRoot.getProblems(); for (int i = 0; i < problems.length; i++) { IProblem curr = problems[i];// w w w . jav a2 s .co m if (curr instanceof CategorizedProblem) { CategorizedProblem cat = (CategorizedProblem) curr; if (curr.isError() && (curr.getID() & IProblem.Syntax) != 0 && isARealProblem(model, cat)) { fParsingError = problems[i]; return false; } } } @SuppressWarnings("unchecked") List<ImportDeclaration> imports = astRoot.imports(); for (int i = 0; i < imports.size(); i++) { ImportDeclaration curr = imports.get(i); String id = ASTResolving.getFullName(curr.getName()); if (curr.isOnDemand()) { oldDemandImports.add(id); } else { oldSingleImports.add(id); } } IJavaProject project = fCompilationUnit.getJavaProject(); ImportReferencesCollector.collect(astRoot, project, null, typeReferences, staticReferences); return true; }
From source file:org.eclipse.gmf.internal.common.codegen.OrganizeImportsPostprocessor.java
License:Open Source License
private boolean checkForNoSyntaxErrors(CompilationUnit astRoot) { IProblem[] problems = astRoot.getProblems(); for (int i = 0; i < problems.length; i++) { IProblem curr = problems[i];/*from w w w .j av a 2s . c o m*/ if (curr.isError() && (curr.getID() & IProblem.Syntax) != 0) { return false; } } return true; }
From source file:org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator.java
License:Open Source License
/** * Creates an IMessage from asn IProblem * //w ww .j a va 2s .co m * @param problem * @param f * @param translation * @param structuredDoc * @return message representation of the problem, or null if it could not * create one */ private IMessage createMessageFromProblem(IProblem problem, IFile f, IJSPTranslation translation, IStructuredDocument structuredDoc) { int sev = -1; int sourceStart = -1; int sourceEnd = -1; if (problem instanceof IJSPProblem) { sourceStart = problem.getSourceStart(); sourceEnd = problem.getSourceEnd(); switch (((IJSPProblem) problem).getEID()) { case IJSPProblem.TEIClassNotFound: sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TEI_CLASS_NOT_FOUND); break; case IJSPProblem.TEIValidationMessage: sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TEI_VALIDATION_MESSAGE); break; case IJSPProblem.TEIClassNotInstantiated: sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TEI_CLASS_NOT_INSTANTIATED); break; case IJSPProblem.TEIClassMisc: sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TEI_CLASS_RUNTIME_EXCEPTION); break; case IJSPProblem.TagClassNotFound: sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_TAG_HANDLER_CLASS_NOT_FOUND); break; case IJSPProblem.UseBeanInvalidID: sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_USEBEAN_INVALID_ID); break; case IJSPProblem.UseBeanMissingTypeInfo: sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_USBEAN_MISSING_TYPE_INFO); break; case IJSPProblem.UseBeanAmbiguousType: sev = getMessageSeverity(JSPCorePreferenceNames.VALIDATION_TRANSLATION_USEBEAN_AMBIGUOUS_TYPE_INFO); break; default: sev = problem.isError() ? IMessage.HIGH_SEVERITY : (problem.isWarning() ? IMessage.NORMAL_SEVERITY : ValidationMessage.IGNORE); } } else { sourceStart = translation.getJspOffset(problem.getSourceStart()); sourceEnd = translation.getJspOffset(problem.getSourceEnd()); switch (problem.getID()) { case IProblem.LocalVariableIsNeverUsed: { sev = getSourceSeverity(JSPCorePreferenceNames.VALIDATION_JAVA_LOCAL_VARIABLE_NEVER_USED, sourceStart, sourceEnd); } break; case IProblem.NullLocalVariableReference: { sev = getSourceSeverity(JSPCorePreferenceNames.VALIDATION_JAVA_NULL_LOCAL_VARIABLE_REFERENCE, sourceStart, sourceEnd); } break; case IProblem.ArgumentIsNeverUsed: { sev = getSourceSeverity(JSPCorePreferenceNames.VALIDATION_JAVA_ARGUMENT_IS_NEVER_USED, sourceStart, sourceEnd); } break; case IProblem.PotentialNullLocalVariableReference: { sev = getSourceSeverity( JSPCorePreferenceNames.VALIDATION_JAVA_POTENTIAL_NULL_LOCAL_VARIABLE_REFERENCE, sourceStart, sourceEnd); } break; case IProblem.UnusedImport: { sev = getSourceSeverity(JSPCorePreferenceNames.VALIDATION_JAVA_UNUSED_IMPORT, sourceStart, sourceEnd); } break; case IProblem.UnusedPrivateField: case IProblem.MissingSerialVersion: { // JSP files don't get serialized...right? sev = ValidationMessage.IGNORE; } break; default: { if (problem.isError()) { sev = IMessage.HIGH_SEVERITY; } else if (problem.isWarning()) { sev = IMessage.NORMAL_SEVERITY; } else { sev = IMessage.LOW_SEVERITY; } } if (sev == ValidationMessage.IGNORE) { return null; } /* problems without JSP positions are in generated code */ if (sourceStart == -1) { int problemID = problem.getID(); /* * Quoting IProblem doc: "When a problem is tagged as * Internal, it means that no change other than a * local source code change can fix the corresponding * problem." Assuming that our generated code is * correct, that should reduce the reported problems * to those the user can correct. */ if (((problemID & IProblem.Internal) != 0) && ((problemID & IProblem.Syntax) != 0) && translation instanceof JSPTranslation) { // Attach to the last code scripting section JSPTranslation jspTranslation = ((JSPTranslation) translation); Position[] jspPositions = (Position[]) jspTranslation.getJsp2JavaMap().keySet() .toArray(new Position[jspTranslation.getJsp2JavaMap().size()]); for (int i = 0; i < jspPositions.length; i++) { sourceStart = Math.max(sourceStart, jspPositions[i].getOffset()); } IMessage m = new LocalizedMessage(sev, problem.getMessage(), f); m.setOffset(sourceStart); m.setLength(1); return m; } else { return null; } } } } if (sev == ValidationMessage.IGNORE) { return null; } final boolean isIndirect = translation.isIndirect(problem.getSourceStart()); if (isIndirect && !FragmentValidationTools.shouldValidateFragment(f)) { return null; } // line number for marker starts @ 1 // line number from document starts @ 0 int lineNo = structuredDoc.getLineOfOffset(sourceStart) + 1; IMessage m = new LocalizedMessage(sev, problem.getMessage(), f); m.setLineNo(lineNo); m.setOffset(sourceStart); m.setLength((sourceEnd >= sourceStart) ? (sourceEnd - sourceStart + 1) : 0); // need additional adjustment for problems from // indirect (included) files // https://bugs.eclipse.org/bugs/show_bug.cgi?id=119633 if (isIndirect) { adjustIndirectPosition(m, translation); } return m; }