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

The following examples show how to use org.eclipse.core.resources.IProject#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: Auditor.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void handleCheckstyleFailure(IProject project, CheckstyleException e)
        throws CheckstylePluginException {
  try {

    CheckstyleLog.log(e);

    // remove pre-existing project level marker
    project.deleteMarkers(CheckstyleMarker.MARKER_ID, false, IResource.DEPTH_ZERO);

    Map<String, Object> attrs = new HashMap<>();
    attrs.put(IMarker.PRIORITY, Integer.valueOf(IMarker.PRIORITY_NORMAL));
    attrs.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR));
    attrs.put(IMarker.MESSAGE, NLS.bind(Messages.Auditor_msgMsgCheckstyleInternalError, null));

    IMarker projectMarker = project.createMarker(CheckstyleMarker.MARKER_ID);
    projectMarker.setAttributes(attrs);
  } catch (CoreException ce) {
    CheckstylePluginException.rethrow(e);
  }
}
 
Example 2
Source File: MarkerUtil.java    From spotbugs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Attempt to redisplay FindBugs problem markers for given project.
 *
 * @param javaProject
 *            the project
 */
public static void redisplayMarkers(final IJavaProject javaProject) {
    final IProject project = javaProject.getProject();
    FindBugsJob job = new FindBugsJob("Refreshing SpotBugs markers", project) {
        @Override
        protected void runWithProgress(IProgressMonitor monitor) throws CoreException {
            // TODO in case we removed some of previously available
            // detectors, we should
            // throw away bugs reported by them

            // Get the saved bug collection for the project
            SortedBugCollection bugs = FindbugsPlugin.getBugCollection(project, monitor);
            // Remove old markers
            project.deleteMarkers(FindBugsMarker.NAME, true, IResource.DEPTH_INFINITE);
            // Display warnings
            createMarkers(javaProject, bugs, project, monitor);
        }
    };
    job.setRule(project);
    job.scheduleInteractive();
}
 
Example 3
Source File: JavaCompilationParticipant.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 6 votes vote down vote up
public static void cleanBuildArtifacts(IProject project) {
  try {
    project.deleteMarkers(GWTJavaProblem.MARKER_ID, true,
        IResource.DEPTH_INFINITE);

    // Clear Java ref index entries for this project
    JavaRefIndex.getInstance().clear(project);

    // Clear ClientBundle resource index entries
    ClientBundleResourceDependencyIndex.getInstance().clear(project);

    // Clear UiBinder source references from the various indices
    UiBinderReferenceManager.INSTANCE.getReferenceManager().removeSourceReferences(
        project);
    UiBinderReferenceManager.INSTANCE.getSubtypeToOwnerIndex().clear(project);
    UiBinderReferenceManager.INSTANCE.getSubtypeToUiXmlIndex().clear(project);
    UiBinderReferenceManager.INSTANCE.getUiXmlReferencedFieldIndex().clear(
        JavaCore.create(project));
  } catch (CoreException e) {
    GWTPluginLog.logError(e);
  }
}
 
Example 4
Source File: CodewindEclipseApplication.java    From codewind-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void resetValidation() {
	// Delete all Codewind markers for a project
	IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(name);
	if (project != null && project.isAccessible()) {
		try {
			project.deleteMarkers(MARKER_TYPE, true, IResource.DEPTH_INFINITE);
		} catch (CoreException e) {
			Logger.logError("Failed to delete existing markers for the " + name + " project.", e); //$NON-NLS-1$
		}
	}
}
 
Example 5
Source File: SolidityBuilder.java    From uml2solidity with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Delete all the solidity compile markers for the project.
 * 
 * @param project
 * @return
 */
private boolean deleteCompilerMarkers(IProject project) {
	try {
		project.deleteMarkers(SOLIDITY_MARKER_ID, false, IResource.DEPTH_INFINITE);
		return true;
	} catch (CoreException e) {
		Activator.logError("Error cleaning Markers.", e);
	}
	return false;
}
 
Example 6
Source File: TexBuilder.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Clears errors and warnings from the problem view. If LaTeX runs more than once, this
 * makes sure, the view only shows the messages of the last run, which are still valid.
 *
 * @param project the project
 */
private void clearMarkers(IProject project) {
       try {
           project.deleteMarkers(TexlipseBuilder.MARKER_TYPE, false, IResource.DEPTH_INFINITE);
           project.deleteMarkers(TexlipseBuilder.LAYOUT_WARNING_TYPE, false, IResource.DEPTH_INFINITE);
       } catch (CoreException e) {
       }
}
 
