Package org.apache.flex.compiler.internal.definitions

Examples of org.apache.flex.compiler.internal.definitions.ClassDefinition


        }

        Multiname mname = Multiname.crackDottedQName(this.project, qname);
        INamespaceDefinition packageNS = Iterables.getOnlyElement(mname.getNamespaceSet());
        assert packageNS instanceof INamespaceReference;
        currentClassDefinition = new ClassDefinition(mname.getBaseName(), (INamespaceReference)packageNS);
        currentClassDefinition.setLocation(rootTag);
        currentClassDefinition.setBaseClassReference(baseClass);
        currentClassDefinition.setImplementedInterfaceReferences(implementedInterfaces);
        currentClassDefinition.setMetaTags(new IMetaTag[0]);
        // Grr... CM clients expect the name start of the root class definition to be at 0.
View Full Code Here


        assert fileScope.isDefinitionTag(definitionTag);
       
        // An <fx:Definition> tag will create a new class.
        // Save off the current class definition and scope
        // because we're going to change them before recursing down.
        ClassDefinition oldClassDefinition = currentClassDefinition;
        TypeScope oldClassScope = currentClassScope;
       
        // Walk the attributes looking for 'name'.
        IMXMLTagAttributeData[] definitionTagAttrs = definitionTag.getAttributeDatas();
        String definitionName = null;
        int nameStart = -1;
        int nameEnd = -1;
        for (IMXMLTagAttributeData attr : definitionTagAttrs)
        {
            if ((!(attr instanceof IMXMLNamespaceAttributeData)) && (attr.hasValue()))
            {
               if ((attr.getURI() == null) && (ATTRIBUTE_NAME.equals(attr.getName())))
               {
                   if (definitionName == null)
                   {
                       definitionName = attr.getRawValue();
                       nameStart = attr.getValueStart() + 1;
                       nameEnd = attr.getValueEnd() - 1;
                   }
                   // TODO create problem if definition name has already been set.
               }
            }
        }
       
        // We expect one child tag inside <fx:Definition>.
        IMXMLTagData firstChild = definitionTag.getFirstChild(true);
        if (firstChild != null)
        {
            // TODO create problem if there is more than one child tag
            // in a definition.
            IMXMLTagData secondChild = firstChild.getNextSibling(true);
            if (secondChild != null)
                return;
           
            // This child tag specifies the base class of the definition class.
            String baseClassQName = fileScope.resolveTagToQualifiedName(firstChild);
            // TODO create problem if we can't resolve the base class name.
            if (baseClassQName == null)
                return;
           
            // Add a class definition for the definition class to the file scope.
            // The file scope will handle resolving a tag like <fx:MyDefinition>
            // to the class for <fx:Definition name="MyDefinition">.
            ClassDefinition fxDefinitionClassDefinition =
                fileScope.addFXDefinition(qname, definitionTag, definitionName, baseClassQName);
            fxDefinitionClassDefinition.setLocation(firstChild);
            fxDefinitionClassDefinition.setNameLocation(nameStart, nameEnd);
           
            // Set up the "context" for building definitions inside the definition class.
            currentClassDefinition = fxDefinitionClassDefinition;
            currentClassScope = (TypeScope)fxDefinitionClassDefinition.getContainedScope();
           
            // add the definitions inside the definition tag to the definition class scope.
            processTag(firstChild);
        }
       
