@Override public String getArrayType() { return arrayType != null ? arrayType.getName() : ""; }
@Override public IVariableDefinition resolveProperty(ICompilerProject project) { if (propertyNameNode == null) return null; IDefinition definition = propertyNameNode.resolve(project); if (!(definition instanceof IVariableDefinition)) return null; return (IVariableDefinition)definition; }
@Override protected IdentifierNode copy() { return new IdentifierNode(this); }
/** * Create a dummy {@code IdentifierNode} after the given token. This is used * to repair the AST where an identifier node is expected. * * @param token The empty ID node will have start offset following this * token. * @return Dummy identifier node. */ public static IdentifierNode createEmptyIdentifierNodeAfterToken(final Token token) { final IdentifierNode result = new IdentifierNode(""); result.startAfter(token); result.endAfter(token); return result; }
private REF_TYPE getRefType() { if (isMemberRef()) { // If this is a member expr, then the stem better be a package; // otherwise we can't possibly be a type ref. if (baseIsPackage()) return REF_TYPE.PACKAGE_QUALIFIED; else return REF_TYPE.MEMBER; } else if (isQualifiedRef()) { return REF_TYPE.NAMESPACE_QUALIFIED; } else { return REF_TYPE.LEXICAL; } }
/** * Constructor. * * @param node The node reprsenting the namespace. */ public NamespaceIdentifierNode(IdentifierNode node) { super(node.getName()); span(node.getAbsoluteStart(), node.getAbsoluteEnd(), node.getLine(), node.getColumn()); setSourcePath(node.getSourcePath()); }
ASScope asScope = getASScope(); if (this.isAttributeIdentifier()) return null; if (isPartOfPackageReference()) return null; final String name = getName(); IQualifiers qualifier = null; if (isQualifiedRef()) qualifier = resolveQualifier(project); boolean isMemberRef = isMemberRef(); boolean wasMemberRef = isMemberRef; if (isMemberRef && baseIsPackage()) ExpressionNodeBase base = getBaseExpression(); if (isNameNode()) IDefinitionNode defNode = getParentAsDefinition(); if (defNode != null) result = defNode.getDefinition(); result = resolveMemberRef(project, asScope, name, qualifier);
IDefinition def = resolve(project); if (canEarlyBind(project, def)) return ((DefinitionBase)def).getMName(project); if (getParent().getNodeID() == ASTNodeID.MemberAccessExpressionID) MemberAccessExpressionNode mae = (MemberAccessExpressionNode) getParent(); if (mae.getRightOperandNode() == this) INamespaceDefinition nd = nr.resolveNamespaceReference(project); Set<INamespaceDefinition> nsset = ImmutableSet.of((INamespaceDefinition)nd); return makeName(nsset, getName(), isAttributeIdentifier()); ASScope scope = getASScope(); if (isQualifiedRef()) IQualifiers qual = resolveQualifier(project); nameKind = isAttributeIdentifier() ? CONSTANT_QnameA : CONSTANT_Qname; if (isMemberRef()) ExpressionNodeBase baseExpr = getBaseExpression(); if (baseExpr instanceof LanguageIdentifierNode && ((LanguageIdentifierNode)baseExpr).getKind() == LanguageIdentifierKind.SUPER) nameKind = isAttributeIdentifier() ? CONSTANT_MultinameA : CONSTANT_Multiname;
public Binding reduce_simpleName(IASNode iNode) { final Binding result; final IdentifierNode identifier = (IdentifierNode)iNode; if (identifier.getName().equals(IASLanguageConstants.ANY_TYPE) && SemanticUtils.isE4XWildcardProperty(identifier)) { // TODO: This is a specific fix for CMP-1731. CMP-696 should be able // to cover this use case in a more generic and robust way. Revisit // this implementation when CMP-696 is fixed. final ICompilerProject project = currentScope.getProject(); final Nsset qualifiers = SemanticUtils.getOpenNamespaces(iNode, project); final Name name = new Name(CONSTANT_Multiname, qualifiers, null); result = new Binding(iNode, name, identifier.resolve(project)); } else { result = currentScope.resolveName(identifier); currentScope.getMethodBodySemanticChecker().checkSimpleName(iNode, result); } return result; }
@Override public ITypeDefinition resolveType(ICompilerProject project) { IDefinition def = resolve(project); if (def != null) { if (isXMLish(def.getParent(), project)) { // XML and XMLList members should be treated as '*' because any access could // resolve to some content inside the XML (i.e. it has a child tag named 'name'). // return '*' since we can't statically know what the type will be. // Compat with ASC behavior. return project.getBuiltinType(IASLanguageConstants.BuiltinType.ANY_TYPE); } return def.resolveType(project); } return null; }
return IdentifierNode.isXMLish(leftDef, getWalker().getProject()); if (rightDef != null) return IdentifierNode.isXMLish(rightDef, getWalker().getProject()); String fname = ((IdentifierNode)boan.getChild(1)).getName(); if (fname.equals("XML") || fname.equals("XMLList")) return true; IDefinition leftDef = leftNode.resolveType(getWalker().getProject()); if (leftDef != null) return IdentifierNode.isXMLish(leftDef, getWalker().getProject());
/** * Can this Node be early bound to the Definition it refers to. * We can early bind if we resolve to a definition, the definition is not ambiguous, and * the definition is not something defined in one of the XML classes (XML or XMLList). * @param project project to resolve things in * @param def the definition this node resolved to * @return true if we can early bind, otherwise false */ protected boolean canEarlyBind(ICompilerProject project, IDefinition def) { if (def instanceof DefinitionBase && !AmbiguousDefinition.isAmbiguous(def)) { // Can't early bind to XML/XMLList properties as they may be hidden by the unknown contents // of the XML itself, i.e. a child tag named 'parent' // Matches ASC behavior. if (!isXMLish(def.getParent(), project)) return true; } return false; }
@Override IReference computeTypeReference() { // Parser creates IdentifierNodes for "" for some error cases of improperly written code, // like class C extends {} - it gets an IDNode of "" for the extends clause if (name == "") return null; IReference typeRef = null; IWorkspace w = getWorkspace(); switch (getRefType()) { case PACKAGE_QUALIFIED: { ExpressionNodeBase baseExpr = getBaseExpression(); typeRef = ReferenceFactory.packageQualifiedReference(w, baseExpr.computeSimpleReference(), computeSimpleReference(), false); break; } case LEXICAL: { typeRef = ReferenceFactory.lexicalReference(w, computeSimpleReference()); break; } default: { typeRef = ReferenceFactory.notATypeReference(w, computeSimpleReference()); break; } } return typeRef; }
protected final IdentifierNode build(Token token) { IdentifierNode name = new IdentifierNode(getText(token)); name.span(token); return name; }
node = IdentifierNode.createEmptyIdentifierNodeAfterToken(current); node = new IdentifierNode(token.getText(), (IASToken)token); node = new IdentifierNode(la1.getText(), (IASToken)la1); consume(); node = IdentifierNode.createEmptyIdentifierNodeAfterToken(current);
ExpressionNodeBase baseExpr = getBaseExpression(); if (baseExpr != null) if (!((RoyaleProject)project).useStrictXML() && isXMLish(baseType, project)) return null;
if(name.getStart() == -1) { name.startAfter(keyword); name.endAfter(keyword);
/** * Constructor. * <p> * Creates a {@code BinaryOperatorNode} from an operator and both operands. * If either operand is {@code null}, we will synthesize * empty {@link IdentifierNode} to repair the tree. * * @param op operator token * @param left first operand * @param right second operand */ public BinaryOperatorNodeBase(IASToken op, ExpressionNodeBase left, ExpressionNodeBase right) { super(op); // Synthesize an empty ID node if either operand is null. (Fix for CMP-883) if (left == null) leftOperandNode = IdentifierNode.createEmptyIdentifierNodeAfterToken((Token)op); else leftOperandNode = left; if (right == null) rightOperandNode = IdentifierNode.createEmptyIdentifierNodeAfterToken((Token)op); else rightOperandNode = right; span(leftOperandNode, rightOperandNode); }
ASScope asScope = getASScope(); if (this.isAttributeIdentifier()) return null; if (isPartOfPackageReference()) return null; final String name = getName(); IQualifiers qualifier = null; if (isQualifiedRef()) qualifier = resolveQualifier(project); boolean isMemberRef = isMemberRef(); boolean wasMemberRef = isMemberRef; if (isMemberRef && baseIsPackage()) ExpressionNodeBase base = getBaseExpression(); if (isNameNode()) IDefinitionNode defNode = getParentAsDefinition(); if (defNode != null) result = defNode.getDefinition(); result = resolveMemberRef(project, asScope, name, qualifier);