示例#1
0
 private ASTNode parseCondition(IfContext context) throws IfStatementError {
   if (context.isEOF()) {
     throw new IfStatementError(
         Messages.TclIfProcessor_missingCondition, context.start(), context.end());
   }
   ASTNode node = context.get();
   if (node instanceof TclBlockExpression) {
     TclBlockExpression bl = (TclBlockExpression) node;
     List parseBlock = bl.parseBlockSimple(false);
     ASTListNode list = new ASTListNode(bl.sourceStart() + 1, bl.sourceEnd() - 1);
     for (int j = 0; j < parseBlock.size(); j++) {
       Object st = parseBlock.get(j);
       if (st instanceof TclStatement) {
         List expressions = ((TclStatement) st).getExpressions();
         for (int k = 0; k < expressions.size(); k++) {
           ASTNode expr = (ASTNode) expressions.get(k);
           list.addNode(expr);
         }
       }
     }
     return list;
   } else if (node instanceof SimpleReference) {
     return node;
   } else if (node instanceof TclAdvancedExecuteExpression) {
     TclAdvancedExecuteExpression ex = (TclAdvancedExecuteExpression) node;
     List childs = ex.getChilds();
     return new ASTListNode(node.sourceStart(), node.sourceEnd(), childs);
   } else if (node instanceof TclExecuteExpression) {
     return node;
   } else if (node instanceof Block) {
     return node;
   }
   throw new IfStatementError(Messages.TclIfProcessor_incorrectCondition, node);
 }
  @Override
  protected String[] processSuperClasses(TypeDeclaration type) {
    final ASTListNode superClasses = type.getSuperClasses();
    if (superClasses == null) {
      return new String[] {};
    }
    final List superClassNames = superClasses.getChilds();
    final List<String> result = new ArrayList<String>(superClassNames.size());
    final Iterator iterator = superClassNames.iterator();
    while (iterator.hasNext()) {
      final Object nameNode = iterator.next();

      String name;
      if (nameNode instanceof FullyQualifiedReference) {
        final FullyQualifiedReference fullyQualifiedName = (FullyQualifiedReference) nameNode;
        name = fullyQualifiedName.getFullyQualifiedName();
        if (fullyQualifiedName.getNamespace() != null) {
          final String namespace = fullyQualifiedName.getNamespace().getName();
          if (name.charAt(0) == NamespaceReference.NAMESPACE_SEPARATOR) {
            name = name.substring(1);
          } else if (fLastUseParts.containsKey(namespace)) {
            name =
                new StringBuilder(
                        fLastUseParts.get(namespace).getNamespace().getFullyQualifiedName())
                    .append(NamespaceReference.NAMESPACE_SEPARATOR)
                    .append(fullyQualifiedName.getName())
                    .toString();
          } else if (fLastNamespace != null) {
            name =
                new StringBuilder(fLastNamespace.getName())
                    .append(NamespaceReference.NAMESPACE_SEPARATOR)
                    .append(name)
                    .toString();
          }
        } else if (fLastUseParts.containsKey(name)) {
          name = fLastUseParts.get(name).getNamespace().getFullyQualifiedName();
          if (name.charAt(0) == NamespaceReference.NAMESPACE_SEPARATOR) {
            name = name.substring(1);
          }
        } else {
          if (fLastNamespace != null) {
            name =
                new StringBuilder(fLastNamespace.getName())
                    .append(NamespaceReference.NAMESPACE_SEPARATOR)
                    .append(name)
                    .toString();
          }
        }
        result.add(name);
      } else if (nameNode instanceof SimpleReference) {
        result.add(((SimpleReference) nameNode).getName());
      }
    }
    return result.toArray(new String[result.size()]);
  }
 protected String[] processSuperClasses(TypeDeclaration type) {
   ASTListNode superClasses = type.getSuperClasses();
   if (superClasses == null) {
     return new String[] {};
   }
   List<ASTNode> superClassNames = superClasses.getChilds();
   List<String> result = new ArrayList<String>(superClassNames.size());
   Iterator<ASTNode> iterator = superClassNames.iterator();
   while (iterator.hasNext()) {
     String name = processNameNode(iterator.next());
     if (name != null) {
       result.add(name);
     }
   }
   return (String[]) result.toArray(new String[result.size()]);
 }
示例#4
0
 protected String[] processSuperClasses(TypeDeclaration type) {
   ASTListNode superClasses = type.getSuperClasses();
   if (superClasses == null) {
     return new String[] {};
   }
   List<ASTNode> superClassNames = superClasses.getChilds();
   List<String> result = new ArrayList<String>(superClassNames.size());
   Iterator<ASTNode> iterator = superClassNames.iterator();
   while (iterator.hasNext()) {
     ASTNode nameNode = iterator.next();
     String name;
     if (nameNode instanceof FullyQualifiedReference) {
       FullyQualifiedReference fullyQualifiedName = (FullyQualifiedReference) nameNode;
       name = fullyQualifiedName.getFullyQualifiedName();
       if (fullyQualifiedName.getNamespace() != null) {
         String namespace = fullyQualifiedName.getNamespace().getName();
         String subnamespace = ""; // $NON-NLS-1$
         if (namespace.charAt(0) != NamespaceReference.NAMESPACE_SEPARATOR
             && namespace.indexOf(NamespaceReference.NAMESPACE_SEPARATOR) > 0) {
           int firstNSLocation = namespace.indexOf(NamespaceReference.NAMESPACE_SEPARATOR);
           subnamespace = namespace.substring(firstNSLocation);
           namespace = namespace.substring(0, firstNSLocation);
         }
         if (name.charAt(0) == NamespaceReference.NAMESPACE_SEPARATOR) {
           name = name.substring(1);
         } else if (fLastUseParts.containsKey(namespace)) {
           name =
               new StringBuilder(
                       fLastUseParts.get(namespace).getNamespace().getFullyQualifiedName())
                   .append(subnamespace)
                   .append(NamespaceReference.NAMESPACE_SEPARATOR)
                   .append(fullyQualifiedName.getName())
                   .toString();
         } else if (fCurrentNamespace != null) {
           name =
               new StringBuilder(fCurrentNamespace.getName())
                   .append(NamespaceReference.NAMESPACE_SEPARATOR)
                   .append(name)
                   .toString();
         }
       } else if (fLastUseParts.containsKey(name)) {
         name = fLastUseParts.get(name).getNamespace().getFullyQualifiedName();
         if (name.charAt(0) == NamespaceReference.NAMESPACE_SEPARATOR) {
           name = name.substring(1);
         }
       } else {
         if (fCurrentNamespace != null) {
           name =
               new StringBuilder(fCurrentNamespace.getName())
                   .append(NamespaceReference.NAMESPACE_SEPARATOR)
                   .append(name)
                   .toString();
         }
       }
       result.add(name);
     } else if (nameNode instanceof SimpleReference) {
       result.add(((SimpleReference) nameNode).getName());
     }
   }
   return (String[]) result.toArray(new String[result.size()]);
 }