Java Code Examples for org.eclipse.core.resources.IMarker#setAttributes()

The following examples show how to use org.eclipse.core.resources.IMarker#setAttributes() . 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: SpellChecker.java    From texlipse with Eclipse Public License 1.0 6 votes vote down vote up
/**
     * Adds a spelling error marker to the given file.
     * 
     * @param file the resource to add the marker to
     * @param proposals list of proposals for correcting the error
     * @param charBegin  beginning offset in the file
     * @param wordLength length of the misspelled word
     */
    private void createMarker(IResource file, String[] proposals, int charBegin, String word, int lineNumber) {
        
        Map<String, ? super Object> attributes = new HashMap<String, Object>();
        attributes.put(IMarker.CHAR_START, Integer.valueOf(charBegin));
        attributes.put(IMarker.CHAR_END, Integer.valueOf(charBegin+word.length()));
        attributes.put(IMarker.LINE_NUMBER, Integer.valueOf(lineNumber));
        attributes.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_WARNING));
        attributes.put(IMarker.MESSAGE, 
            MessageFormat.format(TexlipsePlugin.getResourceString("spellMarkerMessage"),
                new Object[] { word }));
        try {
            IMarker marker = file.createMarker(SPELLING_ERROR_MARKER_TYPE);
            marker.setAttributes(attributes);
            proposalMap.put(marker, proposals);
/*            MarkerUtilities.createMarker(file, attributes, SPELLING_ERROR_MARKER_TYPE);
            addProposal(file, charBegin, charBegin+word.length(), proposals);*/
            
        } catch (CoreException e) {
            TexlipsePlugin.log("Adding spelling marker", e);
        }
    }
 
Example 3
Source File: UnifiedBuilder.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
private void addMarkers(Collection<IProblem> items, String markerType, IFile file, IProgressMonitor monitor)
		throws CoreException
{
	if (CollectionsUtil.isEmpty(items))
	{
		return;
	}
	SubMonitor sub = SubMonitor.convert(monitor, items.size() * 2);
	for (IProblem item : items)
	{
		IMarker marker = file.createMarker(markerType);
		sub.worked(1);
		marker.setAttributes(item.createMarkerAttributes());
		sub.worked(1);
	}
	sub.done();
}
 
Example 4
Source File: ImpexTypeHyperlink.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 5 votes vote down vote up
@Override
public void open() {
	IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
	
	String typeLocation = Activator.getDefault().getTypeLoaderInfo(location);
	String fileName = typeLocation.substring(0, typeLocation.indexOf(":"));
	String extensionName = fileName.replaceAll("-items.xml", "");
	String lineNumberStr = typeLocation.substring(typeLocation.indexOf(":") + 1, typeLocation.indexOf("("));
	
	IProject extension = ResourcesPlugin.getWorkspace().getRoot().getProject(extensionName);
   	IFile itemsxml = extension.getFile("resources/" + fileName);
   	if (itemsxml.exists()) {
       	IMarker marker;
       	try {
			marker = itemsxml.createMarker(IMarker.TEXT);
			HashMap<String, Object> map = new HashMap<String, Object>();
			map.put(IMarker.LINE_NUMBER, Integer.parseInt(lineNumberStr));
			marker.setAttributes(map);
			//IDE.openEditor(getSite().getPage(), marker);
			IDE.openEditor(page, marker);
			marker.delete();
		}
       	catch (CoreException e) {
       		Activator.logError("Eclipse CoreException", e);
		}
   	}
   	else {
   		MessageBox dialog = new MessageBox(PlatformUI.getWorkbench().getDisplay().getActiveShell(), SWT.ICON_WARNING | SWT.OK);
   		dialog.setText("Extension not found");
   		dialog.setMessage("The extension " + extensionName + " was not found in the workspace. Please import it and try again.");
   		dialog.open();
   	}
}
 
