Skip to content
This repository was archived by the owner on Nov 4, 2020. It is now read-only.

Commit 6e46777

Browse files
committed
Merge pull request #18 from dscho/resource-leak
Fix resource leak warning, generics warning and remove DOS line endings.
2 parents 84141db + 0512317 commit 6e46777

20 files changed

+1656
-1652
lines changed

plugin.properties

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
commandCategoryName = EclipseScript
2-
commandCategoryDescription = Commands for using the EclipseScript plug-in
3-
commandRunLastName = EclipseScript: Run Last
4-
commandRunLastDescription = Run the last EclipseScript that has been executed
5-
commandRunCurrentName = EclipseScript: Run Current
6-
commandRunCurrentDescription = Run the currently edited EclipseScript
7-
commandRunScriptParameterName = Script
8-
commandOpenScriptDialogName = EclipseScript: Open Script Dialog
9-
commandOpenScriptDialogDescription = Search and select available scripts
10-
11-
markerName=EclipseScript Problem
12-
pluginName=EclipseScript
13-
bundleVendor=eclipsescript.org
14-
commandRunLastSequence = Ctrl+R
15-
commandRunCurrentSequence = Alt+R
16-
commandOpenScriptDialogSequence = M1+4
1+
commandCategoryName = EclipseScript
2+
commandCategoryDescription = Commands for using the EclipseScript plug-in
3+
commandRunLastName = EclipseScript: Run Last
4+
commandRunLastDescription = Run the last EclipseScript that has been executed
5+
commandRunCurrentName = EclipseScript: Run Current
6+
commandRunCurrentDescription = Run the currently edited EclipseScript
7+
commandRunScriptParameterName = Script
8+
commandOpenScriptDialogName = EclipseScript: Open Script Dialog
9+
commandOpenScriptDialogDescription = Search and select available scripts
10+
11+
markerName=EclipseScript Problem
12+
pluginName=EclipseScript
13+
bundleVendor=eclipsescript.org
14+
commandRunLastSequence = Ctrl+R
15+
commandRunCurrentSequence = Alt+R
16+
commandOpenScriptDialogSequence = M1+4