Example 7
Source File: CheckstyleBuilder.java    From eclipse-cs with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected final IProject[] build(final int kind, @SuppressWarnings("rawtypes") final Map args,
        final IProgressMonitor monitor) throws CoreException {

  // get the associated project for this builder
  IProject project = getProject();

  // remove project level error markers
  project.deleteMarkers(CheckstyleMarker.MARKER_ID, false, IResource.DEPTH_ZERO);

  if (CheckstyleNature.hasCorrectBuilderOrder(project)) {

    //
    // get the project configuration
    //
    IProjectConfiguration config = null;
    try {
      config = ProjectConfigurationFactory.getConfiguration(project);
    } catch (CheckstylePluginException e) {
      Status status = new Status(IStatus.ERROR, CheckstylePlugin.PLUGIN_ID, IStatus.ERROR,
              e.getMessage() != null ? e.getMessage()
                      : Messages.CheckstyleBuilder_msgErrorUnknown,
              e);
      throw new CoreException(status);
    }

    Collection<IResource> resources = null;

    // get the delta of the latest changes
    IResourceDelta resourceDelta = getDelta(project);

    IFilter[] filters = config.getFilters().toArray(new IFilter[config.getFilters().size()]);

    // find the files for the build
    if (resourceDelta != null) {
      resources = getResources(resourceDelta, filters);
    } else {
      resources = getResources(project, filters);
    }

    handleBuildSelection(resources, config, monitor, project, kind);

  } else {

    // the builder order is wrong. Refuse to check and create a error
    // marker.

    // remove all existing Checkstyle markers
    project.deleteMarkers(CheckstyleMarker.MARKER_ID, false, IResource.DEPTH_INFINITE);

    Map<String, Object> markerAttributes = new HashMap<>();
    markerAttributes.put(IMarker.PRIORITY, Integer.valueOf(IMarker.PRIORITY_HIGH));
    markerAttributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR));
    markerAttributes.put(IMarker.MESSAGE,
            NLS.bind(Messages.CheckstyleBuilder_msgWrongBuilderOrder, project.getName()));

    // enables own category under Java Problem Type
    // setting for Problems view (RFE 1530366)
    markerAttributes.put("categoryId", Integer.valueOf(999)); //$NON-NLS-1$

    // create a marker for the actual resource
    IMarker marker = project.createMarker(CheckstyleMarker.MARKER_ID);
    marker.setAttributes(markerAttributes);
  }

  return new IProject[] { project };
}
 
Example 8
Source File: CMakeBuildRunner.java    From cmake4eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public boolean invokeBuild(int kind, IProject project,
    IConfiguration configuration, IBuilder builder, IConsole console,
    IMarkerGenerator markerGenerator,
    IncrementalProjectBuilder projectBuilder, IProgressMonitor monitor)
    throws CoreException {
  /*
   * wrap the passed-in builder into one that gets its build command from the
   * Cmake-generator. First do a sanity check.
   */
  IBuilder supa = builder;
  do {
    if (supa.getBaseId().equals("de.marw.cdt.cmake.core.genscriptbuilder")) {
      break;
    }
  } while ((supa = supa.getSuperClass()) != null);
  if (supa != null) {
    project.deleteMarkers(MARKER_ID, false, IResource.DEPTH_INFINITE);

    final ICConfigurationDescription cfgd = ManagedBuildManager
        .getDescriptionForConfiguration(configuration);
    final IPath builderCWD = cfgd.getBuildSetting().getBuilderCWD();

    if (kind == IncrementalProjectBuilder.CLEAN_BUILD) {
      // avoid calling 'rm -rf' if it is a clean build and the build dir was
      // deleted
      final IPath location = ResourcesPlugin.getWorkspace().getRoot().getFile(builderCWD).getLocation();
      if (location == null || !location.toFile().exists()) {
        return true; // is clean
      }
    }

    final CMakePreferences prefs = ConfigurationManager.getInstance()
        .getOrLoad(cfgd);
    final AbstractOsPreferences osPrefs = AbstractOsPreferences
        .extractOsPreferences(prefs);

    // try to get CMAKE_BUILD_TOOL entry from CMakeCache.txt...
    final CmakeGenerator generator = osPrefs.getGenerator();
    String buildscriptProcessorCmd = getCommandFromCMakeCache(cfgd,
        generator != osPrefs.getGeneratedWith(), project, markerGenerator);
    if (buildscriptProcessorCmd == null) {
      // actually this should not happen, since cmake will abort if it cannot determine
      // the build tool,.. but the variable name might change in future
      return false;
    }
    builder = new CmakeBuildToolInjectorBuilder(builder,
        buildscriptProcessorCmd, generator);
  }
  return super.invokeBuild(kind, project, configuration, builder, console,
      markerGenerator, projectBuilder, monitor);
}
 
Example 9
Source File: MarkerUtilities.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Clears all markers with the given markerID from the project and all of its
 * child resources.
 */
public static void clearMarkers(String markerID, IProject project)
    throws CoreException {
  project.deleteMarkers(markerID, false, IResource.DEPTH_INFINITE);
}
 
Example 10
Source File: TexlipseBuilder.java    From texlipse with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Delete old build errors and layout markers from project
 * @param project
 * @throws CoreException
 */
protected void deleteMarkers (IProject project) throws CoreException{
    project.deleteMarkers(MARKER_TYPE, false, IResource.DEPTH_INFINITE);
    project.deleteMarkers(LAYOUT_WARNING_TYPE, false, IResource.DEPTH_INFINITE);
}
 
Example 11
Source File: CMakeErrorParser.java    From cmake4eclipse with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Deletes all CMake error markers on the specified project.
 *
 * @param project
 *          the project where to remove the error markers.
 * @throws CoreException
 */
public static void deleteErrorMarkers(IProject project) throws CoreException {
  project.deleteMarkers(CMAKE_PROBLEM_MARKER_ID, false, IResource.DEPTH_INFINITE);
}