Skip to content

Commit b4d32a1

Browse files
committed
scala: partially cleaned sources
1 parent 1f6bd00 commit b4d32a1

4 files changed

Lines changed: 7 additions & 172 deletions

File tree

RubyScript/src/org/knime/ext/jruby/RubyScriptNodeModel.scala

Lines changed: 1 addition & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -189,15 +189,6 @@ end
189189
case _ => templateScript
190190
})
191191

192-
// if (snippetMode) {
193-
// buffer ++= templateSnippet
194-
// } else {
195-
// if (numInputs > 0) {
196-
// buffer ++= templateScriptMultiInput
197-
// } else {
198-
// buffer ++= templateScript
199-
// }
200-
// }
201192
script = buffer.toString()
202193

203194
if (snippetMode) {
@@ -214,10 +205,6 @@ end
214205
val outSpecs = configure(if (numInputs > 0) Array(inData(0).getDataTableSpec) else null)
215206
val outContainer = Array.tabulate(numOutputs) { i => new DataContainer(outSpecs(i)) }
216207

217-
// val outContainer = Array.ofDim[DataContainer](numOutputs)
218-
// for (i <- 0 to numOutputs - 1) {
219-
// outContainer(i) = new DataContainer(outSpecs(i))
220-
// }
221208
val fileSep = System.getProperty("file.separator")
222209
val core = Platform.getBundle("org.knime.core")
223210
val coreClassPath = core.getHeaders.get("Bundle-Classpath").toString
@@ -236,32 +223,18 @@ end
236223
.map(s => FileLocator.find(core, new Path(s), null)).filter(_ != null)
237224
.map(FileLocator.resolve(_).getFile)
238225

239-
// val classpath = new ArrayList[String]()
240-
// for (s <- coreClassPath.split(",")) {
241-
// val u = FileLocator.find(core, new Path(s), null)
242-
// if (u != null) {
243-
// classpath.add(FileLocator.resolve(u).getFile)
244-
// }
245-
// }
246226
classpath.add(corePluginPath + fileSep + "bin")
247227
baseClassPath.split(",").view
248228
.map(s => FileLocator.find(base, new Path(s), null)).filter(_ != null)
249229
.foreach { u => classpath.add(FileLocator.resolve(u).getFile) }
250230

251-
// for (s <- baseClassPath.split(",")) {
252-
// val u = FileLocator.find(base, new Path(s), null)
253-
// if (u != null) {
254-
// classpath.add(FileLocator.resolve(u).getFile)
255-
// }
256-
// }
257231
classpath.add(basePluginPath + fileSep + "bin")
258232
classpath.add(getJavaClasspathExtensionPath)
259233
if (RubyScriptNodePlugin.getDefault.getPreferenceStore.getBoolean(PreferenceConstants.JRUBY_USE_EXTERNAL_GEMS)) {
260234
val str = RubyScriptNodePlugin.getDefault.getPreferenceStore.getString(PreferenceConstants.JRUBY_PATH)
261235
System.setProperty("jruby.home", str)
262236
}
263-
var container: ScriptingContainer = null
264-
container = new ScriptingContainer(LocalContextScope.THREADSAFE)
237+
var container = new ScriptingContainer(LocalContextScope.THREADSAFE)
265238
container.setCompatVersion(CompatVersion.RUBY2_0)
266239
container.setCompileMode(CompileMode.JIT)
267240
container.setLoadPaths(classpath)
@@ -310,11 +283,6 @@ end
310283
exec.createBufferedDataTable(outContainer(i).getTable, exec)
311284
}
312285

313-
// val result = Array.ofDim[BufferedDataTable](numOutputs)
314-
// for (i <- 0 to numOutputs - 1) {
315-
// outContainer(i).close()
316-
// result(i) = exec.createBufferedDataTable(outContainer(i).getTable, exec)
317-
// }
318286
result
319287
}
320288