Example 5
Source File: MarkerReporter.java    From spotbugs with GNU Lesser General Public License v2.1 5 votes vote down vote up
private void addMarker(MarkerParameter mp) throws CoreException {
    Map<String, Object> attributes = createMarkerAttributes(mp);
    if (attributes.isEmpty()) {
        collection.remove(mp.bug);
        return;
    }
    IResource markerTarget = mp.resource.getMarkerTarget();
    IMarker[] existingMarkers = markerTarget.findMarkers(mp.markerType, true, IResource.DEPTH_ZERO);

    // XXX Workaround for bug 2785257 (has to be solved better)
    // see
    // http://sourceforge.net/tracker/?func=detail&atid=614693&aid=2785257&group_id=96405
    // currently we can't run FB only on a subset of classes related to the
    // specific
    // source folder if source folders have same class output directory.
    // In this case the classes from BOTH source folders are examined by FB
    // and
    // new markers can be created for issues which are already reported.
    // Therefore here we check if a marker with SAME bug id is already
    // known,
    // and if yes, delete it (replacing with newer one)
    if (existingMarkers.length > 0) {
        IMarker oldMarker = findSameBug(attributes, existingMarkers);
        if (oldMarker != null) {
            oldMarker.delete();
        }
    }
    IMarker newMarker = markerTarget.createMarker(mp.markerType);
    newMarker.setAttributes(attributes);
}
 
Example 6
Source File: Model.java    From tlaplus with MIT License 5 votes vote down vote up
/**
    * Installs a marker on the model
 * @param properties a map of attribute names to attribute values 
 *		(key type : <code>String</code> value type : <code>String</code>, 
 *		<code>Integer</code>, or <code>Boolean</code>) or <code>null</code>
    */
public IMarker setMarker(Map<String, Object> properties, String markerType) {
	try {
		IMarker marker = getFile().createMarker(markerType);
		marker.setAttributes(properties);
		return marker;
	} catch (CoreException shouldNotHappen) {
		TLCActivator.logError(shouldNotHappen.getMessage(), shouldNotHappen);
	}
	return null;
}
 
Example 7
Source File: JavaSearchResultPage.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void showWithMarker(IEditorPart editor, IFile file, int offset, int length) throws PartInitException {
	try {
		IMarker marker= file.createMarker(NewSearchUI.SEARCH_MARKER);
		HashMap<String, Integer> attributes= new HashMap<String, Integer>(4);
		attributes.put(IMarker.CHAR_START, new Integer(offset));
		attributes.put(IMarker.CHAR_END, new Integer(offset + length));
		marker.setAttributes(attributes);
		IDE.gotoMarker(editor, marker);
		marker.delete();
	} catch (CoreException e) {
		throw new PartInitException(SearchMessages.JavaSearchResultPage_error_marker, e);
	}
}
 
Example 8
Source File: PyParser.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Creates a marker on the given resource with the given type and attributes.
 * <p>
 * This method modifies the workspace (progress is not reported to the user).</p>
 *
 * @param resource the resource
 * @param attributes the attribute map
 * @param markerType the type of marker
 * @throws CoreException if this method fails
 * @see IResource#createMarker(java.lang.String)
 */
public static void createMarker(final IResource resource, final Map<String, Object> attributes,
        final String markerType) throws CoreException {

    IWorkspaceRunnable r = new IWorkspaceRunnable() {
        @Override
        public void run(IProgressMonitor monitor) throws CoreException {
            IMarker marker = resource.createMarker(markerType);
            marker.setAttributes(attributes);
        }
    };

    resource.getWorkspace().run(r, null, IWorkspace.AVOID_UPDATE, null);
}
 
