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/29 16:51:06 UTC
svn commit: r1477113 [2/18] - in
/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide:
./ core/ core/builder/ core/codeassist/ core/extensions/ core/packages/
core/parser/ core/search/ debug/ debug/ui/ debug/ui/handlers/ debug/ui...
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaCalleeProcessor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaCalleeProcessor.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaCalleeProcessor.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaCalleeProcessor.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,209 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.core;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.dltk.ast.references.SimpleReference;
+import org.eclipse.dltk.compiler.SourceElementRequestorAdaptor;
+import org.eclipse.dltk.compiler.env.MethodSourceCode;
+import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.dltk.core.DLTKLanguageManager;
+import org.eclipse.dltk.core.ICalleeProcessor;
+import org.eclipse.dltk.core.IMethod;
+import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.ISourceElementParser;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.core.search.IDLTKSearchScope;
+import org.eclipse.dltk.core.search.SearchEngine;
+import org.eclipse.dltk.core.search.SearchParticipant;
+import org.eclipse.dltk.core.search.SearchPattern;
+import org.eclipse.dltk.core.search.SearchRequestor;
+
+
+public class RutaCalleeProcessor implements ICalleeProcessor {
+ protected static int EXACT_RULE = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
+
+ private Map fSearchResults = new HashMap();
+
+ private IMethod method;
+
+ // private IDLTKSearchScope scope;
+
+ public RutaCalleeProcessor(IMethod method, IProgressMonitor monitor, IDLTKSearchScope scope) {
+ this.method = method;
+ // this.scope = scope;
+ }
+
+ private class CaleeSourceElementRequestor extends SourceElementRequestorAdaptor {
+
+ @Override
+ public void acceptMethodReference(String methodName, int argCount,
+ int sourcePosition, int sourceEndPosition) {
+ String name = new String(methodName);
+ int off = 0;
+ try {
+ off = method.getSourceRange().getOffset();
+ } catch (ModelException e) {
+ if (DLTKCore.DEBUG) {
+ e.printStackTrace();
+ }
+ }
+ SimpleReference ref = new SimpleReference(off + sourcePosition, off + sourceEndPosition, name);
+ IMethod[] methods = findMethods(name, argCount, off + sourcePosition);
+ fSearchResults.put(ref, methods);
+ }
+ }
+
+ public Map doOperation() {
+ try {
+ if (method.getSource() != null) {
+ CaleeSourceElementRequestor requestor = new CaleeSourceElementRequestor();
+ ISourceElementParser parser = DLTKLanguageManager
+ .getSourceElementParser(RutaNature.NATURE_ID);
+ parser.setRequestor(requestor);
+ parser.parseSourceModule(new MethodSourceCode(method));
+ } else {
+ // TODO: Report error here.
+ }
+ return fSearchResults;
+ } catch (ModelException e) {
+ if (DLTKCore.DEBUG) {
+ e.printStackTrace();
+ }
+ } catch (CoreException e) {
+ if (DLTKCore.DEBUG) {
+ e.printStackTrace();
+ }
+ }
+ return fSearchResults;
+ }
+
+ public IMethod[] findMethods(final String methodName, int argCount, int sourcePosition) {
+ final List methods = new ArrayList();
+ ISourceModule module = this.method.getSourceModule();
+ try {
+ IModelElement[] elements = module.codeSelect(sourcePosition, methodName.length());
+ for (int i = 0; i < elements.length; ++i) {
+ if (elements[i] instanceof IMethod) {
+ methods.add(elements[i]);
+ }
+ }
+ } catch (ModelException e) {
+ if (DLTKCore.DEBUG) {
+ e.printStackTrace();
+ }
+ }
+ // final String nsName;
+ // if( methodName.indexOf("::") != -1 ) {
+ // String mmName = methodName;
+ // if( mmName.startsWith("::")) {
+ // mmName = mmName.substring(2);
+ // }
+ // if( mmName.indexOf("::") != -1 ) {
+ // int posb = mmName.indexOf("::");
+ // nsName = mmName.substring(0, posb);
+ // }
+ // else {
+ // nsName = null;
+ // }
+ // }
+ // else {
+ // nsName = null;
+ // }
+ // SearchRequestor requestor = new SearchRequestor() {
+ // public void acceptSearchMatch(SearchMatch match) throws CoreException
+ // {
+ // Object element = match.getElement();
+ // if( element instanceof IMethod ) {
+ // IMethod method = (IMethod)element;
+ // String mn = method.getTypeQualifiedName('$', false).replaceAll("\\$",
+ // "::");
+ // if( mn.equals(methodName) && !isIgnoredBySearchScope(method) ) {
+ // methods.add(method);
+ // }
+ // }
+ // else {
+ // IType type = (IType) element;
+ // if( !( type.getParent() instanceof ISourceModule )) {
+ // return;
+ // }
+ // processTypeFunctions(type);
+ // }
+ // }
+ // private void processTypeFunctions(IType type) throws ModelException {
+ // IMethod[] tmethods = type.getMethods();
+ // for (int i = 0; i < tmethods.length; ++i) {
+ // String mn = tmethods[i].getTypeQualifiedName('$',
+ // false).replaceAll("\\$", "::");
+ // if( mn.equals(methodName) && !isIgnoredBySearchScope(tmethods[i]) ) {
+ // methods.add(tmethods[i]);
+ // }
+ // }
+ // IType[] types = type.getTypes();
+ // for( int i = 0; i < types.length; ++i ) {
+ // processTypeFunctions(types[i]);
+ // }
+ // }
+ // };
+ //
+ // try {
+ // String pattern = methodName;
+ // if( pattern.startsWith("::")) {
+ // pattern = pattern.substring(2);
+ // }
+ // if( pattern.indexOf("::")==-1) {
+ // search(pattern, IDLTKSearchConstants.METHOD,
+ // IDLTKSearchConstants.DECLARATIONS, scope, requestor);
+ // }
+ // if( nsName != null ) {
+ // search(nsName, IDLTKSearchConstants.TYPE,
+ // IDLTKSearchConstants.DECLARATIONS, scope, requestor);
+ // }
+ // } catch (CoreException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+
+ return (IMethod[]) methods.toArray(new IMethod[methods.size()]);
+ }
+
+ protected void search(String patternString, int searchFor, int limitTo, IDLTKSearchScope scope,
+ SearchRequestor resultCollector) throws CoreException {
+ search(patternString, searchFor, limitTo, EXACT_RULE, scope, resultCollector);
+ }
+
+ protected void search(String patternString, int searchFor, int limitTo, int matchRule,
+ IDLTKSearchScope scope, SearchRequestor requestor) throws CoreException {
+ if (patternString.indexOf('*') != -1 || patternString.indexOf('?') != -1) {
+ matchRule |= SearchPattern.R_PATTERN_MATCH;
+ }
+ SearchPattern pattern = SearchPattern.createPattern(patternString, searchFor, limitTo,
+ matchRule, scope.getLanguageToolkit());
+ new SearchEngine().search(pattern, new SearchParticipant[] { SearchEngine
+ .getDefaultSearchParticipant() }, scope, requestor, null);
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaConstants.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaConstants.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaConstants.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaConstants.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.core;
+
+public class RutaConstants {
+ protected RutaConstants() {
+ }
+
+ public final static String TM_PARTITIONING = "__ruta_partitioning";
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaContentDescriber.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaContentDescriber.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaContentDescriber.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaContentDescriber.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.core;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.dltk.core.ScriptContentDescriber;
+
+public class RutaContentDescriber extends ScriptContentDescriber {
+ protected static Pattern[] header_patterns = { Pattern.compile("\\s*PACKAGE", Pattern.MULTILINE), }; //$NON-NLS-1$
+
+ @Override
+ protected Pattern[] getHeaderPatterns() {
+ return header_patterns;
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaCorePreferences.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaCorePreferences.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaCorePreferences.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaCorePreferences.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.core;
+
+public class RutaCorePreferences {
+ public static final String BUILDER_RESOLVE_IMPORTS = "BuilderResolveImports";
+
+ public static final String BUILDER_IMPORT_BY_NAME = "BuilderImportByName";
+
+ public static final String BUILDER_IGNORE_DUPLICATE_SHORTNAMES = "BuilderErrorOnDuplicateShortnames";
+
+ public static final String PROJECT_CLEAR_OUTPUT = "ProjectClearOutput";
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaExtensionManager.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaExtensionManager.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaExtensionManager.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaExtensionManager.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,427 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.core;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.uima.ruta.extensions.IEngineLoader;
+import org.apache.uima.ruta.extensions.IRutaActionExtension;
+import org.apache.uima.ruta.extensions.IRutaBooleanFunctionExtension;
+import org.apache.uima.ruta.extensions.IRutaConditionExtension;
+import org.apache.uima.ruta.extensions.IRutaNumberFunctionExtension;
+import org.apache.uima.ruta.extensions.IRutaStringFunctionExtension;
+import org.apache.uima.ruta.extensions.IRutaTypeFunctionExtension;
+import org.apache.uima.ruta.ide.RutaIdePlugin;
+import org.apache.uima.ruta.ide.core.extensions.ICompletionExtension;
+import org.apache.uima.ruta.ide.core.extensions.IIDEActionExtension;
+import org.apache.uima.ruta.ide.core.extensions.IIDEBooleanFunctionExtension;
+import org.apache.uima.ruta.ide.core.extensions.IIDEConditionExtension;
+import org.apache.uima.ruta.ide.core.extensions.IIDENumberFunctionExtension;
+import org.apache.uima.ruta.ide.core.extensions.IIDEStringFunctionExtension;
+import org.apache.uima.ruta.ide.core.extensions.IIDETypeFunctionExtension;
+import org.apache.uima.ruta.ide.core.extensions.IMatchLocatorExtension;
+import org.apache.uima.ruta.ide.core.extensions.IMixinBuildVisitorExtension;
+import org.apache.uima.ruta.ide.core.extensions.ISelectionExtension;
+import org.apache.uima.ruta.ide.core.extensions.ISourceElementRequestVisitorExtension;
+import org.apache.uima.ruta.ide.core.extensions.IRutaLanguageExtension;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.dltk.core.PriorityClassDLTKExtensionManager;
+import org.eclipse.dltk.core.PriorityDLTKExtensionManager.ElementInfo;
+
+public class RutaExtensionManager {
+ PriorityClassDLTKExtensionManager manager = new PriorityClassDLTKExtensionManager(
+ RutaIdePlugin.PLUGIN_ID + ".tmExtension", "language");
+
+ private static RutaExtensionManager sInstance;
+
+ public static RutaExtensionManager getDefault() {
+ if (sInstance == null) {
+ sInstance = new RutaExtensionManager();
+ }
+ return sInstance;
+ }
+
+ public IRutaLanguageExtension[] getExtensions() {
+ ElementInfo[] infos = manager.getElementInfos();
+ if (infos == null) {
+ return new IRutaLanguageExtension[0];
+ }
+ List extensions = new ArrayList();
+ for (int i = 0; i < infos.length; i++) {
+ Object object = manager.getInitObject(infos[i]);
+ if (object instanceof IRutaLanguageExtension) {
+ extensions.add(object);
+ }
+ }
+ return (IRutaLanguageExtension[]) extensions
+ .toArray(new IRutaLanguageExtension[extensions.size()]);
+ }
+
+ public ISourceElementRequestVisitorExtension[] getSourceElementRequestoVisitorExtensions() {
+ IRutaLanguageExtension[] extensions = getExtensions();
+ List result = new ArrayList();
+ for (int i = 0; i < extensions.length; i++) {
+ ISourceElementRequestVisitorExtension visitorExtension = extensions[i]
+ .createSourceElementRequestVisitorExtension();
+ if (visitorExtension != null) {
+ result.add(visitorExtension);
+ }
+ }
+ return (ISourceElementRequestVisitorExtension[]) result
+ .toArray(new ISourceElementRequestVisitorExtension[result.size()]);
+ }
+
+ public IMixinBuildVisitorExtension[] getMixinVisitorExtensions() {
+ IRutaLanguageExtension[] extensions = getExtensions();
+ List result = new ArrayList();
+ for (int i = 0; i < extensions.length; i++) {
+ IMixinBuildVisitorExtension visitorExtension = extensions[i]
+ .createMixinBuildVisitorExtension();
+ if (visitorExtension != null) {
+ result.add(visitorExtension);
+ }
+ }
+ return (IMixinBuildVisitorExtension[]) result.toArray(new IMixinBuildVisitorExtension[result
+ .size()]);
+ }
+
+ public IMatchLocatorExtension[] getMatchLocatorExtensions() {
+ IRutaLanguageExtension[] extensions = getExtensions();
+ List result = new ArrayList();
+ for (int i = 0; i < extensions.length; i++) {
+ IMatchLocatorExtension visitorExtension = extensions[i].createMatchLocatorExtension();
+ if (visitorExtension != null) {
+ result.add(visitorExtension);
+ }
+ }
+ return (IMatchLocatorExtension[]) result.toArray(new IMatchLocatorExtension[result.size()]);
+ }
+
+ public ICompletionExtension[] getCompletionExtensions() {
+ IRutaLanguageExtension[] extensions = getExtensions();
+ List result = new ArrayList();
+ for (int i = 0; i < extensions.length; i++) {
+ ICompletionExtension visitorExtension = extensions[i].createCompletionExtension();
+ if (visitorExtension != null) {
+ result.add(visitorExtension);
+ }
+ }
+ return (ICompletionExtension[]) result.toArray(new ICompletionExtension[result.size()]);
+ }
+
+ public ISelectionExtension[] getSelectionExtensions() {
+ IRutaLanguageExtension[] extensions = getExtensions();
+ List result = new ArrayList();
+ for (int i = 0; i < extensions.length; i++) {
+ ISelectionExtension visitorExtension = extensions[i].createSelectionExtension();
+ if (visitorExtension != null) {
+ result.add(visitorExtension);
+ }
+ }
+ return (ISelectionExtension[]) result.toArray(new ISelectionExtension[result.size()]);
+ }
+
+ public IIDEConditionExtension[] getIDEConditionExtensions() {
+ Collection<IIDEConditionExtension> result = new ArrayList<IIDEConditionExtension>();
+ IExtension[] conditionExtensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(RutaIdePlugin.PLUGIN_ID, "conditionExtension").getExtensions();
+ for (IExtension extension : conditionExtensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement configurationElement : configurationElements) {
+ Object obj = null;
+ try {
+ obj = configurationElement.createExecutableExtension("class");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (obj instanceof IIDEConditionExtension) {
+ result.add((IIDEConditionExtension) obj);
+ }
+ }
+ }
+ return result.toArray(new IIDEConditionExtension[0]);
+ }
+
+ public IIDEActionExtension[] getIDEActionExtensions() {
+ Collection<IIDEActionExtension> result = new ArrayList<IIDEActionExtension>();
+ IExtension[] conditionExtensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(RutaIdePlugin.PLUGIN_ID, "actionExtension").getExtensions();
+ for (IExtension extension : conditionExtensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement configurationElement : configurationElements) {
+ Object obj = null;
+ try {
+ obj = configurationElement.createExecutableExtension("class");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (obj instanceof IIDEActionExtension) {
+ result.add((IIDEActionExtension) obj);
+ }
+ }
+ }
+ return result.toArray(new IIDEActionExtension[0]);
+ }
+
+ public IIDENumberFunctionExtension[] getIDENumberFunctionExtensions() {
+ Collection<IIDENumberFunctionExtension> result = new ArrayList<IIDENumberFunctionExtension>();
+ IExtension[] extensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(RutaIdePlugin.PLUGIN_ID, "numberFunctionExtension")
+ .getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement configurationElement : configurationElements) {
+ Object obj = null;
+ try {
+ obj = configurationElement.createExecutableExtension("class");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (obj instanceof IIDENumberFunctionExtension) {
+ result.add((IIDENumberFunctionExtension) obj);
+ }
+ }
+ }
+ return result.toArray(new IIDENumberFunctionExtension[0]);
+ }
+
+ public IIDEBooleanFunctionExtension[] getIDEBooleanFunctionExtensions() {
+ Collection<IIDEBooleanFunctionExtension> result = new ArrayList<IIDEBooleanFunctionExtension>();
+ IExtension[] extensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(RutaIdePlugin.PLUGIN_ID, "booleanFunctionExtension")
+ .getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement configurationElement : configurationElements) {
+ Object obj = null;
+ try {
+ obj = configurationElement.createExecutableExtension("class");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (obj instanceof IIDEBooleanFunctionExtension) {
+ result.add((IIDEBooleanFunctionExtension) obj);
+ }
+ }
+ }
+ return result.toArray(new IIDEBooleanFunctionExtension[0]);
+ }
+
+ public IIDEStringFunctionExtension[] getIDEStringFunctionExtensions() {
+ Collection<IIDEStringFunctionExtension> result = new ArrayList<IIDEStringFunctionExtension>();
+ IExtension[] extensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(RutaIdePlugin.PLUGIN_ID, "stringFunctionExtension")
+ .getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement configurationElement : configurationElements) {
+ Object obj = null;
+ try {
+ obj = configurationElement.createExecutableExtension("class");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (obj instanceof IIDEStringFunctionExtension) {
+ result.add((IIDEStringFunctionExtension) obj);
+ }
+ }
+ }
+ return result.toArray(new IIDEStringFunctionExtension[0]);
+ }
+
+ public IIDETypeFunctionExtension[] getIDETypeFunctionExtensions() {
+ Collection<IIDETypeFunctionExtension> result = new ArrayList<IIDETypeFunctionExtension>();
+ IExtension[] extensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(RutaIdePlugin.PLUGIN_ID, "typeFunctionExtension")
+ .getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement configurationElement : configurationElements) {
+ Object obj = null;
+ try {
+ obj = configurationElement.createExecutableExtension("class");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (obj instanceof IIDETypeFunctionExtension) {
+ result.add((IIDETypeFunctionExtension) obj);
+ }
+ }
+ }
+ return result.toArray(new IIDETypeFunctionExtension[0]);
+ }
+
+ public IRutaConditionExtension[] getRutaConditionExtensions() {
+ Collection<IRutaConditionExtension> result = new ArrayList<IRutaConditionExtension>();
+ IExtension[] conditionExtensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(RutaIdePlugin.PLUGIN_ID, "conditionExtension").getExtensions();
+ for (IExtension extension : conditionExtensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement configurationElement : configurationElements) {
+ Object obj = null;
+ try {
+ obj = configurationElement.createExecutableExtension("engine");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (obj instanceof IRutaConditionExtension) {
+ result.add((IRutaConditionExtension) obj);
+ }
+ }
+ }
+ return result.toArray(new IRutaConditionExtension[0]);
+ }
+
+ public IRutaActionExtension[] getRutaActionExtensions() {
+ Collection<IRutaActionExtension> result = new ArrayList<IRutaActionExtension>();
+ IExtension[] conditionExtensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(RutaIdePlugin.PLUGIN_ID, "actionExtension").getExtensions();
+ for (IExtension extension : conditionExtensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement configurationElement : configurationElements) {
+ Object obj = null;
+ try {
+ obj = configurationElement.createExecutableExtension("engine");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (obj instanceof IRutaActionExtension) {
+ result.add((IRutaActionExtension) obj);
+ }
+ }
+ }
+ return result.toArray(new IRutaActionExtension[0]);
+ }
+
+ public IRutaNumberFunctionExtension[] getRutaNumberFunctionExtensions() {
+ Collection<IRutaNumberFunctionExtension> result = new ArrayList<IRutaNumberFunctionExtension>();
+ IExtension[] extensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(RutaIdePlugin.PLUGIN_ID, "numberFunctionExtension")
+ .getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement configurationElement : configurationElements) {
+ Object obj = null;
+ try {
+ obj = configurationElement.createExecutableExtension("engine");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (obj instanceof IRutaNumberFunctionExtension) {
+ result.add((IRutaNumberFunctionExtension) obj);
+ }
+ }
+ }
+ return result.toArray(new IRutaNumberFunctionExtension[0]);
+ }
+
+ public IRutaBooleanFunctionExtension[] getRutaBooleanFunctionExtensions() {
+ Collection<IRutaBooleanFunctionExtension> result = new ArrayList<IRutaBooleanFunctionExtension>();
+ IExtension[] extensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(RutaIdePlugin.PLUGIN_ID, "booleanFunctionExtension")
+ .getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement configurationElement : configurationElements) {
+ Object obj = null;
+ try {
+ obj = configurationElement.createExecutableExtension("engine");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (obj instanceof IRutaBooleanFunctionExtension) {
+ result.add((IRutaBooleanFunctionExtension) obj);
+ }
+ }
+ }
+ return result.toArray(new IRutaBooleanFunctionExtension[0]);
+ }
+
+ public IRutaStringFunctionExtension[] getRutaStringFunctionExtensions() {
+ Collection<IRutaStringFunctionExtension> result = new ArrayList<IRutaStringFunctionExtension>();
+ IExtension[] extensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(RutaIdePlugin.PLUGIN_ID, "stringFunctionExtension")
+ .getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement configurationElement : configurationElements) {
+ Object obj = null;
+ try {
+ obj = configurationElement.createExecutableExtension("engine");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (obj instanceof IRutaStringFunctionExtension) {
+ result.add((IRutaStringFunctionExtension) obj);
+ }
+ }
+ }
+ return result.toArray(new IRutaStringFunctionExtension[0]);
+ }
+
+ public IRutaTypeFunctionExtension[] getRutaTypeFunctionExtensions() {
+ Collection<IRutaTypeFunctionExtension> result = new ArrayList<IRutaTypeFunctionExtension>();
+ IExtension[] extensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(RutaIdePlugin.PLUGIN_ID, "typeFunctionExtension")
+ .getExtensions();
+ for (IExtension extension : extensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement configurationElement : configurationElements) {
+ Object obj = null;
+ try {
+ obj = configurationElement.createExecutableExtension("engine");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (obj instanceof IRutaTypeFunctionExtension) {
+ result.add((IRutaTypeFunctionExtension) obj);
+ }
+ }
+ }
+ return result.toArray(new IRutaTypeFunctionExtension[0]);
+ }
+
+ public IEngineLoader[] getEngineExtensions() {
+ Collection<IEngineLoader> result = new ArrayList<IEngineLoader>();
+ IExtension[] conditionExtensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(RutaIdePlugin.PLUGIN_ID, "engineExtension").getExtensions();
+ for (IExtension extension : conditionExtensions) {
+ IConfigurationElement[] configurationElements = extension.getConfigurationElements();
+ for (IConfigurationElement configurationElement : configurationElements) {
+ Object obj = null;
+ try {
+ obj = configurationElement.createExecutableExtension("class");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ if (obj instanceof IEngineLoader) {
+ result.add((IEngineLoader) obj);
+ }
+ }
+ }
+ return result.toArray(new IEngineLoader[0]);
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaKeywords.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaKeywords.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaKeywords.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaKeywords.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.core;
+
+public class RutaKeywords implements IRutaKeywords {
+
+ private static String[] condition = { "CONTAINS", "IF", "INLIST", "PARTOF", "TOTALCOUNT",
+ "CURRENTCOUNT", "CONTEXTCOUNT", "LAST", "VOTE", "COUNT", "NEAR", "REGEXP", "POSITION",
+ "SCORE", "ISLISTEMPTY", "MOFN", "AND", "OR", "FEATURE", "PARSE", "IS", "BEFORE", "AFTER",
+ "STARTSWITH", "ENDSWITH", "PARTOFNEQ", "SIZE", "NOT" };
+
+ private static String[] declaration = { "WORDLIST", "DECLARE", "BOOLEAN", "PACKAGE", "TYPE",
+ "TYPESYSTEM", "INT", "DOUBLE", "FLOAT", "STRING", "SCRIPT", "WORDTABLE", "ENGINE", "BLOCK",
+ "RULES", "BOOLEANLIST", "INTLIST", "DOUBLELIST", "FLOATLIST", "STRINGLIST", "TYPELIST" };
+
+ private static String[] action = { "DEL", "CALL", "MARK", "MARKSCORE", "COLOR", "LOG", "REPLACE",
+ "FILLOBJECT", "RETAINTYPE", "SETFEATURE", "ASSIGN", "PUTINLIST", "ATTRIBUTE", "MARKFAST",
+ "FILTERTYPE", "CREATE", "FILL", "MARKTABLE", "UNMARK", "TRANSFER", "MARKONCE", "TRIE",
+ "GATHER", "EXEC", "MARKLAST", "ADD", "REMOVE", "MERGE", "GET", "GETLIST", "REMOVEDUPLICATE",
+ "GETFEATURE", "MATCHEDTEXT", "CLEAR", "UNMARKALL", "SHIFT", "CONFIGURE", "DYNAMICANCHORING",
+ "TRIM", "ADDRETAINTYPE", "REMOVERETAINTYPE", "ADDFILTERTYPE", "REMOVEFILTERTYPE" };
+
+ private static String[] basic = { "ALL", "ANY", "AMP", "BREAK", "W", "NUM", "PM", "Document",
+ "MARKUP", "SW", "CW", "CAP", "PERIOD", "NBSP", "SENTENCEEND", "COLON", "COMMA", "SEMICOLON",
+ "WS", "_", "SPACE", "SPECIAL", "EXCLAMATION", "QUESTION", "#" };
+
+ private static String[] booleanFunction = { "true", "false" };
+
+ private static String[] numberFunction = { "EXP", "SIN", "COS", "TAN", "LOGN" };
+
+ private static String[] stringFunction = { "REMOVESTRING" };
+
+ private static String[] typeFunction = {};
+
+ private static String[] then = { "->" };
+
+ public String[] getKeywords(int type) {
+ if (type == CONDITION) {
+ return condition;
+ } else if (type == ACTION) {
+ return action;
+ } else if (type == DECLARATION) {
+ return declaration;
+ } else if (type == BASIC) {
+ return basic;
+ } else if (type == BOOLEANFUNCTION) {
+ return booleanFunction;
+ } else if (type == NUMBERFUNCTION) {
+ return numberFunction;
+ } else if (type == STRINGFUNCTION) {
+ return stringFunction;
+ } else if (type == TYPEFUNCTION) {
+ return typeFunction;
+ } else if (type == THEN) {
+ return then;
+ }
+ return getKeywords();
+ }
+
+ public static String[] append(String prefix, String[] a, String[] b) {
+ int len = 0;
+ if (a != null) {
+ len = a.length;
+ }
+ String[] ns = new String[len + b.length];
+ if (a != null) {
+ System.arraycopy(a, 0, ns, 0, len);
+ }
+ for (int i = 0; i < b.length; i++) {
+ ns[len + i] = prefix + b[i];
+ }
+ return ns;
+ }
+
+ public static String[] append(String[] a, String[] b) {
+ if (b == null) {
+ return a;
+ }
+ String[] ns = new String[a.length + b.length];
+ System.arraycopy(a, 0, ns, 0, a.length);
+ System.arraycopy(b, 0, ns, a.length, b.length);
+ return ns;
+ }
+
+ public String[] getKeywords() {
+ return null;
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaKeywordsManager.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaKeywordsManager.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaKeywordsManager.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaKeywordsManager.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.core;
+
+import org.apache.uima.ruta.extensions.IRutaActionExtension;
+import org.apache.uima.ruta.extensions.IRutaBooleanFunctionExtension;
+import org.apache.uima.ruta.extensions.IRutaConditionExtension;
+import org.apache.uima.ruta.extensions.IRutaNumberFunctionExtension;
+import org.apache.uima.ruta.extensions.IRutaStringFunctionExtension;
+import org.apache.uima.ruta.extensions.IRutaTypeFunctionExtension;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.dltk.core.DLTKCore;
+
+public final class RutaKeywordsManager {
+ private static final String EXTENSION_POINT = "org.apache.uima.ruta.ide.tmkeywords";
+
+ private static final String CLASS = "class";
+
+ private static String[][] all = new String[IRutaKeywords.END_INDEX][];
+
+ private static boolean initialized = false;
+
+ private static void initialize() {
+ if (initialized) {
+ return;
+ }
+ initialized = true;
+ IConfigurationElement[] cfg = Platform.getExtensionRegistry().getConfigurationElementsFor(
+ EXTENSION_POINT);
+ for (int i = 0; i < IRutaKeywords.END_INDEX; i++) {
+ all[i] = new String[0];
+ }
+ for (int i = 0; i < cfg.length; i++) {
+ if (cfg[i].getName().equals("keywords")) {
+ try {
+ IRutaKeywords keywords = (IRutaKeywords) cfg[i]
+ .createExecutableExtension(CLASS);
+ if (keywords != null) {
+ for (int q = 0; q < IRutaKeywords.END_INDEX; ++q) {
+ String[] kw2 = keywords.getKeywords(q);
+ all[q] = RutaKeywords.append(all[q], kw2);
+ }
+ }
+ } catch (CoreException e) {
+ if (DLTKCore.DEBUG) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ IRutaActionExtension[] actionExtensions = RutaExtensionManager.getDefault()
+ .getRutaActionExtensions();
+ for (IRutaActionExtension each : actionExtensions) {
+ String[] knownExtensions = each.getKnownExtensions();
+ all[IRutaKeywords.ACTION] = RutaKeywords.append(all[IRutaKeywords.ACTION], knownExtensions);
+ }
+ IRutaConditionExtension[] conditionExtensions = RutaExtensionManager.getDefault()
+ .getRutaConditionExtensions();
+ for (IRutaConditionExtension each : conditionExtensions) {
+ String[] knownExtensions = each.getKnownExtensions();
+ all[IRutaKeywords.CONDITION] = RutaKeywords.append(all[IRutaKeywords.CONDITION], knownExtensions);
+ }
+ IRutaBooleanFunctionExtension[] booleanFunctionExtensions = RutaExtensionManager.getDefault()
+ .getRutaBooleanFunctionExtensions();
+ for (IRutaBooleanFunctionExtension each : booleanFunctionExtensions) {
+ String[] knownExtensions = each.getKnownExtensions();
+ all[IRutaKeywords.BOOLEANFUNCTION] = RutaKeywords.append(all[IRutaKeywords.BOOLEANFUNCTION], knownExtensions);
+ }
+ IRutaNumberFunctionExtension[] numberFunctionExtensions = RutaExtensionManager.getDefault()
+ .getRutaNumberFunctionExtensions();
+ for (IRutaNumberFunctionExtension each : numberFunctionExtensions) {
+ String[] knownExtensions = each.getKnownExtensions();
+ all[IRutaKeywords.NUMBERFUNCTION] = RutaKeywords.append(all[IRutaKeywords.NUMBERFUNCTION], knownExtensions);
+ }
+ IRutaStringFunctionExtension[] stringFunctionExtensions = RutaExtensionManager.getDefault()
+ .getRutaStringFunctionExtensions();
+ for (IRutaStringFunctionExtension each : stringFunctionExtensions) {
+ String[] knownExtensions = each.getKnownExtensions();
+ all[IRutaKeywords.STRINGFUNCTION] = RutaKeywords.append(all[IRutaKeywords.STRINGFUNCTION], knownExtensions);
+ }
+ IRutaTypeFunctionExtension[] typeFunctionExtensions = RutaExtensionManager.getDefault()
+ .getRutaTypeFunctionExtensions();
+ for (IRutaTypeFunctionExtension each : typeFunctionExtensions) {
+ String[] knownExtensions = each.getKnownExtensions();
+ all[IRutaKeywords.TYPEFUNCTION] = RutaKeywords.append(all[IRutaKeywords.TYPEFUNCTION], knownExtensions);
+ }
+ }
+
+ public static String[] getKeywords() {
+ initialize();
+ return all[IRutaKeywords.ALL];
+ }
+
+ public static String[] getKeywords(int type) {
+ initialize();
+ if (type >= 0 && type < all.length) {
+ return all[type];
+ }
+ return new String[0];
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaLanguageToolkit.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaLanguageToolkit.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaLanguageToolkit.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaLanguageToolkit.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.core;
+
+import java.io.File;
+import java.io.FilenameFilter;
+
+import org.apache.uima.ruta.ide.RutaIdePlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.dltk.core.AbstractLanguageToolkit;
+
+public class RutaLanguageToolkit extends AbstractLanguageToolkit {
+ private static final String[] languageExtensions = new String[] { "tm" };
+
+ private static RutaLanguageToolkit sInstance = new RutaLanguageToolkit();
+
+ public RutaLanguageToolkit() {
+ }
+
+ @Override
+ public boolean languageSupportZIPBuildpath() {
+ return true;
+ }
+
+ public boolean validateSourcePackage(IPath path) {
+ File file = new File(path.toOSString());
+ if (file != null) {
+ String members[] = file.list(new FilenameFilter() {
+
+ public boolean accept(File dir, String name) {
+ if (name.toLowerCase().equals("__init__.tm")) {
+ return true;
+ }
+ return false;
+ }
+ });
+ if (members.length > 0) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public String getNatureId() {
+ return RutaNature.NATURE_ID;
+ }
+
+ public String[] getLanguageFileExtensions() {
+ return languageExtensions;
+ }
+
+ public String getLanguageName() {
+ return "Ruta";
+ }
+
+ public String getLanguageContentType() {
+ return "org.apache.uima.ruta.ide.tmContentType";
+ }
+
+ public static RutaLanguageToolkit getDefault() {
+ return sInstance;
+ }
+
+ @Override
+ public String getPreferenceQualifier() {
+ return RutaIdePlugin.PLUGIN_ID;
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaMatchLocatorParser.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaMatchLocatorParser.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaMatchLocatorParser.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaMatchLocatorParser.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.core;
+
+import org.eclipse.dltk.ast.ASTNode;
+import org.eclipse.dltk.ast.declarations.FieldDeclaration;
+import org.eclipse.dltk.ast.declarations.MethodDeclaration;
+import org.eclipse.dltk.ast.references.Reference;
+import org.eclipse.dltk.ast.references.VariableReference;
+import org.eclipse.dltk.core.search.matching.MatchLocator;
+import org.eclipse.dltk.core.search.matching.MatchLocatorParser;
+import org.eclipse.dltk.core.search.matching.PatternLocator;
+
+public class RutaMatchLocatorParser extends MatchLocatorParser {
+
+ public RutaMatchLocatorParser(MatchLocator locator) {
+ super(locator);
+ }
+
+ @Override
+ protected void processStatement(ASTNode node, PatternLocator locator) {
+ super.processStatement(node, locator);
+ if (node instanceof VariableReference) {
+ locator.match((Reference) node, getNodeSet());
+ } else if (node instanceof FieldDeclaration) {
+ locator.match((FieldDeclaration) node, getNodeSet());
+ } else if (node instanceof MethodDeclaration) {
+ locator.match((MethodDeclaration) node, getNodeSet());
+ }
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaNature.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaNature.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaNature.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaNature.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.core;
+
+import org.apache.uima.ruta.ide.RutaIdePlugin;
+import org.eclipse.dltk.core.ScriptNature;
+
+public class RutaNature extends ScriptNature {
+
+ public static final String NATURE_ID = RutaIdePlugin.PLUGIN_ID + ".nature";
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaPreferenceInitializer.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaPreferenceInitializer.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaPreferenceInitializer.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaPreferenceInitializer.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.core;
+
+import org.apache.uima.ruta.ide.RutaIdePlugin;
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+public class RutaPreferenceInitializer extends AbstractPreferenceInitializer {
+
+ public RutaPreferenceInitializer() {
+ }
+
+ public void initializeDefaultPreferences() {
+ IPreferenceStore store = RutaIdePlugin.getDefault().getPreferenceStore();
+// TaskTagUtils.initializeDefaultValues(store);
+ store.setDefault(RutaCorePreferences.BUILDER_IMPORT_BY_NAME, false);
+ store.setDefault(RutaCorePreferences.BUILDER_RESOLVE_IMPORTS, false);
+ store.setDefault(RutaCorePreferences.BUILDER_IGNORE_DUPLICATE_SHORTNAMES, false);
+ store.setDefault(RutaCorePreferences.PROJECT_CLEAR_OUTPUT, false);
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaProblems.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaProblems.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaProblems.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaProblems.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.core;
+
+import org.eclipse.dltk.compiler.problem.IProblem;
+
+public class RutaProblems {
+
+ public static final int UNKNOWN_REQUIRED_PACKAGE = IProblem.ImportRelated + 1;
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaSearchFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaSearchFactory.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaSearchFactory.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/RutaSearchFactory.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.core;
+
+import org.eclipse.dltk.core.search.AbstractSearchFactory;
+import org.eclipse.dltk.core.search.IMatchLocatorParser;
+import org.eclipse.dltk.core.search.matching.MatchLocator;
+
+
+/**
+ * Ruta search factory
+ */
+public class RutaSearchFactory extends AbstractSearchFactory {
+
+ public IMatchLocatorParser createMatchParser(MatchLocator locator) {
+ return new RutaMatchLocatorParser(locator);
+ }
+
+// public SourceIndexerRequestor createSourceRequestor() {
+// return new RutaSourceIndexerRequestor();
+// }
+
+// public ISearchPatternProcessor createSearchPatternProcessor() {
+// return new RutaSearchPatternProcessor();
+// }
+}
Modified: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/DescriptorManager.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/DescriptorManager.java?rev=1477113&r1=1477112&r2=1477113&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/DescriptorManager.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/DescriptorManager.java Mon Apr 29 14:50:56 2013
@@ -17,7 +17,7 @@
* under the License.
*/
-package org.apache.uima.textmarker.ide.core.builder;
+package org.apache.uima.ruta.ide.core.builder;
import java.util.ArrayList;
import java.util.Collection;
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuildException.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuildException.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuildException.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuildException.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,30 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.core.builder;
+
+public class RutaBuildException extends Exception {
+
+ private static final long serialVersionUID = 8194208263129900183L;
+
+ public RutaBuildException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuildOptions.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuildOptions.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuildOptions.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuildOptions.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+*/
+
+package org.apache.uima.ruta.ide.core.builder;
+
+import java.util.List;
+
+public class RutaBuildOptions {
+
+ private final List<String> language;
+
+ private final List<String> engines;
+
+ private boolean importByName = false;
+
+ private boolean resolveImports = false;
+
+ private boolean errorOnDuplicateShortNames;
+
+ public RutaBuildOptions(List<String> language, List<String> engines) {
+ super();
+ this.language = language;
+ this.engines = engines;
+ }
+
+ public List<String> getLanguage() {
+ return language;
+ }
+
+ public List<String> getEngines() {
+ return engines;
+ }
+
+ public void setImportByName(boolean importByName) {
+ this.importByName = importByName;
+ }
+
+ public boolean isImportByName() {
+ return importByName;
+ }
+
+ public void setResolveImports(boolean resolveImports) {
+ this.resolveImports = resolveImports;
+ }
+
+ public boolean isResolveImports() {
+ return resolveImports;
+ }
+
+ public void setErrorOnDuplicateShortNames(boolean error) {
+ this.errorOnDuplicateShortNames = error;
+ }
+
+ public boolean isErrorOnDuplicateShortNames() {
+ return errorOnDuplicateShortNames;
+ }
+
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuilder.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuilder.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuilder.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaBuilder.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,304 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.core.builder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.ruta.extensions.IEngineLoader;
+import org.apache.uima.ruta.extensions.IRutaActionExtension;
+import org.apache.uima.ruta.extensions.IRutaBooleanFunctionExtension;
+import org.apache.uima.ruta.extensions.IRutaConditionExtension;
+import org.apache.uima.ruta.extensions.IRutaNumberFunctionExtension;
+import org.apache.uima.ruta.extensions.IRutaStringFunctionExtension;
+import org.apache.uima.ruta.extensions.IRutaTypeFunctionExtension;
+import org.apache.uima.ruta.ide.RutaIdePlugin;
+import org.apache.uima.ruta.ide.core.RutaCorePreferences;
+import org.apache.uima.ruta.ide.core.RutaExtensionManager;
+import org.apache.uima.ruta.ide.parser.ast.RutaModuleDeclaration;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.ModelException;
+import org.eclipse.dltk.core.builder.AbstractBuildParticipantType;
+import org.eclipse.dltk.core.builder.IBuildChange;
+import org.eclipse.dltk.core.builder.IBuildContext;
+import org.eclipse.dltk.core.builder.IBuildParticipant;
+import org.eclipse.dltk.core.builder.IBuildParticipantExtension;
+import org.eclipse.dltk.core.builder.IBuildParticipantExtension2;
+import org.eclipse.dltk.core.builder.IBuildParticipantExtension3;
+import org.eclipse.dltk.core.builder.IBuildState;
+import org.eclipse.jface.preference.IPreferenceStore;
+
+public class RutaBuilder extends AbstractBuildParticipantType implements IBuildParticipant,
+ IBuildParticipantExtension, IBuildParticipantExtension2, IBuildParticipantExtension3 {
+
+ private IScriptProject project;
+
+ public RutaBuilder() {
+ super();
+ }
+
+ public RutaBuilder(IScriptProject project) {
+ super();
+ this.project = project;
+ }
+
+ private void generateDescriptorResources(ISourceModule sourceModule,
+ ModuleDeclaration moduleDeclaration) {
+ IProgressMonitor monitor = createMonitor(10);
+ try {
+ IContainer container = getContainer(sourceModule);
+
+ IPath outputPath = getAbsolutePath(sourceModule);
+ IPath[] generateResources = generateResources(moduleDeclaration, outputPath, container,
+ sourceModule);
+ monitor.worked(2);
+ String defaultDescriptorLocation = RutaProjectUtils.getDefaultDescriptorLocation();
+ IFolder folder = container.getProject().getFolder(defaultDescriptorLocation);
+ for (IPath iPath : generateResources) {
+ iPath = iPath.makeRelativeTo(folder.getLocation());
+ IResource findMember = folder.findMember(iPath);
+ if (findMember != null) {
+ findMember.refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
+ findMember.getParent().refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
+ }
+
+ }
+ folder.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor,
+ generateResources.length));
+
+ monitor.worked(1);
+ } catch (ModelException e) {
+ if (DLTKCore.DEBUG_PARSER) {
+ e.printStackTrace();
+ }
+ } catch (CoreException e) {
+ if (DLTKCore.DEBUG_PARSER) {
+ e.printStackTrace();
+ }
+ }
+ monitor.done();
+ }
+
+ private IPath[] generateResources(ModuleDeclaration moduleDeclaration, IPath outputPath,
+ IContainer container, ISourceModule sourceModule) {
+ List<IPath> result = new ArrayList<IPath>();
+ if (moduleDeclaration instanceof RutaModuleDeclaration) {
+ RutaModuleDeclaration tmmd = (RutaModuleDeclaration) moduleDeclaration;
+ DescriptorManager sm = tmmd.descriptorInfo;
+ IPath pathToModule = sourceModule.getResource().getLocation();
+ String elementName = RutaProjectUtils.getModuleName(pathToModule);
+
+ IScriptProject proj = sourceModule.getScriptProject();
+ // TODO: dont use desc path!
+ IPath descPath = RutaProjectUtils.getDescriptorRootPath(proj.getProject());
+ IPath scriptPath = RutaProjectUtils.getScriptRootPath(proj.getProject());
+ IPath descPackagePath = RutaProjectUtils.getDescriptorPackagePath(sourceModule
+ .getResource().getLocation(), proj.getProject());
+
+ String typeSystem = descPackagePath.append(elementName + "TypeSystem.xml").toPortableString();
+ String engine = descPackagePath.append(elementName + "Engine.xml").toPortableString();
+ String basicTS = descPath.append("BasicTypeSystem.xml").toPortableString();
+ String basicE = descPath.append("BasicEngine.xml").toPortableString();
+
+ // TODO: may not work with other script folders
+ IPath relativeTo = pathToModule.makeAbsolute().makeRelativeTo(scriptPath);
+ List<String> scriptPathList = new ArrayList<String>();
+ List<String> descriptorPathList = new ArrayList<String>();
+
+ // add all folders
+ try {
+ List<IFolder> scriptFolders = RutaProjectUtils.getAllScriptFolders(proj);
+ scriptPathList.addAll(RutaProjectUtils.getFolderLocations(scriptFolders));
+ } catch (CoreException e) {
+ RutaIdePlugin.error(e);
+ }
+
+ try {
+ List<IFolder> descriptorFolders = RutaProjectUtils.getAllDescriptorFolders(proj
+ .getProject());
+ descriptorPathList.addAll(RutaProjectUtils.getFolderLocations(descriptorFolders));
+ } catch (Exception e) {
+ RutaIdePlugin.error(e);
+ }
+
+ String[] descriptorPaths = descriptorPathList.toArray(new String[0]);
+ String[] scriptPaths = scriptPathList.toArray(new String[0]);
+ String mainScript = relativeTo.toPortableString();
+ mainScript = mainScript.replaceAll("/", ".");
+ if (mainScript.endsWith(".tm")) {
+ mainScript = mainScript.substring(0, mainScript.length() - 3);
+ }
+ build(basicTS, basicE, typeSystem, engine, sm, mainScript, scriptPaths, descriptorPaths);
+
+ IPath tsPath = Path.fromPortableString(typeSystem);
+ IPath ePath = Path.fromPortableString(engine);
+ result.add(tsPath);
+ result.add(ePath);
+ }
+ return result.toArray(new IPath[0]);
+ }
+
+ private void build(String basicTypesystem, String basicEngine, String typeSystemDest,
+ String engineDest, DescriptorManager sm, String mainScript, String[] scriptPaths,
+ String[] enginePaths) {
+ RutaSimpleBuilder builder = null;
+ try {
+ builder = new RutaSimpleBuilder(basicTypesystem, basicEngine);
+ } catch (Exception e) {
+ DLTKCore.error(e.getMessage(), e);
+ if (DLTKCore.DEBUG_PARSER) {
+ e.printStackTrace();
+ }
+ }
+
+ IRutaConditionExtension[] conditionExtensions = RutaExtensionManager.getDefault()
+ .getRutaConditionExtensions();
+ IRutaActionExtension[] actionExtensions = RutaExtensionManager.getDefault()
+ .getRutaActionExtensions();
+ IRutaBooleanFunctionExtension[] booleanFunctionExtensions = RutaExtensionManager
+ .getDefault().getRutaBooleanFunctionExtensions();
+ IRutaNumberFunctionExtension[] numberFunctionExtensions = RutaExtensionManager
+ .getDefault().getRutaNumberFunctionExtensions();
+ IRutaStringFunctionExtension[] stringFunctionExtensions = RutaExtensionManager
+ .getDefault().getRutaStringFunctionExtensions();
+ IRutaTypeFunctionExtension[] typeFunctionExtensions = RutaExtensionManager
+ .getDefault().getRutaTypeFunctionExtensions();
+ IEngineLoader[] engineExtensions = RutaExtensionManager.getDefault()
+ .getEngineExtensions();
+
+ List<String> language = new ArrayList<String>();
+ List<String> engines = new ArrayList<String>();
+
+ for (IRutaConditionExtension each : conditionExtensions) {
+ language.add(each.getClass().getName());
+ }
+ for (IRutaActionExtension each : actionExtensions) {
+ language.add(each.getClass().getName());
+ }
+ for (IRutaBooleanFunctionExtension each : booleanFunctionExtensions) {
+ language.add(each.getClass().getName());
+ }
+ for (IRutaNumberFunctionExtension each : numberFunctionExtensions) {
+ language.add(each.getClass().getName());
+ }
+ for (IRutaStringFunctionExtension each : stringFunctionExtensions) {
+ language.add(each.getClass().getName());
+ }
+ for (IRutaTypeFunctionExtension each : typeFunctionExtensions) {
+ language.add(each.getClass().getName());
+ }
+ for (IEngineLoader each : engineExtensions) {
+ engines.add(each.getClass().getName());
+ }
+
+ try {
+ RutaBuildOptions option = new RutaBuildOptions(language, engines);
+ IPreferenceStore store = RutaIdePlugin.getDefault().getPreferenceStore();
+ option.setImportByName(store.getBoolean(RutaCorePreferences.BUILDER_IMPORT_BY_NAME));
+ option.setResolveImports(store.getBoolean(RutaCorePreferences.BUILDER_RESOLVE_IMPORTS));
+ builder.build(sm, typeSystemDest, engineDest, option, mainScript, scriptPaths, enginePaths);
+ } catch (Exception e) {
+ DLTKCore.error(e.getMessage(), e);
+ if (DLTKCore.DEBUG_PARSER) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private IProgressMonitor createMonitor(int totalWork) {
+ IProgressMonitor pm = new NullProgressMonitor();
+ pm.beginTask("Creating descriptors ", totalWork);
+ return pm;
+ }
+
+ public static IContainer getContainer(ISourceModule sourceModule) {
+ try {
+ IResource file = sourceModule.getCorrespondingResource();
+ return file.getParent();
+ } catch (ModelException e) {
+ if (DLTKCore.DEBUG_PARSER) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ public static IPath getAbsolutePath(ISourceModule sourceModule) {
+ try {
+ IResource file = sourceModule.getCorrespondingResource();
+ IPath absolutePath = file.getRawLocation().removeLastSegments(1);
+ return absolutePath;
+ } catch (ModelException e) {
+ if (DLTKCore.DEBUG_PARSER) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ public static IPath getRelativePath(ISourceModule sourceModule, String resourceName) {
+ IContainer parent = getContainer(sourceModule);
+ IPath relativePath = parent.getFullPath();
+ IPath relativeFilePath = relativePath.append(resourceName);
+ return relativeFilePath;
+ }
+
+ public void clean() {
+ }
+
+ public void prepare(IBuildChange buildChange, IBuildState buildState) throws CoreException {
+ }
+
+ public void buildExternalModule(IBuildContext context) throws CoreException {
+
+ }
+
+ public boolean beginBuild(int buildType) {
+ return buildType != RECONCILE_BUILD;
+ }
+
+ public void endBuild(IProgressMonitor monitor) {
+
+ }
+
+ public void build(IBuildContext context) throws CoreException {
+ final ModuleDeclaration ast = (ModuleDeclaration) context
+ .get(IBuildContext.ATTR_MODULE_DECLARATION);
+ ISourceModule sourceModule = context.getSourceModule();
+ generateDescriptorResources(sourceModule, ast);
+ }
+
+ @Override
+ public IBuildParticipant createBuildParticipant(IScriptProject project) throws CoreException {
+ return new RutaBuilder(project);
+ }
+}
Added: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.java?rev=1477113&view=auto
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.java (added)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/core/builder/RutaProjectUtils.java Mon Apr 29 14:50:56 2013
@@ -0,0 +1,293 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.uima.ruta.ide.core.builder;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.TreeSet;
+
+import javax.swing.UIManager;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.uima.ruta.ide.RutaIdePlugin;
+import org.apache.uima.ruta.ide.core.RutaNature;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectNature;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.QualifiedName;
+import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.IScriptFolder;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ModelException;
+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;
+
+public class RutaProjectUtils {
+
+ public static final String JAVANATURE = "org.eclipse.jdt.core.javanature";
+ private static final String CDE_DATA_PATH = "CDEdataPath";
+
+ public static IPath getEngineDescriptorPath(IPath scriptPath, IProject project) {
+ String elementName = getModuleName(scriptPath);
+ IPath descPackagePath = getDescriptorPackagePath(scriptPath, project);
+ IPath result = descPackagePath.append(elementName + "Engine.xml");
+ return result;
+ }
+
+ public static IPath getTypeSystemDescriptorPath(IPath scriptPath, IProject project) {
+ String elementName = getModuleName(scriptPath);
+ IPath descPackagePath = getDescriptorPackagePath(scriptPath.makeAbsolute(), project);
+ IPath result = descPackagePath.append(elementName + "TypeSystem.xml");
+ return result;
+ }
+
+ public static IPath getDescriptorRootPath(IProject project) {
+ IPath projectPath = project.getLocation();
+ IPath descPath = projectPath.append(getDefaultDescriptorLocation());
+ return descPath;
+ }
+
+ public static List<IFolder> getAllScriptFolders(IScriptProject proj) throws CoreException {
+ List<IFolder> result = new ArrayList<IFolder>();
+ result.addAll(getScriptFolders(proj));
+ result.addAll(getReferencedScriptFolders(proj));
+ return result;
+ }
+
+ public static List<IFolder> getReferencedScriptFolders(IScriptProject proj) throws CoreException {
+ return getReferencedScriptFolders(proj, new HashSet<IProject>());
+ }
+
+ public static List<IFolder> getReferencedScriptFolders(IScriptProject proj, Collection<IProject> visited) throws CoreException {
+ List<IFolder> result = new ArrayList<IFolder>();
+ IProject[] referencedProjects = proj.getProject().getReferencedProjects();
+ for (IProject eachProject : referencedProjects) {
+ if(!visited.contains(eachProject)) {
+ IScriptProject scriptProject = DLTKCore.create(eachProject);
+ result.addAll(RutaProjectUtils.getScriptFolders(scriptProject));
+ visited.add(eachProject);
+ result.addAll(getReferencedScriptFolders(scriptProject, visited));
+ }
+ }
+ return result;
+ }
+
+ public static List<IFolder> getScriptFolders(IScriptProject proj) {
+ List<IFolder> result = new ArrayList<IFolder>();
+ IScriptFolder[] scriptFolders = null;
+ try {
+ scriptFolders = proj.getScriptFolders();
+ } catch (ModelException e) {
+ // referring to a non-ruta project
+ // RutaIdePlugin.error(e);
+ }
+ if (scriptFolders != null) {
+ for (IScriptFolder eachScriptFolder : scriptFolders) {
+ IModelElement parent = eachScriptFolder.getParent();
+ IResource resource = parent.getResource();
+ if (parent != null && resource != null && resource instanceof IFolder) {
+ if (!result.contains(resource)) {
+ result.add((IFolder) resource);
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public static List<IFolder> getAllDescriptorFolders(IProject proj) throws CoreException {
+ List<IFolder> result = new ArrayList<IFolder>();
+ result.addAll(getDescriptorFolders(proj));
+ result.addAll(getReferencedDescriptorFolders(proj));
+ return result;
+ }
+
+ public static List<IFolder> getReferencedDescriptorFolders(IProject proj) throws CoreException {
+ return getReferencedDescriptorFolders(proj, new HashSet<IProject>());
+ }
+
+ public static List<IFolder> getReferencedDescriptorFolders(IProject proj, Collection<IProject> visited) throws CoreException {
+ List<IFolder> result = new ArrayList<IFolder>();
+ Collection<IProject> referencedProjects = getReferencedProjects(proj, new HashSet<IProject>());
+ for (IProject eachProject : referencedProjects) {
+ if(!visited.contains(eachProject)) {
+ result.addAll(RutaProjectUtils.getDescriptorFolders(eachProject));
+ visited.add(eachProject);
+ result.addAll(getReferencedDescriptorFolders(eachProject, visited));
+ }
+ }
+ return result;
+ }
+
+ private static Collection<IProject> getReferencedProjects(IProject proj, Collection<IProject> visited) throws CoreException {
+ Collection<IProject> result = new HashSet<IProject>();
+ IProject[] referencedProjects = proj.getReferencedProjects();
+ result.addAll(Arrays.asList(referencedProjects));
+ IProjectNature nature = proj.getNature(JAVANATURE);
+ if(nature != null) {
+ JavaProject javaProject = (JavaProject) JavaCore.create(proj);
+ IClasspathEntry[] resolvedClasspath = javaProject.getResolvedClasspath();
+ for (IClasspathEntry eachCPE : resolvedClasspath) {
+ if(eachCPE.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
+ IProject project = getProject(eachCPE.getPath());
+ result.add(project);
+ }
+ }
+ }
+ return result;
+ }
+
+ public static List<IFolder> getDescriptorFolders(IProject proj) throws CoreException {
+ List<IFolder> result = new ArrayList<IFolder>();
+ IProjectNature javaNature = proj.getNature(JAVANATURE);
+ if (javaNature != null) {
+ IJavaProject javaProject = JavaCore.create(proj);
+ IPath readOutputLocation = javaProject.readOutputLocation();
+ IFolder folder = ResourcesPlugin.getWorkspace().getRoot().getFolder(readOutputLocation);
+ result.add(folder);
+ }
+ IProjectNature pearNature = proj.getNature("org.apache.uima.pear.UimaNature");
+ if (pearNature != null) {
+ IFolder findElement = proj.getFolder("desc");
+ if (findElement != null) {
+ result.add((IFolder) findElement);
+ }
+ }
+ IProjectNature rutaNature = proj.getNature(RutaNature.NATURE_ID);
+ if (rutaNature != null) {
+ IFolder findElement = proj.getFolder(getDefaultDescriptorLocation());
+ if (findElement != null) {
+ result.add((IFolder) findElement);
+ }
+ }
+ return result;
+ }
+
+ public static List<String> getFolderLocations(List<IFolder> folders) {
+ List<String> result = new ArrayList<String>();
+ if (folders == null)
+ return result;
+ for (IFolder each : folders) {
+ String portableString = each.getLocation().toPortableString();
+ result.add(portableString);
+ }
+ return result;
+ }
+
+ public static IPath getScriptRootPath(IProject project) {
+ IPath projectPath = project.getLocation();
+ IPath descPath = projectPath.append(getDefaultScriptLocation());
+ return descPath;
+ }
+
+ public static IPath getDescriptorPackagePath(IPath scriptPath, IProject project) {
+ IPath projectPath = project.getLocation().makeAbsolute();
+ IPath packagePath = scriptPath.removeLastSegments(1);
+ IPath relativePackagePath;
+ relativePackagePath = packagePath.makeRelativeTo(projectPath).removeFirstSegments(1);
+ IPath descPackagePath = projectPath.append(getDefaultDescriptorLocation());
+ descPackagePath = descPackagePath.append(relativePackagePath);
+ return descPackagePath;
+ }
+
+ public static String getModuleName(IPath path) {
+ String result = path.lastSegment();
+ int lastIndexOf = result.lastIndexOf(".tm");
+ if (lastIndexOf != -1) {
+ result = result.substring(0, lastIndexOf);
+ }
+ return result;
+ }
+
+ public static void addProjectDataPath(IProject project, IFolder folder) throws CoreException {
+ String dataPath = project.getPersistentProperty((new QualifiedName("", CDE_DATA_PATH)));
+ if (dataPath == null) {
+ dataPath = "";
+ }
+ String addon = folder.getLocation().toPortableString();
+ if (!StringUtils.isEmpty(dataPath)) {
+ dataPath += File.pathSeparator;
+ }
+ dataPath += addon;
+ project.setPersistentProperty(new QualifiedName("", CDE_DATA_PATH), dataPath);
+ }
+
+ public static void removeProjectDataPath(IProject project, IFolder folder) throws CoreException {
+ String dataPath = project.getPersistentProperty((new QualifiedName("", CDE_DATA_PATH)));
+ if (dataPath == null) {
+ return;
+ }
+ String path = folder.getLocation().toPortableString();
+ if (!StringUtils.isEmpty(dataPath)) {
+ dataPath.replaceAll(path, "");
+ dataPath.replaceAll(File.pathSeparator + File.pathSeparator, "");
+ }
+ project.setPersistentProperty(new QualifiedName("", CDE_DATA_PATH), dataPath);
+ }
+
+ public static IProject getProject(IPath path) {
+ IResource member = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
+ if (member instanceof IProject) {
+ IProject p = (IProject) member;
+ return p;
+ }
+ return null;
+ }
+
+
+ public static String getDefaultInputLocation() {
+ return "input";
+ }
+
+ public static String getDefaultOutputLocation() {
+ return "output";
+ }
+
+ public static String getDefaultTestLocation() {
+ return "test";
+ }
+
+ public static String getDefaultScriptLocation() {
+ return "script";
+ }
+
+ public static String getDefaultResourcesLocation() {
+ return "resources";
+ }
+
+ public static String getDefaultDescriptorLocation() {
+ return "descriptor";
+ }
+
+ public static String getDefaultTempTestLocation() {
+ return "temp";
+ }
+}