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/06/13 11:46:48 UTC

svn commit: r1492602 - in /uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide: formatter/RutaFormattedPrinter.java parser/ast/ActionFactory.java parser/ast/ConditionFactory.java

Author: pkluegl
Date: Thu Jun 13 09:46:48 2013
New Revision: 1492602

URL: http://svn.apache.org/r1492602
Log:
UIMA-2938	
- fixed formatting of implicit elements

Modified:
    uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormattedPrinter.java
    uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ActionFactory.java
    uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ConditionFactory.java

Modified: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormattedPrinter.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormattedPrinter.java?rev=1492602&r1=1492601&r2=1492602&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormattedPrinter.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/formatter/RutaFormattedPrinter.java Thu Jun 13 09:46:48 2013
@@ -26,7 +26,9 @@ import java.util.List;
 import java.util.Map;
 
 import org.antlr.runtime.CommonToken;
+import org.apache.uima.ruta.ide.parser.ast.ActionFactory;
 import org.apache.uima.ruta.ide.parser.ast.ComposedRuleElement;
+import org.apache.uima.ruta.ide.parser.ast.ConditionFactory;
 import org.apache.uima.ruta.ide.parser.ast.RutaAbstractDeclaration;
 import org.apache.uima.ruta.ide.parser.ast.RutaAction;
 import org.apache.uima.ruta.ide.parser.ast.RutaBinaryArithmeticExpression;
@@ -331,7 +333,10 @@ public class RutaFormattedPrinter extend
       append(name);
       List<? extends ASTNode> childs = a.getChilds();
       if (childs != null && !childs.isEmpty()) {
-        append(PAR_OPEN);
+        boolean addPar = !a.getName().equals(ActionFactory.IMPLICIT);
+        if(addPar) {
+          append(PAR_OPEN);
+        }
         // special format for create
         if (a instanceof RutaStructureAction) {
           if (name.equals("TRIE")) {
@@ -348,7 +353,9 @@ public class RutaFormattedPrinter extend
           RutaLogAction logAction = (RutaLogAction) a;
           append(logAction.getLogLevelStart(), logAction.getLogLevelEnd());
         }
-        append(PAR_CLOSE);
+        if(addPar) {
+          append(PAR_CLOSE);
+        }
       }
       return false;
     }
@@ -358,11 +365,12 @@ public class RutaFormattedPrinter extend
       append(document.get(c.getNameStart(), c.getNameEnd()));
       List<? extends ASTNode> childs = c.getChilds();
       // minus is a condition without parameter parantheses:
-      if (s.getKind() != RutaConditionConstants.COND_MINUS && childs != null && !childs.isEmpty()) {
+      boolean addPar = !c.getName().equals(ConditionFactory.IMPLICIT) && s.getKind() != RutaConditionConstants.COND_MINUS && childs != null && !childs.isEmpty();
+      if (addPar) {
         append(PAR_OPEN);
       }
       traverseAstNodes(childs);
-      if (s.getKind() != RutaConditionConstants.COND_MINUS && childs != null && !childs.isEmpty()) {
+      if (addPar) {
         append(PAR_CLOSE);
       }
       return false;

Modified: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ActionFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ActionFactory.java?rev=1492602&r1=1492601&r2=1492602&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ActionFactory.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ActionFactory.java Thu Jun 13 09:46:48 2013
@@ -31,6 +31,8 @@ import org.eclipse.dltk.ast.expressions.
 
 public class ActionFactory extends AbstractFactory {
 
+  public static final String IMPLICIT = "Implicit";
+  
   public static RutaAction createAction(Token type, List exprsRaw) {
     int bounds[] = getBounds(type);
     int nameStart = bounds[0];
@@ -245,7 +247,7 @@ public class ActionFactory extends Abstr
     }
     int[] bounds = getBounds(exprL.get(0), exprL.get(exprL.size() - 1));
     return new RutaAction(bounds[0], bounds[1], exprL, ExpressionConstants.USER_EXPRESSION_START,
-            "", bounds[0], bounds[0]);
+            IMPLICIT, bounds[0], bounds[0]);
   }
 
 }

