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

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


    protected void addImplicitOpenNamespaces(CompilerProject compilerProject, Set<INamespaceDefinition> result, ScopeKind lookupKind)
    {
        IDefinition currentDefinition = this.getDefinition();
        if (currentDefinition instanceof ClassDefinition)
        {
            ClassDefinition initialClassDef = (ClassDefinition)currentDefinition;
            // Private namespace always added - same private namespace can be used for static and instance properties
            result.add(initialClassDef.getPrivateNamespaceReference());

            // Protected namespaces differ for static & instance scopes
            if (lookupKind.findInstance())
            {
                result.add(initialClassDef.getProtectedNamespaceReference());
            }
            // Add all the static protected namespaces to the namespace set.
            // Instance protected namespaces are added to the namespace set
            // in TypeScope as we walk up the class hierarchy.  The instance
            // protected namespace needs to change as we walk up the class hierarchy.
            if (lookupKind.findStatics())
            {
                for (IClassDefinition classDef : initialClassDef.classIterable(compilerProject, true))
                    result.add(((ClassDefinition)classDef).getStaticProtectedNamespaceReference());
            }

        }
        else if (currentDefinition instanceof InterfaceDefinition)
View Full Code Here


        {
            // TODO This belongs in MXMLDocumentNode.
            MXMLDocumentNode documentNode = (MXMLDocumentNode)fileNode.getDocumentNode();
            if (documentNode != null)
            {
                ClassDefinition mainClassDefinition = fileScope.getMainClassDefinition();
                if (mainClassDefinition != null)
                {
                    TypeScope mainClassScope = (TypeScope)mainClassDefinition.getContainedScope();
                    documentNode.setScope(mainClassScope);
                }
            }
           
            // Start CSS semantic analysis.
View Full Code Here

            SemanticUtils.checkScopedToDefaultNamespaceProblem(classScope, n, classDefinition, null);
        }
        // Resolve the super class, checking that it exists,
        // that it is a class rather than an interface,
        // that it isn't final, and that it isn't the same as this class.
        ClassDefinition superclassDefinition =
            SemanticUtils.resolveBaseClass(node, class_definition, project, classScope.getProblems());

        // Check that the superclass isn't a forward reference, but only need to do this if both
        // definitions come from the same containing source.  getContainingFilePath() returns the file
        // from the ASFileScope, so no need to worry about included files.
        if (!classDefinition.isGeneratedEmbedClass() && classDefinition.getContainingFilePath().equals(superclassDefinition.getContainingFilePath()))
        {
            // If the absolute offset in the class is less than the
            // offset of the super class, it must be a forward reference in the file
            int classOffset = classDefinition.getAbsoluteStart();
            int superClassOffset = superclassDefinition.getAbsoluteEnd();
            if (classOffset < superClassOffset)
                classScope.addProblem(new ForwardReferenceToBaseClassProblem(node, superclassDefinition.getQualifiedName()));
        }

        // Set the superclass Name.
        this.superclassName = superclassDefinition.getMName(project);
        iinfo.superName = superclassName;
       
        // Resolve the interfaces.
        IInterfaceDefinition[] interfaces = classDefinition.resolveImplementedInterfaces(
            project, classScope.getProblems());
       
        // Set the interface Names.
        int n_interfaces = interfaces.length;
        ArrayList<Name> interface_names = new ArrayList<Name>(n_interfaces);
        for (int i = 0; i < n_interfaces; i++)
        {
            InterfaceDefinition idef = (InterfaceDefinition)interfaces[i];
            if (idef != null)
            {
                Name interfaceName = ((InterfaceDefinition)interfaces[i]).getMName(project);
                interface_names.add(interfaceName);
            }
        }
        iinfo.interfaceNames = interface_names.toArray(new Name[interface_names.size()]);
       
        // Set the flags corresponding to 'final' and 'dynamic'.
        if (classDefinition.isFinal())
            iinfo.flags |= ABCConstants.CLASS_FLAG_final;
        if (!classDefinition.isDynamic())
            iinfo.flags |= ABCConstants.CLASS_FLAG_sealed;
       
        iinfo.protectedNs = ((NamespaceDefinition)classDefinition.getProtectedNamespaceReference()).getAETNamespace();
       
        this.cv = emitter.visitClass(iinfo, cinfo);
        cv.visit();
       
        this.itraits = cv.visitInstanceTraits();
        this.ctraits = cv.visitClassTraits();

        this.classScope.traitsVisitor = this.itraits;
        this.classStaticScope.traitsVisitor = this.ctraits;

        // Build an array of the names of all the ancestor classes.
        ArrayList<Name> ancestorClassNames = new ArrayList<Name>();
       
        // Walk the superclass chain, starting with this class
        // and (unless there are problems) ending with Object.
        // This will accomplish three things:
        // - find loops;
        // - build the array of names of ancestor classes;
        // - set the needsProtected flag if this class or any of its ancestor classes needs it.

        boolean needsProtected = false;

        //  Remember the most recently examined class in case there's a cycle in the superclass
        //  chain, in which case we'll need it to issue a diagnostic.
        ClassDefinition c = null;

        IClassDefinition.IClassIterator classIterator =
            classDefinition.classIterator(project, true);

        while (classIterator.hasNext())
        {
            c = (ClassDefinition)classIterator.next();
            needsProtected |= c.getOwnNeedsProtected();
            if (c != classDefinition)
                ancestorClassNames.add(c.getMName(project));
        }
       
        // Report a loop in the superclass chain, such as A extends B and B extends A.
        // Note: A extends A was found previously by SemanticUtils.resolveBaseClass().
        if (classIterator.foundLoop())
            classScope.addProblem(new CircularTypeReferenceProblem(c, c.getQualifiedName()));
       
        // In the case of class A extends A, ancestorClassNames will be empty at this point.
        // Change it to be Object to prevent "Warning: Stack underflow" in the script init code below.
        if (ancestorClassNames.isEmpty())
        {
            ClassDefinition objectDefinition = (ClassDefinition)project.getBuiltinType(
                IASLanguageConstants.BuiltinType.OBJECT);
            ancestorClassNames.add(objectDefinition.getMName(project));
        }
       
        // If this class or any of its ancestor classes needs the protected flag set, set it.
        if (needsProtected)
            iinfo.flags |= ABCConstants.CLASS_FLAG_protected;
View Full Code Here

       
        LinkedList<Name> ancestorNames = new LinkedList<Name>();
       
        for (IClassDefinition ancestorIClass : baseClass.classIterable(project, true))
        {
            final ClassDefinition ancestorClass = (ClassDefinition) ancestorIClass;
            ancestorNames.addFirst(ancestorClass.getMName(project));
        }
       
        scriptInitInstructions.addInstruction(OP_getscopeobject, 0);
       
        //  Push ancestor classes onto the scope stack in
View Full Code Here

    @Override
    protected IFileScopeRequestResult handleFileScopeRequest() throws InterruptedException
    {
        final ASFileScope fileScope = new ASFileScope(getProject().getWorkspace(), cssFile.getPath());
        // TODO: Generate class names from CSS file name after the CSS module runtime code is finalized.
        final ClassDefinition classDefinition = new ClassDefinition(
                "CSSModule2Main",
                NamespaceDefinition.createPackagePublicNamespaceDefinition(""));
        fileScope.addDefinition(classDefinition);
        return new FileScopeRequestResultBase(
                Collections.<ICompilerProblem> emptySet(),
View Full Code Here

        String namespace = packageName.isEmpty() ? "*" : packageName + ".*";
        XMLName xmlName = new XMLName(namespace, baseName);

        // Create a ClassDefinition for the component class,
        // and add it to this file scope.
        ClassDefinition fxComponentClassDefinition =
                new ClassDefinition(className, getFilePrivateNamespaceReference());
        fxComponentClassDefinition.setBaseClassReference(
                ReferenceFactory.packageQualifiedReference(getWorkspace(), componentBaseClassQName));
        fxComponentClassDefinition.setMetaTags(new IMetaTag[0]);
        addDefinition(fxComponentClassDefinition);

        // Create a class scope for the component class.
        TypeScope classScope = new TypeScope(this, fxComponentClassDefinition);
        classScope.setContainingDefinition(fxComponentClassDefinition);
        fxComponentClassDefinition.setContainedScope(classScope);
        fxComponentClassDefinition.setupThisAndSuper();

        // Keep track of the tag-name-to-class-definition mapping so that we can
        // resolve a tag like <MyComponent>.
        if (fxComponentsMap == null)
            fxComponentsMap = new HashMap<XMLName, ClassDefinition>();
View Full Code Here

       
        XMLName definitionXMLName = new XMLName(definitionTag.getURI(), definitionName);

        // Create a ClassDefinition for the definition class,
        // and add it to this file scope.
        ClassDefinition fxDefinitionClassDefinition =
                new ClassDefinition(className, getFilePrivateNamespaceReference());
        fxDefinitionClassDefinition.setBaseClassReference(
                ReferenceFactory.packageQualifiedReference(getWorkspace(), definitionBaseClassQName));
        fxDefinitionClassDefinition.setMetaTags(new IMetaTag[0]);
        addDefinition(fxDefinitionClassDefinition);

        // Create a class scope for the definition class.
        TypeScope classScope = new TypeScope(this, fxDefinitionClassDefinition);
        classScope.setContainingDefinition(fxDefinitionClassDefinition);
        fxDefinitionClassDefinition.setContainedScope(classScope);
        fxDefinitionClassDefinition.setupThisAndSuper();

        // Keep track of the tag-name-to-class-definition mapping so that we can
        // resolve a tag like <fx:MyDefinition>.
        if (fxDefinitionsMap == null)
            fxDefinitionsMap = new HashMap<XMLName, ClassDefinition>();
View Full Code Here

    }

    @Override
    public String resolveXMLNameToQualifiedName(XMLName tagName, MXMLDialect mxmlDialect)
    {
        ClassDefinition classDef = getClassDefinitionForDefinitionTagName(tagName);
        if (classDef != null)
            return classDef.getQualifiedName();

        return project.resolveXMLNameToQualifiedName(tagName, mxmlDialect);
    }
View Full Code Here

     */
    @Override
    public IDefinition resolveXMLNameToDefinition(XMLName tagXMLName, MXMLDialect mxmlDialect)
    {
        // See if there is a class defined by a <Component> tag.
        ClassDefinition componentTagClassDef = getClassDefinitionForComponentTagName(tagXMLName);
        if (componentTagClassDef != null)
            return componentTagClassDef;

        // See if there is a class defined by a <Definition> tag.
        ClassDefinition definitionTagClassDef = getClassDefinitionForDefinitionTagName(tagXMLName);
        if (definitionTagClassDef != null)
            return definitionTagClassDef;
       
        return project.resolveXMLNameToDefinition(tagXMLName, mxmlDialect);
    }
View Full Code Here

        fileScope.addDefinition(packageDefinition);

        Multiname mname = Multiname.crackDottedQName(getProject(), qname);
        INamespaceDefinition packageNS = Iterables.getOnlyElement(mname.getNamespaceSet());

        ClassDefinition classDefinition = new ClassDefinition(mname.getBaseName(), (INamespaceReference)packageNS);
        IReference baseClass = ReferenceFactory.packageQualifiedReference(getProject().getWorkspace(), fxgBaseClassName);
        classDefinition.setBaseClassReference(baseClass);

        TypeScope classScope = new TypeScope(packageScope, classDefinition);
        classScope.setContainingDefinition(classDefinition);
        classDefinition.setContainedScope(classScope);
        classDefinition.setupThisAndSuper();

        packageScope.addDefinition(classDefinition);

        return fileScope;
    }
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.