clear console command
I would really really really like to have a ‘clear’ command in Stratego that would clear the console each time I call it.
I use ‘debug’ often and I keep losing track of what’s new and what’s old after I rebuild. It’s really annoying to keep reaching with my mouse for the ‘Clear Console’ button.
Do you think it’s easy to do?
Submitted by Radu Mereuta on 25 June 2012 at 22:59
Issue Log
I don’t think this would be hard to do. In fact it probably already is supported in the REPL.
I think that adding a ‘clear’ strategy to Stratego would be like adding System.out.debug to Java. The design issue aside you can easily write a native term-preserving strategy that will clear the Spoofax console. Of course this would break hard as soon as you try to run your compiler outside of Spoofax (Eclipse).
Here’s the code that ought to do it:
public class clear_console_0_0 extends Strategy {public static clear_console_0_0 instance = new clear_console_0_0(); public final static String conName = "Spoofax Console"; @Override public IStrategoTerm invoke(Context context, IStrategoTerm current) { IOConsole cons = getSpoofaxConsole(); if(cons!=null) cons.clearConsole(); return current; } private IOConsole getSpoofaxConsole() { ConsolePlugin plugin = ConsolePlugin.getDefault(); IConsoleManager conMan = plugin.getConsoleManager(); IConsole[] existing = conMan.getConsoles(); for (IConsole cons : existing) { if (cons.getName().equals(conName)) return (IOConsole) cons; } return null; }
}
Thanks, this works.
But I’m still having a few issues with including the jar file in the class path.
Right now I’m using something like this in the .classpath:
Is it possible to skip the version of the jar?
Glad that the clear strategy works.
I’m sorry but I do not understand your last question. Could you please ellaborate? Since it seems related to class loading issues perhaps a separate ticket is better.
It seems that I forgot to escape some characters, and they wouldn’t show here.
What I was trying to say, is that I linked the library with the version number, and if this changes, it will break the project for future users.
<classpathentry kind=“var” path=“ECLIPSE_HOME/plugins/org.eclipse.ui.console_3.5.0.v20100526.jar”/>
Not really important, you can relink it, but it would be nice to do it properly.
Radu, what about adding org.eclipse.ui.console to your plug-in’s dependencies list?
Thanks, I finally managed to do that, by editing MANIFEST.MF.
For some reason the plug-in dependencies list is read only.
Log in to post comments