Java Code Examples for org.eclipse.ui.texteditor.MarkerUtilities#createMarker()
The following examples show how to use
org.eclipse.ui.texteditor.MarkerUtilities#createMarker() .
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: SootAttributesJavaHover.java From JAADAS with GNU General Public License v3.0 | 6 votes |
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()); } } }
Example 2
Source File: SootAttrJimpleIconGenerator.java From JAADAS with GNU General Public License v3.0 | 6 votes |
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()); } } } }
Example 3
Source File: SootAttrJavaIconGenerator.java From JAADAS with GNU General Public License v3.0 | 6 votes |
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()); } } } }
Example 4
Source File: MarkerHandler.java From texlipse with Eclipse Public License 1.0 | 6 votes |
/** * 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); } } }
Example 5
Source File: AbstractProgramRunner.java From texlipse with Eclipse Public License 1.0 | 6 votes |
/** * 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); } } }
Example 6
Source File: ProblemHoverTest.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
private void createCustomMarkerOnResource(IResource resource, int severenity) throws CoreException{ HashMap<String, Object> attributes = new HashMap<String, Object>(); attributes.put(IMarker.MESSAGE, CUSTOM_MARKER_TEST_MESSAGE); attributes.put(IMarker.LINE_NUMBER, 1); attributes.put(IMarker.LOCATION, resource.getFullPath().toPortableString()); attributes.put(IMarker.SEVERITY, severenity); MarkerUtilities.createMarker(resource, attributes, CUSTOM_MARKER_ID); }
Example 7
Source File: MarkerHandler.java From texlipse with Eclipse Public License 1.0 | 5 votes |
/** * 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); } } }
Example 8
Source File: MarkerHandler.java From texlipse with Eclipse Public License 1.0 | 5 votes |
/** * Adds a fatal error to the problem log. * * @param editor The editor to add the errors to * @param error The error message */ public void addFatalError(ITextEditor editor, String error) { IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class); if (resource == null) return; //IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput()); try { Map<String, ? super Object> map = new HashMap<String, Object>(); map.put(IMarker.MESSAGE, error); map.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR)); MarkerUtilities.createMarker(resource, map, IMarker.PROBLEM); } catch (CoreException ce) { TexlipsePlugin.log("Creating marker", ce); } }
Example 9
Source File: MarkerHandler.java From texlipse with Eclipse Public License 1.0 | 5 votes |
/** * Creates an error marker on the given line * * @param resource The resource to create the error to * @param message The message for the marker * @param lineNumber The line number to create the error on */ public void createErrorMarker(IResource resource, String message, int lineNumber) { try { Map<String, ? super Object> map = new HashMap<String, Object>(); map.put(IMarker.LINE_NUMBER, Integer.valueOf(lineNumber)); map.put(IMarker.MESSAGE, message); map.put(IMarker.SEVERITY, Integer.valueOf(IMarker.SEVERITY_ERROR)); MarkerUtilities.createMarker(resource, map, IMarker.PROBLEM); } catch (CoreException ce) { TexlipsePlugin.log("Creating marker", ce); } }
Example 10
Source File: ProblemReporter.java From cppcheclipse with Apache License 2.0 | 4 votes |
private void reportProblem(IResource resource, String message, int severity, int lineNumber, String id, File file, int originalLineNumber) throws CoreException { // TODO: open external file, see // https://bugs.eclipse.org/bugs/show_bug.cgi?id=151005 on how to // generate markers for external files // Do not put in duplicates IMarker[] cur = resource.findMarkers(CHECKER_MARKER_TYPE, false, IResource.DEPTH_ZERO); if (cur != null) { for (IMarker element : cur) { int oldLineNumber = element .getAttribute(IMarker.LINE_NUMBER, 0); if (lineNumber == oldLineNumber) { String oldMessage = element.getAttribute(IMarker.MESSAGE, ""); //$NON-NLS-1$ int oldSeverity = element.getAttribute(IMarker.SEVERITY, 100); if (severity == oldSeverity && message.equals(oldMessage)) return; } } } // see // http://wiki.eclipse.org/FAQ_Why_don%27t_my_markers_appear_in_the_editor%27s_vertical_ruler%3F Map<String, Object> attributes = new HashMap<String, Object>(); if (lineNumber != 0) { MarkerUtilities.setLineNumber(attributes, lineNumber); } MarkerUtilities.setMessage(attributes, message); attributes.put(IMarker.SEVERITY, severity); // the following attributes are only used for the quick fixes attributes.put(ATTRIBUTE_ID, id); if (file != null) { attributes.put(ATTRIBUTE_FILE, file.toString()); } attributes.put(ATTRIBUTE_ORIGINAL_LINE_NUMBER, originalLineNumber); MarkerUtilities.createMarker(resource, attributes, CHECKER_MARKER_TYPE); }
Example 11
Source File: TestabilityReportLaunchListener.java From testability-explorer with Apache License 2.0 | 4 votes |
private void createMarkersFromClassIssues(List<ClassIssues> classIssues, IJavaProject javaProject) throws CoreException { javaProject.getProject().deleteMarkers(TestabilityConstants.TESTABILITY_COLLABORATOR_MARKER_TYPE, true, IResource.DEPTH_INFINITE); javaProject.getProject().deleteMarkers(TestabilityConstants.TESTABILITY_CONSTRUCTOR_MARKER_TYPE, true, IResource.DEPTH_INFINITE); javaProject.getProject().deleteMarkers(TestabilityConstants.TESTABILITY_DIRECT_COST_MARKER_TYPE, true, IResource.DEPTH_INFINITE); IPackageFragmentRoot[] roots = javaProject.getPackageFragmentRoots(); List<IPath> sourceFolderPaths = new ArrayList<IPath>(); for (IPackageFragmentRoot root : roots) { if (!root.isArchive()) { IResource rootResource = root.getCorrespondingResource(); sourceFolderPaths.add(rootResource.getFullPath().removeFirstSegments(1)); } } for (ClassIssues classIssue : classIssues) { IResource resource = getAbsolutePathFromJavaFile(classIssue.getClassName(), sourceFolderPaths, javaProject.getProject()); if (resource != null) { for (Issue issue : classIssue.getMostImportantIssues()) { Map<String, Object> attributes = new HashMap<String, Object>(); attributes.put(IMarker.SEVERITY, IMarker.SEVERITY_ERROR); attributes.put(IMarker.LINE_NUMBER, issue.getLocation().getLineNumber()); attributes.put(IMarker.MESSAGE, retriever.getSuggestion(issue.getType(), issue.getSubType())); IssueType issueType = issue.getType(); attributes.put(TestabilityConstants.ISSUE_TYPE, issue.getType().toString()); String markerType = null; if (IssueType.COLLABORATOR.equals(issueType)) { markerType = TestabilityConstants.TESTABILITY_COLLABORATOR_MARKER_TYPE; } else if (IssueType.CONSTRUCTION.equals(issueType)) { markerType = TestabilityConstants.TESTABILITY_CONSTRUCTOR_MARKER_TYPE; } else if (IssueType.DIRECT_COST.equals(issueType)) { markerType = TestabilityConstants.TESTABILITY_DIRECT_COST_MARKER_TYPE; } if (markerType != null) { MarkerUtilities.createMarker(resource, attributes, markerType); } } } else { logger.logException("No Resource found for Class : " + classIssue.getClassName(), null); } } }