Package org.apache.uima.ruta.ide.parser.ast

Examples of org.apache.uima.ruta.ide.parser.ast.RutaCondition


  }

  public boolean checkSyntax(Expression element, IRutaCheckerProblemFactory problemFactory,
          IProblemReporter rep) throws RecognitionException {
    if (element instanceof RutaCondition) {
      RutaCondition a = (RutaCondition) element;
      String name = a.getName();
      if (!name.equals(strings[0])) {
        IProblem problem = problemFactory.createUnknownConditionProblem(a);
        rep.reportProblem(problem);
        return false;
      }
      boolean ok = true;
      List<Expression> childs = a.getChilds();
      if (childs.size() != 2) {
        IProblem problem = problemFactory.createWrongNumberOfArgumentsProblem(name, element, 2);
        rep.reportProblem(problem);
        ok = false;
      }
View Full Code Here


      }
      return false;
    }
    // special format for conditions
    if (s instanceof RutaCondition) {
      RutaCondition c = (RutaCondition) s;
      append(document.get(c.getNameStart(), c.getNameEnd()));
      List<? extends ASTNode> childs = c.getChilds();
      // minus is a condition without parameter parantheses:
      boolean addPar = !c.getName().equals(ConditionFactory.IMPLICIT)
              && s.getKind() != RutaConditionConstants.COND_MINUS && childs != null
              && !childs.isEmpty();
      if (addPar) {
        append(PAR_OPEN);
      }
View Full Code Here

          }
        }
      }
    }
    if (s instanceof RutaCondition) {
      RutaCondition cond = (RutaCondition) s;
      String conditionName = sourceModule.getSource().substring(cond.getNameStart(),
              cond.getNameEnd());
      String[] keywords = RutaKeywordsManager.getKeywords(IRutaKeywords.CONDITION);
      List<String> asList = Arrays.asList(keywords);
      if (!StringUtils.isEmpty(conditionName) && !"-".equals(conditionName)
              && !asList.contains(conditionName) && !implicitString.equals(cond.getName())) {
        IProblem problem = problemFactory.createUnknownConditionProblem(cond);
        pr.reportProblem(problem);
      }

      IRutaExtension extension = conditionExtensions.get(conditionName);
      if (extension != null) {
        // boolean checkSyntax =
        extension.checkSyntax(cond, problemFactory, pr);
      }

      if (conditionName.equals("FEATURE")) {
        if (matchedType != null) {
          List<?> args = cond.getChilds();
          RutaStringExpression se = (RutaStringExpression) args.get(0);
          String feat = se.toString();
          feat = getFeatureName(se, feat);
          boolean featureFound = findFeature(matchedType, feat, -1);
          if (!featureFound) {
View Full Code Here

          return (ASTNode) expression.getChilds().get(0);
        }
      }
    }
    if (node instanceof RutaCondition) {
      RutaCondition c = (RutaCondition) node;
      if (ConditionFactory.IMPLICIT.equals(c.getName()) && !c.getChilds().isEmpty()) {
        Expression expression = c.getChilds().get(0);
        if (expression != null && !expression.getChilds().isEmpty()) {
          return (ASTNode) expression.getChilds().get(0);
        }
      }
    }
View Full Code Here

      RutaAction a2 = (RutaAction) s;
      if (a1.getName().equals(a2.getName())) {
        result.add(s);
      }
    } else if (s instanceof RutaCondition && node instanceof RutaCondition) {
      RutaCondition c1 = (RutaCondition) node;
      RutaCondition c2 = (RutaCondition) s;
      if (c1.getName().equals(c2.getName())) {
        result.add(s);
      }

    }
    return super.visit(s);
View Full Code Here

        if (each instanceof RutaAction) {
          RutaAction e = (RutaAction) each;
          sourceStart = e.getNameStart();
          sourceEnd = e.getNameEnd();
        } else if (each instanceof RutaCondition) {
          RutaCondition e = (RutaCondition) each;
          sourceStart = e.getNameStart();
          sourceEnd = e.getNameEnd();
        }
        position = new Position(sourceStart, sourceEnd - sourceStart);
        myAnnotations.put(annotation, position);
      }
      addAnnotations(myAnnotations);
View Full Code Here

      RutaAction a2 = (RutaAction) s;
      if (a1.getName().equals(a2.getName())) {
        result.add(s);
      }
    } else if (s instanceof RutaCondition && node instanceof RutaCondition) {
      RutaCondition c1 = (RutaCondition) node;
      RutaCondition c2 = (RutaCondition) s;
      if (c1.getName().equals(c2.getName())) {
        result.add(s);
      }

    }
    return super.visit(s);
View Full Code Here

  }

  public boolean checkSyntax(Expression element, RutaCheckerProblemFactory problemFactory,
          IProblemReporter rep) throws RecognitionException {
    if (element instanceof RutaCondition) {
      RutaCondition a = (RutaCondition) element;
      String name = a.getName();
      if (!name.equals(strings[0])) {
        IProblem problem = problemFactory.createUnknownConditionProblem(a);
        rep.reportProblem(problem);
        return false;
      }
      boolean ok = true;
      List<Expression> childs = a.getChilds();
      if(childs.size() != 2) {
        IProblem problem = problemFactory.createWrongNumberOfArgumentsProblem(name, element, 2);
        rep.reportProblem(problem);
        ok = false;
      }
View Full Code Here

            }
          }
        }
      }
      if (s instanceof RutaCondition) {
        RutaCondition cond = (RutaCondition) s;
        String conditionName = currentFile.getSource().substring(cond.getNameStart(),
                cond.getNameEnd());
        String[] keywords = RutaKeywordsManager.getKeywords(IRutaKeywords.CONDITION);
        List<String> asList = Arrays.asList(keywords);
        if (!StringUtils.isEmpty(conditionName) && !"-".equals(conditionName)
                && !asList.contains(conditionName)) {
          IProblem problem = problemFactory.createUnknownConditionProblem(cond);
          rep.reportProblem(problem);
        }

        IRutaExtension extension = conditionExtensions.get(conditionName);
        if (extension != null) {
          // boolean checkSyntax =
          extension.checkSyntax(cond, problemFactory, rep);
        }
       
       
        if (conditionName.equals("FEATURE")) {
          if (matchedType != null) {
            List<?> args = cond.getChilds();
            RutaStringExpression se = (RutaStringExpression) args.get(0);
            String feat = se.toString();
            feat = getFeatureName(se, feat);
            boolean featureFound = findFeature(matchedType, feat);
            if (!featureFound) {
View Full Code Here

        if (each instanceof RutaAction) {
          RutaAction e = (RutaAction) each;
          sourceStart = e.getNameStart();
          sourceEnd = e.getNameEnd();
        } else if (each instanceof RutaCondition) {
          RutaCondition e = (RutaCondition) each;
          sourceStart = e.getNameStart();
          sourceEnd = e.getNameEnd();
        }
        position = new Position(sourceStart, sourceEnd - sourceStart);
        myAnnotations.put(annotation, position);
      }
      addAnnotations(myAnnotations);
View Full Code Here

TOP

Related Classes of org.apache.uima.ruta.ide.parser.ast.RutaCondition

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.