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

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


          } else if (object instanceof StringLiteral) {
            StringLiteral sl = (StringLiteral) object;
            String value = sl.getValue();
            append(value);
          } else if (object instanceof RutaVariableReference) {
            RutaVariableReference vr = (RutaVariableReference) object;
            append(vr.getName());
          }
          if (childs2.indexOf(object) < childs2.size() - 1) {
            append(CONCAT);
          }
        }
View Full Code Here


    if (s instanceof RutaDeclareDeclarationsStatement) {
      RutaDeclareDeclarationsStatement dds = (RutaDeclareDeclarationsStatement) s;
      ASTNode parent = dds.getParent();
      if (parent != null && parent instanceof RutaVariableReference) {
        RutaVariableReference p = (RutaVariableReference) parent;
        String name = p.getName();
        name = expand(name);
        parentTypeInDeclaration = name;
        // TODO remember name for new types and their features!
        if (finalTypes.contains(name)) {
          IProblem problem = problemFactory.createInheritenceFinalProblem(p);
View Full Code Here

      String featText = fme.getFeature().getText();
      checkTypeOfFeatureMatch(featText, fme);
      return true;
    }
    if (s instanceof RutaVariableReference) {
      RutaVariableReference ref = (RutaVariableReference) s;
      if ((ref.getType() & RutaTypeConstants.RUTA_TYPE_AT) != 0) {
        // types
        String name = ref.getName();
        if (name.equals("Document")) {
          return false;
        }

        Set<String> set = ambiguousTypeAlias.get(name);
        if (set != null && !set.isEmpty()) {
          pr.reportProblem(problemFactory.createAmbiguousShortName(ref, set, ProblemSeverity.ERROR));
          return false;
        }
        if (namespaces.keySet().contains(name) || namespaces.values().contains(name)
                || allLongTypeNames.contains(name)
                || getVariableType(name) == RutaTypeConstants.RUTA_TYPE_AT) {
          return false;
        }
        if (isFeatureMatch(ref.getName()) != null) {
          return false;
        }
        pr.reportProblem(problemFactory.createTypeProblem(ref, sourceModule));
        return false;
      }
      if (!isVariableDeclared(ref)) {
        return false;
      }
      checkTypeOfVariable(ref);
      return false;
    }
    // check assign types
    if (s instanceof RutaAction) {
      RutaAction tma = (RutaAction) s;

      String actionName = sourceModule.getSource().substring(tma.getNameStart(), tma.getNameEnd());
      String[] keywords = RutaKeywordsManager.getKeywords(IRutaKeywords.ACTION);
      List<String> asList = Arrays.asList(keywords);
      if (!StringUtils.isEmpty(actionName) && !"-".equals(actionName)
              && !asList.contains(actionName) && !implicitString.equals(tma.getName())) {
        IProblem problem = problemFactory.createUnknownActionProblem(tma);
        pr.reportProblem(problem);
      }

      IRutaExtension extension = actionExtensions.get(actionName);
      if (extension != null) {
        extension.checkSyntax(tma, problemFactory, pr);
      }

      if (tma.getName().equals("GETFEATURE") || tma.getName().equals("SETFEATURE")) {
        List<?> childs = tma.getChilds();
        RutaStringExpression stringExpr = (RutaStringExpression) childs.get(0);
        String feat = stringExpr.toString();
        feat = getFeatureName(stringExpr, feat);
        boolean featureFound = findFeature(matchedType, feat, -1);
        if (!featureFound) {
          IProblem problem = problemFactory.createUnknownFeatureProblem(stringExpr, matchedType);
          pr.reportProblem(problem);
        }
      }

      if (tma.getKind() == RutaActionConstants.A_ASSIGN) {
        List<?> childs = tma.getChilds();
        try {
          RutaVariableReference ref = (RutaVariableReference) childs.get(0);
          RutaExpression expr = (RutaExpression) childs.get(1);
          int type = expr.getKind();
          if (ref.getType() == RutaTypeConstants.RUTA_TYPE_G) {
            ref.setType(type);
          }
        } catch (IndexOutOfBoundsException e) {
          // exception should have been recognized and reported in
          // parser
          return false;
View Full Code Here

  }

  @Override
  public boolean visit(Expression s) throws Exception {
    if (s instanceof RutaVariableReference && node instanceof RutaVariableReference) {
      RutaVariableReference vr0 = (RutaVariableReference) node;
      RutaVariableReference vr1 = (RutaVariableReference) s;
      if (vr1.getStringRepresentation().equals(vr0.getStringRepresentation())
              && vr1.getType() == vr0.getType()) {
        result.add(s);
      }
    } else if (s instanceof ComponentDeclaration && node instanceof ComponentDeclaration) {

    } else if (s instanceof ComponentReference && node instanceof ComponentReference) {
View Full Code Here

        RutaReferenceVisitor referenceVisitor = new RutaReferenceVisitor(wordRegion.getOffset());
        moduleDeclaration.traverse(referenceVisitor);
        ASTNode node = referenceVisitor.getResult();
        if (node instanceof RutaVariableReference
                && moduleDeclaration instanceof RutaModuleDeclaration) {
          RutaVariableReference vr = (RutaVariableReference) node;
          RutaModuleDeclaration parsed = (RutaModuleDeclaration) moduleDeclaration;
          if (vr.getType() == RutaTypeConstants.RUTA_TYPE_AT) {
            String nodeText = vr.getStringRepresentation();
            Collection<String> importedTypeSystems = parsed.descriptorInfo.getImportedTypeSystems();
            List<IHyperlink> result = new ArrayList<IHyperlink>();
            for (String tsString : importedTypeSystems) {
              IFolder folder = modelElement.getScriptProject().getProject()
                      .getFolder(RutaProjectUtils.getDefaultDescriptorLocation());
View Full Code Here

          String type = currentFile.getSource().substring(head.sourceStart(), head.sourceEnd());
          matchedType = type;
        }
      }
      if (s instanceof RutaVariableReference) {
        RutaVariableReference ref = (RutaVariableReference) s;
        // filter AnnotationTypeReferences
        if ((ref.getType() & RutaTypeConstants.RUTA_TYPE_AT) != 0) {
          return false;
        }
        if (!isVariableDeclared(ref)) {
          return false;
        }
        checkTypeOfReference(ref);
        return false;
      }
      // check assign types
      if (s instanceof RutaAction) {
        RutaAction tma = (RutaAction) s;

        String actionName = currentFile.getSource().substring(tma.getNameStart(), tma.getNameEnd());
        String[] keywords = RutaKeywordsManager.getKeywords(IRutaKeywords.ACTION);
        List<String> asList = Arrays.asList(keywords);
        if (!StringUtils.isEmpty(actionName) && !"-".equals(actionName)
                && !asList.contains(actionName)) {
          IProblem problem = problemFactory.createUnknownActionProblem(tma);
          rep.reportProblem(problem);
        }

        IRutaExtension extension = actionExtensions.get(actionName);
        if (extension != null) {
          // boolean checkSyntax =
          extension.checkSyntax(tma, problemFactory, rep);
        }

        if (tma.getName().equals("GETFEATURE") || tma.getName().equals("SETFEATURE")) {
          List<?> childs = tma.getChilds();
          RutaStringExpression stringExpr = (RutaStringExpression) childs.get(0);
          String feat = stringExpr.toString();
          feat = getFeatureName(stringExpr, feat);
          boolean featureFound = findFeature(matchedType, feat);
          if (!featureFound) {
            IProblem problem = problemFactory.createUnknownFeatureProblem(stringExpr, matchedType);
            rep.reportProblem(problem);
          }
        }

        if (tma.getKind() == RutaActionConstants.A_ASSIGN) {
          List<?> childs = tma.getChilds();
          try {
            RutaVariableReference ref = (RutaVariableReference) childs.get(0);
            RutaExpression expr = (RutaExpression) childs.get(1);
            int type = expr.getKind();
            if (ref.getType() == RutaTypeConstants.RUTA_TYPE_G) {
              ref.setType(type);
            }
          } catch (IndexOutOfBoundsException e) {
            // exception should have been recognized and reported in
            // parser
            return false;
View Full Code Here

  }

  @Override
  public boolean visit(Expression s) throws Exception {
    if (s instanceof RutaVariableReference && node instanceof RutaVariableReference) {
      RutaVariableReference vr0 = (RutaVariableReference) node;
      RutaVariableReference vr1 = (RutaVariableReference) s;
      if (vr1.getStringRepresentation().equals(vr0.getStringRepresentation())
              && vr1.getType() == vr0.getType()) {
        result.add(s);
      }
    } else if (s instanceof ComponentDeclaration && node instanceof ComponentDeclaration) {

    } else if (s instanceof ComponentReference && node instanceof ComponentReference) {
View Full Code Here

                .getOffset());
        moduleDeclaration.traverse(referenceVisitor);
        ASTNode node = referenceVisitor.getResult();
        if (node instanceof RutaVariableReference
                && moduleDeclaration instanceof RutaModuleDeclaration) {
          RutaVariableReference vr = (RutaVariableReference) node;
          RutaModuleDeclaration parsed = (RutaModuleDeclaration) moduleDeclaration;
          if (vr.getType() == RutaTypeConstants.RUTA_TYPE_AT) {
            String nodeText = vr.getStringRepresentation();
            Collection<String> importedTypeSystems = parsed.descriptorInfo.getImportedTypeSystems();
            List<IHyperlink> result = new ArrayList<IHyperlink>();
            for (String tsString : importedTypeSystems) {
              IFolder folder = modelElement.getScriptProject().getProject().getFolder(
                      RutaProjectUtils.getDefaultDescriptorLocation());
View Full Code Here

          } else if (object instanceof StringLiteral) {
            StringLiteral sl = (StringLiteral) object;
            String value = sl.getValue();
            append(value);
          } else if (object instanceof RutaVariableReference) {
            RutaVariableReference vr = (RutaVariableReference) object;
            append(vr.getName());
          }
          if (childs2.indexOf(object) < childs2.size() - 1) {
            append(CONCAT);
          }
        }
View Full Code Here

      }
      if (s instanceof RutaDeclareDeclarationsStatement) {
        RutaDeclareDeclarationsStatement dds = (RutaDeclareDeclarationsStatement) s;
        ASTNode parent = dds.getParent();
        if (parent != null && parent instanceof RutaVariableReference) {
          RutaVariableReference p = (RutaVariableReference) parent;
          String name = p.getName();
          if (finalTypes.contains(name)) {
            IProblem problem = problemFactory.createInheritenceFinalProblem(p);
            rep.reportProblem(problem);
          }
        }
View Full Code Here

TOP

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

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.