Package com.google.dart.engine.internal.element

Examples of com.google.dart.engine.internal.element.LocalVariableElementImpl


  @Override
  public void apply(AngularHtmlUnitResolver resolver, XmlTagNode node) {
    InterfaceType type = ((ClassElement) element.getEnclosingElement()).getType();
    String name = element.getName();
    LocalVariableElementImpl variable = resolver.createLocalVariableWithName(type, name);
    resolver.defineVariable(variable);
    variable.setToolkitObjects(new AngularElement[] {element});
  }
View Full Code Here


  @Override
  public Void visitCatchClause(CatchClause node) {
    SimpleIdentifier exceptionParameter = node.getExceptionParameter();
    if (exceptionParameter != null) {
      LocalVariableElementImpl exception = new LocalVariableElementImpl(exceptionParameter);

      currentHolder.addLocalVariable(exception);
      exceptionParameter.setStaticElement(exception);

      SimpleIdentifier stackTraceParameter = node.getStackTraceParameter();
      if (stackTraceParameter != null) {
        LocalVariableElementImpl stackTrace = new LocalVariableElementImpl(stackTraceParameter);

        currentHolder.addLocalVariable(stackTrace);
        stackTraceParameter.setStaticElement(stackTrace);
      }
    }
View Full Code Here

  @Override
  public Void visitDeclaredIdentifier(DeclaredIdentifier node) {
    SimpleIdentifier variableName = node.getIdentifier();
    Token keyword = node.getKeyword();

    LocalVariableElementImpl element = new LocalVariableElementImpl(variableName);
    ForEachStatement statement = (ForEachStatement) node.getParent();
    int declarationEnd = node.getOffset() + node.getLength();
    int statementEnd = statement.getOffset() + statement.getLength();
    element.setVisibleRange(declarationEnd, statementEnd - declarationEnd - 1);
    element.setConst(matches(keyword, Keyword.CONST));
    element.setFinal(matches(keyword, Keyword.FINAL));

    currentHolder.addLocalVariable(element);
    variableName.setStaticElement(element);
    return super.visitDeclaredIdentifier(node);
  }
View Full Code Here

      currentHolder.addField(field);
      fieldName.setStaticElement(field);
    } else if (inFunction) {
      SimpleIdentifier variableName = node.getName();
      LocalVariableElementImpl variable;
      if (isConst && hasInitializer) {
        variable = new ConstLocalVariableElementImpl(variableName);
      } else {
        variable = new LocalVariableElementImpl(variableName);
      }
      element = variable;
      Block enclosingBlock = node.getAncestor(Block.class);
      int functionEnd = node.getOffset() + node.getLength();
      int blockEnd = enclosingBlock.getOffset() + enclosingBlock.getLength();
      // TODO(brianwilkerson) This isn't right for variables declared in a for loop.
      variable.setVisibleRange(functionEnd, blockEnd - functionEnd - 1);

      currentHolder.addLocalVariable(variable);
      variableName.setStaticElement(element);
    } else {
      SimpleIdentifier variableName = node.getName();
      TopLevelVariableElementImpl variable;
      if (isConst && hasInitializer) {
        variable = new ConstTopLevelVariableElementImpl(variableName);
      } else {
        variable = new TopLevelVariableElementImpl(variableName);
      }
      element = variable;

      currentHolder.addTopLevelVariable(variable);
      variableName.setStaticElement(element);
    }

    element.setConst(isConst);
    element.setFinal(isFinal);
    if (hasInitializer) {
      ElementHolder holder = new ElementHolder();
      boolean wasInFieldContext = inFieldContext;
      inFieldContext = false;
      try {
        visit(holder, node.getInitializer());
      } finally {
        inFieldContext = wasInFieldContext;
      }
      FunctionElementImpl initializer = new FunctionElementImpl(
          node.getInitializer().getBeginToken().getOffset());
      initializer.setFunctions(holder.getFunctions());
      initializer.setLabels(holder.getLabels());
      initializer.setLocalVariables(holder.getLocalVariables());
      initializer.setSynthetic(true);
      element.setInitializer(initializer);
      holder.validate();
    }
    if (element instanceof PropertyInducingElementImpl) {
      PropertyInducingElementImpl variable = (PropertyInducingElementImpl) element;

      if (inFieldContext) {
        ((FieldElementImpl) variable).setStatic(matches(
            ((FieldDeclaration) node.getParent().getParent()).getStaticKeyword(),
            Keyword.STATIC));
      }

      PropertyAccessorElementImpl getter = new PropertyAccessorElementImpl(variable);
      getter.setGetter(true);

      currentHolder.addAccessor(getter);
      variable.setGetter(getter);

      if (!isFinal) {
        PropertyAccessorElementImpl setter = new PropertyAccessorElementImpl(variable);
        setter.setSetter(true);
        ParameterElementImpl parameter = new ParameterElementImpl(
            "_" + variable.getName(),
            variable.getNameOffset());
        parameter.setSynthetic(true);
        parameter.setParameterKind(ParameterKind.REQUIRED);
        setter.setParameters(new ParameterElement[] {parameter});

        currentHolder.addAccessor(setter);
        variable.setSetter(setter);
      }
    }
    return null;
  }
