Java Code Examples for org.eclipse.core.resources.IResource#deleteMarkers()

The following examples show how to use org.eclipse.core.resources.IResource#deleteMarkers() . 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: ClearMarkersOperation.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
protected boolean doDeleteProjectMarkers(String markerType, IOperationMonitor parentOM) 
		throws OperationCancellation {
	
	try(IOperationSubMonitor om = parentOM.enterSubTask(LangCoreMessages.BUILD_ClearingProblemMarkers)) {
		
		ArrayList2<IResource> resources = ResourceUtils.getResourcesAt(location);
		for (IResource container : resources) {
		try {
			IMarker[] findMarkers = container.findMarkers(markerType, true, IResource.DEPTH_INFINITE);
			parentOM.checkCancellation();
			if(findMarkers.length != 0) {
				container.deleteMarkers(markerType, true, IResource.DEPTH_INFINITE);
				return true;
			}
		} catch (CoreException ce) {
			EclipseCore.logStatus(ce);
		}
		}
	}
	return false;
}
 
Example 2
Source File: MarkerHandler.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Delete all error markers from the currently open file.
 * 
 * @param editor The editor to clear the markers from
 */
public void clearErrorMarkers(ITextEditor editor) {
	// talk about ugly code...
    // TODO if this case occurs, then the user has probably not correctly created a project
    // -> we should somehow inform the user
    IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
    if (resource == null) return;

    try {
        // TODO what should we clear and when?
        // regular problems == parsing errors
        resource.deleteMarkers(IMarker.PROBLEM, false, IResource.DEPTH_INFINITE);
        // builder markers == build problems (don't clean them)
        //resource.deleteMarkers(TexlipseBuilder.MARKER_TYPE, false, IResource.DEPTH_INFINITE);
        // don't clear spelling errors
    } catch (CoreException e) {
        TexlipsePlugin.log("Deleting error markers", e);
    }
}
 
Example 3
Source File: CrossflowMarkerNavigationProvider.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
public static void deleteMarkers(IResource resource) {
	try {
		resource.deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_ZERO);
	} catch (CoreException e) {
		CrossflowDiagramEditorPlugin.getInstance().logError("Failed to delete validation markers", e); //$NON-NLS-1$
	}
}
 
Example 4
Source File: ProcessMarkerNavigationProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
public static void deleteMarkers(IResource resource) {
	try {
		resource.deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_ZERO);
	} catch (CoreException e) {
		ProcessDiagramEditorPlugin.getInstance().logError("Failed to delete validation markers", e); //$NON-NLS-1$
	}
}
 
Example 5
Source File: UnifiedBuilder.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
private static void removeProblemsAndTasksFor(IResource resource)
{
	try
	{
		if (resource != null && resource.isAccessible())
		{
			resource.deleteMarkers(IMarkerConstants.PROBLEM_MARKER, true, IResource.DEPTH_INFINITE);
			resource.deleteMarkers(IMarkerConstants.TASK_MARKER, true, IResource.DEPTH_INFINITE);
		}
	}
	catch (CoreException e)
	{
		// assume there were no problems
	}
}
 
Example 6
Source File: BaseParser.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * This function will remove the markers related to errors.
 * @param resource the file that should have the markers removed
 * @throws CoreException
 */
public static void deleteErrorMarkers(IResource resource) throws CoreException {
    IMarker[] markers = resource.findMarkers(IMarker.PROBLEM, false, IResource.DEPTH_ZERO);
    if (markers.length > 0) {
        resource.deleteMarkers(IMarker.PROBLEM, false, IResource.DEPTH_ZERO);
    }
}
 
Example 7
Source File: ProblemReporter.java    From cppcheclipse with Apache License 2.0 5 votes vote down vote up
public void deleteMarkers(IResource file, boolean isRecursive)
		throws CoreException {
	final int depth;
	if (isRecursive) {
		depth = IResource.DEPTH_INFINITE;
	} else {
		depth = IResource.DEPTH_ZERO;
	}
	file.deleteMarkers(CHECKER_MARKER_TYPE, true, depth);
}
 
Example 8
Source File: ProverHelper.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Removes all status markers from the module.
 */