@@ -404,16 +372,6 @@ end
404372
private def findErrorSource(thr: Throwable, filename: String): Int = {
405373
val err = thr.getMessage
406374
if (err.startsWith("(SyntaxError)")) {
407-
// val pLineS = Pattern.compile("(?<=:)(\\d+):(.*)")
408-
// val mLine = pLineS.matcher(err)
409-
// if (mLine.find()) {
410-
// logger.debug("SyntaxError error line: " + mLine.group(1))
411-
// script_error.text = if (mLine.group(2) == null) script_error.text else mLine.group(2)
412-
// logger.debug("SyntaxError: " + script_error.text)
413-
// script_error.lineNum = java.lang.Integer.parseInt(mLine.group(1))
414-
// script_error.columnNum = -1
415-
// script_error.`type` = "SyntaxError"
416-
// }
417375
val pLineS = """(?<=:)(\d+):(.*)""".r
418376
err match {
419377
case pLineS(line, text) =>
@@ -427,11 +385,6 @@ end
427385
}
428386

429387
} else {
430-
// val `type` = Pattern.compile("(?<=\\()(\\w*)")
431-
// val mLine = `type`.matcher(err)
432-
// if (mLine.find()) {
433-
// script_error.`type` = mLine.group(1)
434-
// }
435388
script_error.errType = """(?<=\()(\w*)""".r
436389
.findFirstMatchIn(err).map(_ group 2).getOrElse(script_error.errType)
437390

@@ -443,11 +396,6 @@ end
443396
script_error.columnNum = -1
444397
script_error.lineNum = line.getLineNumber
445398
script_error.text = thr.getMessage
446-
// val knimeType = Pattern.compile("(?<=org.knime.)(.*)(?=:)")
447-
// val mKnimeType = knimeType.matcher(script_error.text)
448-
// script_error.`type` =
449-
// if (mKnimeType.find()) mKnimeType.group(1) else "RuntimeError"
450-
451399
script_error.errType = """(?<=org.knime.)(.*)(?=:)""".r
452400
.findFirstMatchIn(err).map(_ group 1).getOrElse("RuntimeError")
453401
//break
@@ -460,14 +408,6 @@ end
460408
(if (script_error.columnNum != -1) " at column " + script_error.columnNum)
461409
})
462410

463-
// if (script_error.lineNum != -1) {
464-
// script_error.msg += " stopped with error in line " + script_error.lineNum
465-
// if (script_error.columnNum != -1) {
466-
// script_error.msg += " at column " + script_error.columnNum
467-
// }
468-
// } else {
469-
// script_error.msg += "] stopped with error at line --unknown--"
470-
// }
471411
if (script_error.errType == "RuntimeError") {
472412
logger.error(script_error.msg + "\n" + script_error.errType + " ( " + script_error.text + " )")
473413
val cause = thr.getCause

RubyScript/src/org/knime/ext/jruby/preferences/PreferenceConstants.scala

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,4 @@ object PreferenceConstants {
1212
val JRUBY_PATH = "pathPreference"
1313

1414
val JRUBY_USE_EXTERNAL_GEMS = "booleanPreference"
15-
16-
/*
17-
Original Java:
18-
package org.knime.ext.jruby.preferences;
19-
20-
|**
21-
* Constant definitions for plug-in preferences.
22-
*|
23-
public class PreferenceConstants {
24-
public static final String JRUBY_PLUGIN = "org.knime.ext.jruby";
25-
26-
public static final String JRUBY_PATH = "pathPreference";
27-
28-
public static final String JRUBY_USE_EXTERNAL_GEMS = "booleanPreference";
29-
3015
}
31-
32-
*/
33-
}

RubyScript/src/org/knime/ext/jruby/preferences/PreferenceInitializer.scala

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -20,35 +20,4 @@ class PreferenceInitializer extends AbstractPreferenceInitializer {
2020
store.setDefault(PreferenceConstants.JRUBY_USE_EXTERNAL_GEMS, false)
2121
store.setDefault(PreferenceConstants.JRUBY_PATH, "")
2222
}
23-
24-
/*
25-
Original Java:
26-
package org.knime.ext.jruby.preferences;
27-
28-
import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
29-
import org.eclipse.jface.preference.IPreferenceStore;
30-
31-
import org.knime.ext.jruby.RubyScriptNodePlugin;
32-
33-
|**
34-
* Class used to initialize default preference values.
35-
*|
36-
public class PreferenceInitializer extends AbstractPreferenceInitializer {
37-
38-
|*
39-
* (non-Javadoc)
40-
*
41-
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#
42-
* initializeDefaultPreferences()
43-
*|
44-
public final void initializeDefaultPreferences() {
45-
IPreferenceStore store = RubyScriptNodePlugin.getDefault()
46-
.getPreferenceStore();
47-
store.setDefault(PreferenceConstants.JRUBY_USE_EXTERNAL_GEMS, false);
48-
store.setDefault(PreferenceConstants.JRUBY_PATH, "");
49-
}
50-
5123
}
52-
53-
*/
54-
}

