Package org.apache.flex.compiler.internal.tree.as

Examples of org.apache.flex.compiler.internal.tree.as.IdentifierNode


    }

    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);
View Full Code Here


                        ast.getAllImportNodes(importNodes);
                        if (baseNode == null)
                        {
                            // bindable class extends Object, must switch to
                            // extend EventDispatcher
                            IdentifierNode baseClassNode = new IdentifierNode("EventDispatcher");
                            baseClassNode.setParent(classNode);
                            classNode.setBaseClass(baseClassNode);
                            IdentifierNode flash = new IdentifierNode("flash");
                            IdentifierNode events = new IdentifierNode("events");
                            FullNameNode flashDotEvents = new FullNameNode(flash,
                                    new ASToken(ASToken.TOKEN_OPERATOR_MEMBER_ACCESS, 0, 0, 0, 0, "."), events);
                            FullNameNode fullNameNode = new FullNameNode(flashDotEvents,
                                    new ASToken(ASToken.TOKEN_OPERATOR_MEMBER_ACCESS, 0, 0, 0, 0, "."),
                                    baseClassNode);
View Full Code Here

    }

    public IDefinitionNode[] getDefinitions()
    {
        IDefinitionNode[] retVal = new IDefinitionNode[4];
        VariableNode thisNode = new VariableNode(new IdentifierNode(IASKeywordConstants.THIS));
        thisNode.setType(null, new IdentifierNode(IASLanguageConstants.Vector));
        retVal[0] = thisNode;

        //and super
        VariableNode superNode = new VariableNode(new IdentifierNode(IASKeywordConstants.SUPER));
        superNode.setType(null, new IdentifierNode(IASLanguageConstants.Object));
        retVal[1] = superNode;

        //add the fixed getter/setter pair
        GetterNode fixGetter = new GetterNode(null, null, new IdentifierNode("fixed"));
        NamespaceIdentifierNode pub = new NamespaceIdentifierNode(INamespaceConstants.public_);
        pub.span(-1, -1, -1, -1);
        fixGetter.setNamespace(pub);
        fixGetter.setType(null, new IdentifierNode(IASLanguageConstants.Boolean));
        retVal[2] = fixGetter;

        SetterNode fixSetter = new SetterNode(null, null, new IdentifierNode("fixed"));
        pub = new NamespaceIdentifierNode(INamespaceConstants.public_);
        pub.span(-1, -1, -1, -1);
        fixSetter.setNamespace(pub);
        fixSetter.setType(null, new IdentifierNode(IASLanguageConstants.void_));
        ParameterNode value = new ParameterNode(new IdentifierNode("value"));
        value.setType(null, new IdentifierNode(IASLanguageConstants.Boolean));
        fixSetter.getParametersContainerNode().addChild(value);
        retVal[3] = fixSetter;

        return retVal;
    }
View Full Code Here

     */
    public ExpressionNodeBase toExpression()
    {
        if (elementType instanceof AppliedVectorDefinition)
        {
            return new TypedExpressionNode(new IdentifierNode(IASLanguageConstants.Vector), ((AppliedVectorDefinition)elementType).toExpression());
        }
        return new IdentifierNode(elementType.getBaseName());
    }
View Full Code Here

     */
    public TypedExpressionNode toTypedExpression()
    {
        if (elementType instanceof AppliedVectorDefinition)
        {
            return new TypedExpressionNode(new IdentifierNode(IASLanguageConstants.Vector), ((AppliedVectorDefinition)elementType).toTypedExpression());
        }
        return new TypedExpressionNode(new IdentifierNode(IASLanguageConstants.Vector), new IdentifierNode(elementType.getBaseName()));
    }
View Full Code Here

        return token != null ? token.getText() : "";
    }

    protected final IdentifierNode build(Token token)
    {
        IdentifierNode name = new IdentifierNode(getText(token));
        name.span(token);
        return name;
    }
