本文整理汇总了Java中org.eclipse.ui.texteditor.MarkerUtilities类的典型用法代码示例。如果您正苦于以下问题:Java MarkerUtilities类的具体用法?Java MarkerUtilities怎么用?Java MarkerUtilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MarkerUtilities类属于org.eclipse.ui.texteditor包,在下文中一共展示了MarkerUtilities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: assertMarkers
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
/***/
public static IMarker[] assertMarkers(String assertMessage, final IResource resource, String markerType, int count,
final Predicate<IMarker> markerPredicate) throws CoreException {
IMarker[] markers = resource.findMarkers(markerType, true, IResource.DEPTH_INFINITE);
List<IMarker> markerList = from(Arrays.asList(markers)).filter(markerPredicate).toList();
if (markerList.size() != count) {
StringBuilder message = new StringBuilder(assertMessage);
message.append("\nbut was:");
for (IMarker marker : markerList) {
message.append("\n");
message.append("line " + MarkerUtilities.getLineNumber(marker) + ": ");
message.append(marker.getAttribute(IMarker.MESSAGE, "<no message>"));
}
Assert.assertEquals(message.toString(), count, markers.length);
}
return markers;
}
示例2: assertIssues
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
/**
* Asserts that the given resource (usually an N4JS file) contains issues with the given messages and no other
* issues. Each message given should be prefixed with the line numer where the issues occurs, e.g.:
*
* <pre>
* line 5: Couldn't resolve reference to identifiable element 'unknown'.
* </pre>
*
* Column information is not provided, so this method is not intended for several issues within a single line.
*/
public static void assertIssues(final IResource resource, String... expectedMessages) throws CoreException {
final IMarker[] markers = resource.findMarkers(MarkerTypes.ANY_VALIDATION, true, IResource.DEPTH_INFINITE);
final String[] actualMessages = new String[markers.length];
for (int i = 0; i < markers.length; i++) {
final IMarker m = markers[i];
actualMessages[i] = "line " + MarkerUtilities.getLineNumber(m) + ": " + m.getAttribute(IMarker.MESSAGE);
}
if (!Objects.equals(
new HashSet<>(Arrays.asList(actualMessages)),
new HashSet<>(Arrays.asList(expectedMessages)))) {
final Joiner joiner = Joiner.on("\n ");
final String msg = "expected these issues:\n"
+ " " + joiner.join(expectedMessages) + "\n"
+ "but got these:\n"
+ " " + joiner.join(actualMessages);
System.out.println("*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*");
System.out.println(msg);
System.out.println("*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*#*");
Assert.fail(msg);
}
}
示例3: createMarker
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
private void createMarker(IResource resource, String message, int lineNumber, String markerType, int severity,
int charStart, int charEnd) throws CoreException {
if (lineNumber <= 0)
lineNumber = 1;
IMarker marker = findMarker(resource, message, lineNumber, markerType);
if (marker == null) {
HashMap<String, Object> map = new HashMap<>();
map.put(IMarker.SEVERITY, new Integer(severity));
map.put(IMarker.LOCATION, resource.getFullPath().toOSString());
map.put(IMarker.MESSAGE, message);
MarkerUtilities.setLineNumber(map, lineNumber);
MarkerUtilities.setMessage(map, message);
if (charStart != -1) {
MarkerUtilities.setCharStart(map, charStart);
MarkerUtilities.setCharEnd(map, charEnd);
}
internalCreateMarker(resource, map, markerType);
}
}
示例4: getExistingMarkerFor
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
private IMarker getExistingMarkerFor(IResource resource, String message, int start, int end,
Set<IMarker> remainingMarkers) {
ITextFileBuffer textFileBuffer = FileBuffers.getTextFileBufferManager()
.getTextFileBuffer(resource.getFullPath(), LocationKind.IFILE);
if (textFileBuffer == null) {
return null;
}
try {
for (IMarker marker : remainingMarkers) {
int startOffset = MarkerUtilities.getCharStart(marker);
int endOffset = MarkerUtilities.getCharEnd(marker);
if (MarkerUtils.getOptionType(marker) == null && message.equals(MarkerUtilities.getMessage(marker))) {
if (start <= startOffset && end >= endOffset) {
return marker;
}
}
}
} catch (CoreException e) {
e.printStackTrace();
}
return null;
}
示例5: addSootAttributeMarkers
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
protected void addSootAttributeMarkers() {
if (getAttrsHandler() == null)return;
if (getAttrsHandler().getAttrList() == null) return;
Iterator it = getAttrsHandler().getAttrList().iterator();
HashMap markerAttr = new HashMap();
while (it.hasNext()) {
SootAttribute sa = (SootAttribute)it.next();
if (((sa.getAllTextAttrs("<br>") == null) || (sa.getAllTextAttrs("<br>").length() == 0)) &&
((sa.getAllLinkAttrs() == null) || (sa.getAllLinkAttrs().size() ==0))) continue;
markerAttr.put(IMarker.LINE_NUMBER, new Integer(sa.getJavaStartLn()));
try {
MarkerUtilities.createMarker(getRec(), markerAttr, "ca.mcgill.sable.soot.sootattributemarker");
}
catch(CoreException e) {
System.out.println(e.getMessage());
}
}
}
示例6: addSootAttributeMarkers
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
public void addSootAttributeMarkers(){//SootAttributesHandler handler, IFile rec) {
if (getHandler().getAttrList() == null) return;
Iterator it = getHandler().getAttrList().iterator();
HashMap markerAttr = new HashMap();
while (it.hasNext()) {
SootAttribute sa = (SootAttribute)it.next();
if (getHandler().isShowAllTypes() || typesContainsOneOf(sa.getAnalysisTypes())){
if (((sa.getAllTextAttrs("") == null) || (sa.getAllTextAttrs("").length() == 0)) &&
((sa.getAllLinkAttrs() == null) || (sa.getAllLinkAttrs().size() ==0))) continue;
markerAttr.put(IMarker.LINE_NUMBER, new Integer(sa.getJimpleStartLn()));
try {
MarkerUtilities.createMarker(getRec(), markerAttr, "ca.mcgill.sable.soot.sootattributemarker");
}
catch(CoreException e) {
System.out.println(e.getMessage());
}
}
}
}
示例7: addSootAttributeMarkers
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
public void addSootAttributeMarkers(){//SootAttributesHandler handler, IFile rec) {
if (getHandler().getAttrList() == null) return;
Iterator it = getHandler().getAttrList().iterator();
HashMap markerAttr = new HashMap();
while (it.hasNext()) {
SootAttribute sa = (SootAttribute)it.next();
if (getHandler().isShowAllTypes() || typesContainsOneOf(sa.getAnalysisTypes())) {
if (((sa.getAllTextAttrs("<br>") == null) || (sa.getAllTextAttrs("<br>").length() == 0)) &&
((sa.getAllLinkAttrs() == null) || (sa.getAllLinkAttrs().size() ==0))) continue;
markerAttr.put(IMarker.LINE_NUMBER, new Integer(sa.getJavaStartLn()));
try {
MarkerUtilities.createMarker(getRec(), markerAttr, "ca.mcgill.sable.soot.sootattributemarker");
}
catch(CoreException e) {
System.out.println(e.getMessage());
}
}
}
}
示例8: createReferencingErrorMarkers
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
/**
* Creates warning markers for undefined references.
*
* @param editor The editor to add the errors to
* @param errors The errors to add as instances of <code>DocumentReference</code>
*/
public void createReferencingErrorMarkers(ITextEditor editor, List<DocumentReference> errors) {
IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
if (resource == null) return;
IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
for (DocumentReference msg : errors) {
try {
int beginOffset = document.getLineOffset(msg.getLine() - 1) + msg.getPos();
Map<String, ? super Object> map = new HashMap<String, Object>();
map.put(IMarker.LINE_NUMBER, Integer.valueOf(msg.getLine()));
map.put(IMarker.CHAR_START, Integer.valueOf(beginOffset));
map.put(IMarker.CHAR_END, Integer.valueOf(beginOffset + msg.getLength()));
map.put(IMarker.MESSAGE, "Key " + msg.getKey() + " is undefined");
map.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_WARNING));
MarkerUtilities.createMarker(resource, map, IMarker.PROBLEM);
} catch (CoreException ce) {
TexlipsePlugin.log("Creating marker", ce);
} catch (BadLocationException ble) {
TexlipsePlugin.log("Creating marker", ble);
}
}
}
示例9: createMarker
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
/**
* Create a layout warning marker to the given resource.
*
* @param resource the file where the problem occurred
* @param message error message
* @param lineNumber line number
* @param markerType
* @param severity Severity of the error
*/
@SuppressWarnings("unchecked")
protected static void createMarker(IResource resource,
Integer lineNumber, String message, String markerType, int severity) {
int lineNr = -1;
if (lineNumber != null) {
lineNr = lineNumber;
}
IMarker marker = AbstractProgramRunner.findMarker(resource, lineNr, message, markerType);
if (marker == null) {
try {
HashMap map = new HashMap();
map.put(IMarker.MESSAGE, message);
map.put(IMarker.SEVERITY, new Integer (severity));
if (lineNumber != null)
map.put(IMarker.LINE_NUMBER, lineNumber);
MarkerUtilities.createMarker(resource, map, markerType);
} catch (CoreException e) {
throw new RuntimeException(e);
}
}
}
示例10: createIssue
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
public Issue createIssue(IMarker marker) {
Issue.IssueImpl issue = new Issue.IssueImpl();
issue.setMessage(MarkerUtilities.getMessage(marker));
issue.setLineNumber(MarkerUtilities.getLineNumber(marker) - 1);
issue.setOffset(MarkerUtilities.getCharStart(marker));
issue.setLength(MarkerUtilities.getCharEnd(marker)-MarkerUtilities.getCharStart(marker));
issue.setCode(getCode(marker));
issue.setData(getIssueData(marker));
issue.setUriToProblem(getUriToProblem(marker));
issue.setSeverity(getSeverity(marker));
issue.setType(getCheckType(marker));
// Note, isSyntaxError is unset, but currently the api does not allow fixing
// syntax errors anyway.
return issue;
}
示例11: addMarker
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
@SuppressWarnings("rawtypes")
public static void addMarker(IFile file, String message, int line, int colPos, int markerType) {
try {
Map<String, Comparable> attributes = new HashMap<String, Comparable>(5);
attributes.put(IMarker.SEVERITY, new Integer(markerType));
attributes.put(IMarker.MESSAGE, message);
attributes.put(IMarker.TEXT, message);
if (colPos > 0) {
attributes.put(IMarker.CHAR_START, new Integer(colPos));
attributes.put(IMarker.CHAR_END, new Integer(colPos));
}
else {
attributes.put(IMarker.LINE_NUMBER, new Integer(line));
}
MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM);
} catch (Exception e) {}
}
示例12: addMarker
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
private void addMarker(RuleFailure ruleViolation) {
try {
Path path = new Path(ruleViolation.getName());
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
RuleFailurePosition startPosition = ruleViolation.getStartPosition();
RuleFailurePosition endPosition = ruleViolation.getEndPosition();
Map<String, Object> attributes = Maps.newHashMap();
attributes.put(IMarker.LINE_NUMBER, startPosition.getLine() + 1);
attributes.put(IMarker.CHAR_START, startPosition.getPosition());
attributes.put(IMarker.CHAR_END, endPosition.getPosition());
attributes.put(IMarker.MESSAGE, ruleViolation.getFailure());
attributes.put(IMarker.PRIORITY, IMarker.PRIORITY_NORMAL);
attributes.put(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
MarkerUtilities.createMarker(file, attributes, MARKER_TYPE);
} catch (CoreException e) {
throw new RuntimeException(e);
}
}
示例13: sendFeedback
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
@Override
public void sendFeedback(FeedbackInstance feedbackInstance) {
// Get all markers on the resource in question
// place the marker
Map<String, Object> map = new HashMap<String, Object>();
map.put(IMarker.SEVERITY, IMarker.SEVERITY_WARNING);
map.put(IMarker.MESSAGE, feedbackInstance.getMessage());
map.put(IMarker.CHAR_START, feedbackInstance.getStartPosition());
map.put(IMarker.CHAR_END, feedbackInstance.getEndPosition());
try {
MarkerUtilities.createMarker(contextModel.getResource(), map, "ESPSecurityPlugin.secproblem");
} catch (CoreException e) {
// LOG.log(Level.INFO, "Could not create marker: " + e.getMessage());
}
}
示例14: addMarker
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
public void addMarker(int markerSeverity, String Marker,IFile file, String message, Integer lineNumber, Integer beginChar, Integer endChar, String msgGroup) {
try {
HashMap<String, java.lang.Object> datas = new HashMap<String, java.lang.Object>();
datas.put( IMarker.MESSAGE, message != null ? message : "<null>" );
datas.put( IMarker.SEVERITY, markerSeverity );
if ( beginChar != null )
datas.put( IMarker.CHAR_START, beginChar );
else
datas.put( IMarker.CHAR_START, 0 );
if ( endChar != null )
datas.put( IMarker.CHAR_END, endChar );
else
datas.put( IMarker.CHAR_END, 0 );
if(lineNumber != null)
datas.put(IMarker.LINE_NUMBER, lineNumber);
datas.put(KERMETA_MARKER_ATTRIBUTE, msgGroup);
MarkerUtilities.createMarker( file, datas, IMarker.PROBLEM );
/*
IMarker marker = file.createMarker(Marker);
marker.setAttribute(IMarker.MESSAGE, message != null ? message : "<null>");
marker.setAttribute(IMarker.SEVERITY, markerSeverity);
if (lineNumber == -1) {
lineNumber = 1;
}
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
marker.setAttribute(IMarker.CHAR_START, beginChar);
marker.setAttribute(IMarker.CHAR_END, endChar);
marker.setAttribute(KERMETA_MARKER_ATTRIBUTE, msgGroup);
*/
} catch (CoreException e) {
ms.log(Kind.DevERROR, "Failed to mark TextFile", Activator.PLUGIN_ID, e);
}
}
示例15: createMarkers
import org.eclipse.ui.texteditor.MarkerUtilities; //导入依赖的package包/类
/**
* Creates markers from a given list of <code>ParseErrorMessage</code>s.
*
* @param editor The editor to add the errors to
* @param markers The markers to add as instances of <code>ParseErrorMessage</code>
* @param markerType The type of the markers as <code>IMarker</code> types
*/
private void createMarkers(ITextEditor editor, List<ParseErrorMessage> markers, final String markerType) {
IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
if (resource == null) return;
//IResource resource = ((FileEditorInput)editor.getEditorInput()).getFile();
IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
for (ParseErrorMessage msg : markers) {
try {
int beginOffset = document.getLineOffset(msg.getLine() - 1) + msg.getPos();
Map<String, ? super Object> map = new HashMap<String, Object>();
map.put(IMarker.LINE_NUMBER, Integer.valueOf(msg.getLine()));
map.put(IMarker.CHAR_START, Integer.valueOf(beginOffset));
map.put(IMarker.CHAR_END, Integer.valueOf(beginOffset + msg.getLength()));
map.put(IMarker.MESSAGE, msg.getMsg());
// we can do this since we're referring to a static field
if (IMarker.PROBLEM == markerType)
map.put(IMarker.SEVERITY, Integer.valueOf(msg.getSeverity()));
if (IMarker.TASK == markerType)
map.put(IMarker.PRIORITY, Integer.valueOf(msg.getSeverity()));
MarkerUtilities.createMarker(resource, map, markerType);
} catch (CoreException ce) {
TexlipsePlugin.log("Creating marker", ce);
} catch (BadLocationException ble) {
TexlipsePlugin.log("Creating marker", ble);
}
}
}