Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Pontesegger2014-11-25 15:19:10 +0000
committerChristian Pontesegger2014-11-25 15:19:10 +0000
commitd379ccde36be46bd8e64bcc36fd62d58c6343230 (patch)
treeb099f3281ec0222f9cbe8fb34ae01fc399a55959
parente9c589aa9d0c50bdbe611888b2d13dbdf02265ba (diff)
downloadorg.eclipse.ease.scripts-d379ccde36be46bd8e64bcc36fd62d58c6343230.tar.gz
org.eclipse.ease.scripts-d379ccde36be46bd8e64bcc36fd62d58c6343230.tar.xz
org.eclipse.ease.scripts-d379ccde36be46bd8e64bcc36fd62d58c6343230.zip
add script to find all System.out.print statements in java files
binds to the toolbar of the Project Explorer Change-Id: Idc7b4547b3cfab6bbfecd1f323c0b67062250c49
-rw-r--r--JavaScript Snippets/Java helpers/Add println Tasks.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/JavaScript Snippets/Java helpers/Add println Tasks.js b/JavaScript Snippets/Java helpers/Add println Tasks.js
new file mode 100644
index 0000000..c664d95
--- /dev/null
+++ b/JavaScript Snippets/Java helpers/Add println Tasks.js
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2014 Christian Pontesegger and others. All rights reserved.
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors: Christian Pontesegger - initial API and implementation
+ *
+ * name : Add println() tasks
+ * toolbar : Project Explorer
+ * description : Adds TODOs for all System.out.println lines it detects in java files
+ ******************************************************************************/
+
+loadModule('/System/Resources');
+for each (file in findFiles("*.java")) {
+ var lineNumber = 1;
+ var fileHandle = openFile(file, READ);
+ // TODO foobar
+ var line = readLine(fileHandle);
+ while(line != null) {
+ if (line.search(/System.out.print/) >= 0) {
+
+ // create marker
+ var marker = file.createMarker(org.eclipse.core.resources.IMarker.TASK);
+ marker.setAttribute(org.eclipse.core.resources.IMarker.TRANSIENT, true);
+ marker.setAttribute(org.eclipse.core.resources.IMarker.LINE_NUMBER, lineNumber);
+ marker.setAttribute(org.eclipse.core.resources.IMarker.MESSAGE, "TODO " + line.trim());
+
+ }
+ var line = readLine(fileHandle);
+ lineNumber++;
+ }
+} \ No newline at end of file

Back to the top