Modified: uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ConditionFactory.java
URL: http://svn.apache.org/viewvc/uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ConditionFactory.java?rev=1492602&r1=1492601&r2=1492602&view=diff
==============================================================================
--- uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ConditionFactory.java (original)
+++ uima/sandbox/ruta/trunk/ruta-ep-ide/src/main/java/org/apache/uima/ruta/ide/parser/ast/ConditionFactory.java Thu Jun 13 09:46:48 2013
@@ -27,6 +27,8 @@ import org.eclipse.dltk.ast.expressions.
 
 public class ConditionFactory extends AbstractFactory {
 
+  public static final String IMPLICIT = "Implicit";
+
   public static RutaCondition createCondition(Token type, List exprs) {
     int wholeConditionBounds[] = getBounds(type);
     int nameStart = wholeConditionBounds[0];
@@ -57,7 +59,7 @@ public class ConditionFactory extends Ab
     }
     int[] bounds = getBounds(exprL.get(0), exprL.get(exprL.size() - 1));
     return new RutaCondition(bounds[0], bounds[1], exprL, RutaConditionConstants.CONSTANT_OFFSET,
-            "IF", bounds[0], bounds[0]);
+            IMPLICIT, bounds[0], bounds[0]);
   }
 
   public static RutaCondition createCondition(Token type, Expression... exprsArray) {
@@ -79,130 +81,4 @@ public class ConditionFactory extends Ab
             RutaConditionConstants.CONSTANT_OFFSET, "", bounds[0], bounds[0]);
   }
 
-  // public static RutaCondition createConditionAnd(int start, int end,
-  // DLTKToken token, List<RutaCondition> conds,
-  // RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-
-  // public static RutaCondition createConditionContains(
-  // Expression typeExpr, Token name, Expression min, Expression max,
-  // Expression percent) {
-  // int bounds[];
-  // bounds = getBounds(name);
-  // List<Expression> list = new ArrayList<Expression>();
-  // if (min != null && max != null) {
-  // list.add(min);
-  // list.add(max);
-  // bounds[1] = max.sourceEnd();
-  // }
-  // boolean percentSet;
-  // if (percent == null) {
-  // percentSet = false;
-  // } else {
-  // percentSet = true;
-  // bounds[1] = percent.sourceEnd();
-  // }
-  // return new RutaContainsCondition(bounds[0], bounds[1], list,
-  // percentSet);
-  // }
-  //
-  // public static RutaCondition createConditionCount(int start, int end,
-  // String text, Expression text2, Expression text3,
-  // RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionContextCount(int start,
-  // int end, String text, Expression text2, Expression text3,
-  // RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionInList(int start, int end,
-  // String wordList, Expression text, Expression text2,
-  // RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionInList(int start, int end,
-  // List<String> list, Expression text, Expression text2,
-  // RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionIsInTag(int start,
-  // int end, Expression text, List<Expression> list1,
-  // List<Expression> list2, RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionMOfN(int start, int end,
-  // List<RutaCondition> conds, Expression text, Expression text2,
-  // RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionNear(int start, int end,
-  // Expression text, Expression text2, Expression text3,
-  // RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionNot(int start, int end,
-  // RutaCondition c, RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionOr(int start, int end,
-  // List<RutaCondition> conds, RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionPartOf(int start, int end,
-  // String text, RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionPosition(int start,
-  // int end, String text, Expression text2, RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionRegExp(int start, int end,
-  // Expression text, RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionScore(int start, int end,
-  // String text, Expression text2, Expression text3,
-  // RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionVote(int start, int end,
-  // String text, String text2, RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionLast(int start, int end,
-  // String text, RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionIf(int start, int end,
-  // Expression e, RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionFeature(int start,
-  // int end, RutaBlock parent) {
-  // return new RutaCondition(start, end);
-  // }
-  //
-  // public static RutaCondition createConditionParse(int start, int end,
-  // RutaBlock env) {
-  // return new RutaCondition(start, end);
-  // }
-
 }