public static void removeStatusFromModule(IResource module)
{
    try
    {
        module.deleteMarkers(STEP_STATUS_MARKER, true, IResource.DEPTH_ZERO);
    } catch (CoreException e)
    {
        ProverUIActivator.getDefault().logError("Error removing status markers from module " + module, e);
    }
}
 
Example 9
Source File: ProverHelper.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Removes all markers indicating obligation information on  a resource. Does
 * nothing if the resource does not exist. It deletes these markers only at one level
 * under the resource. That is, if the resource is a directory, it deletes markers
 * on its children.
 * 
 * @param resource
 * @throws CoreException 
 */
public static void clearObligationMarkers(IResource resource) throws CoreException
{
    if (resource.exists())
    {
        /*
         * Obligation markers should only be on files directly in the project folder, so we
         * only need to delete markers to depth one. Depth infinite would search any
         * checkpoint folders, which can be slow if there are many files.
         */
        resource.deleteMarkers(OBLIGATION_MARKER, false, IResource.DEPTH_ONE);
    }
}
 
Example 10
Source File: ShowUsesParseResultListener.java    From tlaplus with MIT License 5 votes vote down vote up
/** 
 * This method is called when the spec is parsed, as well as on other occasions
 * that don't interest us.  It deletes the Show Use markers if the user's preference
 * is to do so and if we can find any to delete.
 */
public boolean eventOccured(SpecEvent event)
{

    if (event.getType() != SpecEvent.TYPE_PARSE)
    {
        return true;
    }

    // Check if user preference is to remove use markers on parse.
    if (!Activator.getDefault().getPreferenceStore().getBoolean(
            EditorPreferencePage.CLEAR_DECLARATION_USE_MARKERS_ON_PARSE)) {
        return true;
    }
    
    // User wants to remove markers.  Remove them if there are any.
    Spec spec = event.getSpec();
    String moduleName = spec.getModuleToShow();
    if (moduleName == null)
    {
        return true;
    }
    IResource resource = ResourceHelper.getResourceByModuleName(moduleName);
    if (resource == null)
    {
        return true;
    }
    try
    {
        resource.deleteMarkers(ShowUsesHandler.SHOW_USE_MARKER_TYPE, false, 99);
    } catch (CoreException e)
    {
        // I don't know why this should ever fail, but there's nothing to be done 
        // if marker deletion fails except to hope that it's because there 
        // weren't any.
    }
    
    return true;

}
 
Example 11
Source File: Spec.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Transitively deletes the given marker type on all modules (including the root
 * module) of the spec.
 */
public void deleteMarker(final String markerType) throws CoreException {
	getRootFile().deleteMarkers(markerType, true, IResource.DEPTH_INFINITE);
	for (IResource r : getModuleResources()) {
		r.deleteMarkers(markerType, true, IResource.DEPTH_INFINITE);
	}
}
 
Example 12
Source File: MarkerUtil.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Delete all the problem markers related with current resource
 * 
 * @param resource
 * @throws CoreException
 */
public static void clear( IResource resource ) throws CoreException
{
	if ( resource != null )
	{
		resource.deleteMarkers( PROBLEMS_MARKER_ID, true,
				IResource.DEPTH_INFINITE );
	}
}
 
Example 13
Source File: PyMarkerUtils.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param original
 * @param pydevCoverageMarker
 */
public static void removeMarkers(IResource resource, String markerType) {
    if (resource == null) {
        return;
    }
    try {
        resource.deleteMarkers(markerType, false, IResource.DEPTH_ZERO);
    } catch (Exception e) {
        Log.log(e);
    }
}
 
Example 14
Source File: MarkerHandler.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Clears the task markers
 * 
 * @param editor The editor to clear the markers from
 */
public void clearTaskMarkers(ITextEditor editor) {
    IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
    if (resource == null) return;
    try {
        resource.deleteMarkers(IMarker.TASK, false, IResource.DEPTH_INFINITE);
    } catch (CoreException e) {
        TexlipsePlugin.log("Deleting task markers", e);
    }
}
 
Example 15
Source File: MarkerHandler.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Clears the problem markers (such as parsing errors)
 * 
 * @param resource The resource whose markers to clear
 */