View Full Code Here

        assert fileScope.isComponentTag(componentTag);
       
        // An <fx:Definition> tag will create a new class.
        // Save off the current class definition and scope
        // because we're going to change them before recursing down.
        ClassDefinition oldClassDefinition = currentClassDefinition;
        TypeScope oldClassScope = currentClassScope;
       
        // Walk the attributes looking for 'className'.
        IMXMLTagAttributeData[] definitionTagAttrs = componentTag.getAttributeDatas();
        String className = null;
        int nameStart = -1;
        int nameEnd = -1;
        for (IMXMLTagAttributeData attr : definitionTagAttrs)
        {
            if ((!(attr instanceof IMXMLNamespaceAttributeData)) && (attr.hasValue()))
            {
               if ((attr.getURI() == null) && (attr.getName().equals("className")))
               {
                   if (className == null)
                   {
                       className = attr.getRawValue();
                       nameStart = attr.getValueStart() + 1;
                       nameEnd = attr.getValueEnd() - 1;
                   }
                   // TODO create problem if className has already been set.
               }
            }
        }
               
        // We expect one child tag inside <fx:Component>.
        IMXMLTagData firstChild = componentTag.getFirstChild(true);
        if (firstChild != null)
        {
            // TODO create problem if there is more than one child tag
            // in a definition.
            IMXMLTagData secondChild = firstChild.getNextSibling(true);
            if (secondChild != null)
                return;
           
            // This child tag specifies the base class of the component class.
            String baseClassQName = fileScope.resolveTagToQualifiedName(firstChild);
            // TODO create problem if we can't resolve the base class name.
            if (baseClassQName == null)
                return;
           
            // Add a class definition for the component class to the file scope.
            ClassDefinition fxComponentClassDefinition =
                fileScope.addFXComponent(qname, componentTag.getAbsoluteStart(), className, baseClassQName);
            fxComponentClassDefinition.setNameLocation(nameStart, nameEnd);
           
            if (className == null)
                fxComponentClassDefinition.setExcludedClass();
           
            // Set up the "context" for building definitions inside the definition class.
            currentClassDefinition = fxComponentClassDefinition;
            currentClassScope = (TypeScope)fxComponentClassDefinition.getContainedScope();

            currentClassDefinition.buildOuterDocumentMember(ReferenceFactory.resolvedReference(oldClassDefinition));

            // add the definitions inside the component tag to the component class scope.
            processTag(firstChild);
View Full Code Here

            else
                this.superState = SuperState.Armed;
        }

        //  Check parameters if possible.
        ClassDefinition super_def = (ClassDefinition) super_node.resolveType(project);

        if (super_def != null)
        {
            IFunctionDefinition ctor = super_def.getConstructor();

            if (ctor instanceof FunctionDefinition)
            {
                checkFormalsVsActuals(super_node, (FunctionDefinition)ctor, args);
            }
View Full Code Here

                roundUpUsualSuspects(class_binding, iNode)
            ));
        }
        else if ( def instanceof ClassDefinition )
        {
            ClassDefinition class_def = (ClassDefinition)def;

            IFunctionDefinition ctor = class_def.getConstructor();

            if ( ctor instanceof FunctionDefinition )
            {
                FunctionDefinition func = (FunctionDefinition)ctor;
                checkFormalsVsActuals(iNode, func, args);
View Full Code Here

        final IDefinition moduleFactoryBaseClassDef =
            moduleFactoryBaseClassReference.resolve(flexProject);
        if (!(moduleFactoryBaseClassDef instanceof ClassDefinition))
            return ModuleFactoryInfo.create(Collections.<ICompilerProblem>emptyList()); // TODO make a compiler problem here!
       
        final ClassDefinition moduleFactoryBaseClass =
            (ClassDefinition)moduleFactoryBaseClassDef;
       
        final ICompilationUnit moduleFactoryBaseClassCompilationUnit =
            flexProject.getScope().getCompilationUnitForDefinition(moduleFactoryBaseClass);
        assert moduleFactoryBaseClassCompilationUnit != null : "Unable to find compilation unit for definition!";
View Full Code Here

            for(IDefinition def : result.getExternallyVisibleDefinitions())
            {
                if(def instanceof ClassDefinition)
                {
                    ClassDefinition classDef = (ClassDefinition)def;
                    //check whether class extends ResourceBundle, but not ResourceBundle.
                    if(!resourceBundleDefinition.equals(classDef) &&
                            classDef.isInstanceOf(resourceBundleDefinition, flexProject))
                    {
                        //this is a class that extents mx.resources.ResourceBundle, so add it to the list
                        compiledResourceBundleNames.add(def.getQualifiedName());
                    }
                }
View Full Code Here

    @Override
    protected void analyze(EnumSet<PostProcessStep> set, ASScope scope, Collection<ICompilerProblem> problems)
    {
        if (set.contains(PostProcessStep.POPULATE_SCOPE))
        {
            ClassDefinition definition = buildDefinition();
            setDefinition(definition);
            scope.addDefinition(definition);

            // The BlockNode inside a ClassNode creates a new ASScope,
            // with the current scope as its parent.
            // This new scope then gets passed down as the current scope.
            TypeScope typeScope = new TypeScope(scope, contentsNode, definition);
            definition.setContainedScope(typeScope);
            definition.setupThisAndSuper();
            definition.buildContingentDefinitions();
            scope = typeScope;
        }

        if (set.contains(PostProcessStep.RECONNECT_DEFINITIONS))
        {
View Full Code Here

        // out fix for this is to run the string
        // through Multiname.getBaseNameForQName.
        String definitionName = Multiname.getBaseNameForQName(nameNode.computeSimpleReference());
        INamespaceReference namespaceReference = NamespaceDefinition.createNamespaceReference(getASScope(), getNamespaceNode());

        ClassDefinition definition = new ClassDefinition(definitionName, namespaceReference);
        definition.setNode(this);

        fillInModifiers(definition);
        fillInMetadata(definition);
        fillInStateNames(definition);

        // Set the base class.
        IReference baseRef = null;
        if (baseClassNode != null)
            baseRef = baseClassNode.computeTypeReference();
        definition.setBaseClassReference(baseRef);

        // Set the implemented interfaces.
        if (interfacesNode != null)
        {
            int n = interfacesNode.getChildCount();
            List<IReference> interfaces = new ArrayList<IReference>(n);
            for (int i = 0; i < n; i++)
            {
                IASNode child = interfacesNode.getChild(i);
                if (child instanceof ExpressionNodeBase)
                {
                    IReference typeReference = ((ExpressionNodeBase)child).computeTypeReference();
                    if (typeReference != null)
                        interfaces.add(typeReference);
                }
            }
            definition.setImplementedInterfaceReferences(interfaces.toArray(new IReference[interfaces.size()]));
        }

        return definition;
    }
View Full Code Here

   
    private FlexDelegate getDelegate()
    {
        if (delegate != null)
            return delegate;
        final ClassDefinition mainAppClass = getRootClassDefinition();
        assert mainAppClass != null : "build should be abort before this point if root class does not exist!";
        delegate = new FlexDelegate(mainAppClass, targetSettings, flexProject);
        return delegate;
    }
View Full Code Here

TOP

Related Classes of org.apache.flex.compiler.internal.definitions.ClassDefinition

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.