Java Code Examples for org.eclipse.core.resources.IResourceStatus#MARKER_NOT_FOUND

The following examples show how to use org.eclipse.core.resources.IResourceStatus#MARKER_NOT_FOUND . 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: ProblemsLabelDecorator.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Compute the flags that were set on the give object. We expect an IResource for this computation, and we return
 * the flags according to the warnings or errors set on the resource.
 * 
 * @param obj
 *            A IResource (expected)
 * @return An integer representing an ERROR or a WARNING; -1 if the give object was not an IResource or when we got
 *         an exception retrieving the {@link IMarker}s from the resource.
 */
protected int computeAdornmentFlags(Object obj)
{
	try
	{
		if (obj instanceof IResource)
		{
			return getErrorTicksFromMarkers((IResource) obj, IResource.DEPTH_INFINITE);
		}
	}
	catch (CoreException e)
	{
		if (e.getStatus().getCode() == IResourceStatus.MARKER_NOT_FOUND)
		{
			return -1;
		}
		IdeLog.logWarning(EditorEplPlugin.getDefault(),
				"Error computing label-decoration adornment flags", e, EditorEplPlugin.DEBUG_SCOPE); //$NON-NLS-1$
	}
	return -1;
}
 
Example 2
Source File: ProblemsLabelDecorator.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Computes the adornment flags for the given element.
 *
 * @param obj the element to compute the flags for
 *
 * @return the adornment flags
 */
protected ImageDescriptor computeAdornmentFlags(Object obj) {
	try {
		if (obj instanceof IResource) {
			return getErrorTicksFromMarkers((IResource) obj, IResource.DEPTH_INFINITE);
		}
	} catch (CoreException e) {
		if (e.getStatus().getCode() == IResourceStatus.MARKER_NOT_FOUND) {
			return null;
		}

		EclipseCore.logStatus(e);
	}
	return null;
}
 
Example 3
Source File: ProblemsLabelDecorator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Computes the adornment flags for the given element.
 *
 * @param obj the element to compute the flags for
 *
 * @return the adornment flags
 */
protected int computeAdornmentFlags(Object obj) {
	try {
		if (obj instanceof IJavaElement) {
			IJavaElement element= (IJavaElement) obj;
			int type= element.getElementType();
			switch (type) {
				case IJavaElement.JAVA_MODEL:
				case IJavaElement.JAVA_PROJECT:
				case IJavaElement.PACKAGE_FRAGMENT_ROOT:
					int flags= getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_INFINITE, null);
					switch (type) {
						case IJavaElement.PACKAGE_FRAGMENT_ROOT:
							IPackageFragmentRoot root= (IPackageFragmentRoot) element;
							if (flags != ERRORTICK_ERROR && root.getKind() == IPackageFragmentRoot.K_SOURCE && isIgnoringOptionalProblems(root.getRawClasspathEntry())) {
								flags= ERRORTICK_IGNORE_OPTIONAL_PROBLEMS;
							}
							break;
						case IJavaElement.JAVA_PROJECT:
							IJavaProject project= (IJavaProject) element;
							if (flags != ERRORTICK_ERROR && flags != ERRORTICK_BUILDPATH_ERROR && isIgnoringOptionalProblems(project)) {
								flags= ERRORTICK_IGNORE_OPTIONAL_PROBLEMS;
							}
							break;
					}
					return flags;
				case IJavaElement.PACKAGE_FRAGMENT:
					return getPackageErrorTicksFromMarkers((IPackageFragment) element);
				case IJavaElement.COMPILATION_UNIT:
				case IJavaElement.CLASS_FILE:
					return getErrorTicksFromMarkers(element.getResource(), IResource.DEPTH_ONE, null);
				case IJavaElement.PACKAGE_DECLARATION:
				case IJavaElement.IMPORT_DECLARATION:
				case IJavaElement.IMPORT_CONTAINER:
				case IJavaElement.TYPE:
				case IJavaElement.INITIALIZER:
				case IJavaElement.METHOD:
				case IJavaElement.FIELD:
				case IJavaElement.LOCAL_VARIABLE:
					ICompilationUnit cu= (ICompilationUnit) element.getAncestor(IJavaElement.COMPILATION_UNIT);
					if (cu != null) {
						ISourceReference ref= (type == IJavaElement.COMPILATION_UNIT) ? null : (ISourceReference) element;
						// The assumption is that only source elements in compilation unit can have markers
						IAnnotationModel model= isInJavaAnnotationModel(cu);
						int result= 0;
						if (model != null) {
							// open in Java editor: look at annotation model
							result= getErrorTicksFromAnnotationModel(model, ref);
						} else {
							result= getErrorTicksFromMarkers(cu.getResource(), IResource.DEPTH_ONE, ref);
						}
						fCachedRange= null;
						return result;
					}
					break;
				default:
			}
		} else if (obj instanceof IResource) {
			return getErrorTicksFromMarkers((IResource) obj, IResource.DEPTH_INFINITE, null);
		}
	} catch (CoreException e) {
		if (e instanceof JavaModelException) {
			if (((JavaModelException) e).isDoesNotExist()) {
				return 0;
			}
		}
		if (e.getStatus().getCode() == IResourceStatus.MARKER_NOT_FOUND) {
			return 0;
		}

		JavaPlugin.log(e);
	}
	return 0;
}