You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by pk...@apache.org on 2013/04/02 13:29:25 UTC
svn commit: r1463490 - in /uima/sandbox/textmarker/trunk/textmarker-ep-ide:
./ src/main/java/org/apache/uima/textmarker/ide/
src/main/java/org/apache/uima/textmarker/ide/core/codeassist/
src/main/java/org/apache/uima/textmarker/ide/formatter/ src/main/...
Author: pkluegl
Date: Tue Apr 2 11:29:24 2013
New Revision: 1463490
URL: http://svn.apache.org/r1463490
Log:
UIMA-2519
- keeping InterpreterInstall, but added check on "install" location
- organized imports
Modified:
uima/sandbox/textmarker/trunk/textmarker-ep-ide/plugin.xml
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/TextMarkerIdePlugin.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/TextMarkerFormatter.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/GenericTextMarkerInstall.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/GenericTextMarkerInstallType.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConfigurationDelegate.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerVarRefChecker.java
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/plugin.xml
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/plugin.xml?rev=1463490&r1=1463489&r2=1463490&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/plugin.xml (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/plugin.xml Tue Apr 2 11:29:24 2013
@@ -506,7 +506,7 @@ under the License.
<buildpathContainerPath
class="org.apache.uima.textmarker.ide.debug.ui.interpreters.TextMarkerInterpreterContainerWizardPage"
id="org.apache.uima.textmarker.ide.launching.INTERPRETER_CONTAINER"
- name="textmarker Interpreter Libraries"
+ name="TextMarker Interpreter Libraries"
nature="org.apache.uima.textmarker.ide.nature" />
</extension>
<extension point="org.eclipse.ui.perspectiveExtensions">
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/TextMarkerIdePlugin.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/TextMarkerIdePlugin.java?rev=1463490&r1=1463489&r2=1463490&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/TextMarkerIdePlugin.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/TextMarkerIdePlugin.java Tue Apr 2 11:29:24 2013
@@ -19,18 +19,30 @@
package org.apache.uima.textmarker.ide;
+import java.io.File;
import java.io.IOException;
+import java.net.URL;
import java.util.ArrayList;
import java.util.List;
+import org.apache.uima.textmarker.ide.core.TextMarkerNature;
import org.apache.uima.textmarker.ide.ui.text.TextMarkerTextTools;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.dltk.core.environment.FileAsFileHandle;
import org.eclipse.dltk.core.environment.IDeployment;
+import org.eclipse.dltk.core.environment.IEnvironment;
import org.eclipse.dltk.core.environment.IExecutionEnvironment;
import org.eclipse.dltk.core.environment.IFileHandle;
+import org.eclipse.dltk.core.internal.environment.LocalEnvironment;
+import org.eclipse.dltk.launching.IInterpreterInstall;
+import org.eclipse.dltk.launching.ScriptRuntime;
+import org.eclipse.dltk.launching.ScriptRuntime.DefaultInterpreterEntry;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbench;
@@ -53,7 +65,7 @@ public class TextMarkerIdePlugin extends
private TextMarkerTextTools textTools;
private BundleContext bundleContext;
-
+
// The shared instance
private static TextMarkerIdePlugin plugin;
@@ -72,6 +84,9 @@ public class TextMarkerIdePlugin extends
super.start(context);
plugin = this;
bundleContext = context;
+
+ checkTextMarkerInterpreter();
+
IWorkbench workbench = PlatformUI.getWorkbench();
workbench.addWorkbenchListener(new IWorkbenchListener() {
public boolean preShutdown(IWorkbench workbench, boolean forced) {
@@ -138,24 +153,49 @@ public class TextMarkerIdePlugin extends
path.append("ConsoleProxy.tm");
return deployment.getFile(path);
}
-
+
public Bundle getBundle(String bundleName) {
Bundle[] bundles = getBundles(bundleName, null);
if (bundles != null && bundles.length > 0)
return bundles[0];
return null;
}
-
-public Bundle[] getBundles(String bundleName, String version) {
+
+ public Bundle[] getBundles(String bundleName, String version) {
Bundle[] bundles = Platform.getBundles(bundleName, version);
if (bundles != null)
return bundles;
// Accessing bundle which is not resolved
- PackageAdmin admin = (PackageAdmin) bundleContext.getService(
- bundleContext.getServiceReference(PackageAdmin.class.getName()));
+ PackageAdmin admin = (PackageAdmin) bundleContext.getService(bundleContext
+ .getServiceReference(PackageAdmin.class.getName()));
bundles = admin.getBundles(bundleName, version);
if (bundles != null && bundles.length > 0)
return bundles;
return null;
}
+
+ public String pluginIdToJarPath(String pluginId) throws IOException {
+ Bundle bundle = getBundle(pluginId);
+ URL url = bundle.getEntry("/");
+ if (url == null) {
+ throw new IOException();
+ }
+ return FileLocator.toFileURL(url).getFile();
+ }
+
+ private void checkTextMarkerInterpreter() throws IOException, CoreException {
+ IEnvironment localEnv = LocalEnvironment.getInstance();
+ DefaultInterpreterEntry defaultInterpreterEntry = new DefaultInterpreterEntry(
+ TextMarkerNature.NATURE_ID, localEnv.getId());
+ IInterpreterInstall defaultInterpreterInstall = ScriptRuntime.getDefaultInterpreterInstall(defaultInterpreterEntry);
+ IFileHandle rawInstallLocation = defaultInterpreterInstall.getRawInstallLocation();
+ if(!rawInstallLocation.exists()) {
+ String pluginIdToJarPath = pluginIdToJarPath(TextMarkerIdePlugin.PLUGIN_ID);
+ FileAsFileHandle fh = new FileAsFileHandle(new File(pluginIdToJarPath));
+ defaultInterpreterInstall.setInstallLocation(fh);
+ ScriptRuntime.setDefaultInterpreterInstall(defaultInterpreterInstall, new NullProgressMonitor());
+
+ }
+ }
+
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java?rev=1463490&r1=1463489&r2=1463490&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/codeassist/TextMarkerCompletionEngine.java Tue Apr 2 11:29:24 2013
@@ -42,7 +42,6 @@ import org.apache.uima.textmarker.ide.co
import org.apache.uima.textmarker.ide.core.parser.TextMarkerParseUtils;
import org.apache.uima.textmarker.ide.parser.ast.ComponentDeclaration;
import org.apache.uima.textmarker.ide.parser.ast.ComponentReference;
-import org.apache.uima.textmarker.ide.parser.ast.TMExpressionConstants;
import org.apache.uima.textmarker.ide.parser.ast.TMTypeConstants;
import org.apache.uima.textmarker.ide.parser.ast.TextMarkerAction;
import org.apache.uima.textmarker.ide.parser.ast.TextMarkerCondition;
@@ -57,7 +56,6 @@ import org.eclipse.core.resources.IResou
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.dltk.ast.ASTNode;
-import org.eclipse.dltk.ast.declarations.TypeDeclaration;
import org.eclipse.dltk.codeassist.RelevanceConstants;
import org.eclipse.dltk.codeassist.ScriptCompletionEngine;
import org.eclipse.dltk.compiler.CharOperation;
@@ -68,7 +66,6 @@ import org.eclipse.dltk.core.IMethod;
import org.eclipse.dltk.core.IModelElement;
import org.eclipse.dltk.core.IType;
import org.eclipse.dltk.core.ModelException;
-import org.eclipse.dltk.internal.core.ModelManager;
import org.eclipse.dltk.internal.core.SourceField;
import org.eclipse.dltk.internal.core.SourceMethod;
import org.eclipse.dltk.internal.core.SourceModule;
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/TextMarkerFormatter.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/TextMarkerFormatter.java?rev=1463490&r1=1463489&r2=1463490&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/TextMarkerFormatter.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/formatter/TextMarkerFormatter.java Tue Apr 2 11:29:24 2013
@@ -29,7 +29,6 @@ import org.antlr.runtime.BitSet;
import org.antlr.runtime.CommonToken;
import org.antlr.runtime.CommonTokenStream;
import org.apache.commons.lang3.StringUtils;
-import org.apache.uima.textmarker.ide.core.parser.TextMarkerParser;
import org.apache.uima.textmarker.ide.core.parser.TextMarkerSourceParser;
import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
import org.eclipse.dltk.ast.parser.IModuleDeclaration;
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/GenericTextMarkerInstall.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/GenericTextMarkerInstall.java?rev=1463490&r1=1463489&r2=1463490&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/GenericTextMarkerInstall.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/GenericTextMarkerInstall.java Tue Apr 2 11:29:24 2013
@@ -33,6 +33,10 @@ import org.eclipse.dltk.launching.IInter
public class GenericTextMarkerInstall extends AbstractInterpreterInstall {
+ public GenericTextMarkerInstall(IInterpreterInstallType type, String id) {
+ super(type, id);
+ }
+
@Override
public String getBuiltinModuleContent(String name) {
InputStream stream = GenericTextMarkerInstall.class.getResourceAsStream("builtins.tm");
@@ -57,11 +61,8 @@ public class GenericTextMarkerInstall ex
public String[] getBuiltinModules() {
return new String[] { "builtins.tm" };
}
-
- public GenericTextMarkerInstall(IInterpreterInstallType type, String id) {
- super(type, id);
- }
-
+
+
@Override
public IInterpreterRunner getInterpreterRunner(String mode) {
IInterpreterRunner runner = super.getInterpreterRunner(mode);
@@ -78,4 +79,5 @@ public class GenericTextMarkerInstall ex
public String getNatureId() {
return TextMarkerNature.NATURE_ID;
}
+
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/GenericTextMarkerInstallType.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/GenericTextMarkerInstallType.java?rev=1463490&r1=1463489&r2=1463490&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/GenericTextMarkerInstallType.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/GenericTextMarkerInstallType.java Tue Apr 2 11:29:24 2013
@@ -92,11 +92,10 @@ public class GenericTextMarkerInstallTyp
@Override
protected String[] parsePaths(String result) {
- ArrayList paths = new ArrayList();
+ ArrayList<String> paths = new ArrayList<String>();
String subs = null;
int index = 0;
while (index < result.length()) {
- // skip whitespaces
while (index < result.length() && Character.isWhitespace(result.charAt(index)))
index++;
if (index == result.length())
@@ -127,4 +126,5 @@ public class GenericTextMarkerInstallTyp
protected ILog getLog() {
return TextMarkerIdePlugin.getDefault().getLog();
}
+
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConfigurationDelegate.java?rev=1463490&r1=1463489&r2=1463490&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConfigurationDelegate.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/launching/TextMarkerLaunchConfigurationDelegate.java Tue Apr 2 11:29:24 2013
@@ -32,14 +32,10 @@ import java.util.Map;
import org.apache.uima.textmarker.ide.TextMarkerIdePlugin;
import org.apache.uima.textmarker.ide.core.TextMarkerCorePreferences;
import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils;
-import org.eclipse.core.internal.resources.Project;
-import org.eclipse.core.internal.resources.Workspace;
import org.eclipse.core.resources.IBuildConfiguration;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
@@ -53,21 +49,15 @@ import org.eclipse.core.runtime.Qualifie
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationType;
import org.eclipse.dltk.core.DLTKCore;
import org.eclipse.dltk.core.IBuildpathEntry;
import org.eclipse.dltk.core.IScriptProject;
-import org.eclipse.dltk.core.ScriptProjectUtil;
-import org.eclipse.dltk.internal.core.ScriptProject;
import org.eclipse.dltk.launching.AbstractScriptLaunchConfigurationDelegate;
-import org.eclipse.dltk.launching.InterpreterConfig;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
-import org.eclipse.jdt.internal.core.JavaProject;
import org.eclipse.jdt.launching.JavaLaunchDelegate;
import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.ui.internal.Workbench;
import org.osgi.framework.Bundle;
public class TextMarkerLaunchConfigurationDelegate extends JavaLaunchDelegate {
@@ -116,6 +106,7 @@ public class TextMarkerLaunchConfigurati
@Override
public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException {
+ TextMarkerIdePlugin d = TextMarkerIdePlugin.getDefault();
// The class path already contains the jars which are specified in the Classpath tab
List<String> extendedClasspath = new ArrayList<String>();
Collections.addAll(extendedClasspath, super.getClasspath(configuration));
@@ -152,12 +143,12 @@ public class TextMarkerLaunchConfigurati
if (!Platform.inDevelopmentMode()) {
try {
// Add this plugin jar to the classpath
- extendedClasspath.add(pluginIdToJarPath(TextMarkerIdePlugin.PLUGIN_ID));
+ extendedClasspath.add(d.pluginIdToJarPath(TextMarkerIdePlugin.PLUGIN_ID));
// UIMA jar should be added the end of the class path, because user uima jars
// (maybe a different version) should appear first on the class path
- extendedClasspath.add(pluginIdToJarPath("org.apache.uima.runtime"));
- extendedClasspath.add(pluginIdToJarPath("org.apache.uima.textmarker.engine"));
+ extendedClasspath.add(d.pluginIdToJarPath("org.apache.uima.runtime"));
+ extendedClasspath.add(d.pluginIdToJarPath("org.apache.uima.textmarker.engine"));
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, TextMarkerIdePlugin.PLUGIN_ID,
IStatus.OK, "Failed to compose classpath!", e));
@@ -169,7 +160,7 @@ public class TextMarkerLaunchConfigurati
else {
try {
// Add classes folder of this plugin to class path
- extendedClasspath.add(pluginIdToJarPath(TextMarkerIdePlugin.PLUGIN_ID) + "target/classes");
+ extendedClasspath.add(d.pluginIdToJarPath(TextMarkerIdePlugin.PLUGIN_ID) + "target/classes");
// Add org.apache.uima.runtime jar to class path
Bundle bundle = TextMarkerIdePlugin.getDefault().getBundle("org.apache.uima.runtime");
@@ -178,7 +169,7 @@ public class TextMarkerLaunchConfigurati
if (bundle != null) {
Enumeration<?> jarEnum = bundle.findEntries("/", "*.jar", true);
if (jarEnum == null) {
- extendedClasspath.add(pluginIdToJarPath("org.apache.uima.runtime"));
+ extendedClasspath.add(d.pluginIdToJarPath("org.apache.uima.runtime"));
}
while (jarEnum != null && jarEnum.hasMoreElements()) {
URL element = (URL) jarEnum.nextElement();
@@ -249,13 +240,6 @@ public class TextMarkerLaunchConfigurati
}
}
- private String pluginIdToJarPath(String pluginId) throws IOException {
- Bundle bundle = TextMarkerIdePlugin.getDefault().getBundle(pluginId);
- URL url = bundle.getEntry("/");
- if (url == null) {
- throw new IOException();
- }
- return FileLocator.toFileURL(url).getFile();
- }
+
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerVarRefChecker.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerVarRefChecker.java?rev=1463490&r1=1463489&r2=1463490&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerVarRefChecker.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/validator/TextMarkerVarRefChecker.java Tue Apr 2 11:29:24 2013
@@ -36,7 +36,6 @@ import org.apache.uima.resource.metadata
import org.apache.uima.resource.metadata.TypeDescription;
import org.apache.uima.resource.metadata.TypeSystemDescription;
import org.apache.uima.textmarker.ide.core.ITextMarkerKeywords;
-import org.apache.uima.textmarker.ide.core.TextMarkerKeywords;
import org.apache.uima.textmarker.ide.core.TextMarkerKeywordsManager;
import org.apache.uima.textmarker.ide.core.builder.TextMarkerProjectUtils;
import org.apache.uima.textmarker.ide.parser.ast.TMActionConstants;