Example 9
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 10
Source File: Auditor.java    From eclipse-cs with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void addError(AuditEvent error) {
  try {
    if (!mLimitMarkers || mMarkerCount < mMarkerLimit) {

      SeverityLevel severity = error.getSeverityLevel();

      if (!severity.equals(SeverityLevel.IGNORE) && mResource != null) {

        RuleMetadata metaData = MetadataFactory.getRuleMetadata(error.getSourceName());

        // create generic metadata if none can be found
        if (metaData == null) {
          Module module = new Module(error.getSourceName());
          metaData = MetadataFactory.createGenericMetadata(module);
        }

        mMarkerAttributes.put(CheckstyleMarker.MODULE_NAME, metaData.getInternalName());
        mMarkerAttributes.put(CheckstyleMarker.MESSAGE_KEY,
                error.getLocalizedMessage().getKey());
        mMarkerAttributes.put(IMarker.PRIORITY, Integer.valueOf(IMarker.PRIORITY_NORMAL));
        mMarkerAttributes.put(IMarker.SEVERITY, Integer.valueOf(getSeverityValue(severity)));
        mMarkerAttributes.put(IMarker.LINE_NUMBER, Integer.valueOf(error.getLine()));
        mMarkerAttributes.put(IMarker.MESSAGE, getMessage(error));

        // calculate offset for editor annotations
        calculateMarkerOffset(error, mMarkerAttributes);

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

        // create a marker for the actual resource
        IMarker marker = mResource.createMarker(CheckstyleMarker.MARKER_ID);
        marker.setAttributes(mMarkerAttributes);

        mMarkerCount++;

        // clear the marker attributes to reuse the map for the
        // next error
        mMarkerAttributes.clear();
      }
    }
  } catch (CoreException e) {
    CheckstyleLog.log(e);
  }
}
 
Example 11
Source File: SolidityBuilder.java    From uml2solidity with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Create the marker from the compiler output.
 * 
 * @param error
 */
