Skip to content

Instantly share code, notes, and snippets.

@tracymiranda
Last active February 10, 2016 12:32
Show Gist options
  • Save tracymiranda/6556482e278c9afc421d to your computer and use it in GitHub Desktop.
Save tracymiranda/6556482e278c9afc421d to your computer and use it in GitHub Desktop.
This script runs with Eclipse EASE Jython engine. It adds an Eclipse Task Marker for all printStackTrace lines it detects in java files in the workspace.
loadModule('/System/Resources')
from org.eclipse.core.resources import IMarker
for ifile in findFiles("*.java"):
file_name = str(ifile.getLocation())
print "Processing " + file_name
with open(file_name) as f:
for line_no, line in enumerate(f, start=1):
if "printStackTrace" in line:
marker = ifile.createMarker(IMarker.TASK)
marker.setAttribute(IMarker.TRANSIENT, True)
marker.setAttribute(IMarker.LINE_NUMBER, line_no)
marker.setAttribute(IMarker.MESSAGE, "Fix in Sprint 2: " + line.strip())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment