Aptana Scripting背景处理范例
时间:2014-07-22 15:07 来源: 我爱IT技术网 作者:山风
一个 Aptana Scripting的背景处理范例:
源代码如下:
- /*
- * 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();
- }
- }
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
