예제 #1
0
  public void test_visitConstructorDeclaration_unnamed() {
    ElementHolder holder = new ElementHolder();
    ElementBuilder builder = new ElementBuilder(holder);
    String className = "A";
    ConstructorDeclaration constructorDeclaration =
        constructorDeclaration(
            null,
            null,
            identifier(className),
            null,
            formalParameterList(),
            null,
            blockFunctionBody());
    constructorDeclaration.accept(builder);
    ConstructorElement[] constructors = holder.getConstructors();
    assertLength(1, constructors);

    ConstructorElement constructor = constructors[0];
    assertNotNull(constructor);
    assertFalse(constructor.isFactory());
    assertEquals("", constructor.getName());
    assertLength(0, constructor.getFunctions());
    assertLength(0, constructor.getLabels());
    assertLength(0, constructor.getLocalVariables());
    assertLength(0, constructor.getParameters());
    assertSame(constructor, constructorDeclaration.getElement());
  }
예제 #2
0
 @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;
 }
예제 #3
0
  @Override
  public Void visitConstructorDeclaration(ConstructorDeclaration node) {
    ElementHolder holder = new ElementHolder();
    visitChildren(holder, node);

    ConstructorElementImpl element = new ConstructorElementImpl(node.getName());
    Token keyword = node.getKeyword();
    if (keyword instanceof KeywordToken
        && ((KeywordToken) keyword).getKeyword() == Keyword.FACTORY) {
      element.setFactory(true);
    }
    element.setFunctions(holder.getFunctions());
    element.setLabels(holder.getLabels());
    element.setLocalVariables(holder.getVariables());
    if (holder.getParameters() != null) {
      element.setParameters(holder.getParameters());
    }
    currentHolder.addConstructor(element);
    return null;
  }
예제 #4
0
  @Override
  public Void visitConstructorDeclaration(ConstructorDeclaration node) {
    ElementHolder holder = new ElementHolder();
    visitChildren(holder, node);

    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.getVariables());
    element.setParameters(holder.getParameters());

    currentHolder.addConstructor(element);
    node.setElement(element);
    if (constructorName != null) {
      constructorName.setElement(element);
    }
    return null;
  }
예제 #5
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;
  }
 @Override
 public R visitConstructorDeclaration(ConstructorDeclaration node) {
   node.visitChildren(this);
   return null;
 }