4 comments

  1. These examples made me giggle. 🙂

    Nice work! 🙂

    Jeroen Leenarts

  2. Nice… I have been trying to come up with examples to highlight features for the new Eclipse Monkey and I think I will borrow yours. Btw, when you have a chance, look into Groovy Monkey, it is my port of Eclipse Monkey, with a bunch more features and will be the basis of the new Eclipse Monkey project.

    James E. Ervin

  3. For fun I rewrote your script to run in Groovy Monkey using the Groovy Language. I think it is straightforward to figure out. Notice you did not have to spawn the ProgressMonitorDialog to get out of the UI Thread.

    --- Came wiffling through the eclipsey wood ---
    /*
     * Menu: Info Support > Find commented code
     * Script-Path: /GroovyMonkeyScripts/monkey/Info_Support__Find_Commented_Code.gm
     * Kudos: Peter Hendriks
     * License: EPL 1.0
     */
    import org.eclipse.jface.dialogs.*
    import org.eclipse.jface.operation.*
     
    def files = resources.filesMatching( ".*\.java" )
    monitor.beginTask( "Searching for commented code...", files.length )		
    
    for( file in files ) 
    {
    	monitor.subTask( file.eclipseObject.name )
      	file.removeMyTasks( metadata.scriptPath() )
      	def previousLineCodeComment = false
       	for( line in file.lines ) 
       	{
        	if( monitor.isCanceled() )
      			return
       		def match = line.string =~ /^.*//.*[;{}]s*$/
       		if( match.matches() )
       		{
       			if( !previousLineCodeComment )
         			line.addMyTask( metadata.scriptPath(), "Commented code: " + match[0] )
           		previousLineCodeComment = true
       		} 
       		else 
       			previousLineCodeComment = false
      	}
      	monitor.worked( 1 )
    }
    
    jface.syncExec
    {
        window.activePage.showView( "org.eclipse.ui.views.TaskList" )
    }
    --- And burbled as it ran! ---
    

    James E. Ervin

  4. Thank you James! I am glad the Eclipse Monkey project gets reincarnated as a new separate project. I think it’s a nice power tool and geek toy and it deserves an active project. I will look into GroovyMonkey some more, your rewritten code is a lot simpler. It’s also a good excuse to finally learn some Groovy. 🙂

    peterhe

Comments are closed.