View Full Code Here

   * @param type the {@link Type} of the variable
   * @param identifier the identifier to create variable for
   * @return the new {@link LocalVariableElementImpl}
   */
  LocalVariableElementImpl createLocalVariableFromIdentifier(Type type, SimpleIdentifier identifier) {
    LocalVariableElementImpl variable = new LocalVariableElementImpl(identifier);
    definedVariables.add(variable);
    variable.setType(type);
    return variable;
  }
View Full Code Here

   * {@link ClassElement}.
   */
  private void defineTopVariable_forClassElement(AngularElement element) {
    ClassElement classElement = (ClassElement) element.getEnclosingElement();
    InterfaceType type = classElement.getType();
    LocalVariableElementImpl variable = createLocalVariableWithName(type, element.getName());
    defineTopVariable(variable);
    variable.setToolkitObjects(new AngularElement[] {element});
  }
View Full Code Here

  /**
   * Defines variable for the given {@link AngularScopePropertyElement}.
   */
  private void defineTopVariable_forScopeProperty(AngularScopePropertyElement element) {
    Type type = element.getType();
    LocalVariableElementImpl variable = createLocalVariableWithName(type, element.getName());
    defineTopVariable(variable);
    variable.setToolkitObjects(new AngularElement[] {element});
  }
View Full Code Here

      return;
    }
    SimpleIdentifier identifier = (SimpleIdentifier) expression;
    // define variable Element
    InterfaceType type = resolver.getTypeProvider().getStringType();
    LocalVariableElementImpl element = resolver.createLocalVariableFromIdentifier(type, identifier);
    resolver.defineTopVariable(element);
    // remember expression
    identifier.setStaticElement(element);
    identifier.setStaticType(type);
    setExpression(attribute, identifier);
View Full Code Here

    new ElementBuilder(new ElementHolder()).visitDeclaredIdentifier(loopVariable);
    resolver.resolveNode(loopStatement);
    // define item variable
    Type itemType = varName.getBestType();
    {
      LocalVariableElementImpl variable = (LocalVariableElementImpl) varName.getStaticElement();
      variable.setType(itemType);
      resolver.defineVariable(variable);
    }
    // resolve formatters
    resolveFormatters(resolver, iterableExpr, itemType);
    // remember expressions
View Full Code Here

    return node.getAttribute(NG_REPEAT) != null;
  }

  private void defineLocalVariable_bool(AngularHtmlUnitResolver resolver, String name) {
    InterfaceType type = resolver.getTypeProvider().getBoolType();
    LocalVariableElementImpl variable = resolver.createLocalVariableWithName(type, name);
    resolver.defineVariable(variable);
  }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.internal.element.LocalVariableElementImpl

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.