public void clearProblemMarkers(IResource resource) {
    try {
        resource.deleteMarkers(IMarker.PROBLEM, false, IResource.DEPTH_INFINITE);
    } catch (CoreException e) {
        TexlipsePlugin.log("Deleting error markers", e);
    }
}
 
Example 16
Source File: ClearSelectedFilesAction.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {

  for (IResource resource : mResourcesToClear) {
    if (resource.isAccessible()) {
      resource.deleteMarkers(CheckstyleMarker.MARKER_ID, true, IResource.DEPTH_INFINITE);
    }
  }

  return Status.OK_STATUS;
}
 
Example 17
Source File: TypeScriptResourceUtil.java    From typescript.java with MIT License 4 votes vote down vote up
public static void deleteTscMarker(IResource resource) throws CoreException {
	resource.deleteMarkers(TSC_MARKER_TYPE, true, IResource.DEPTH_INFINITE);
}
 
Example 18
Source File: IDEMultiPageReportEditor.java    From birt with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Deletes existed problem markers and adds new markers
 * 
 * @throws CoreException
 */
public void refreshMarkers( IEditorInput input ) throws CoreException
{
	IResource file = getFile( input );
	if ( file != null )
	{
		// Deletes existed markers
		file.deleteMarkers( ProblemMarkID, true, IResource.DEPTH_INFINITE );

		// Adds markers
		ModuleHandle reportDesignHandle = getModel( );
		if ( reportDesignHandle == null )
		{
			return;
		}

		// Model said that should checkReport( ) before getting error and
		// warning list.
		reportDesignHandle.checkReportIfNecessary( );
		List list = reportDesignHandle.getErrorList( );
		int errorListSize = list.size( );
		list.addAll( reportDesignHandle.getWarningList( ) );

		for ( int i = 0, m = list.size( ); i < m; i++ )
		{
			ErrorDetail errorDetail = (ErrorDetail) list.get( i );
			IMarker marker = file.createMarker( ProblemMarkID );

			Map<String, Object> attrib = new HashMap<String, Object>( );

			// The first part is from error list, the other is from warning
			// list
			if ( i < errorListSize )
			{
				attrib.put( IMarker.SEVERITY, IMarker.SEVERITY_ERROR );
			}
			else
			{
				attrib.put( IMarker.SEVERITY, IMarker.SEVERITY_WARNING );
			}

			attrib.put( IMarker.MESSAGE, errorDetail.getMessage( ) );
			attrib.put( IMarker.LINE_NUMBER, errorDetail.getLineNo( ) );
			attrib.put( IMarker.LOCATION, errorDetail.getTagName( ) );

			if ( errorDetail.getElement( ) != null
					&& errorDetail.getElement( ).getID( ) != 0 )
			{
				attrib.put( ELEMENT_ID,
						Integer.valueOf( (int) errorDetail.getElement( )
								.getID( ) ) );
			}

			// set all attributes together to reduce notification events
			marker.setAttributes( attrib );
		}
	}
}
 
Example 19
Source File: ProverHelper.java    From tlaplus with MIT License 2 votes vote down vote up
/**
 * Removes all SANY step markers on the module.
 * See {@link ProverHelper#SANY_MARKER} for a description of
 * these markers.
 * 
 * @param module
 * @throws CoreException 
 */
public static void removeSANYStepMarkers(IResource module) throws CoreException
{
    module.deleteMarkers(SANY_MARKER, false, IResource.DEPTH_ZERO);
}
 
Example 20
Source File: MarkerUtils.java    From xds-ide with Eclipse Public License 1.0 2 votes vote down vote up
/**
 *  Deletes xds build markers on given resource, and, 
 * optionally, deletes such markers from its children.  If <code>includeSubtypes</code>
 * is <code>false</code>, only markers whose type exactly matches 
 * the given type are deleted.  
 * <p/>
 * @param resource where to delete markers
 * @param includeSubtypes whether or not to consider sub-types of the given type
 * @param depth how far to recurse (see <code>IResource.DEPTH_* </code>)
 * @throws CoreException
 */
public static void deleteBuildProblemMarkers(IResource resource, boolean isIncludeSubtypes, int depth) throws CoreException {
	resource.deleteMarkers(XdsMarkerConstants.BUILD_PROBLEM_MARKER_TYPE, isIncludeSubtypes, depth);
}