View Full Code Here

     * @return generated class AST
     */
    public FileNode buildAST(Collection<ICompilerProblem> problems, String filename)
    {
        FileNode fileNode = new FileNode(workspace, filename);
        PackageNode packageNode = new PackageNode(new IdentifierNode(""), null);
        fileNode.addItem(packageNode);

        ScopedBlockNode contents = packageNode.getScopedNode();
        ImportNode importNode = ImportNode.buildImportNode(getBaseClassQName());
        contents.addItem(importNode);

        ClassNode classNode = new ClassNode(new IdentifierNode(data.getQName()));
        classNode.setBaseClass(new IdentifierNode(getBaseClassName()));
        classNode.setNamespace(new NamespaceIdentifierNode(INamespaceConstants.public_));
        contents.addItem(classNode);

        fileNode.runPostProcess(EnumSet.of(PostProcessStep.POPULATE_SCOPE));

View Full Code Here

    protected IdentifierNode handleMissingIdentifier(RecognitionException ex)
    {
        consumeParsingError(ex); //we don't want to drop a semicolon here
        //now let's guard against the case where the very next token is an identifier.
        //if we produce an identifier here, everything downstream might fail
        final IdentifierNode node;
        ASToken current = buffer.previous();
        ASToken la2 = LT(1 + 1);
        ASToken la1 = LT(1);

        if (current.getType() == ASTokenTypes.TOKEN_RESERVED_WORD_EXTENDS)
        {
            // Fix for CMP-1087: the following two branches are too greedy.
            // i.e.
            //   public class T extends   implements MyInterface
            //                          ^
            // The "extends" keyword expects an identifier. However, instead of
            // reporting the missing identifier and continue with "implements",
            // the following recovery logic throws away "implements" keyword and
            // sends back "MyInterface".
            node = IdentifierNode.createEmptyIdentifierNodeAfterToken(current);
        }
        else if (la2.getType() == ASTokenTypes.TOKEN_IDENTIFIER && la2.getLine() == current.getLine())
        {
            //let's make sure this is on the same line, avoiding possibly going past the end of the statement
            //since this is all repair code anyway, this produces a much "saner" repaired tree
            ASToken token = LT(1 + 1);
            node = new IdentifierNode(token.getText(), (IASToken)token);
            consume(); //consume error token
            consume(); //act as match() for identifier, which consumes it
        }
        else if (la1.isKeywordOrContextualReservedWord() && la1.getLine() == current.getLine())
        {
            // If it's a keyword, repair by making an identifier node with the text of the keyword
            // This makes a more sensible tree - the user may be in the middle of typing an identifier that
            // starts with a keyword.  They probably meant "f.is" rather than "(f.)is" for example
            node = new IdentifierNode(la1.getText(), (IASToken)la1);
            consume();
        }
        else
        {
            node = IdentifierNode.createEmptyIdentifierNodeAfterToken(current);
View Full Code Here

            final String configVar)
    {
        final ConfigExpressionNode configExpression = new ConfigExpressionNode(
                new NamespaceIdentifierNode(configNamespace),
                opToken,
                new IdentifierNode(configVar));

        final Object value = configProcessor.evaluateConstNodeExpressionToJavaObject(configExpression);
        return value == null ? false : ECMASupport.toBoolean(value);
    }
View Full Code Here

    @Override
    public FileNode buildAST(Collection<ICompilerProblem> problems, String filename)
    {
        FileNode fileNode = new FileNode(workspace, filename);
        PackageNode packageNode = new PackageNode(new IdentifierNode(""), null);
        fileNode.addItem(packageNode);

        ScopedBlockNode contents = packageNode.getScopedNode();

        ClassNode classNode = new ClassNode(new IdentifierNode(data.getQName()));
        classNode.setNamespace(new NamespaceIdentifierNode(INamespaceConstants.public_));
        contents.addItem(classNode);

        // generate: public static var data:XML = ${XML_DATA};
        VariableNode variableNodeData = new VariableNode(new IdentifierNode("data"));
        variableNodeData.setNamespace(new NamespaceIdentifierNode(INamespaceConstants.public_));
        variableNodeData.addModifier(new ModifierNode(IASKeywordConstants.STATIC));
        variableNodeData.setType(null, new IdentifierNode("XML"));
        ASToken assignToken = new ASToken(ASTokenTypes.TOKEN_OPERATOR_ASSIGNMENT, -1, -1, -1, -1, "=");
        String xmlContents = getXMLString(problems);
        LiteralNode xmlData = new LiteralNode(LiteralType.STRING, xmlContents);
        variableNodeData.setAssignedValue(assignToken, xmlData);
        classNode.getScopedNode().addItem(variableNodeData);
View Full Code Here

TOP

Related Classes of org.apache.flex.compiler.internal.tree.as.IdentifierNode

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.