private void createMarker(String error) {
	String[] errors = error.trim().split(MESSAGE_SPLITTER);
	Pattern pattern = Pattern.compile(ERROR_PARSER, Pattern.DOTALL | Pattern.MULTILINE);
	IPath location = getProject().getLocation();

	for (String errorMessage : errors) {
		Matcher matcher = pattern.matcher(errorMessage.trim());
		if (!matcher.matches())
			continue;

		String filename = matcher.group(1).trim();
		String lineNumber = matcher.group(2);
		String errorType = matcher.group(4).trim();
		String errorM = matcher.group(5).trim();

		Path path = new Path(filename);
		if (location.isPrefixOf(path)) {
			IPath filePath = path.removeFirstSegments(location.segmentCount());
			IResource resource = getProject().findMember(filePath);
			if (!resource.exists())
				continue;

			try {
				int lineN = Integer.parseInt(lineNumber);
				IMarker marker = resource.createMarker(SOLIDITY_MARKER_ID);
				Map<String, Object> attributes = new HashMap<String, Object>();

				attributes.put(IMarker.MESSAGE, errorM);
				attributes.put(IMarker.LINE_NUMBER, lineN);
				if ("Error".equalsIgnoreCase(errorType))
					attributes.put(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
				else if ("Warning".equalsIgnoreCase(errorType))
					attributes.put(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
				else
					attributes.put(IMarker.SEVERITY, IMarker.SEVERITY_INFO);

				marker.setAttributes(attributes);
			} catch (Exception e) {
				Activator.logError("Error creating marker for: " + filename, e);
			}
		}
	}
}
 
Example 12
Source File: MarkerManager.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Creates a bunch of markers in the workspace as the single atomic operation - thus resulting in a single delta
 * @param fileToMarkerInfo
 * @param progressMonitor
 */
public static void commitParserMarkers(final Map<IFileStore, FileMarkerInfo> fileToMarkerInfo, IProgressMonitor progressMonitor) {
	int i = 0;
	
	final IFileStore[] files = new IFileStore[fileToMarkerInfo.size()];
	IFile[] ifiles = new IFile[fileToMarkerInfo.size()];
	
	for (Entry<IFileStore, FileMarkerInfo> keyValue : fileToMarkerInfo.entrySet()) {
		files[i] = keyValue.getKey();
		ifiles[i] = keyValue.getValue().getIFile();
		i++;
	}
	
	ISchedulingRule rule = ResourceUtils.createRule(Arrays.asList(ifiles));
	
	WorkspaceJob job = new WorkspaceJob("Update markers job") { //$NON-NLS-1$
		@Override
		public IStatus runInWorkspace(IProgressMonitor monitor){
			for (int j = 0; j < files.length; j++) {
				FileMarkerInfo fileMarkerInfo = fileToMarkerInfo.get(files[j]);
				if (fileMarkerInfo != null) {
					IFile iFile = fileMarkerInfo.getIFile();
					
					try {
						if (iFile.exists()) {
							Map<Integer, IMarker> offset2BuildMarker = createOffset2BuildMarkerMap(iFile);
							
							MarkerUtils.deleteParserProblemMarkers(iFile, IResource.DEPTH_INFINITE);
							Set<MarkerInfo> parserMarkers = fileMarkerInfo.getParserMarkers();
							for (MarkerInfo parserMarker : parserMarkers) {
								if (offset2BuildMarker.containsKey(parserMarker.getCharStart())) {
									continue;
								}
								IMarker marker = iFile.createMarker(parserMarker.getType());
								marker.setAttributes(parserMarker.getAttributes());
							}
						}
					} catch (CoreException e) {
						LogHelper.logError(e);
					}
				}
			}
			return Status.OK_STATUS;
		}
	};
	job.setRule(rule);
	job.schedule();
}
 
Example 13
Source File: GotoMatchingParenHandler.java    From tlaplus with MIT License 4 votes vote down vote up
/**
 * The method called when the user executes the Goto Matching Paren command.
 * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
 */
public Object execute(ExecutionEvent event) throws ExecutionException {
    TLAEditor tlaEditor = EditorUtil.getTLAEditorWithFocus();
    document = tlaEditor.publicGetSourceViewer().getDocument();
    
    try {
        ITextSelection selection = (ITextSelection) tlaEditor
                .getSelectionProvider().getSelection();
        Region selectedRegion = new Region(selection.getOffset(),
                selection.getLength());
        
        int selectedParenIdx = getSelectedParen(selectedRegion);
        
        int lineNumber = selection.getStartLine();
          // Note: if the selection covers multiple lines, then 
          // selectParenIdx should have thrown an exception.
        if (lineNumber < 0) {
            throw new ParenErrorException("Toolbox bug: bad selected line computed", null, null);
        }
        
        setLineRegions(lineNumber);
        setRegionInfo();
        
        if (selectedParenIdx < PCOUNT) {
            findMatchingRightParen(selectedParenIdx);
        } 
        else {
            findMatchingLeftParen(selectedParenIdx);
        }
        tlaEditor.selectAndReveal(currLoc, 0);            
    } catch (ParenErrorException e) {
        /*
         * Report the error.
         */
        IResource resource = ResourceHelper
                .getResourceByModuleName(tlaEditor.getModuleName());
        ErrorMessageEraser listener = new ErrorMessageEraser(tlaEditor,
                resource);
        tlaEditor.getViewer().getTextWidget().addCaretListener(listener);
        tlaEditor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(e.message);
        
        Region[] regions = e.regions;
        if (regions[0] != null) {
            try {
                // The following code was largely copied from the The
                // ShowUsesHandler class.
                Spec spec = ToolboxHandle.getCurrentSpec();
                spec.setMarkersToShow(null);
                IMarker[] markersToShow = new IMarker[2];
                for (int i = 0; i < 2; i++) {
                    IMarker marker = resource
                            .createMarker(PAREN_ERROR_MARKER_TYPE);
                    Map<String, Integer> markerAttributes = new HashMap<String, Integer>(
                            2);
                    markerAttributes.put(IMarker.CHAR_START, new Integer(
                            regions[i].getOffset()));
                    markerAttributes.put(
                            IMarker.CHAR_END,
                            new Integer(regions[i].getOffset()
                                    + regions[i].getLength()));
                    marker.setAttributes(markerAttributes);

                    markersToShow[i] = marker;
                }
                spec.setMarkersToShow(markersToShow);
            } catch (CoreException exc) {
                System.out
                        .println("GotoMatchingParenHandler.execute threw CoreException");
            }
        }
    }
    return null;
}
 
Example 14
Source File: JavaProject.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Record a new marker denoting a classpath problem
 */
public void createClasspathProblemMarker(IJavaModelStatus status) {

	IMarker marker = null;
	int severity;
	String[] arguments = CharOperation.NO_STRINGS;
	boolean isCycleProblem = false, isClasspathFileFormatProblem = false, isOutputOverlapping = false;
	switch (status.getCode()) {

		case  IJavaModelStatusConstants.CLASSPATH_CYCLE :
			isCycleProblem = true;
			if (JavaCore.ERROR.equals(getOption(JavaCore.CORE_CIRCULAR_CLASSPATH, true))) {
				severity = IMarker.SEVERITY_ERROR;
			} else {
				severity = IMarker.SEVERITY_WARNING;
			}
			break;

		case  IJavaModelStatusConstants.INVALID_CLASSPATH_FILE_FORMAT :
			isClasspathFileFormatProblem = true;
			severity = IMarker.SEVERITY_ERROR;
			break;

		case  IJavaModelStatusConstants.INCOMPATIBLE_JDK_LEVEL :
			String setting = getOption(JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL, true);
			if (JavaCore.ERROR.equals(setting)) {
				severity = IMarker.SEVERITY_ERROR;
			} else if (JavaCore.WARNING.equals(setting)) {
				severity = IMarker.SEVERITY_WARNING;
			} else {
				return; // setting == IGNORE
			}
			break;
		case IJavaModelStatusConstants.OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE :
			isOutputOverlapping = true;
			setting = getOption(JavaCore.CORE_OUTPUT_LOCATION_OVERLAPPING_ANOTHER_SOURCE, true);
			if (JavaCore.ERROR.equals(setting)) {
				severity = IMarker.SEVERITY_ERROR;
			} else if (JavaCore.WARNING.equals(setting)) {
				severity = IMarker.SEVERITY_WARNING;
			} else {
				return; // setting == IGNORE
			}
			break;
		default:
			IPath path = status.getPath();
			if (path != null) arguments = new String[] { path.toString() };
			if (JavaCore.ERROR.equals(getOption(JavaCore.CORE_INCOMPLETE_CLASSPATH, true)) &&
				status.getSeverity() != IStatus.WARNING) {
				severity = IMarker.SEVERITY_ERROR;
			} else {
				severity = IMarker.SEVERITY_WARNING;
			}
			break;
	}

	try {
		marker = this.project.createMarker(IJavaModelMarker.BUILDPATH_PROBLEM_MARKER);
		marker.setAttributes(
			new String[] {
				IMarker.MESSAGE,
				IMarker.SEVERITY,
				IMarker.LOCATION,
				IJavaModelMarker.CYCLE_DETECTED,
				IJavaModelMarker.CLASSPATH_FILE_FORMAT,
				IJavaModelMarker.OUTPUT_OVERLAPPING_SOURCE,
				IJavaModelMarker.ID,
				IJavaModelMarker.ARGUMENTS ,
				IJavaModelMarker.CATEGORY_ID,
				IMarker.SOURCE_ID,
			},
			new Object[] {
				status.getMessage(),
				new Integer(severity),
				Messages.classpath_buildPath,
				isCycleProblem ? "true" : "false",//$NON-NLS-1$ //$NON-NLS-2$
				isClasspathFileFormatProblem ? "true" : "false",//$NON-NLS-1$ //$NON-NLS-2$
				isOutputOverlapping ? "true" : "false", //$NON-NLS-1$ //$NON-NLS-2$
				new Integer(status.getCode()),
				Util.getProblemArgumentsForMarker(arguments) ,
				new Integer(CategorizedProblem.CAT_BUILDPATH),
				JavaBuilder.SOURCE_ID,
			}
		);
	} catch (CoreException e) {
		// could not create marker: cannot do much
		if (JavaModelManager.VERBOSE) {
			e.printStackTrace();
		}
	}
}
 
Example 15
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 );
		}
	}
}