/*
* Menu: Info Support > Find commented code
* Kudos: Peter Hendriks
* License: EPL 1.0
* DOM: http://download.eclipse.org/technology/dash/update/org.eclipse.eclipsemonkey.lang.javascript
*/
function main() {
loadBundle("org.eclipse.core.jobs");
var ProgressMonitorDialog = Packages.org.eclipse.jface.dialogs.ProgressMonitorDialog;
var IRunnableWithProgress = Packages.org.eclipse.jface.operation.IRunnableWithProgress;
var runnableWithProgress = new IRunnableWithProgress({ run: runCommentSearch });
new ProgressMonitorDialog(window.getShell()).run(true, true, runnableWithProgress);
window.getActivePage().showView("org.eclipse.ui.views.TaskList");
}
function runCommentSearch(monitor) {
var files = resources.filesMatching(".*\\.java");
monitor.beginTask("Searching for commented code...", files.length);
try {
var match;
for each( file in files ) {
monitor.subTask(file.getEclipseObject().getName());
file.removeMyTasks();
var previousLineCodeComment = false;
for each( line in file.lines ) {
if (monitor.isCanceled()) {
return;
}
if (match = line.string.match(/^.*\/\/.*[;{}]\s*$/)) {
if (!previousLineCodeComment) {
line.addMyTask("Commented code: " + match[0]);
}
previousLineCodeComment = true;
} else {
previousLineCodeComment = false;
}
}
monitor.worked(1);
}
} finally {
monitor.done();
}
}
2011-12-21
[轉載] Aptana Scripting 一個背景處理的範例
轉載自:Monkeying with Eclipse | Info Support
沒有留言:
張貼留言
你好!歡迎你在我的 Blog 上留下你寶貴的意見。