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/26 08:36:54 UTC
svn commit: r1476065 - in /uima/sandbox/textmarker/trunk:
textmarker-core/src/main/antlr3/org/apache/uima/textmarker/parser/
textmarker-core/src/main/java/org/apache/uima/textmarker/extensions/
textmarker-ep-ide/src/main/antlr3/org/apache/uima/textmark...
Author: pkluegl
Date: Fri Apr 26 06:36:53 2013
New Revision: 1476065
URL: http://svn.apache.org/r1476065
Log:
UIMA-2834
- fixed grammars
- fixed highlighting
- adapted ide interfaces
- build process automatically adds extensions to descriptors
- extend classpath of vm with available extensions
Added:
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerFunction.java
Removed:
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/AbstractIDEActionExtension.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/AbstractIDEBooleanFunctionExtension.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/AbstractIDEConditionExtension.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/AbstractIDENumberFunctionExtension.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/AbstractIDEStringFunctionExtension.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/AbstractIDETypeFunctionExtension.java
Modified:
uima/sandbox/textmarker/trunk/textmarker-core/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerParser.g
uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/extensions/TextMarkerExternalFactory.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/TextMarkerKeywordsManager.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEActionExtension.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEBooleanFunctionExtension.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEConditionExtension.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDENumberFunctionExtension.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEStringFunctionExtension.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDETypeFunctionExtension.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/ITextMarkerExtension.java
uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/TextMarkerExternalFactory.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/parser/ast/ExpressionFactory.java
Modified: uima/sandbox/textmarker/trunk/textmarker-core/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerParser.g
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-core/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerParser.g?rev=1476065&r1=1476064&r2=1476065&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-core/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerParser.g (original)
+++ uima/sandbox/textmarker/trunk/textmarker-core/src/main/antlr3/org/apache/uima/textmarker/parser/TextMarkerParser.g Fri Apr 26 06:36:53 2013
@@ -851,7 +851,7 @@ externalTypeFunction returns [TypeExpres
:
//{isVariableOfType($blockDeclaration::env, input.LT(1).getText(), "TYPEFUNCTION")}?
id = Identifier LPAREN
- args = varArgumentList RPAREN
+ args = varArgumentList? RPAREN
{
expr = external.createExternalTypeFunction(id, args);
}
@@ -963,7 +963,7 @@ condition returns [AbstractTextMarkerCo
externalCondition returns [AbstractTextMarkerCondition condition = null]
:
- id = Identifier LPAREN args = varArgumentList RPAREN
+ id = Identifier LPAREN args = varArgumentList? RPAREN
{
condition = external.createExternalCondition(id, args);
}
@@ -1206,7 +1206,7 @@ action returns [AbstractTextMarkerActio
externalAction returns [AbstractTextMarkerAction action = null]
:
- id = Identifier LPAREN args = varArgumentList RPAREN
+ id = Identifier LPAREN args = varArgumentList? RPAREN
{
action = external.createExternalAction(id, args);
}
@@ -1681,7 +1681,7 @@ List<TypeExpression> list = new ArrayLis
varArgumentList returns [List args = new ArrayList()]
:
- (LPAREN arg = argument {args.add(arg);}(COMMA arg = argument {args.add(arg);})* RPAREN)?
+ arg = argument {args.add(arg);}(COMMA arg = argument {args.add(arg);})*
;
argument returns [TextMarkerExpression expr = null]
@@ -1776,7 +1776,7 @@ externalNumberFunction returns [NumberEx
:
//{isVariableOfType($blockDeclaration::env, input.LT(1).getText(), "NUMBERFUNCTION")}?
id = Identifier LPAREN
- args = varArgumentList RPAREN
+ args = varArgumentList? RPAREN
{
expr = external.createExternalNumberFunction(id, args);
}
@@ -1860,7 +1860,7 @@ externalStringFunction returns [StringEx
:
//{isVariableOfType($blockDeclaration::env, input.LT(1).getText(), "STRINGFUNCTION")}?
id = Identifier LPAREN
- args = varArgumentList RPAREN
+ args = varArgumentList? RPAREN
{
expr = external.createExternalStringFunction(id, args);
}
@@ -1910,7 +1910,7 @@ externalBooleanFunction returns [Boolean
:
//{isVariableOfType($blockDeclaration::env, input.LT(1).getText(), "BOOLEANFUNCTION")}?
id = Identifier LPAREN
- args = varArgumentList RPAREN
+ args = varArgumentList? RPAREN
{
expr = external.createExternalBooleanFunction(id, args);
}
Modified: uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/extensions/TextMarkerExternalFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/extensions/TextMarkerExternalFactory.java?rev=1476065&r1=1476064&r2=1476065&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/extensions/TextMarkerExternalFactory.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-core/src/main/java/org/apache/uima/textmarker/extensions/TextMarkerExternalFactory.java Fri Apr 26 06:36:53 2013
@@ -76,7 +76,7 @@ public class TextMarkerExternalFactory {
if (extension != null) {
return extension.createAction(name, args);
}
- // Throw exception
+ // TODO throw exception
return null;
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g?rev=1476065&r1=1476064&r2=1476065&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/antlr3/org/apache/uima/textmarker/ide/core/parser/TextMarkerParser.g Fri Apr 26 06:36:53 2013
@@ -850,7 +850,7 @@ typeExpression returns [Expression expr
expr = ExpressionFactory.createEmptyTypeExpression(input.LT(1));
}
:
- tf = typeFunction {expr = tf;}
+ (typeFunction)=> tf = typeFunction {expr = tf;}
| st = simpleTypeExpression
{expr = ExpressionFactory.createTypeExpression(st);
}
@@ -865,9 +865,9 @@ typeFunction returns [Expression expr =
// not checked
externalTypeFunction returns [Expression expr = null]
:
- {isVariableOfType(input.LT(1).getText(), "TYPEFUNCTION")}? id = Identifier
+ id = Identifier
LPAREN
- args = varArgumentList
+ args = varArgumentList?
RPAREN
{
expr = external.createExternalTypeFunction(id, args);
@@ -948,8 +948,7 @@ result = ConditionFactory.createEmptyCon
| c = conditionEndsWith
| c = conditionPartOfNeq
| c = conditionSize
- | (c = externalCondition)=> c = externalCondition
- | c = variableCondition
+ | c = externalCondition
) {result = c;}
;
@@ -967,12 +966,12 @@ variableCondition returns [TextMarkerCon
externalCondition returns [TextMarkerCondition condition = null]
:
- {isVariableOfType(input.LT(1).getText(), "CONDITION")}? id = Identifier
- LPAREN
- {condition = external.createExternalCondition(id, args);}
- args = varArgumentList
+ id = Identifier
{condition = external.createExternalCondition(id, args);}
+ LPAREN
+ args = varArgumentList?
RPAREN
+ {condition = external.createExternalCondition(id, args);}
;
conditionAnd returns [TextMarkerCondition cond = null]
:
@@ -1254,8 +1253,8 @@ result = ActionFactory.createEmptyAction
| a = actionAddRetainType
| a = actionRemoveFilterType
| a = actionRemoveRetainType
- | (a = externalAction)=> a = externalAction
- | a = variableAction
+ | a = externalAction
+ // | a = variableAction
) {result = a;}
;
@@ -1272,10 +1271,10 @@ variableAction returns [TextMarkerAction
externalAction returns [TextMarkerAction action = null]
:
- {isVariableOfType(input.LT(1).getText(), "ACTION")}? id = Identifier
- LPAREN
- args = varArgumentList
- RPAREN
+ id = Identifier
+ LPAREN
+ args = varArgumentList?
+ RPAREN
{
action = external.createExternalAction(id, args);
}
@@ -1858,7 +1857,7 @@ actionClear returns [TextMarkerAction ac
//OKdc
varArgumentList returns [List<Expression> args = new ArrayList<Expression>()]
:
- (LPAREN arg = argument {args.add(arg);} (COMMA arg = argument {args.add(arg);})* RPAREN)?
+ arg = argument {args.add(arg);} (COMMA arg = argument {args.add(arg);})*
;
//changed but unknown statuslistExpression
@@ -2035,9 +2034,9 @@ numberFunction returns [Expression expr
// not checked
externalNumberFunction returns [Expression expr = null]
:
- {isVariableOfType(input.LT(1).getText(), "NUMBERFUNCTION")}? id = Identifier
+ id = Identifier
LPAREN
- args = varArgumentList
+ args = varArgumentList?
RPAREN
{
expr = external.createExternalNumberFunction(id, args);
@@ -2088,9 +2087,9 @@ stringFunction returns [Expression expr
// not checked
externalStringFunction returns [Expression expr = null]
:
- {isVariableOfType(input.LT(1).getText(), "STRINGFUNCTION")}? id = Identifier
+ id = Identifier
LPAREN
- args = varArgumentList
+ args = varArgumentList?
RPAREN
{
expr = external.createExternalStringFunction(id, args);
@@ -2151,9 +2150,9 @@ booleanFunction returns [Expression expr
// not checked
externalBooleanFunction returns [Expression expr = null]
:
- {isVariableOfType(input.LT(1).getText(), "BOOLEANFUNCTION")}? id = Identifier
+ id = Identifier
LPAREN
- args = varArgumentList
+ args = varArgumentList?
RPAREN
{
expr = external.createExternalBooleanFunction(id, args);
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/TextMarkerKeywordsManager.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/TextMarkerKeywordsManager.java?rev=1476065&r1=1476064&r2=1476065&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/TextMarkerKeywordsManager.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/TextMarkerKeywordsManager.java Fri Apr 26 06:36:53 2013
@@ -19,6 +19,12 @@
package org.apache.uima.textmarker.ide.core;
+import org.apache.uima.textmarker.extensions.ITextMarkerActionExtension;
+import org.apache.uima.textmarker.extensions.ITextMarkerBooleanFunctionExtension;
+import org.apache.uima.textmarker.extensions.ITextMarkerConditionExtension;
+import org.apache.uima.textmarker.extensions.ITextMarkerNumberFunctionExtension;
+import org.apache.uima.textmarker.extensions.ITextMarkerStringFunctionExtension;
+import org.apache.uima.textmarker.extensions.ITextMarkerTypeFunctionExtension;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.Platform;
@@ -61,6 +67,42 @@ public final class TextMarkerKeywordsMan
}
}
}
+ ITextMarkerActionExtension[] actionExtensions = TextMarkerExtensionManager.getDefault()
+ .getTextMarkerActionExtensions();
+ for (ITextMarkerActionExtension each : actionExtensions) {
+ String[] knownExtensions = each.getKnownExtensions();
+ all[ITextMarkerKeywords.ACTION] = TextMarkerKeywords.append(all[ITextMarkerKeywords.ACTION], knownExtensions);
+ }
+ ITextMarkerConditionExtension[] conditionExtensions = TextMarkerExtensionManager.getDefault()
+ .getTextMarkerConditionExtensions();
+ for (ITextMarkerConditionExtension each : conditionExtensions) {
+ String[] knownExtensions = each.getKnownExtensions();
+ all[ITextMarkerKeywords.CONDITION] = TextMarkerKeywords.append(all[ITextMarkerKeywords.CONDITION], knownExtensions);
+ }
+ ITextMarkerBooleanFunctionExtension[] booleanFunctionExtensions = TextMarkerExtensionManager.getDefault()
+ .getTextMarkerBooleanFunctionExtensions();
+ for (ITextMarkerBooleanFunctionExtension each : booleanFunctionExtensions) {
+ String[] knownExtensions = each.getKnownExtensions();
+ all[ITextMarkerKeywords.BOOLEANFUNCTION] = TextMarkerKeywords.append(all[ITextMarkerKeywords.BOOLEANFUNCTION], knownExtensions);
+ }
+ ITextMarkerNumberFunctionExtension[] numberFunctionExtensions = TextMarkerExtensionManager.getDefault()
+ .getTextMarkerNumberFunctionExtensions();
+ for (ITextMarkerNumberFunctionExtension each : numberFunctionExtensions) {
+ String[] knownExtensions = each.getKnownExtensions();
+ all[ITextMarkerKeywords.NUMBERFUNCTION] = TextMarkerKeywords.append(all[ITextMarkerKeywords.NUMBERFUNCTION], knownExtensions);
+ }
+ ITextMarkerStringFunctionExtension[] stringFunctionExtensions = TextMarkerExtensionManager.getDefault()
+ .getTextMarkerStringFunctionExtensions();
+ for (ITextMarkerStringFunctionExtension each : stringFunctionExtensions) {
+ String[] knownExtensions = each.getKnownExtensions();
+ all[ITextMarkerKeywords.STRINGFUNCTION] = TextMarkerKeywords.append(all[ITextMarkerKeywords.STRINGFUNCTION], knownExtensions);
+ }
+ ITextMarkerTypeFunctionExtension[] typeFunctionExtensions = TextMarkerExtensionManager.getDefault()
+ .getTextMarkerTypeFunctionExtensions();
+ for (ITextMarkerTypeFunctionExtension each : typeFunctionExtensions) {
+ String[] knownExtensions = each.getKnownExtensions();
+ all[ITextMarkerKeywords.TYPEFUNCTION] = TextMarkerKeywords.append(all[ITextMarkerKeywords.TYPEFUNCTION], knownExtensions);
+ }
}
public static String[] getKeywords() {
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEActionExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEActionExtension.java?rev=1476065&r1=1476064&r2=1476065&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEActionExtension.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEActionExtension.java Fri Apr 26 06:36:53 2013
@@ -19,16 +19,8 @@
package org.apache.uima.textmarker.ide.core.extensions;
-import java.util.List;
-
-import org.antlr.runtime.RecognitionException;
-import org.antlr.runtime.Token;
-import org.apache.uima.textmarker.ide.parser.ast.TextMarkerAction;
-import org.eclipse.dltk.ast.expressions.Expression;
public interface IIDEActionExtension extends ITextMarkerExtension {
- TextMarkerAction createAction(Token type, List<Expression> args) throws RecognitionException;
-
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEBooleanFunctionExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEBooleanFunctionExtension.java?rev=1476065&r1=1476064&r2=1476065&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEBooleanFunctionExtension.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEBooleanFunctionExtension.java Fri Apr 26 06:36:53 2013
@@ -19,15 +19,7 @@
package org.apache.uima.textmarker.ide.core.extensions;
-import java.util.List;
-
-import org.antlr.runtime.RecognitionException;
-import org.antlr.runtime.Token;
-import org.apache.uima.textmarker.ide.parser.ast.TextMarkerExpression;
-import org.eclipse.dltk.ast.expressions.Expression;
public interface IIDEBooleanFunctionExtension extends ITextMarkerExtension {
- TextMarkerExpression createBooleanFunction(Token type, List<Expression> args)
- throws RecognitionException;
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEConditionExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEConditionExtension.java?rev=1476065&r1=1476064&r2=1476065&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEConditionExtension.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEConditionExtension.java Fri Apr 26 06:36:53 2013
@@ -19,17 +19,8 @@
package org.apache.uima.textmarker.ide.core.extensions;
-import java.util.List;
-
-import org.antlr.runtime.RecognitionException;
-import org.antlr.runtime.Token;
-import org.apache.uima.textmarker.ide.parser.ast.TextMarkerCondition;
-import org.eclipse.dltk.ast.expressions.Expression;
public interface IIDEConditionExtension extends ITextMarkerExtension {
- TextMarkerCondition createCondition(Token type, List<Expression> args)
- throws RecognitionException;
-
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDENumberFunctionExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDENumberFunctionExtension.java?rev=1476065&r1=1476064&r2=1476065&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDENumberFunctionExtension.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDENumberFunctionExtension.java Fri Apr 26 06:36:53 2013
@@ -19,15 +19,7 @@
package org.apache.uima.textmarker.ide.core.extensions;
-import java.util.List;
-
-import org.antlr.runtime.RecognitionException;
-import org.antlr.runtime.Token;
-import org.apache.uima.textmarker.ide.parser.ast.TextMarkerExpression;
-import org.eclipse.dltk.ast.expressions.Expression;
public interface IIDENumberFunctionExtension extends ITextMarkerExtension {
- TextMarkerExpression createNumberFunction(Token type, List<Expression> args)
- throws RecognitionException;
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEStringFunctionExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEStringFunctionExtension.java?rev=1476065&r1=1476064&r2=1476065&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEStringFunctionExtension.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDEStringFunctionExtension.java Fri Apr 26 06:36:53 2013
@@ -19,15 +19,7 @@
package org.apache.uima.textmarker.ide.core.extensions;
-import java.util.List;
-
-import org.antlr.runtime.RecognitionException;
-import org.antlr.runtime.Token;
-import org.apache.uima.textmarker.ide.parser.ast.TextMarkerExpression;
-import org.eclipse.dltk.ast.expressions.Expression;
public interface IIDEStringFunctionExtension extends ITextMarkerExtension {
- TextMarkerExpression createStringFunction(Token type, List<Expression> args)
- throws RecognitionException;
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDETypeFunctionExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDETypeFunctionExtension.java?rev=1476065&r1=1476064&r2=1476065&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDETypeFunctionExtension.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/IIDETypeFunctionExtension.java Fri Apr 26 06:36:53 2013
@@ -19,15 +19,7 @@
package org.apache.uima.textmarker.ide.core.extensions;
-import java.util.List;
-
-import org.antlr.runtime.RecognitionException;
-import org.antlr.runtime.Token;
-import org.apache.uima.textmarker.ide.parser.ast.TextMarkerExpression;
-import org.eclipse.dltk.ast.expressions.Expression;
public interface IIDETypeFunctionExtension extends ITextMarkerExtension {
- TextMarkerExpression createTypeFunction(Token type, List<Expression> args)
- throws RecognitionException;
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/ITextMarkerExtension.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/ITextMarkerExtension.java?rev=1476065&r1=1476064&r2=1476065&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/ITextMarkerExtension.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/ITextMarkerExtension.java Fri Apr 26 06:36:53 2013
@@ -19,8 +19,16 @@
package org.apache.uima.textmarker.ide.core.extensions;
+import java.util.List;
+
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.Token;
+import org.eclipse.dltk.ast.expressions.Expression;
+
public interface ITextMarkerExtension {
String[] getKnownExtensions();
+
+ void checkSyntax(Token name, List<Expression> arguments) throws RecognitionException;
}
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/TextMarkerExternalFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/TextMarkerExternalFactory.java?rev=1476065&r1=1476064&r2=1476065&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/TextMarkerExternalFactory.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/core/extensions/TextMarkerExternalFactory.java Fri Apr 26 06:36:53 2013
@@ -23,13 +23,14 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.antlr.runtime.NoViableAltException;
import org.antlr.runtime.RecognitionException;
import org.antlr.runtime.Token;
import org.apache.uima.textmarker.ide.core.TextMarkerExtensionManager;
+import org.apache.uima.textmarker.ide.parser.ast.ActionFactory;
+import org.apache.uima.textmarker.ide.parser.ast.ConditionFactory;
+import org.apache.uima.textmarker.ide.parser.ast.ExpressionFactory;
import org.apache.uima.textmarker.ide.parser.ast.TextMarkerAction;
import org.apache.uima.textmarker.ide.parser.ast.TextMarkerCondition;
-import org.apache.uima.textmarker.ide.parser.ast.TextMarkerExpression;
import org.eclipse.dltk.ast.expressions.Expression;
public class TextMarkerExternalFactory {
@@ -105,71 +106,56 @@ public class TextMarkerExternalFactory {
}
+
public TextMarkerCondition createExternalCondition(Token id, List<Expression> args)
throws RecognitionException {
String name = id.getText();
- IIDEConditionExtension extension = conditionExtensions.get(name);
- if (extension != null) {
- return extension.createCondition(id, args);
- }
- throw new NoViableAltException();
+ ITextMarkerExtension extension = conditionExtensions.get(name);
+ extension.checkSyntax(id, args);
+ return ConditionFactory.createCondition(id, args);
}
public TextMarkerAction createExternalAction(Token id, List<Expression> args)
throws RecognitionException {
String name = id.getText();
- IIDEActionExtension extension = actionExtensions.get(name);
- if (extension != null) {
- return extension.createAction(id, args);
- }
- throw new NoViableAltException("Unknown action : " + name, id.getType(), id.getType(),
- id.getInputStream());
+ ITextMarkerExtension extension = actionExtensions.get(name);
+ extension.checkSyntax(id, args);
+ return ActionFactory.createAction(id, args);
}
- public TextMarkerExpression createExternalNumberFunction(Token id, List<Expression> args)
+ public Expression createExternalNumberFunction(Token id, List<Expression> args)
throws RecognitionException {
String name = id.getText();
- IIDENumberFunctionExtension extension = numberFunctionExtensions.get(name);
- if (extension != null) {
- return extension.createNumberFunction(id, args);
- }
- throw new NoViableAltException("Unknown number function : " + name, id.getType(), id.getType(),
- id.getInputStream());
+ ITextMarkerExtension extension = numberFunctionExtensions.get(name);
+ extension.checkSyntax(id, args);
+ return ExpressionFactory.createNumberFunction(id, args);
}
- public TextMarkerExpression createExternalBooleanFunction(Token id, List<Expression> args)
+ public Expression createExternalBooleanFunction(Token id, List<Expression> args)
throws RecognitionException {
String name = id.getText();
- IIDEBooleanFunctionExtension extension = booleanFunctionExtensions.get(name);
- if (extension != null) {
- return extension.createBooleanFunction(id, args);
- }
- throw new NoViableAltException("Unknown number function : " + name, id.getType(), id.getType(),
- id.getInputStream());
+ ITextMarkerExtension extension = booleanFunctionExtensions.get(name);
+ extension.checkSyntax(id, args);
+ return ExpressionFactory.createBooleanFunction(id, args);
}
- public TextMarkerExpression createExternalStringFunction(Token id, List<Expression> args)
+ public Expression createExternalStringFunction(Token id, List<Expression> args)
throws RecognitionException {
String name = id.getText();
- IIDEStringFunctionExtension extension = stringFunctionExtensions.get(name);
- if (extension != null) {
- return extension.createStringFunction(id, args);
- }
- throw new NoViableAltException("Unknown number function : " + name, id.getType(), id.getType(),
- id.getInputStream());
+ ITextMarkerExtension extension = stringFunctionExtensions.get(name);
+ extension.checkSyntax(id, args);
+ return ExpressionFactory.createStringFunction(id, args);
}
- public TextMarkerExpression createExternalTypeFunction(Token id, List<Expression> args)
+ public Expression createExternalTypeFunction(Token id, List<Expression> args)
throws RecognitionException {
String name = id.getText();
- IIDETypeFunctionExtension extension = typeFunctionExtensions.get(name);
- if (extension != null) {
- return extension.createTypeFunction(id, args);
- }
- throw new NoViableAltException("Unknown number function : " + name, id.getType(), id.getType(),
- id.getInputStream());
+ ITextMarkerExtension extension = typeFunctionExtensions.get(name);
+ extension.checkSyntax(id, args);
+ return ExpressionFactory.createTypeFunction(id, args);
}
+
public void addExtension(String id, ITextMarkerExtension extension) {
if (extension instanceof IIDEActionExtension) {
addActionExtension(id, (IIDEActionExtension) extension);
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=1476065&r1=1476064&r2=1476065&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 Fri Apr 26 06:36:53 2013
@@ -42,6 +42,7 @@ import org.eclipse.core.resources.IResou
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
@@ -193,9 +194,34 @@ public class TextMarkerLaunchConfigurati
Collection<String> dependencies = getDependencies(configuration);
extendedClasspath.addAll(dependencies);
+ Collection<String> extensions = getExtensions(configuration);
+ extendedClasspath.addAll(extensions);
+
return extendedClasspath.toArray(new String[extendedClasspath.size()]);
}
+ private Collection<String> getExtensions(ILaunchConfiguration configuration) throws CoreException {
+ TextMarkerIdePlugin d = TextMarkerIdePlugin.getDefault();
+ Collection<String> result = new TreeSet<String>();
+ IExtension[] extensions = Platform.getExtensionRegistry()
+ .getExtensionPoint(TextMarkerIdePlugin.PLUGIN_ID, "actionExtension").getExtensions();
+ for (IExtension each : extensions) {
+ String namespaceIdentifier = each.getNamespaceIdentifier();
+ try {
+ if (!Platform.inDevelopmentMode()) {
+ result.add(d.pluginIdToJarPath(namespaceIdentifier));
+ } else {
+ result.add(d.pluginIdToJarPath(namespaceIdentifier)+ "target/classes");
+ result.add(d.pluginIdToJarPath(namespaceIdentifier)+ "bin");
+ }
+ } catch (IOException e) {
+ throw new CoreException(new Status(IStatus.ERROR, TextMarkerIdePlugin.PLUGIN_ID,
+ IStatus.OK, "Failed to extend classpath with " + namespaceIdentifier + "!", e));
+ }
+ }
+ return result;
+ }
+
private Collection<String> getDependencies(ILaunchConfiguration configuration)
throws CoreException {
Collection<String> result = new TreeSet<String>();
@@ -253,8 +279,6 @@ public class TextMarkerLaunchConfigurati
}
}
-
-
@Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch,
IProgressMonitor monitor) throws CoreException {
Modified: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ExpressionFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ExpressionFactory.java?rev=1476065&r1=1476064&r2=1476065&view=diff
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ExpressionFactory.java (original)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/ExpressionFactory.java Fri Apr 26 06:36:53 2013
@@ -338,9 +338,46 @@ public class ExpressionFactory extends A
public static Expression createStringFunction(Token name, Expression var, List<Expression> list) {
list.add(0, var);
- return createStringExpression(list);
+ return createStringFunction(name, list);
}
+ public static Expression createBooleanFunction(Token id, List<Expression> args) {
+ return createFunction(id, args, TMTypeConstants.TM_TYPE_B);
+ }
+
+ public static Expression createNumberFunction(Token id, List<Expression> args) {
+ return createFunction(id, args, TMTypeConstants.TM_TYPE_N);
+ }
+
+ public static Expression createStringFunction(Token id, List<Expression> args) {
+ return createFunction(id, args, TMTypeConstants.TM_TYPE_S);
+ }
+
+ public static Expression createTypeFunction(Token id, List<Expression> args) {
+ return createFunction(id, args, TMTypeConstants.TM_TYPE_AT);
+ }
+
+ public static TextMarkerFunction createFunction(Token type, List<Expression> exprsRaw, int kind) {
+ int bounds[] = getBounds(type);
+ int nameStart = bounds[0];
+ int nameEnd = bounds[1];
+ List<Expression> exprs = new ArrayList<Expression>();
+ if (exprsRaw != null) {
+ for (Object expressionObj : exprsRaw) {
+ Expression expr = (Expression) expressionObj;
+ if (expr != null) {
+ exprs.add(expr);
+ }
+ }
+ if (!exprs.isEmpty()) {
+ Expression lastExpr = (Expression) exprs.get(exprs.size() - 1);
+ bounds[1] = Math.max(bounds[1], lastExpr.sourceEnd());
+ }
+ }
+ return new TextMarkerFunction(bounds[0], bounds[1], exprs,
+ kind, type.getText(), nameStart,
+ nameEnd);
+ }
}
Added: uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerFunction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerFunction.java?rev=1476065&view=auto
==============================================================================
--- uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerFunction.java (added)
+++ uima/sandbox/textmarker/trunk/textmarker-ep-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerFunction.java Fri Apr 26 06:36:53 2013
@@ -0,0 +1,107 @@
+/*
+ * 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.textmarker.ide.parser.ast;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.expressions.Expression;
+
+public class TextMarkerFunction extends Expression {
+ protected List<Expression> exprs;
+
+ protected int kind;
+
+ private int nameStart;
+
+ private int nameEnd;
+
+ private String name;
+
+ /**
+ * @param start
+ * @param end
+ * @param exprs
+ * @param kind
+ */
+ public TextMarkerFunction(int start, int end, List<Expression> exprs, int kind, String name,
+ int nameStart, int nameEnd) {
+ super(start, end);
+ if (exprs != null) {
+ this.exprs = exprs;
+ } else {
+ this.exprs = new ArrayList<Expression>();
+ }
+ this.kind = kind;
+ this.name = name;
+ this.nameStart = nameStart;
+ this.nameEnd = nameEnd;
+ }
+
+ /**
+ * Copy-Constructor
+ *
+ * @param source
+ */
+ public TextMarkerFunction(TextMarkerFunction source) {
+ super(source.sourceStart(), source.sourceEnd());
+ this.exprs = source.exprs;
+ this.kind = source.kind;
+ }
+
+ @Override
+ public int getKind() {
+ return this.kind;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public void traverse(ASTVisitor visitor) throws Exception {
+ if (visitor.visit(this)) {
+ for (Expression expr : exprs) {
+ if (expr != null) {
+ expr.traverse(visitor);
+ }
+ }
+ visitor.endvisit(this);
+ }
+ }
+
+ @Override
+ public List<Expression> getChilds() {
+ return exprs;
+ }
+
+ public String toString() {
+ return this.getClass().getSimpleName() + " : " + super.toString();
+ }
+
+ public int getNameStart() {
+ return nameStart;
+ }
+
+ public int getNameEnd() {
+ return nameEnd;
+ }
+}