Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I just realized that PyDev has rather powerful scripting support. Unfortunately I don't have the time to do it all for you (but if you complete this, please post it here :)</p> <p>If you create a file named <code>pyedit_nose.py</code> that looks like this in an otherwise empty folder :</p> <pre><code>assert cmd is not None assert editor is not None if cmd == 'onSave': from java.lang import Runtime from java.io import BufferedReader from java.io import InputStreamReader from org.eclipse.core.resources import ResourcesPlugin from org.eclipse.core.resources import IMarker from org.eclipse.core.resources import IResource proc = Runtime.getRuntime().exec('ls -al') extra_message = BufferedReader(InputStreamReader(proc.inputStream)).readLine() r = ResourcesPlugin.getWorkspace().getRoot() for marker in r.findMarkers(IMarker.PROBLEM, False, IResource.DEPTH_INFINITE): if marker.getAttribute(IMarker.MESSAGE).startsWith("Some test failed!"): marker.delete() for rr in r.getProjects(): marker = rr.createMarker(IMarker.PROBLEM) marker.setAttribute(IMarker.MESSAGE, "Some test failed! " + extra_message) marker.setAttribute(IMarker.PRIORITY, IMarker.PRIORITY_HIGH) marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR) </code></pre> <p>and set up Preferences->PyDev->Scripting Pydev to point to this directory you will get all projects in your workspace marked with an error every time a file is saved.</p> <p>By executing a script that returns the test results in some easy to parse format rather than <code>ls</code> and parsing the output you should be able to put your markers in the right places.</p> <p>See this for some starting points:</p> <ul> <li><a href="http://fabioz.com/pydev/manual_articles_scripting.html" rel="noreferrer">Jython Scripting in Pydev</a></li> <li><a href="http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/resources/IMarker.html" rel="noreferrer">IMarker</a> is what represents a marker.</li> <li><a href="http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/resources/IResource.html" rel="noreferrer">IResource</a> is what you attach your markers to. Can be workspaces, projects, files, directories etc. <code>resource.createMarker(IMarker.PROBLEM)</code> creates a problem marker.</li> <li><a href="http://help.eclipse.org/stable/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/resources/IProject.html" rel="noreferrer">IProject</a> is a type of <code>IResource</code> that represents a project. Use the <code>members()</code> method to get the contents.</li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload