Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2009 itemis AG (http://www.itemis.eu) and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html /
 
 package org.eclipse.xtext.ui.editor.validation;
 
import  org.eclipse.core.resources.IMarker;
import  org.eclipse.core.resources.IResource;
import  org.eclipse.core.runtime.CoreException;

Author(s):
Sven Efftinge - Initial contribution and API
public class MarkerCreator {
	private static final String FIXABLE_KEY = "FIXABLE_KEY";
	@Inject(optional=true)
	public void createMarker(Issue issue, IResource resourceString markerTypethrows CoreException {
		IMarker marker = resource.createMarker(markerType);
		setMarkerAttributes(issueresourcemarker);
	}

Since:
2.0
	protected void setMarkerAttributes(Issue issue, IResource resource, IMarker markerthrows CoreException {
		String lineNR = "";
		if (issue.getLineNumber() != null) {
			lineNR = "line: " + issue.getLineNumber() + " ";
		}
		marker.setAttribute(IMarker.LOCATION, lineNR + resource.getFullPath().toString());
		marker.setAttribute(.issue.getCode());		
		marker.setAttribute(IMarker.SEVERITY, getSeverity(issue));
		marker.setAttribute(IMarker.CHAR_START, issue.getOffset());
		if(issue.getOffset() != null && issue.getLength() != null)
			marker.setAttribute(IMarker.CHAR_END, issue.getOffset()+issue.getLength());
		marker.setAttribute(IMarker.LINE_NUMBER, issue.getLineNumber());
		marker.setAttribute(IMarker.MESSAGE, issue.getMessage());
		if (issue.getUriToProblem()!=null
			marker.setAttribute(.issue.getUriToProblem().toString());
		if(issue.getData() != null && issue.getData().length > 0) {
			marker.setAttribute(., Strings.pack(issue.getData()));
		}
			marker.setAttribute(true);
		}
	}
	private Object getSeverity(Issue issue) {
		switch (issue.getSeverity()) {
			case  : 
				return IMarker.SEVERITY_ERROR;
			case  : 
				return IMarker.SEVERITY_WARNING;
			case  : 
				return IMarker.SEVERITY_INFO;
			default:
				throw new IllegalArgumentException(String.valueOf(issue.getSeverity()));
		}
	}
New to GrepCode? Check out our FAQ X