You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by jo...@apache.org on 2011/08/12 13:00:51 UTC
svn commit: r1157047 [17/27] - in
/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide: ./ .settings/
META-INF/ icons/ schema/ src/ src/main/ src/main/java/ src/main/java/org/
src/main/java/org/apache/ src/main/java/org/apache/uima/ src/main/java/org...
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStatement.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStatement.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStatement.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStatement.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,142 @@
+/*
+ * 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.Iterator;
+import java.util.List;
+
+import org.eclipse.dltk.ast.ASTNode;
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.ast.statements.Statement;
+import org.eclipse.dltk.ast.statements.StatementConstants;
+import org.eclipse.dltk.utils.CorePrinter;
+
+public class TextMarkerStatement extends Statement {
+ private List<Expression> expressions;
+
+ /**
+ * Statement with bounds from first to last expression.
+ *
+ * @param expressions
+ */
+ public TextMarkerStatement(List<Expression> expressions) {
+ if (!expressions.isEmpty()) {
+ // First
+ Expression first = expressions.get(0);
+ if (first != null) {
+ this.setStart(first.sourceStart());
+ }
+ // Last
+ Expression last = expressions.get(expressions.size() - 1);
+ if (last != null) {
+ this.setEnd(last.sourceEnd());
+ }
+ }
+ this.expressions = expressions;
+ }
+
+ /**
+ * Statement with specified bounds and expression list.
+ *
+ * @param start
+ * @param end
+ * @param expressions
+ */
+ public TextMarkerStatement(int start, int end, List<Expression> expressions) {
+ super(start, end);
+ if (expressions == null) {
+ this.expressions = new ArrayList<Expression>();
+ } else {
+ this.expressions = expressions;
+ }
+ }
+
+ public List<Expression> getExpressions() {
+ return this.expressions;
+ }
+
+ public Expression getAt(int index) {
+ if (index >= 0 && index < this.expressions.size()) {
+ return this.expressions.get(index);
+ }
+
+ return null;
+ }
+
+ public int getCount() {
+ return this.expressions.size();
+ }
+
+ @Override
+ public int getKind() {
+ return StatementConstants.S_BLOCK;
+ // return TextMarkerConstants.TM_STATEMENT;
+ }
+
+ @Override
+ public void traverse(ASTVisitor visitor) throws Exception {
+ if (visitor.visit(this)) {
+ if (this.expressions != null) {
+ for (int i = 0; i < this.expressions.size(); i++) {
+ ASTNode node = this.expressions.get(i);
+ if (node != null) {
+ node.traverse(visitor);
+ }
+ }
+ }
+ visitor.endvisit(this);
+ }
+ }
+
+ @Override
+ public void printNode(CorePrinter output) {
+ if (this.expressions != null) {
+ output.formatPrintLn("");
+ Iterator i = this.expressions.iterator();
+ while (i.hasNext()) {
+ ASTNode node = (ASTNode) i.next();
+ node.printNode(output);
+ output.formatPrintLn(" ");
+ }
+ }
+ }
+
+ @Override
+ public String toString() {
+ String value = "";
+ if (this.expressions != null) {
+ Iterator i = this.expressions.iterator();
+ while (i.hasNext()) {
+ ASTNode node = (ASTNode) i.next();
+ value += node.toString();
+ value += " ";
+ }
+ }
+
+ return value;
+ }
+
+ public void setExpressions(List<Expression> asList) {
+ this.expressions = asList;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStatement.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStatement.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStringExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStringExpression.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStringExpression.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStringExpression.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,65 @@
+/*
+ * 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.List;
+
+import org.eclipse.dltk.ast.ASTListNode;
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.ast.expressions.ExpressionConstants;
+import org.eclipse.dltk.utils.CorePrinter;
+
+/**
+ * Simple string literal or concatenation of strings / string expressions
+ *
+ *
+ */
+public class TextMarkerStringExpression extends TextMarkerExpression {
+ private ASTListNode exprs;
+
+ public TextMarkerStringExpression(int start, int end, List<Expression> exprList) {
+ super(start, end, null, TMTypeConstants.TM_TYPE_S);
+ this.exprs = new ASTListNode(start, end, exprList);
+ }
+
+ @Override
+ public int getKind() {
+ return ExpressionConstants.E_CONCAT;
+ }
+
+ @Override
+ public void traverse(ASTVisitor visitor) throws Exception {
+ if (visitor.visit(this)) {
+ this.exprs.traverse(visitor);
+ }
+ }
+
+ @Override
+ public void printNode(CorePrinter output) {
+ exprs.printNode(output);
+ }
+
+ @Override
+ public String getOperator() {
+ return "+";
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStringExpression.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStringExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStructureAction.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStructureAction.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStructureAction.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStructureAction.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,83 @@
+/*
+ * 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.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.expressions.Expression;
+
+public class TextMarkerStructureAction extends TextMarkerAction {
+ private Expression structure;
+
+ private Map<Expression, Expression> assignments;
+
+ public TextMarkerStructureAction(int start, int end, List<Expression> indexExprs, int kind,
+ String name, int nameStart, int nameEnd, Map<Expression, Expression> assignments,
+ Expression structure) {
+ super(start, end, indexExprs, kind, name, nameStart, nameEnd);
+ this.structure = structure;
+ this.assignments = assignments;
+ }
+
+ @Override
+ public void traverse(ASTVisitor visitor) throws Exception {
+ if (visitor.visit(this)) {
+ structure.traverse(visitor);
+ for (Expression e : super.exprs) {
+ e.traverse(visitor);
+ }
+ Iterator it = assignments.entrySet().iterator();
+ while (it.hasNext()) {
+ Map.Entry pairs = (Map.Entry) it.next();
+ if (pairs.getKey() == null || pairs.getValue() == null) {
+ break;
+ }
+ ((Expression) pairs.getKey()).traverse(visitor);
+ ((Expression) pairs.getValue()).traverse(visitor);
+ }
+ }
+ }
+
+ @Override
+ public List getChilds() {
+ List l = new ArrayList<Expression>();
+ l.add(structure);
+ l.addAll(super.getChilds());
+ l.addAll(assignments.keySet());
+ l.addAll(assignments.values());
+ return l;
+ }
+
+ public Map<Expression, Expression> getAssignments() {
+ return assignments;
+ }
+
+ public Expression getStructure() {
+ return structure;
+ }
+
+ public List<Expression> getIndices() {
+ return super.exprs;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStructureAction.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerStructureAction.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerTypeDeclaration.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerTypeDeclaration.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerTypeDeclaration.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerTypeDeclaration.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,60 @@
+/*
+ * 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.references.SimpleReference;
+
+public class TextMarkerTypeDeclaration extends TextMarkerAbstractDeclaration {
+
+ private List<TextMarkerFeatureDeclaration> features = new ArrayList<TextMarkerFeatureDeclaration>();
+
+ public TextMarkerTypeDeclaration(String name, int nameStart, int nameEnd, int declStart,
+ int declEnd, SimpleReference ref) {
+ super(name, nameStart, nameEnd, declStart, declEnd, ref);
+ }
+
+ public TextMarkerTypeDeclaration(String name, int nameStart, int nameEnd, int declStart,
+ int declEnd, SimpleReference ref, List<TextMarkerFeatureDeclaration> features) {
+ super(name, nameStart, nameEnd, declStart, declEnd, ref);
+ this.setFeatures(features);
+ }
+
+ public void traverse(ASTVisitor visitor) throws Exception {
+ if (visitor.visit(this)) {
+ getRef().traverse(visitor);
+ for (TextMarkerFeatureDeclaration each : getFeatures()) {
+ each.traverse(visitor);
+ }
+ visitor.endvisit(this);
+ }
+ }
+
+ public void setFeatures(List<TextMarkerFeatureDeclaration> features) {
+ this.features = features;
+ }
+
+ public List<TextMarkerFeatureDeclaration> getFeatures() {
+ return features;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerTypeDeclaration.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerTypeDeclaration.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerUnaryArithmeticExpression.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerUnaryArithmeticExpression.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerUnaryArithmeticExpression.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerUnaryArithmeticExpression.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,72 @@
+/*
+ * 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.Iterator;
+import java.util.Map;
+
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.expressions.Expression;
+
+public class TextMarkerUnaryArithmeticExpression extends Expression {
+ private int opID;
+
+ private Expression expr;
+
+ public TextMarkerUnaryArithmeticExpression(int start, int end, Expression expr, int opID) {
+ super(start, end);
+ this.opID = opID;
+ this.expr = expr;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.dltk.ast.statements.Statement#getKind()
+ */
+ @Override
+ public int getKind() {
+ return opID;
+ }
+
+ @Override
+ public String getOperator() {
+ Map<String, Integer> map = TMExpressionConstants.opIDs;
+ for (Iterator iterator = map.keySet().iterator(); iterator.hasNext();) {
+ String key = (String) iterator.next();
+ Integer intID = map.get(key);
+ if (intID.equals(opID)) {
+ return key;
+ }
+ }
+ return super.getOperator();
+ }
+
+ @Override
+ public void traverse(ASTVisitor visitor) throws Exception {
+ if (visitor.visit(this)) {
+ if (expr != null) {
+ this.expr.traverse(visitor);
+ }
+ visitor.endvisit(this);
+ }
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerUnaryArithmeticExpression.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerUnaryArithmeticExpression.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerVariableDeclaration.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerVariableDeclaration.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerVariableDeclaration.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerVariableDeclaration.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,76 @@
+/*
+ * 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 org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.ast.references.SimpleReference;
+
+public class TextMarkerVariableDeclaration extends TextMarkerAbstractDeclaration {
+
+ private int type;
+
+ private boolean hasInitExpression;
+
+ private Expression initExpression;
+
+ public TextMarkerVariableDeclaration(String name, int nameStart, int nameEnd, int declStart,
+ int declEnd, SimpleReference ref, int type) {
+ super(name, nameStart, nameEnd, declStart, declEnd, ref);
+ this.type = type;
+ hasInitExpression = false;
+ }
+
+ public TextMarkerVariableDeclaration(String name, int nameStart, int nameEnd, int declStart,
+ int declEnd, SimpleReference ref, int type, Expression initExpression) {
+ this(name, nameStart, nameEnd, declStart, declEnd, ref, type);
+ this.initExpression = initExpression;
+ if (initExpression != null) {
+ hasInitExpression = true;
+ }
+ }
+
+ @Override
+ public void traverse(ASTVisitor visitor) throws Exception {
+ if (visitor.visit(this)) {
+ getRef().traverse(visitor);
+ if (hasInitExpression) {
+ initExpression.traverse(visitor);
+ }
+ visitor.endvisit(this);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return this.getName() + ":: TextMarkerIntVariable :: " + super.toString();
+ }
+
+ /**
+ * @return see {@link TMTypeConstants}
+ */
+ public int getType() {
+ return this.type;
+ }
+
+ public boolean hasInitExpression() {
+ return hasInitExpression;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerVariableDeclaration.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerVariableDeclaration.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerVariableReference.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerVariableReference.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerVariableReference.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerVariableReference.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,46 @@
+/*
+ * 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 org.eclipse.dltk.ast.references.VariableReference;
+
+public class TextMarkerVariableReference extends VariableReference {
+ private int typeId;
+
+ /**
+ * @param start
+ * @param end
+ * @param name
+ * @param typedId
+ * raw type id from {@link TMTypeConstants}
+ */
+ public TextMarkerVariableReference(int start, int end, String name, int typedId) {
+ super(start, end, name);
+ this.typeId = typedId;
+ }
+
+ public int getType() {
+ return this.typeId;
+ }
+
+ public void setType(int type) {
+ this.typeId = type;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerVariableReference.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/parser/ast/TextMarkerVariableReference.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/ITextMarkerTestingEngine.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/ITextMarkerTestingEngine.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/ITextMarkerTestingEngine.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/ITextMarkerTestingEngine.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,38 @@
+/*
+ * 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.testing;
+
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.launching.InterpreterConfig;
+import org.eclipse.dltk.testing.ITestingProcessor;
+
+public interface ITextMarkerTestingEngine {
+ String getId();
+
+ String getName();
+
+ boolean isValidModule(ISourceModule module);
+
+ ITestingProcessor getProcessor(ILaunch launch);
+
+ void correctLaunchConfiguration(InterpreterConfig config, ILaunchConfiguration configuration);
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/ITextMarkerTestingEngine.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/ITextMarkerTestingEngine.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerOutputProcessor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerOutputProcessor.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerOutputProcessor.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerOutputProcessor.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,85 @@
+/*
+ * 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.testing;
+
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.dltk.testing.DLTKTestingPlugin;
+import org.eclipse.dltk.testing.ITestingClient;
+import org.eclipse.dltk.testing.ITestingProcessor;
+import org.eclipse.dltk.testing.model.ITestRunSession;
+
+class TextMarkerOutputProcessor implements ITestingProcessor {
+ private ILaunch launch;
+
+ public TextMarkerOutputProcessor(ILaunch launch) {
+ this.launch = launch;
+ }
+
+ public void done() {
+ client.testTerminated(0);
+ }
+
+ static int i = 0;
+
+ private ITestRunSession session;
+
+ private ITestingClient client;
+
+ public void processLine(String line) {
+
+ // System.out.println("#" + line);
+ if (line.length() == 0) {
+ return;
+ }
+ final String name = line;
+
+ int id = ++i;
+ client.testTree(id, name, false, 0);
+ client.testStarted(id, name);
+ // client.receiveMessage(MessageIds.TRACE_START);
+ // client.receiveMessage("This is Trace");
+ // client.receiveMessage(MessageIds.TRACE_END);
+ session.setTotalCount(id);
+ if (i % 3 == 0) {
+ client.testFailed(id, name);
+ client.traceMessage("This is trace");
+ } else if (i % 4 == 0) {
+ client.testError(id, name);
+ client.traceMessage("This is trace");
+ } else {
+ client.testEnded(id, name);
+ }
+ // client.receiveMessage(MessageIds.TEST_END + name + ","
+ // + name);
+
+ }
+
+ public void start() {
+ i = 0;
+ session = DLTKTestingPlugin.getTestRunSession(launch);
+ if (session == null)
+ return;
+
+ client = session.getTestRunnerClient();
+
+ client.testRunStart(100);
+
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerOutputProcessor.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerOutputProcessor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestMemberResolver.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestMemberResolver.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestMemberResolver.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestMemberResolver.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,78 @@
+/*
+ * 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.testing;
+
+import org.apache.uima.textmarker.ide.parser.ast.TextMarkerStatement;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.dltk.ast.ASTNode;
+import org.eclipse.dltk.ast.ASTVisitor;
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.ast.expressions.Expression;
+import org.eclipse.dltk.ast.references.SimpleReference;
+import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.dltk.testing.AbstractTestingElementResolver;
+import org.eclipse.dltk.testing.ITestingElementResolver;
+
+public class TextMarkerTestMemberResolver extends AbstractTestingElementResolver implements
+ ITestingElementResolver {
+ @Override
+ protected ASTNode findNode(final String testName, ModuleDeclaration decl, String method) {
+ final ASTNode[] nde = new ASTNode[] { null };
+ try {
+ decl.traverse(new ASTVisitor() {
+
+ @Override
+ public boolean visitGeneral(ASTNode node) throws Exception {
+ if (node instanceof TextMarkerStatement && ((TextMarkerStatement) node).getCount() > 2) {
+ TextMarkerStatement st = (TextMarkerStatement) node;
+ Expression cmd = st.getAt(0);
+ if (cmd instanceof SimpleReference) {
+ String cmdName = ((SimpleReference) cmd).getName();
+ if (cmdName.startsWith("::")) {
+ cmdName = cmdName.substring(2);
+ }
+ if ("test".equals(cmdName) || "tmtest::test".equals(cmdName)) {
+
+ // List findLevelsTo = findLevelsTo(decl, node);
+ Expression name = st.getAt(1);
+ if (name instanceof SimpleReference) {
+ String nameValue = ((SimpleReference) name).getName();
+ if (testName.equals(nameValue)) {
+ nde[0] = st;
+ }
+ }
+ }
+ }
+ }
+ return true;
+ }
+ });
+ } catch (CoreException e) {
+ if (DLTKCore.DEBUG) {
+ e.printStackTrace();
+ }
+ } catch (Exception e) {
+ if (DLTKCore.DEBUG) {
+ e.printStackTrace();
+ }
+ }
+ return nde[0];
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestMemberResolver.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestMemberResolver.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestOutputProcessor.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestOutputProcessor.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestOutputProcessor.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestOutputProcessor.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,180 @@
+/*
+ * 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.testing;
+
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.dltk.testing.DLTKTestingPlugin;
+import org.eclipse.dltk.testing.ITestingClient;
+import org.eclipse.dltk.testing.ITestingProcessor;
+import org.eclipse.dltk.testing.model.ITestRunSession;
+
+class TextMarkerTestOutputProcessor implements ITestingProcessor {
+ private ILaunch launch;
+
+ long start = 0;
+
+ public TextMarkerTestOutputProcessor(ILaunch launch) {
+ this.launch = launch;
+ // System.out.println("TextMarkerTestOutputProcessor created");
+ }
+
+ int index = 0;
+
+ private ITestRunSession session;
+
+ private ITestingClient client;
+
+ private boolean skip = false;
+
+ private String message;
+
+ private int state = STATE_NORMAL;
+
+ private static final int STATE_NORMAL = 0;
+
+ private static final int STATE_RESULT_WAS = 1;
+
+ private static final int STATE_RESULT_ACTUAL = 2;
+
+ private String resultActual = "";
+
+ private String resultExpected = "";
+
+ public void done() {
+ // System.out.println("DONE");
+ if (session == null || client == null) {
+ // System.out.println("Session is NULL");
+ return;
+ }
+ session.setTotalCount(index);
+ client.testTerminated((int) (System.currentTimeMillis() - start));
+ }
+
+ public void processLine(String line) {
+ // System.out.println("#" + line);
+ if (session == null || client == null) {
+ return;
+ }
+ // System.out.println("@");
+ if (line.length() == 0) {
+ return;
+ }
+ if (line.startsWith("====")) {
+ if (line.endsWith("FAILED")) {
+ if (!skip) {
+ message = line.substring(line.indexOf(" ", line.indexOf(" ") + 1), line.lastIndexOf(" "));
+
+ }
+ if (skip) {
+ int lastIndexOf = line.indexOf(" ", line.indexOf(" ") + 1);
+ String name = line.substring(5, lastIndexOf);
+
+ int id = ++index;
+
+ client.testTree(id, name, false, 0);
+ client.testStarted(id, name);
+ session.setTotalCount(id);
+ client.testError(id, name);
+
+ client.testActual(resultActual);
+ client.testExpected(resultExpected);
+ client.traceStart();
+ client.traceMessage(message);
+ client.traceEnd();
+
+ resetState();
+ }
+ skip = !skip;
+ }
+ } else if (line.equals("---- Result was:")) {
+ state = STATE_RESULT_WAS;
+ return;
+ } else if (line.equals("---- Result should have been (exact matching):")) {
+ state = STATE_RESULT_ACTUAL;
+ return;
+ }
+ switch (state) {
+ case STATE_RESULT_ACTUAL:
+ String d = resultExpected.length() > 0 ? "\n" : "";
+ resultExpected += d + line;
+ break;
+ case STATE_RESULT_WAS:
+ d = resultActual.length() > 0 ? "\n" : "";
+ resultActual += d + line;
+ break;
+ }
+
+ if (!skip) {
+ if (line.startsWith("++++")) {
+
+ int lastIndexOf = line.lastIndexOf(" ");
+ String name = line.substring(5, lastIndexOf);
+ String state = line.substring(lastIndexOf + 1);
+ if ("PASSED".equals(state)) {
+ int id = ++index;
+ client.testTree(id, name, false, 0);
+ client.testStarted(id, name);
+ session.setTotalCount(id);
+ client.testEnded(id, name);
+ resetState();
+ } else {
+ // We need to test for SKIPPED:
+ String sk = "SKIPPED:";
+ if (line.indexOf(sk) != -1) {
+ lastIndexOf = line.lastIndexOf(sk);
+ name = line.substring(5, lastIndexOf);
+ state = line.substring(lastIndexOf + sk.length());
+
+ int id = ++index;
+ client.testTree(id, name, false, 0);
+ client.testStarted(id, name);
+ session.setTotalCount(id);
+ client.testFailed(id, name);
+
+ client.traceStart();
+ client.traceMessage(state);
+ client.traceEnd();
+ resetState();
+ }
+ }
+ }
+ }
+ }
+
+ private void resetState() {
+ state = STATE_NORMAL;
+ resultActual = "";
+ resultExpected = "";
+ }
+
+ public void start() {
+ // System.out.println("!!!!!!START!!!!!!");
+ this.start = System.currentTimeMillis();
+ index = 0;
+ session = DLTKTestingPlugin.getTestRunSession(launch);
+ if (session == null)
+ return;
+
+ client = session.getTestRunnerClient();
+ if (client != null) {
+ client.testRunStart(0);
+ }
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestOutputProcessor.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestOutputProcessor.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestTestingEngine.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestTestingEngine.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestTestingEngine.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestTestingEngine.java Fri Aug 12 11:00:38 2011
@@ -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.textmarker.ide.testing;
+
+import org.apache.uima.textmarker.ide.TextMarkerIdePlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.dltk.ast.declarations.ModuleDeclaration;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.SourceParserUtil;
+import org.eclipse.dltk.core.environment.IDeployment;
+import org.eclipse.dltk.launching.InterpreterConfig;
+import org.eclipse.dltk.testing.ITestingProcessor;
+
+public class TextMarkerTestTestingEngine implements ITextMarkerTestingEngine {
+ public TextMarkerTestTestingEngine() {
+ }
+
+ public String getId() {
+ return TextMarkerIdePlugin.PLUGIN_ID + ".testingEngine";
+ }
+
+ public String getName() {
+ return "TextMarker Test";
+ }
+
+ public ITestingProcessor getProcessor(ILaunch launch) {
+ return new TextMarkerTestOutputProcessor(launch);
+ }
+
+ public boolean isValidModule(ISourceModule module) {
+ ModuleDeclaration moduleDeclaration = SourceParserUtil.getModuleDeclaration(module, null);
+ return module.getElementName().endsWith(".tm");
+ // ASTNode[] findTests = findTests(moduleDeclaration);
+ // if (findTests.length > 0) {
+ // return true;
+ // }
+ // return false;
+ }
+
+ // private ASTNode[] findTests(ModuleDeclaration decl) {
+ // final List ndes = new ArrayList();
+ // try {
+ // decl.traverse(new ASTVisitor() {
+ // public boolean visitGeneral(ASTNode node) throws Exception {
+ // if (node instanceof TextMarkerStatement2
+ // && ((TextMarkerStatement2) node).getCount() > 2) {
+ // TextMarkerStatement2 st = (TextMarkerStatement2) node;
+ // Expression cmd = st.getAt(0);
+ // if (cmd instanceof SimpleReference) {
+ // String cmdName = ((SimpleReference) cmd).getName();
+ // if (cmdName.startsWith("::")) {
+ // cmdName = cmdName.substring(2);
+ // }
+ // if ("test".equals(cmdName)
+ // || "tmtest::test".equals(cmdName)) {
+ //
+ // // List findLevelsTo = findLevelsTo(decl, node);
+ // Expression name = st.getAt(1);
+ // if (name instanceof SimpleReference) {
+ // String nameValue = ((SimpleReference) name)
+ // .getName();
+ // ndes.add(node);
+ // }
+ // }
+ // }
+ // }
+ // return true;
+ // }
+ // });
+ // } catch (CoreException e) {
+ // if (DLTKCore.DEBUG) {
+ // e.printStackTrace();
+ // }
+ // } catch (Exception e) {
+ // if (DLTKCore.DEBUG) {
+ // e.printStackTrace();
+ // }
+ // }
+ // return (ASTNode[]) ndes.toArray(new ASTNode[ndes.size()]);
+ // }
+
+ public void correctLaunchConfiguration(InterpreterConfig config,
+ ILaunchConfiguration configuration) {
+ // try {
+ IDeployment deployment = config.getExecutionEnvironment().createDeployment();
+ // IPath runner = deployment.add(TextMarkerTestingPlugin.getDefault().getBundle(),
+ // "scripts/tmtestEngine.tm");
+ IPath scriptFilePath = config.getScriptFilePath();
+ // stays the same
+ // config.setScriptFile(runner);
+ if (scriptFilePath != null) {
+ config.addScriptArg(scriptFilePath.toOSString(), 0);
+ }
+ config.addInterpreterArg("testing");
+ // } catch (IOException e) {
+ // if (DLTKCore.DEBUG) {
+ // e.printStackTrace();
+ // }
+ // }
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestTestingEngine.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestTestingEngine.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingEngineManager.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingEngineManager.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingEngineManager.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingEngineManager.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,38 @@
+/*
+ * 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.testing;
+
+import org.apache.uima.textmarker.ide.TextMarkerIdePlugin;
+import org.eclipse.dltk.core.PriorityClassDLTKExtensionManager;
+import org.eclipse.dltk.core.PriorityDLTKExtensionManager.ElementInfo;
+
+public final class TextMarkerTestingEngineManager {
+ private static PriorityClassDLTKExtensionManager manager = new PriorityClassDLTKExtensionManager(
+ TextMarkerIdePlugin.PLUGIN_ID + ".tmTestEngine", "id");
+
+ public static ITextMarkerTestingEngine[] getEngines() {
+ ElementInfo[] elementInfos = manager.getElementInfos();
+ ITextMarkerTestingEngine[] engines = new ITextMarkerTestingEngine[elementInfos.length];
+ for (int i = 0; i < elementInfos.length; i++) {
+ engines[i] = (ITextMarkerTestingEngine) manager.getInitObject(elementInfos[i]);
+ }
+ return engines;
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingEngineManager.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingEngineManager.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingLaunchConfigurationDelegate.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingLaunchConfigurationDelegate.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingLaunchConfigurationDelegate.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingLaunchConfigurationDelegate.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,67 @@
+/*
+ * 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.testing;
+
+import org.apache.uima.textmarker.ide.launching.TextMarkerLaunchConfigurationDelegate;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.model.ILaunchConfigurationDelegate;
+import org.eclipse.dltk.compiler.util.Util;
+import org.eclipse.dltk.launching.IInterpreterRunner;
+import org.eclipse.dltk.launching.InterpreterConfig;
+import org.eclipse.dltk.testing.DLTKTestingConstants;
+import org.eclipse.dltk.testing.DLTKTestingCore;
+
+
+public class TextMarkerTestingLaunchConfigurationDelegate extends
+ TextMarkerLaunchConfigurationDelegate implements ILaunchConfigurationDelegate {
+ private ITextMarkerTestingEngine engine;
+
+ @Override
+ protected InterpreterConfig createInterpreterConfig(ILaunchConfiguration configuration,
+ ILaunch launch) throws CoreException {
+ // We need to create correct execute script for this element.
+ InterpreterConfig config = super.createInterpreterConfig(configuration, launch);
+ ITextMarkerTestingEngine[] engines = TextMarkerTestingEngineManager.getEngines();
+ String engineId = configuration.getAttribute(DLTKTestingConstants.ATTR_ENGINE_ID,
+ Util.EMPTY_STRING);
+ for (int i = 0; i < engines.length; i++) {
+ if (engines[i].getId().equals(engineId)) {
+ engines[i].correctLaunchConfiguration(config, configuration);
+ this.engine = engines[i];
+ break;
+ }
+ }
+ return config;
+ }
+
+ @Override
+ protected void runRunner(ILaunchConfiguration configuration, IInterpreterRunner runner,
+ InterpreterConfig config, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+
+ if (engine != null) {
+ DLTKTestingCore.registerTestingProcessor(launch, engine.getProcessor(launch));
+ }
+
+ super.runRunner(configuration, runner, config, launch, monitor);
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingLaunchConfigurationDelegate.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingLaunchConfigurationDelegate.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingLaunchShortcut.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingLaunchShortcut.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingLaunchShortcut.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingLaunchShortcut.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,394 @@
+/*
+ * 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.testing;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.uima.textmarker.ide.core.TextMarkerNature;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.ui.DebugUITools;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.debug.ui.ILaunchShortcut;
+import org.eclipse.dltk.core.IMethod;
+import org.eclipse.dltk.core.IModelElement;
+import org.eclipse.dltk.core.IScriptProject;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.core.IType;
+import org.eclipse.dltk.internal.testing.util.ExceptionHandler;
+import org.eclipse.dltk.launching.ScriptLaunchConfigurationConstants;
+import org.eclipse.dltk.testing.DLTKTestingConstants;
+import org.eclipse.dltk.ui.DLTKUIPlugin;
+import org.eclipse.dltk.ui.ModelElementLabelProvider;
+import org.eclipse.dltk.ui.ScriptElementLabels;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.dialogs.ElementListSelectionDialog;
+
+public class TextMarkerTestingLaunchShortcut implements ILaunchShortcut {
+
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+
+ /**
+ * Default constructor.
+ */
+ public TextMarkerTestingLaunchShortcut() {
+ }
+
+ public void launch(IEditorPart editor, String mode) {
+ IModelElement element = DLTKUIPlugin.getEditorInputModelElement(editor.getEditorInput());
+ if (element != null) {
+ launch(new Object[] { element }, mode);
+ } else {
+ showNoTestsFoundDialog();
+ }
+ }
+
+ public void launch(ISelection selection, String mode) {
+ if (selection instanceof IStructuredSelection) {
+ launch(((IStructuredSelection) selection).toArray(), mode);
+ } else {
+ showNoTestsFoundDialog();
+ }
+ }
+
+ private void launch(Object[] elements, String mode) {
+ try {
+ IModelElement elementToLaunch = null;
+
+ if (elements.length == 1) {
+ Object selected = elements[0];
+ if (selected instanceof IFolder) {
+ performLaunch((IFolder) selected, mode);
+ return;
+ }
+ if (!(selected instanceof IModelElement) && selected instanceof IAdaptable) {
+ selected = ((IAdaptable) selected).getAdapter(IModelElement.class);
+ }
+ if (selected instanceof IModelElement) {
+ IModelElement element = (IModelElement) selected;
+ switch (element.getElementType()) {
+ case IModelElement.SCRIPT_PROJECT: {
+ IProject project = ((IScriptProject) element).getProject();
+ IFolder specFolder = project.getFolder("test");
+ if (specFolder != null && specFolder.exists()) {
+ performLaunch(specFolder, mode);
+ return;
+ }
+ }
+ break;
+ case IModelElement.PROJECT_FRAGMENT:
+ case IModelElement.SCRIPT_FOLDER: {
+ performLaunch((IFolder) element.getResource(), mode);
+ return;
+ }
+ case IModelElement.SOURCE_MODULE:
+ case IModelElement.METHOD:
+ elementToLaunch = element;
+ break;
+ }
+ }
+ }
+ if (elementToLaunch == null) {
+ showNoTestsFoundDialog();
+ return;
+ }
+ performLaunch(elementToLaunch, mode);
+ } catch (InterruptedException e) {
+ // OK, silently move on
+ } catch (CoreException e) {
+ ExceptionHandler.handle(e, getShell(), "XUnit Launch",
+ "Launching of XUnit tests unexpectedly failed. Check log for details.");
+ }
+ }
+
+ private void showNoTestsFoundDialog() {
+ MessageDialog.openInformation(getShell(), "XUnit Launch", "No XUnit tests found.");
+ }
+
+ private void performLaunch(IModelElement element, String mode) throws InterruptedException,
+ CoreException {
+ ILaunchConfigurationWorkingCopy temparary = createLaunchConfiguration(element);
+ if (temparary == null) {
+ return;
+ }
+ ILaunchConfiguration config = findExistingLaunchConfiguration(temparary, mode);
+ if (config == null) {
+ // no existing found: create a new one
+ config = temparary.doSave();
+ }
+ DebugUITools.launch(config, mode);
+ }
+
+ private void performLaunch(IFolder folder, String mode) throws InterruptedException,
+ CoreException {
+ String name = folder.getName();
+ String testName = name.substring(name.lastIndexOf(IPath.SEPARATOR) + 1);
+
+ ILaunchConfigurationType configType = getLaunchManager().getLaunchConfigurationType(
+ getLaunchConfigurationTypeId());
+ ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager()
+ .generateUniqueLaunchConfigurationNameFrom(testName));
+
+ wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME, folder.getProject()
+ .getName());
+
+ // wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_TEST_NAME, EMPTY_STRING);
+ // wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_CONTAINER_PATH,
+ // folder.getFullPath().toPortableString());
+ // wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_TEST_ELEMENT_NAME, EMPTY_STRING);
+
+ ILaunchConfiguration config = findExistingLaunchConfiguration(wc, mode);
+ if (config == null) {
+ // no existing found: create a new one
+ config = wc.doSave();
+ }
+ DebugUITools.launch(config, mode);
+ }
+
+ private IType chooseType(IType[] types, String mode) throws InterruptedException {
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(),
+ new ModelElementLabelProvider(ModelElementLabelProvider.SHOW_POST_QUALIFIED));
+ dialog.setElements(types);
+ dialog.setTitle("Test Selection");
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+ dialog.setMessage("Select Test to debug");
+ } else {
+ dialog.setMessage("Select Test to run");
+ }
+ dialog.setMultipleSelection(false);
+ if (dialog.open() == Window.OK) {
+ return (IType) dialog.getFirstResult();
+ }
+ throw new InterruptedException(); // cancelled by user
+ }
+
+ private Shell getShell() {
+ return DLTKUIPlugin.getActiveWorkbenchShell();
+ }
+
+ private ILaunchManager getLaunchManager() {
+ return DebugPlugin.getDefault().getLaunchManager();
+ }
+
+ /**
+ * Show a selection dialog that allows the user to choose one of the specified launch
+ * configurations. Return the chosen config, or <code>null</code> if the user cancelled the
+ * dialog.
+ *
+ * @param configList
+ * @param mode
+ * @return ILaunchConfiguration
+ * @throws InterruptedException
+ */
+ private ILaunchConfiguration chooseConfiguration(List configList, String mode)
+ throws InterruptedException {
+ IDebugModelPresentation labelProvider = DebugUITools.newDebugModelPresentation();
+ ElementListSelectionDialog dialog = new ElementListSelectionDialog(getShell(), labelProvider);
+ dialog.setElements(configList.toArray());
+ dialog.setTitle("Select a Test Configuration");
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+ dialog.setMessage("Select configuration to debug");
+ } else {
+ dialog.setMessage("Select configuration to run");
+ }
+ dialog.setMultipleSelection(false);
+ int result = dialog.open();
+ if (result == Window.OK) {
+ return (ILaunchConfiguration) dialog.getFirstResult();
+ }
+ throw new InterruptedException(); // cancelled by user
+ }
+
+ /**
+ * Returns the launch configuration type id of the launch configuration this shortcut will create.
+ * Clients can override this method to return the id of their launch configuration.
+ *
+ * @return the launch configuration type id of the launch configuration this shortcut will create
+ */
+ protected String getLaunchConfigurationTypeId() {
+ return "org.apache.uima.textmarker.ide.testing.launchConfig";
+ }
+
+ /**
+ * Creates a launch configuration working copy for the given element. The launch configuration
+ * type created will be of the type returned by {@link #getLaunchConfigurationTypeId}. The element
+ * type can only be of type {@link IJavaProject}, {@link IPackageFragmentRoot},
+ * {@link IPackageFragment}, {@link IType} or {@link IMethod}.
+ *
+ * Clients can extend this method (should call super) to configure additional attributes on the
+ * launch configuration working copy.
+ *
+ * @return a launch configuration working copy for the given element
+ */
+ protected ILaunchConfigurationWorkingCopy createLaunchConfiguration(IModelElement element)
+ throws CoreException {
+ String testFileName;
+ String containerHandleId;
+ String testElementName;
+
+ String name = ScriptElementLabels.getDefault().getTextLabel(element,
+ ScriptElementLabels.F_FULLY_QUALIFIED);
+ String testName = name.substring(name.lastIndexOf(IPath.SEPARATOR) + 1);
+
+ switch (element.getElementType()) {
+ case IModelElement.SOURCE_MODULE: {
+ containerHandleId = EMPTY_STRING;
+ testFileName = element.getResource().getProjectRelativePath().toPortableString();
+ testElementName = EMPTY_STRING;
+ }
+ break;
+ case IModelElement.METHOD: {
+ containerHandleId = EMPTY_STRING;
+ testFileName = element.getResource().getProjectRelativePath().toPortableString();
+ testElementName = element.getElementName();
+ // testName+= "[" + testElementName + "]";
+ }
+ break;
+ default:
+ throw new IllegalArgumentException(
+ "Invalid element type to create a launch configuration: " + element.getClass().getName()); //$NON-NLS-1$
+ }
+
+ ILaunchConfigurationType configType = getLaunchManager().getLaunchConfigurationType(
+ getLaunchConfigurationTypeId());
+ ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, getLaunchManager()
+ .generateUniqueLaunchConfigurationNameFrom(testName));
+
+ wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME, element
+ .getScriptProject().getElementName());
+ // wc.setAttribute(ITestKind.LAUNCH_ATTR_TEST_KIND, "#");
+ wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_MAIN_SCRIPT_NAME, testFileName);
+ wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_SCRIPT_NATURE,
+ TextMarkerNature.NATURE_ID);
+ wc.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, "true");
+ // wc.setAttribute(XUnitLaunchConfigurationConstants.ATTR_TEST_NAME, testFileName);
+ // wc.setAttribute(ScriptLaunchConfigurationConstants.ATTR_CONTAINER_PATH, containerHandleId);
+ // wc.setAttribute(XUnitLaunchConfigurationConstants.ATTR_TEST_ELEMENT_NAME, testElementName);
+ // XUnitMigrationDelegate.mapResources(wc);
+ ITextMarkerTestingEngine[] engines = TextMarkerTestingEngineManager.getEngines();
+ ISourceModule module = (ISourceModule) element.getAncestor(IModelElement.SOURCE_MODULE);
+ boolean engineFound = false;
+ for (int i = 0; i < engines.length; i++) {
+ if (engines[i].isValidModule(module)) {// TODO!!!
+ wc.setAttribute(DLTKTestingConstants.ATTR_ENGINE_ID, engines[i].getId());
+ engineFound = true;
+ break;
+ }
+ }
+ // if( engineFound == false ) {
+ // return null;
+ // }
+
+ return wc;
+ }
+
+ /**
+ * Returns the attribute names of the attributes that are compared when looking for an existing
+ * similar launch configuration. Clients can override and replace to customize.
+ *
+ * @return the attribute names of the attributes that are compared
+ */
+ protected String[] getAttributeNamesToCompare() {
+ return new String[] { ScriptLaunchConfigurationConstants.ATTR_PROJECT_NAME,
+ ScriptLaunchConfigurationConstants.ATTR_MAIN_SCRIPT_NAME,
+ // IDLTKTestingConstants.ENGINE_ID_ATR,
+ ScriptLaunchConfigurationConstants.ATTR_SCRIPT_NATURE
+ // XUnitLaunchConfigurationConstants.ATTR_TEST_NAME,
+ // XUnitLaunchConfigurationConstants.ATTR_TEST_CONTAINER,
+ // XUnitLaunchConfigurationConstants.ATTR_TEST_ELEMENT_NAME
+ };
+ }
+
+ private static boolean hasSameAttributes(ILaunchConfiguration config1,
+ ILaunchConfiguration config2, String[] attributeToCompare) {
+ try {
+ for (int i = 0; i < attributeToCompare.length; i++) {
+ String val1 = config1.getAttribute(attributeToCompare[i], EMPTY_STRING);
+ String val2 = config2.getAttribute(attributeToCompare[i], EMPTY_STRING);
+ if (!val1.equals(val2)) {
+ return false;
+ }
+ }
+ return true;
+ } catch (CoreException e) {
+ // ignore access problems here, return false
+ }
+ return false;
+ }
+
+ private ILaunchConfiguration findExistingLaunchConfiguration(
+ ILaunchConfigurationWorkingCopy temporary, String mode) throws InterruptedException,
+ CoreException {
+ ILaunchConfigurationType configType = temporary.getType();
+
+ ILaunchConfiguration[] configs = getLaunchManager().getLaunchConfigurations(configType);
+ String[] attributeToCompare = getAttributeNamesToCompare();
+
+ ArrayList candidateConfigs = new ArrayList(configs.length);
+ for (int i = 0; i < configs.length; i++) {
+ ILaunchConfiguration config = configs[i];
+ if (hasSameAttributes(config, temporary, attributeToCompare)) {
+ candidateConfigs.add(config);
+ }
+ }
+
+ // If there are no existing configs associated with the IType, create
+ // one.
+ // If there is exactly one config associated with the IType, return it.
+ // Otherwise, if there is more than one config associated with the
+ // IType, prompt the
+ // user to choose one.
+ int candidateCount = candidateConfigs.size();
+ if (candidateCount == 0) {
+ return null;
+ } else if (candidateCount == 1) {
+ return (ILaunchConfiguration) candidateConfigs.get(0);
+ } else {
+ // Prompt the user to choose a config. A null result means the user
+ // cancelled the dialog, in which case this method returns null,
+ // since cancelling the dialog should also cancel launching
+ // anything.
+ ILaunchConfiguration config = chooseConfiguration(candidateConfigs, mode);
+ if (config != null) {
+ return config;
+ }
+ }
+ return null;
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingLaunchShortcut.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingLaunchShortcut.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingMainLaunchConfigurationTab.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingMainLaunchConfigurationTab.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingMainLaunchConfigurationTab.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingMainLaunchConfigurationTab.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,177 @@
+/*
+ * 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.testing;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.uima.textmarker.ide.debug.ui.launchConfiguration.TextMarkerMainLaunchConfigurationTab;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.dltk.core.DLTKCore;
+import org.eclipse.dltk.core.ISourceModule;
+import org.eclipse.dltk.debug.ui.messages.DLTKLaunchConfigurationsMessages;
+import org.eclipse.dltk.testing.DLTKTestingConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+
+
+public class TextMarkerTestingMainLaunchConfigurationTab extends
+ TextMarkerMainLaunchConfigurationTab {
+ public TextMarkerTestingMainLaunchConfigurationTab(String mode) {
+ super(mode);
+ }
+
+ private Button detect;
+
+ private Combo engineType;
+
+ private Map nameToId = new HashMap();
+
+ @Override
+ protected void doCreateControl(Composite composite) {
+ createMainModuleEditor(composite, DLTKLaunchConfigurationsMessages.mainTab_mainModule);
+ createVerticalSpacer(composite, 1);
+ createTestEngineEditor(composite, "TextMarker Testing engine");
+
+ }
+
+ protected void createTestEngineEditor(Composite parent, String text) {
+ Font font = parent.getFont();
+ Group mainGroup = new Group(parent, SWT.NONE);
+ mainGroup.setText(text);
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ mainGroup.setLayoutData(gd);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 2;
+ mainGroup.setLayout(layout);
+ mainGroup.setFont(font);
+ engineType = new Combo(mainGroup, SWT.SINGLE | SWT.BORDER | SWT.DROP_DOWN);
+ gd = new GridData(GridData.FILL_HORIZONTAL);
+ engineType.setLayoutData(gd);
+ engineType.setFont(font);
+ engineType.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ updateLaunchConfigurationDialog();
+ }
+ });
+ detect = createPushButton(mainGroup, "Detect", null);
+
+ ITextMarkerTestingEngine[] engines = TextMarkerTestingEngineManager.getEngines();
+ for (int i = 0; i < engines.length; i++) {
+ String name = engines[i].getName();
+ this.engineType.add(name);
+ nameToId.put(name, engines[i].getId());
+ }
+ detect.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ handleDetectButtonSelected();
+ }
+ });
+ handleDetectButtonSelected();
+ }
+
+ private void handleDetectButtonSelected() {
+ ITextMarkerTestingEngine[] engines = TextMarkerTestingEngineManager.getEngines();
+ // this.engineType.select(0);
+ ISourceModule module = getSourceModule();
+ if (module != null && module.exists()) {
+ for (int i = 0; i < engines.length; i++) {
+ if (engines[i].isValidModule(module)) {
+ this.engineType.select(i);
+ }
+ }
+ }
+ }
+
+ // private ISourceModule getSourceModule() {
+ // IScriptProject project = this.getProject();
+ // if (project == null) {
+ // return null;
+ // }
+ // IProject prj = project.getProject();
+ // String scriptName = this.getScriptName();
+ // ISourceModule module = null;
+ // IResource res = prj.getFile(scriptName);
+ // module = (ISourceModule) DLTKCore.create(res);
+ // return module;
+ // }
+ private boolean validateEngine() {
+ ISourceModule module = getSourceModule();
+ if (module != null) {
+ ITextMarkerTestingEngine[] engines = TextMarkerTestingEngineManager.getEngines();
+ for (int i = 0; i < engines.length; i++) {
+ String selectedEngine = this.getEngineId();
+ if (engines[i].getId().equals(selectedEngine) && engines[i].isValidModule(module)) {
+ return true;
+ }
+ }
+ }
+ setErrorMessage("Testing engine not support specified script");
+ return true;
+ }
+
+ @Override
+ protected void doPerformApply(ILaunchConfigurationWorkingCopy config) {
+ super.doPerformApply(config);
+ config.setAttribute(DLTKTestingConstants.ATTR_ENGINE_ID, getEngineId());
+ }
+
+ private String getEngineId() {
+ return (String) this.nameToId.get(this.engineType.getText());
+ }
+
+ @Override
+ protected void doInitializeForm(ILaunchConfiguration config) {
+ super.doInitializeForm(config);
+ ITextMarkerTestingEngine[] engines = TextMarkerTestingEngineManager.getEngines();
+ String id = null;
+ try {
+ id = config.getAttribute(DLTKTestingConstants.ATTR_ENGINE_ID, "");
+ } catch (CoreException e) {
+ if (DLTKCore.DEBUG) {
+ e.printStackTrace();
+ }
+ }
+ if (id == null || id.length() == 0) {
+ handleDetectButtonSelected();
+ } else {
+ // this.engineType.select(0);
+ for (int i = 0; i < engines.length; i++) {
+ if (engines[i].getId().equals(id)) {
+ this.engineType.select(i);
+ }
+ }
+ }
+ // handleDetectButtonSelected();
+ }
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingMainLaunchConfigurationTab.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingMainLaunchConfigurationTab.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingTabGroup.java
URL: http://svn.apache.org/viewvc/uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingTabGroup.java?rev=1157047&view=auto
==============================================================================
--- uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingTabGroup.java (added)
+++ uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingTabGroup.java Fri Aug 12 11:00:38 2011
@@ -0,0 +1,50 @@
+/*
+ * 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.testing;
+
+import org.apache.uima.textmarker.ide.debug.ui.interpreters.TextMarkerInterpreterTab;
+import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
+import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
+import org.eclipse.debug.ui.CommonTab;
+import org.eclipse.debug.ui.EnvironmentTab;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.debug.ui.ILaunchConfigurationDialog;
+import org.eclipse.debug.ui.ILaunchConfigurationTab;
+import org.eclipse.dltk.debug.ui.launchConfigurations.ScriptArgumentsTab;
+
+
+public class TextMarkerTestingTabGroup extends AbstractLaunchConfigurationTabGroup {
+
+ public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
+ TextMarkerTestingMainLaunchConfigurationTab main = new TextMarkerTestingMainLaunchConfigurationTab(
+ mode);
+ ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { main,
+ new ScriptArgumentsTab(), new TextMarkerInterpreterTab(main), new EnvironmentTab(),
+ new CommonTab() {
+ @Override
+ public void performApply(ILaunchConfigurationWorkingCopy configuration) {
+ super.performApply(configuration);
+ configuration.setAttribute(IDebugUIConstants.ATTR_CAPTURE_IN_CONSOLE, (String) null);
+ }
+ } };
+ setTabs(tabs);
+ }
+
+}
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingTabGroup.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: uima/sandbox/trunk/TextMarker/uimaj-ep-textmarker-ide/src/main/java/org/apache/uima/textmarker/ide/testing/TextMarkerTestingTabGroup.java
------------------------------------------------------------------------------
svn:mime-type = text/plain