Jeff Mesnil
Weblog · About

'Find Missing Headers' Monkey Script

March 20, 2006

Still playing with Eclipse Monkey.

I wrote this simple script based on the org.eclipse.dash.doms resources DOM. It looks for Java files to find the files which are missing copyright headers. In my script it is looking for the Eclipse Foundation copyright (Copyright (c) 2005 Eclipse Foundation).

--- Came wiffling through the eclipsey wood ---
   * Menu: Find Missing Headers
   * Kudos: Jeff Mesnil
   *  License: EPL 1.0
   * DOM:
  function main() {
    var files = resources.filesMatching(".*\\.java");
    var match;
    for each( file in files ) { 
      file.removeMyTasks(  );
      if (!file.lines[1].string.match(/\* Copyright \(c\) 2005 Eclipse Foundation/)) {

--- And burbled as it ran! ---

If I run it on my workspace with the imported org.eclipse.eclipsemonkey plug-in, it shows that one file is missing the copyright header:

Java Files missing copyright headers