src/org/eclipsescript/core/Activator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void start(BundleContext bundleContext) throws Exception {
113113
// ServiceReference<PlatformAdmin> platformAdminServiceRef = context.getServiceReference(PlatformAdmin.class);
114114
// PlatformAdmin platformAdminService = context.getService(platformAdminServiceRef);
115115
// Eclipse 3.6 api:
116-
ServiceReference platformAdminServiceRef = context.getServiceReference(PlatformAdmin.class.getName());
116+
ServiceReference<?> platformAdminServiceRef = context.getServiceReference(PlatformAdmin.class.getName());
117117
PlatformAdmin platformAdminService = (PlatformAdmin) context.getService(platformAdminServiceRef);
118118

119119
resolver = platformAdminService.createResolver();
Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
package org.eclipsescript.core;
2-
3-
4-
import org.eclipse.core.commands.ExecutionEvent;
5-
import org.eclipse.core.resources.IFile;
6-
import org.eclipse.jface.dialogs.MessageDialog;
7-
import org.eclipse.ui.IEditorInput;
8-
import org.eclipse.ui.part.FileEditorInput;
9-
import org.eclipsescript.messages.Messages;
10-
import org.eclipsescript.scripts.ScriptLanguageHandler;
11-
import org.eclipsescript.scripts.ScriptMetadata;
12-
import org.eclipsescript.scripts.ScriptStore;
13-
import org.eclipsescript.ui.ErrorHandlingHandler;
14-
import org.eclipsescript.util.EclipseUtils;
15-
16-
public class RunCurrentHandler extends ErrorHandlingHandler {
17-
18-
@Override
19-
protected void doExecute(ExecutionEvent event) throws Exception {
20-
IEditorInput editorInput = EclipseUtils.getCurrentEditorInput();
21-
if (editorInput instanceof FileEditorInput) {
22-
FileEditorInput fileInput = (FileEditorInput) editorInput;
23-
IFile editedFile = fileInput.getFile();
24-
boolean isScriptFile = ScriptLanguageHandler.isEclipseScriptFile(editedFile);
25-
if (isScriptFile) {
26-
ScriptMetadata m = new ScriptMetadata(fileInput.getFile());
27-
ScriptStore.executeScript(m);
28-
return;
29-
}
30-
}
31-
MessageDialog.openInformation(EclipseUtils.getWindowShell(), Messages.cannotRunCurrentScriptTitle,
32-
Messages.cannotRunCurrentScriptText);
33-
}
34-
35-
}
1+
package org.eclipsescript.core;
2+
3+
4+
import org.eclipse.core.commands.ExecutionEvent;
5+
import org.eclipse.core.resources.IFile;
6+
import org.eclipse.jface.dialogs.MessageDialog;
7+
import org.eclipse.ui.IEditorInput;
8+
import org.eclipse.ui.part.FileEditorInput;
9+
import org.eclipsescript.messages.Messages;
10+
import org.eclipsescript.scripts.ScriptLanguageHandler;
11+
import org.eclipsescript.scripts.ScriptMetadata;
12+
import org.eclipsescript.scripts.ScriptStore;
13+
import org.eclipsescript.ui.ErrorHandlingHandler;
14+
import org.eclipsescript.util.EclipseUtils;
15+
16+
public class RunCurrentHandler extends ErrorHandlingHandler {
17+
18+
@Override
19+
protected void doExecute(ExecutionEvent event) throws Exception {
20+
IEditorInput editorInput = EclipseUtils.getCurrentEditorInput();
21+
if (editorInput instanceof FileEditorInput) {
22+
FileEditorInput fileInput = (FileEditorInput) editorInput;
23+
IFile editedFile = fileInput.getFile();
24+
boolean isScriptFile = ScriptLanguageHandler.isEclipseScriptFile(editedFile);
25+
if (isScriptFile) {
26+
ScriptMetadata m = new ScriptMetadata(fileInput.getFile());
27+
ScriptStore.executeScript(m);
28+
return;
29+
}
30+
}
31+
MessageDialog.openInformation(EclipseUtils.getWindowShell(), Messages.cannotRunCurrentScriptTitle,
32+
Messages.cannotRunCurrentScriptText);
33+
}
34+
35+
}
Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
package org.eclipsescript.core;
2-
3-
4-
import org.eclipse.core.commands.ExecutionEvent;
5-
import org.eclipse.core.commands.ExecutionException;
6-
import org.eclipse.jface.dialogs.MessageDialog;
7-
import org.eclipsescript.messages.Messages;
8-
import org.eclipsescript.scripts.ScriptMetadata;
9-
import org.eclipsescript.scripts.ScriptStore;
10-
import org.eclipsescript.ui.ErrorHandlingHandler;
11-
import org.eclipsescript.util.EclipseUtils;
12-
13-
public class RunLastHandler extends ErrorHandlingHandler {
14-
15-
public static ScriptMetadata lastRun = null;
16-
17-
@Override
18-
public void doExecute(ExecutionEvent event) throws ExecutionException {
19-
if (lastRun == null) {
20-
MessageDialog.openWarning(EclipseUtils.activeWindow().getShell(), "No script to run", //$NON-NLS-1$
21-
Messages.runScriptBeforeRunningLast);
22-
} else {
23-
ScriptStore.executeScript(lastRun);
24-
}
25-
}
26-
}
1+
package org.eclipsescript.core;
2+
3+
4+
import org.eclipse.core.commands.ExecutionEvent;
5+
import org.eclipse.core.commands.ExecutionException;
6+
import org.eclipse.jface.dialogs.MessageDialog;
7+
import org.eclipsescript.messages.Messages;
8+
import org.eclipsescript.scripts.ScriptMetadata;
9+
import org.eclipsescript.scripts.ScriptStore;
10+
import org.eclipsescript.ui.ErrorHandlingHandler;
11+
import org.eclipsescript.util.EclipseUtils;
12+
13+
public class RunLastHandler extends ErrorHandlingHandler {
14+
15+
public static ScriptMetadata lastRun = null;
16+
17+
@Override
18+
public void doExecute(ExecutionEvent event) throws ExecutionException {
19+
if (lastRun == null) {
20+
MessageDialog.openWarning(EclipseUtils.activeWindow().getShell(), "No script to run", //$NON-NLS-1$
21+
Messages.runScriptBeforeRunningLast);
22+
} else {
23+
ScriptStore.executeScript(lastRun);
24+
}
25+
}
26+
}
Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
package org.eclipsescript.javascript;
2-
3-
import org.eclipsescript.javascript.CustomContextFactory.CustomContext;
4-
import org.eclipsescript.rhino.javascript.Context;
5-
import org.eclipsescript.rhino.javascript.ContextAction;
6-
import org.eclipsescript.rhino.javascript.ImporterTopLevel;
7-
import org.eclipsescript.rhino.javascript.ScriptableObject;
8-
import org.eclipsescript.scriptobjects.Eclipse;
9-
import org.eclipsescript.scripts.IScriptLanguageSupport;
10-
import org.eclipsescript.scripts.ScriptMetadata;
11-
12-
public class JavaScriptLanguageSupport implements IScriptLanguageSupport {
13-
14-
private final CustomContextFactory contextFactory = new CustomContextFactory();
15-
16-
@Override
17-
public void executeScript(final ScriptMetadata script) {
18-
contextFactory.call(new ContextAction() {
19-
@Override
20-
public Object run(Context _context) {
21-
if (!(_context instanceof CustomContext))
22-
throw new IllegalArgumentException("Wrong context class: " + _context.getClass()); //$NON-NLS-1$
23-
CustomContext context = (CustomContext) _context;
24-
ScriptableObject scope = new ImporterTopLevel(context);
25-
JavascriptRuntime jsRuntime = new JavascriptRuntime(context, scope, script);
26-
27-
Eclipse eclipseJavaObject = new Eclipse(jsRuntime);
28-
Object eclipseJsObject = Context.javaToJS(eclipseJavaObject, scope);
29-
ScriptableObject.putConstProperty(scope, Eclipse.VARIABLE_NAME, eclipseJsObject);
30-
31-
try {
32-
jsRuntime.evaluate(script.getFile(), false);
33-
} catch (Throwable e) {
34-
jsRuntime.handleExceptionFromScriptRuntime(e);
35-
}
36-
return null;
37-
}
38-
});
39-
}
40-
}
1+
package org.eclipsescript.javascript;
2+
3+
import org.eclipsescript.javascript.CustomContextFactory.CustomContext;
4+
import org.eclipsescript.rhino.javascript.Context;
5+
import org.eclipsescript.rhino.javascript.ContextAction;
6+
import org.eclipsescript.rhino.javascript.ImporterTopLevel;
7+
import org.eclipsescript.rhino.javascript.ScriptableObject;
8+
import org.eclipsescript.scriptobjects.Eclipse;
9+
import org.eclipsescript.scripts.IScriptLanguageSupport;
10+
import org.eclipsescript.scripts.ScriptMetadata;
11+
12+
public class JavaScriptLanguageSupport implements IScriptLanguageSupport {
13+
14+
private final CustomContextFactory contextFactory = new CustomContextFactory();
15+
16+
@Override
17+
public void executeScript(final ScriptMetadata script) {
18+
contextFactory.call(new ContextAction() {
19+
@Override
20+
public Object run(Context _context) {
21+
if (!(_context instanceof CustomContext))
22+
throw new IllegalArgumentException("Wrong context class: " + _context.getClass()); //$NON-NLS-1$
23+
CustomContext context = (CustomContext) _context;
24+
ScriptableObject scope = new ImporterTopLevel(context);
25+
JavascriptRuntime jsRuntime = new JavascriptRuntime(context, scope, script);
26+
27+
Eclipse eclipseJavaObject = new Eclipse(jsRuntime);
28+
Object eclipseJsObject = Context.javaToJS(eclipseJavaObject, scope);
29+
ScriptableObject.putConstProperty(scope, Eclipse.VARIABLE_NAME, eclipseJsObject);
30+
31+
try {
32+
jsRuntime.evaluate(script.getFile(), false);
33+
} catch (Throwable e) {
34+
jsRuntime.handleExceptionFromScriptRuntime(e);
35+
}
36+
return null;
37+
}
38+
});
39+
}
40+
}
Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,44 @@
1-
package org.eclipsescript.messages;
2-
3-
import org.eclipse.osgi.util.NLS;
4-
5-
/**
6-
* Localization messages using the {@link NLS} system. The static initializer block will initialize the fields of this
7-
* class with values loaded from the messages properties file.
8-
*/
9-
public class Messages extends NLS {
10-
11-
private static final String BUNDLE_NAME = Messages.class.getPackage().getName() + ".messages"; //$NON-NLS-1$
12-
13-
public static String cannotRunCurrentScriptText;
14-
public static String cannotRunCurrentScriptTitle;
15-
public static String clearMarkersJobName;
16-
public static String fileToIncludeDoesNotExist;
17-
public static String fileToReadDoesNotExist;
18-
public static String internalErrorDialogDetails;
19-
public static String internalErrorDialogText;
20-
public static String internalErrorDialogTitle;
21-
public static String noDocumentSelected;
22-
public static String noSelectionSelected;
23-
public static String noTextEditorSelected;
24-
public static String notPossibleToScheduleObject;
25-
public static String removeAllTerminatedConsoles;
26-
public static String Resources_cannotReadFromObject;
27-
public static String runScriptBeforeRunningLast;
28-
public static String scriptAlertDialogTitle;
29-
public static String scriptBackgroundJobName;
30-
public static String scriptConfirmDialogTitle;
31-
public static String scriptConsoleName;
32-
public static String scriptErrorWhenRunningScriptDialogText;
33-
public static String scriptErrorWhenRunningScriptDialogTitle;
34-
public static String scriptErrorWhenRunningScriptJumpToScriptButton;
35-
public static String scriptErrorWhenRunningScriptOkButton;
36-
public static String scriptPromptDialogTitle;
37-
public static String scriptTimeout;
38-
public static String windowOpenArgumentNull;
39-
40-
static {
41-
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
42-
}
43-
44-
}
1+
package org.eclipsescript.messages;
2+
3+
import org.eclipse.osgi.util.NLS;
4+
5+
/**
6+
* Localization messages using the {@link NLS} system. The static initializer block will initialize the fields of this
7+
* class with values loaded from the messages properties file.
8+
*/
9+
public class Messages extends NLS {
10+
11+
private static final String BUNDLE_NAME = Messages.class.getPackage().getName() + ".messages"; //$NON-NLS-1$
12+
13+
public static String cannotRunCurrentScriptText;
14+
public static String cannotRunCurrentScriptTitle;
15+
public static String clearMarkersJobName;
16+
public static String fileToIncludeDoesNotExist;
17+
public static String fileToReadDoesNotExist;
18+
public static String internalErrorDialogDetails;
19+
public static String internalErrorDialogText;
20+
public static String internalErrorDialogTitle;
21+
public static String noDocumentSelected;
22+
public static String noSelectionSelected;
23+
public static String noTextEditorSelected;
24+
public static String notPossibleToScheduleObject;
25+
public static String removeAllTerminatedConsoles;
26+
public static String Resources_cannotReadFromObject;
27+
public static String runScriptBeforeRunningLast;
28+
public static String scriptAlertDialogTitle;
29+
public static String scriptBackgroundJobName;
30+
public static String scriptConfirmDialogTitle;
31+
public static String scriptConsoleName;
32+
public static String scriptErrorWhenRunningScriptDialogText;
33+
public static String scriptErrorWhenRunningScriptDialogTitle;
34+
public static String scriptErrorWhenRunningScriptJumpToScriptButton;
35+
public static String scriptErrorWhenRunningScriptOkButton;
36+
public static String scriptPromptDialogTitle;
37+
public static String scriptTimeout;
38+
public static String windowOpenArgumentNull;
39+
40+
static {
41+
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
42+
}
43+
44+
}
Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
internalErrorDialogTitle=EclipseScript Internal Error
2-
internalErrorDialogText=The error has been logged. See below for details.
3-
internalErrorDialogDetails=Plug-in name: {0}\nPlug-in ID: {1}\nVersion: {2}\n\n{3}
4-
runScriptBeforeRunningLast=No EclipseScript script has been run\!
5-
scriptAlertDialogTitle=EclipseScript Alert
6-
scriptConfirmDialogTitle=EclipseScript Prompt
7-
scriptConsoleName=EclipseScript: {0}
8-
scriptErrorWhenRunningScriptDialogTitle=EclipseScript Error
9-
scriptErrorWhenRunningScriptDialogText=Execution of the script "{0}" failed at line {2} with the following message:\n\n{1}
10-
scriptErrorWhenRunningScriptJumpToScriptButton=&Go to script
11-
scriptErrorWhenRunningScriptOkButton=&Ok
12-
scriptTimeout = Script timeout after {0} seconds.\n\nTry using the eclipse.runtime.schedule(runnable) function for long-running background tasks.
13-
scriptBackgroundJobName=EclipseScript: {0}
14-
scriptPromptDialogTitle=EclipseScript Prompt
15-
cannotRunCurrentScriptText=Cannot run the currently edited script
16-
cannotRunCurrentScriptTitle=Cannot run
17-
clearMarkersJobName=Clear script markers
18-
fileToIncludeDoesNotExist=File does not exist:
19-
fileToReadDoesNotExist=File to read does not exist:
20-
noDocumentSelected=No document selected\!
21-
noSelectionSelected=No selection selected\!
22-
noTextEditorSelected=No text editor selected\!
23-
notPossibleToScheduleObject=Not possible to schedule object:
24-
Resources_cannotReadFromObject=Cannot read from object:
25-
windowOpenArgumentNull=The urlString argument to open(urlString) was null
1+
internalErrorDialogTitle=EclipseScript Internal Error
2+
internalErrorDialogText=The error has been logged. See below for details.
3+
internalErrorDialogDetails=Plug-in name: {0}\nPlug-in ID: {1}\nVersion: {2}\n\n{3}
4+
runScriptBeforeRunningLast=No EclipseScript script has been run\!
5+
scriptAlertDialogTitle=EclipseScript Alert
6+
scriptConfirmDialogTitle=EclipseScript Prompt
7+
scriptConsoleName=EclipseScript: {0}
8+
scriptErrorWhenRunningScriptDialogTitle=EclipseScript Error
9+
scriptErrorWhenRunningScriptDialogText=Execution of the script "{0}" failed at line {2} with the following message:\n\n{1}
10+
scriptErrorWhenRunningScriptJumpToScriptButton=&Go to script
11+
scriptErrorWhenRunningScriptOkButton=&Ok
12+
scriptTimeout = Script timeout after {0} seconds.\n\nTry using the eclipse.runtime.schedule(runnable) function for long-running background tasks.
13+
scriptBackgroundJobName=EclipseScript: {0}
14+
scriptPromptDialogTitle=EclipseScript Prompt
15+
cannotRunCurrentScriptText=Cannot run the currently edited script
16+
cannotRunCurrentScriptTitle=Cannot run
17+
clearMarkersJobName=Clear script markers
18+
fileToIncludeDoesNotExist=File does not exist:
19+
fileToReadDoesNotExist=File to read does not exist:
20+
noDocumentSelected=No document selected\!
21+
noSelectionSelected=No selection selected\!
22+
noTextEditorSelected=No text editor selected\!
23+
notPossibleToScheduleObject=Not possible to schedule object:
24+
Resources_cannotReadFromObject=Cannot read from object:
25+
windowOpenArgumentNull=The urlString argument to open(urlString) was null
2626
removeAllTerminatedConsoles=Remove All EclipseScript Consoles

0 commit comments

Comments
 (0)