List of usage examples for org.eclipse.jdt.core IJavaModelMarker JAVA_MODEL_PROBLEM_MARKER
String JAVA_MODEL_PROBLEM_MARKER
To view the source code for org.eclipse.jdt.core IJavaModelMarker JAVA_MODEL_PROBLEM_MARKER.
Click Source Link
"org.eclipse.jdt.core.problem"
). From source file:com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.java
License:Open Source License
@Override protected void abortOnBadSetup(@NonNull IJavaProject javaProject, @Nullable ProjectState projectState) throws AbortBuildException, CoreException { super.abortOnBadSetup(javaProject, projectState); IProject iProject = getProject();//from w w w . j a v a 2 s . c o m // do a (hopefully quick) search for Precompiler type markers. Those are always only // errors. stopOnMarker(iProject, AdtConstants.MARKER_AAPT_COMPILE, IResource.DEPTH_INFINITE, false /*checkSeverity*/); stopOnMarker(iProject, AdtConstants.MARKER_AIDL, IResource.DEPTH_INFINITE, false /*checkSeverity*/); stopOnMarker(iProject, AdtConstants.MARKER_RENDERSCRIPT, IResource.DEPTH_INFINITE, false /*checkSeverity*/); stopOnMarker(iProject, AdtConstants.MARKER_ANDROID, IResource.DEPTH_ZERO, false /*checkSeverity*/); // do a search for JDT markers. Those can be errors or warnings stopOnMarker(iProject, IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, IResource.DEPTH_INFINITE, true /*checkSeverity*/); stopOnMarker(iProject, IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, IResource.DEPTH_INFINITE, true /*checkSeverity*/); }
From source file:com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.java
License:Open Source License
/** Display the problem list encountered during a render */ private void displayLoggerProblems(IProject project, RenderLogger logger) { if (logger.hasProblems()) { mErrorLabel.setText(""); // A common source of problems is attempting to open a layout when there are // compilation errors. In this case, may not have run (or may not be up to date) // so resources cannot be looked up etc. Explain this situation to the user. boolean hasAaptErrors = false; boolean hasJavaErrors = false; try {/* www.ja v a2s . co m*/ IMarker[] markers; markers = project.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE); if (markers.length > 0) { for (IMarker marker : markers) { String markerType = marker.getType(); if (markerType.equals(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER)) { int severity = marker.getAttribute(IMarker.SEVERITY, -1); if (severity == IMarker.SEVERITY_ERROR) { hasJavaErrors = true; } } else if (markerType.equals(AdtConstants.MARKER_AAPT_COMPILE)) { int severity = marker.getAttribute(IMarker.SEVERITY, -1); if (severity == IMarker.SEVERITY_ERROR) { hasAaptErrors = true; } } } } } catch (CoreException e) { AdtPlugin.log(e, null); } if (logger.seenTagPrefix(LayoutLog.TAG_RESOURCES_RESOLVE_THEME_ATTR)) { addBoldText(mErrorLabel, "Missing styles. Is the correct theme chosen for this layout?\n"); addText(mErrorLabel, "Use the Theme combo box above the layout to choose a different layout, " + "or fix the theme style references.\n\n"); } List<Throwable> trace = logger.getFirstTrace(); if (trace != null && trace.toString().contains("java.lang.IndexOutOfBoundsException: Index: 2, Size: 2") //$NON-NLS-1$ && mConfigChooser.getConfiguration().getDensity() == Density.TV) { addBoldText(mErrorLabel, "It looks like you are using a render target where the layout library " + "does not support the tvdpi density.\n\n"); addText(mErrorLabel, "Please try either updating to " + "the latest available version (using the SDK manager), or if no updated " + "version is available for this specific version of Android, try using " + "a more recent render target version.\n\n"); } if (hasAaptErrors && logger.seenTagPrefix(LayoutLog.TAG_RESOURCES_PREFIX)) { // Text will automatically be wrapped by the error widget so no reason // to insert linebreaks in this error message: String message = "NOTE: This project contains resource errors, so aapt did not succeed, " + "which can cause rendering failures. " + "Fix resource problems first.\n\n"; addBoldText(mErrorLabel, message); } else if (hasJavaErrors && mProjectCallback != null && mProjectCallback.isUsed()) { // Text will automatically be wrapped by the error widget so no reason // to insert linebreaks in this error message: String message = "NOTE: This project contains Java compilation errors, " + "which can cause rendering failures for custom views. " + "Fix compilation problems first.\n\n"; addBoldText(mErrorLabel, message); } if (logger.seenTag(RenderLogger.TAG_MISSING_DIMENSION)) { List<UiElementNode> elements = UiDocumentNode.getAllElements(getModel()); for (UiElementNode element : elements) { String width = element.getAttributeValue(ATTR_LAYOUT_WIDTH); if (width == null || width.length() == 0) { addSetAttributeLink(element, ATTR_LAYOUT_WIDTH); } String height = element.getAttributeValue(ATTR_LAYOUT_HEIGHT); if (height == null || height.length() == 0) { addSetAttributeLink(element, ATTR_LAYOUT_HEIGHT); } } } String problems = logger.getProblems(false /*includeFidelityWarnings*/); addText(mErrorLabel, problems); List<String> fidelityWarnings = logger.getFidelityWarnings(); if (fidelityWarnings != null && fidelityWarnings.size() > 0) { addText(mErrorLabel, "The graphics preview in the layout editor may not be accurate:\n"); for (String warning : fidelityWarnings) { addText(mErrorLabel, warning + ' '); addActionLink(mErrorLabel, ActionLinkStyleRange.IGNORE_FIDELITY_WARNING, "(Ignore for this session)\n", warning); } } mSashError.setMaximizedControl(null); } else { mSashError.setMaximizedControl(mCanvasViewer.getControl()); } }
From source file:com.android.ide.eclipse.auidt.internal.build.builders.PostCompilerBuilder.java
License:Open Source License
@Override protected void abortOnBadSetup(IJavaProject javaProject) throws AbortBuildException { super.abortOnBadSetup(javaProject); IProject iProject = getProject();//from w w w . ja va2 s .c o m // do a (hopefully quick) search for Precompiler type markers. Those are always only // errors. stopOnMarker(iProject, AdtConstants.MARKER_AAPT_COMPILE, IResource.DEPTH_INFINITE, false /*checkSeverity*/); stopOnMarker(iProject, AdtConstants.MARKER_AIDL, IResource.DEPTH_INFINITE, false /*checkSeverity*/); stopOnMarker(iProject, AdtConstants.MARKER_RENDERSCRIPT, IResource.DEPTH_INFINITE, false /*checkSeverity*/); stopOnMarker(iProject, AdtConstants.MARKER_ANDROID, IResource.DEPTH_ZERO, false /*checkSeverity*/); // do a search for JDT markers. Those can be errors or warnings stopOnMarker(iProject, IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, IResource.DEPTH_INFINITE, true /*checkSeverity*/); stopOnMarker(iProject, IJavaModelMarker.BUILDPATH_PROBLEM_MARKER, IResource.DEPTH_INFINITE, true /*checkSeverity*/); }
From source file:com.android.ide.eclipse.auidt.internal.editors.layout.gle2.GraphicalEditorPart.java
License:Open Source License
/** Display the problem list encountered during a render */ private void displayLoggerProblems(IProject project, RenderLogger logger) { if (logger.hasProblems()) { mErrorLabel.setText(""); // A common source of problems is attempting to open a layout when there are // compilation errors. In this case, may not have run (or may not be up to date) // so resources cannot be looked up etc. Explain this situation to the user. boolean hasAaptErrors = false; boolean hasJavaErrors = false; try {/*from w ww . j ava 2 s .c o m*/ IMarker[] markers; markers = project.findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE); if (markers.length > 0) { for (IMarker marker : markers) { String markerType = marker.getType(); if (markerType.equals(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER)) { int severity = marker.getAttribute(IMarker.SEVERITY, -1); if (severity == IMarker.SEVERITY_ERROR) { hasJavaErrors = true; } } else if (markerType.equals(AdtConstants.MARKER_AAPT_COMPILE)) { int severity = marker.getAttribute(IMarker.SEVERITY, -1); if (severity == IMarker.SEVERITY_ERROR) { hasAaptErrors = true; } } } } } catch (CoreException e) { AdtPlugin.log(e, null); } if (logger.seenTagPrefix(LayoutLog.TAG_RESOURCES_RESOLVE_THEME_ATTR)) { addBoldText(mErrorLabel, "Missing styles. Is the correct theme chosen for this layout?\n"); addText(mErrorLabel, "Use the Theme combo box above the layout to choose a different layout, " + "or fix the theme style references.\n\n"); } if (hasAaptErrors && logger.seenTagPrefix(LayoutLog.TAG_RESOURCES_PREFIX)) { // Text will automatically be wrapped by the error widget so no reason // to insert linebreaks in this error message: String message = "NOTE: This project contains resource errors, so aapt did not succeed, " + "which can cause rendering failures. " + "Fix resource problems first.\n\n"; addBoldText(mErrorLabel, message); } else if (hasJavaErrors && mProjectCallback != null && mProjectCallback.isUsed()) { // Text will automatically be wrapped by the error widget so no reason // to insert linebreaks in this error message: String message = "NOTE: This project contains Java compilation errors, " + "which can cause rendering failures for custom views. " + "Fix compilation problems first.\n\n"; addBoldText(mErrorLabel, message); } if (logger.seenTag(RenderLogger.TAG_MISSING_DIMENSION)) { List<UiElementNode> elements = UiDocumentNode.getAllElements(getModel()); for (UiElementNode element : elements) { String width = element.getAttributeValue(ATTR_LAYOUT_WIDTH); if (width == null || width.length() == 0) { addSetAttributeLink(element, ATTR_LAYOUT_WIDTH); } String height = element.getAttributeValue(ATTR_LAYOUT_HEIGHT); if (height == null || height.length() == 0) { addSetAttributeLink(element, ATTR_LAYOUT_HEIGHT); } } } String problems = logger.getProblems(false /*includeFidelityWarnings*/); addText(mErrorLabel, problems); List<String> fidelityWarnings = logger.getFidelityWarnings(); if (fidelityWarnings != null && fidelityWarnings.size() > 0) { addText(mErrorLabel, "The graphics preview in the layout editor may not be accurate:\n"); for (String warning : fidelityWarnings) { addText(mErrorLabel, warning + ' '); addActionLink(mErrorLabel, ActionLinkStyleRange.IGNORE_FIDELITY_WARNING, "(Ignore for this session)\n", warning); } } mSashError.setMaximizedControl(null); } else { mSashError.setMaximizedControl(mCanvasViewer.getControl()); } }
From source file:com.google.appengine.eclipse.core.validators.java.JavaCompilationParticipant.java
License:Open Source License
@Override public void reconcile(ReconcileContext context) { ICompilationUnit cu = context.getWorkingCopy(); try {/*from ww w. ja v a2 s.c o m*/ CompilationUnit ast = null; try { ast = context.getAST3(); } catch (JavaModelException e) { // Fall through to null check below } if (ast == null) { AppEngineCorePluginLog.logError("Could not get AST for " + cu.getPath()); return; } // Add existing Java problems to the list of all problems ArrayList<CategorizedProblem> finalProblemSet = new ArrayList<CategorizedProblem>(); CategorizedProblem[] currentProblems = context.getProblems(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER); if (currentProblems != null) { finalProblemSet.addAll(Arrays.asList(currentProblems)); } // Find and add GAE-specific problems List<? extends CategorizedProblem> newProblems = validateCompilationUnit(ast); finalProblemSet.addAll(newProblems); context.putProblems(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, finalProblemSet.isEmpty() ? null : finalProblemSet.toArray(EMPTY_PROBLEMS)); } catch (OperationCanceledException e) { // Thrown by Eclipse to abort long-running processes throw e; } catch (Exception e) { // Don't want to allow any unexpected exceptions to escape AppEngineCorePluginLog.logError(e, "Unexpected error while validating {0}", cu.getElementName()); } }
From source file:com.ibm.xsp.extlib.designer.relational.utils.ProjectUtils.java
License:Open Source License
public static void buildProject(final IProject project) throws Exception { try {/*from ww w . j a v a 2s . co m*/ project.build(IncrementalProjectBuilder.CLEAN_BUILD, null); project.build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null); } catch (Exception e) { throw new Exception("Could not build project", e); // $NLX-ProjectUtils.Couldnotbuildproject-1$ } IMarker[] markers = project.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); if (markers.length > 0) { throw new Exception( "Plug-in project did not compile. Ensure that the Class and JAR files are correct."); // $NLX-ProjectUtils.PluginprojectdidnotcompileEnsuret-1$ } }
From source file:com.iw.plugins.spindle.core.builder.TapestryBuilder.java
License:Mozilla Public License
/** * Method isWorthBuilding.//from ww w .j av a2 s . c o m * * @return boolean */ private boolean isWorthBuilding() { if (fJavaProject == null) throw new BuilderException(TapestryCore.getString(STRING_KEY + "non-java-projects")); try { fClasspath = fJavaProject.getResolvedClasspath(true); } catch (JavaModelException e3) { throw new BuilderException(TapestryCore.getString(STRING_KEY + "classpath-not-determined")); } try { IResource resource = fJavaProject.getUnderlyingResource(); IMarker[] jprojectMarkers = new IMarker[0]; if (resource != null && resource.exists()) jprojectMarkers = resource.findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_ZERO); if (jprojectMarkers.length > 0) throw new BuilderException(TapestryCore.getString(STRING_KEY + "java-builder-failed")); } catch (CoreException e) { // assume there are no Java builder problems } try { IPath outputPath = fJavaProject.getOutputLocation(); IPath projectPath = fJavaProject.getPath(); if (projectPath.equals(outputPath)) throw new BuilderException(TapestryCore.getString(STRING_KEY + "abort-invalid-output-location", outputPath.toString())); } catch (JavaModelException e1) { throw new BuilderException(TapestryCore.getString(STRING_KEY + "abort-no-output-location")); } if (fTapestryProject == null) throw new BuilderException("could not obtain the TapestryProject instance!"); if (fClasspathRoot == null) throw new BuilderException("could not obtain the ClasspathRoot!"); if (getType(TapestryCore.getString(STRING_KEY + "applicationServletClassname")) == null) throw new BuilderException(TapestryCore.getString(STRING_KEY + "tapestry-jar-missing")); if (fContextRoot == null) throw new BuilderException(TapestryCore.getString(STRING_KEY + "missing-context-bad")); if (!fContextRoot.exists()) throw new BuilderException(TapestryCore.getString(STRING_KEY + "missing-context", fContextRoot)); IResourceWorkspaceLocation webXML = (IResourceWorkspaceLocation) fContextRoot .getRelativeLocation("WEB-INF/web.xml"); if (webXML.getStorage() == null) throw new BuilderException( TapestryCore.getString(STRING_KEY + "abort-missing-web-xml", webXML.toString())); return true; }
From source file:com.siteview.mde.internal.core.exports.WorkspaceExportHelper.java
License:Open Source License
/** * Checks the workspace projects that are being exported or are required plug-ins * of the exported items for build errors. A project will be reported as having an * error if it has a marker with a severity of error and is of Java model or PDE type. * /*from w ww. j av a 2 s .c o m*/ * @param exportedItems the plugins or features being exported * @return set of IProjects containing errors * @throws CoreException */ public Set checkForErrors(Object[] exportedItems) throws CoreException { IProject[] projects = getExportedWorkspaceProjects(exportedItems); Set projectsWithErrors = new HashSet(projects.length); for (int i = 0; i < projects.length; i++) { IMarker[] markers = projects[i].findMarkers(IMarker.PROBLEM, true, IResource.DEPTH_INFINITE); if (markers.length > 0) { for (int j = 0; j < markers.length; j++) { Integer severity = (Integer) (markers[j].getAttribute(IMarker.SEVERITY)); if (severity != null && severity.intValue() >= IMarker.SEVERITY_ERROR) { if (markers[j].getType().equals(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER) || markers[j].getType().equals(MDEMarkerFactory.MARKER_ID)) { projectsWithErrors.add(projects[i]); break; } } } } } return projectsWithErrors; }
From source file:com.siteview.mde.launching.AbstractPDELaunchConfiguration.java
License:Open Source License
protected boolean isLaunchProblem(IMarker problemMarker) throws CoreException { return super.isLaunchProblem(problemMarker) && (problemMarker.getType().equals(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER) || problemMarker.getType().equals(MDEMarkerFactory.MARKER_ID)); }
From source file:dacapo.eclipse.EclipseBuildTests.java
License:Open Source License
/** * Start a build on workspace using given options. * @param options//w w w.ja v a2s .c o m * @throws IOException * @throws CoreException */ private void startBuild(IJavaProject project, Hashtable options, boolean noWarning) throws IOException, CoreException { if (DEBUG) System.out.print("\tstart build..."); JavaCore.setOptions(options); if (project == null) { System.out.println("\tBuilding: full workspace"); env.fullBuild(); } else { System.out.print("\t" + project.toString()); System.out.print(" opening"); project.getProject().open(null); System.out.print(" cleaning"); project.getProject().build(IncrementalProjectBuilder.CLEAN_BUILD, null); System.out.print(" building"); project.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null); System.out.println(); } if (VERIFY) { // Verify markers IMarker[] markers = ResourcesPlugin.getWorkspace().getRoot() .findMarkers(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER, true, IResource.DEPTH_INFINITE); List resources = new ArrayList(); List messages = new ArrayList(); int warnings = 0; for (int i = 0, length = markers.length; i < length; i++) { IMarker marker = markers[i]; switch (((Integer) marker.getAttribute(IMarker.SEVERITY)).intValue()) { case IMarker.SEVERITY_ERROR: resources.add(marker.getResource().getName()); messages.add(marker.getAttribute(IMarker.MESSAGE)); break; case IMarker.SEVERITY_WARNING: warnings++; if (noWarning) { resources.add(marker.getResource().getName()); messages.add(marker.getAttribute(IMarker.MESSAGE)); } break; } } // Assert result int size = messages.size(); if (size > 0) { StringBuffer debugBuffer = new StringBuffer(); for (int i = 0; i < size; i++) { debugBuffer.append(resources.get(i)); debugBuffer.append(":\n\t"); debugBuffer.append(messages.get(i)); debugBuffer.append('\n'); } System.out.println("Unexpected ERROR marker(s):\n" + debugBuffer.toString()); System.out.println("--------------------"); } } if (DEBUG) System.out.println("done"); }