Package dtool.ast.references

Source Code of dtool.ast.references.AutoReference

/*******************************************************************************
* Copyright (c) 2011, 2014 Bruno Medeiros and other Contributors.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
*     Bruno Medeiros - initial API and implementation
*******************************************************************************/
package dtool.ast.references;

import static melnorme.utilbox.core.CoreUtil.assertCast;

import java.util.Collection;

import dtool.ast.ASTCodePrinter;
import dtool.ast.ASTNode;
import dtool.ast.ASTNodeTypes;
import dtool.ast.IASTVisitor;
import dtool.ast.definitions.INamedElement;
import dtool.ast.expressions.IInitializer;
import dtool.engine.common.IValueNode;
import dtool.engine.common.IVarDefinitionLike;
import dtool.engine.modules.IModuleResolver;

/**
* This reference node can only be parsed in special circumstances
*/
public final class AutoReference extends Reference {
 
  public AutoReference() {
  }
 
  @Override
  public ASTNodeTypes getNodeType() {
    return ASTNodeTypes.REF_AUTO;
  }
 
  @Override
  protected ASTNode getParent_Concrete() {
    assertCast(getParent(), IVarDefinitionLike.class);
    return super.getParent_Concrete();
  }
 
  public IVarDefinitionLike getParent_() {
    return assertCast(getParent(), IVarDefinitionLike.class);
  }
 
  @Override
  public void visitChildren(IASTVisitor visitor) {
  }
 
  @Override
  public void toStringAsCode(ASTCodePrinter cp) {
    cp.append("auto");
  }
 
  @Override
  public Collection<INamedElement> findTargetDefElements(IModuleResolver mr, boolean findFirstOnly) {
    IInitializer initializer = getParent_().getDeclaredInitializer();
    if(initializer instanceof IValueNode) {
      IValueNode valueNode = (IValueNode) initializer;
      return valueNode.resolveTypeOfUnderlyingValue(mr);
    }
    return null;
  }
 
}
TOP

Related Classes of dtool.ast.references.AutoReference

TOP
Copyright © 2018 www.massapi.com. 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.