RubyScript/src/org/knime/ext/jruby/preferences/RubyScriptPreferencePage.scala

Lines changed: 6 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -19,73 +19,17 @@ class RubyScriptPreferencePage extends FieldEditorPreferencePage with IWorkbench
1919
* @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
2020
*/
2121
def createFieldEditors() {
22-
addField(new BooleanFieldEditor(PreferenceConstants.JRUBY_USE_EXTERNAL_GEMS, "&Use external jRuby gems", getFieldEditorParent))
23-
addField(new DirectoryFieldEditor(PreferenceConstants.JRUBY_PATH, "&Root path of external jRuby installation:", getFieldEditorParent))
22+
addField(
23+
new BooleanFieldEditor(PreferenceConstants.JRUBY_USE_EXTERNAL_GEMS,
24+
"&Use external jRuby gems", getFieldEditorParent))
25+
addField(
26+
new DirectoryFieldEditor(PreferenceConstants.JRUBY_PATH,
27+
"&Root path of external jRuby installation:", getFieldEditorParent))
2428
}
2529

2630
/* (non-Javadoc)
2731
* @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
2832
*/
2933
def init(workbench: IWorkbench) {
3034
}
31-
32-
/*
33-
Original Java:
34-
package org.knime.ext.jruby.preferences;
35-
36-
import org.eclipse.jface.preference.*;
37-
import org.eclipse.ui.IWorkbenchPreferencePage;
38-
import org.eclipse.ui.IWorkbench;
39-
import org.knime.ext.jruby.RubyScriptNodePlugin;
40-
41-
|**
42-
* This class represents a preference page that is contributed to the
43-
* Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>, we
44-
* can use the field support built into JFace that allows us to create a page
45-
* that is small and knows how to save, restore and apply itself.
46-
* <p>
47-
* This page is used to modify preferences only. They are stored in the
48-
* preference store that belongs to the main plug-in class. That way,
49-
* preferences can be accessed directly via the preference store.
50-
*|
51-
52-
public class RubyScriptPreferencePage extends FieldEditorPreferencePage
53-
implements IWorkbenchPreferencePage {
54-
55-
public RubyScriptPreferencePage() {
56-
super(GRID);
57-
setPreferenceStore(RubyScriptNodePlugin.getDefault()
58-
.getPreferenceStore());
59-
setDescription("Ruby Scripting preferences");
60-
61-
}
62-
63-
|**
64-
* Creates the field editors. Field editors are abstractions of the common
65-
* GUI blocks needed to manipulate various types of preferences. Each field
66-
* editor knows how to save and restore itself.
67-
*|
68-
public final void createFieldEditors() {
69-
addField(new BooleanFieldEditor(
70-
PreferenceConstants.JRUBY_USE_EXTERNAL_GEMS,
71-
"&Use external jRuby gems", getFieldEditorParent()));
72-
73-
addField(new DirectoryFieldEditor(PreferenceConstants.JRUBY_PATH,
74-
"&Root path of external jRuby installation:",
75-
getFieldEditorParent()));
76-
77-
}
78-
79-
|*
80-
* (non-Javadoc)
81-
*
82-
* @see
83-
* org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
84-
*|
85-
public void init(final IWorkbench workbench) {
86-
}
87-
8835
}
89-
90-
*/
91-
}

0 commit comments

Comments
 (0)