コード例 #1
0
ファイル: ToSourceVisitor.java プロジェクト: aam/dartdev
 @Override
 public Void visitConstructorDeclaration(ConstructorDeclaration node) {
   visit(node.getExternalKeyword(), " ");
   visit(node.getConstKeyword(), " ");
   visit(node.getFactoryKeyword(), " ");
   visit(node.getReturnType());
   visit(".", node.getName());
   visit(node.getParameters());
   visitList(" : ", node.getInitializers(), ", ");
   visit(" = ", node.getRedirectedConstructor());
   visit(" ", node.getBody());
   return null;
 }
コード例 #2
0
  @Override
  public Void visitConstructorDeclaration(ConstructorDeclaration node) {
    isValidMixin = false;
    ElementHolder holder = new ElementHolder();
    boolean wasInFunction = inFunction;
    inFunction = true;
    try {
      visitChildren(holder, node);
    } finally {
      inFunction = wasInFunction;
    }

    SimpleIdentifier constructorName = node.getName();
    ConstructorElementImpl element = new ConstructorElementImpl(constructorName);
    if (node.getFactoryKeyword() != null) {
      element.setFactory(true);
    }
    element.setFunctions(holder.getFunctions());
    element.setLabels(holder.getLabels());
    element.setLocalVariables(holder.getLocalVariables());
    element.setParameters(holder.getParameters());
    element.setConst(node.getConstKeyword() != null);

    currentHolder.addConstructor(element);
    node.setElement(element);
    if (constructorName == null) {
      Identifier returnType = node.getReturnType();
      if (returnType != null) {
        element.setNameOffset(returnType.getOffset());
      }
    } else {
      constructorName.setStaticElement(element);
    }
    holder.validate();
    return null;
  }