Esempio n. 1
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
 protected Element internalLookup(
     Identifier identifier, String name, LibraryElement referencingLibrary) {
   Element element = localLookup(name, referencingLibrary);
   if (element != null) {
     return element;
   }
   // May be there is a hidden Element.
   if (hasHiddenName) {
     Element hiddenElement = hiddenElements.get(name);
     if (hiddenElement != null) {
       getErrorListener()
           .onError(
               new AnalysisError(
                   getSource(identifier),
                   identifier.getOffset(),
                   identifier.getLength(),
                   CompileTimeErrorCode.REFERENCED_BEFORE_DECLARATION));
       return hiddenElement;
     }
   }
   // Check enclosing scope.
   return enclosingScope.internalLookup(identifier, name, referencingLibrary);
 }