Package org.apache.flex.compiler.internal.projects

Examples of org.apache.flex.compiler.internal.projects.FlexProject


            modelNode.initializeFromTag(builder, childTag);
            info.addChildNode(modelNode);
        }
        else
        {
            FlexProject project = builder.getProject();
            IDefinition definition = builder.getFileScope().resolveTagToDefinition(childTag);
            if (definition instanceof ClassDefinition)
            {
                MXMLInstanceNode instanceNode = MXMLInstanceNode.createInstanceNode(
                        builder, definition.getQualifiedName(), this);
View Full Code Here


            {
                final IMXMLTextData mxmlTextData = (IMXMLTextData)unit;
                if (mxmlTextData.getTextType() != TextType.WHITESPACE)
                {
                    final Workspace workspace = builder.getWorkspace();
                    final FlexProject project = builder.getProject();
                    final Collection<ICompilerProblem> problems = builder.getProblems();

                    final IncludeHandler includeHandler = new IncludeHandler(builder.getFileSpecificationGetter());
                    includeHandler.setProjectAndCompilationUnit(project, builder.getCompilationUnit());

                    final ScopedBlockNode node = ASParser.parseFragment2(
                            mxmlTextData.getCompilableText(),
                            sourcePath,
                            mxmlTextData.getCompilableTextStart(),
                            mxmlTextData.getCompilableTextLine() - 1,
                            mxmlTextData.getCompilableTextColumn() - 1,
                            problems,
                            workspace,
                            builder.getFileNode(),
                            containingScope,
                            project.getProjectConfigVariables(),
                            EnumSet.of(PostProcessStep.CALCULATE_OFFSETS, buildOrReconnect),
                            true, //follow includes
                            includeHandler
                            );
                    ((MXMLFileNode)ancestorFileNode).updateIncludeTreeLastModified(includeHandler.getLastModified());
View Full Code Here

            // Resolve the attribute value to a normalized path.
            // Doing so makes this compilation unit dependent on that file.
            String sourcePath = resolveSourceAttributePath(builder, attribute, info);
            if (sourcePath != null)
            {
                FlexProject project = builder.getProject();
                Workspace workspace = builder.getWorkspace();
                Collection<ICompilerProblem> problems = builder.getProblems();
                IFileSpecification sourceFileSpec = workspace.getFileSpecification(sourcePath);
                String scriptText = builder.readExternalFile(attribute, sourcePath);

                if (scriptText != null)
                {
                    final IncludeHandler includeHandler = new IncludeHandler(builder.getFileSpecificationGetter());
                    includeHandler.setProjectAndCompilationUnit(project, builder.getCompilationUnit());
                    includeHandler.enterFile(sourcePath);
                    final MXMLFileScope fileScope = builder.getFileScope();
                    final OffsetLookup offsetLookup = fileScope.getOffsetLookup();
                    assert offsetLookup != null : "Expected OffsetLookup on FileScope.";
                    final int[] absoluteOffset = offsetLookup.getAbsoluteOffset(sourcePath, 0);

                    final ScopedBlockNode fragment = ASParser.parseFragment2(
                            scriptText,
                            sourceFileSpec.getPath(),
                            absoluteOffset[0],
                            0,
                            0,
                            problems,
                            workspace,
                            builder.getFileNode(),
                            classScope,
                            project.getProjectConfigVariables(),
                            EnumSet.of(PostProcessStep.CALCULATE_OFFSETS, PostProcessStep.RECONNECT_DEFINITIONS),
                            true /* follow includes */,
                            includeHandler);

                    builder.getFileNode().updateIncludeTreeLastModified(includeHandler.getLastModified());
View Full Code Here

        // First round up all the the state dependent instance nodes
        List<IMXMLNode> stateDependentNodes = classDefinitionNode.getAllStateDependentNodes();
        if (stateDependentNodes==null)
            return;
   
        FlexProject project = getProject();
        String deferredInstanceFromFunctionClass = project.getDeferredInstanceFromFunctionClass();
        Name deferredInstanceFromFunctionName = project.getDeferredInstanceFromFunctionName();

        if (!(classDefinition.isInstanceOf("mx.core.IStateClient2", project)))
        {
            final IResolvedQualifiersReference stateClient2Reference = ReferenceFactory.packageQualifiedReference(
                    this.getProject().getWorkspace(),
                    "mx.core.IStateClient2");
            final Name stateClient2Name = stateClient2Reference.getMName();

            IReference[] implementedInterfaces = classDefinition.getImplementedInterfaceReferences();
            IReference[] newInterfaces = null;
            Name[] newNames = null;
            if (implementedInterfaces != null)
            {
                int n = implementedInterfaces.length;
                newInterfaces = new IReference[n + 1];
                newNames = new Name[n + 1];
                for (int i = 0; i < n; i++)
                {
                    newInterfaces[i] = implementedInterfaces[i];
                    newNames[i] = iinfo.interfaceNames[i];
                }
                newInterfaces[n] = ReferenceFactory.packageQualifiedReference(project.getWorkspace(), "mx.core.IStateClient2");
                newNames[n] = stateClient2Name;
            }
            else
            {
                newInterfaces = new IReference[1];
                newInterfaces[0] = ReferenceFactory.packageQualifiedReference(project.getWorkspace(), "mx.core.IStateClient2");
                newNames = new Name[1];
                newNames[0] = stateClient2Name;
            }
            classDefinition.setImplementedInterfaceReferences(newInterfaces);
            iinfo.interfaceNames = newNames;
        }
       
        // now, process all the state dependent nodes
       
        int instanceNodeCounter = 0;
        IASNode anInstanceNode = null;
        for   (IMXMLNode node : stateDependentNodes)
        {
             // here we only care about instance nodes
            if (node instanceof IMXMLInstanceNode)
            {
                anInstanceNode = node;
                // Generate a map that tell for each state dependent instance node, what slot
                // it corresponds to in the array of
                // deferredInstanceFromFunction's
                if (nodeToIndexMap==null)     
                    nodeToIndexMap = new HashMap<IMXMLNode, Integer>();
                nodeToIndexMap.put(node, instanceNodeCounter);
                ++instanceNodeCounter; 
               
                InstructionList il;
                if (getProject().getTargetSettings().getMxmlChildrenAsData())
                {
                    if (nodeToInstanceDescriptorMap==null)     
                        nodeToInstanceDescriptorMap = new HashMap<IMXMLNode, InstructionList>();
                    il = new InstructionList();
                    nodeToInstanceDescriptorMap.put(node, il);
                    // build the initializer function by processing the node
                    Context stateContext = new Context((IMXMLInstanceNode)node, il);
                    stateContext.isContentFactory = true;
                    processNode(node, stateContext);
                    stateContext.transfer(IL.MXML_CONTENT_FACTORY);
                    stateContext.addInstruction(OP_newarray, stateContext.getCounter(IL.MXML_CONTENT_FACTORY));     
                }
                else
                {
                    context.addInstruction(OP_findpropstrict, deferredInstanceFromFunctionName)
                    // stack: ..., DeferredInstaceFromFunction class
                   
                    // build the initializer function by processing the node
                    processNode(node, context);
                    // stack: ..., DeferredInstaceFromFunction class, initializerFunc
                   
                    context.addInstruction(OP_constructprop, new Object[] { deferredInstanceFromFunctionName, 1});  
                    // stack: ..., DeferredInstaceFromFunction object
                }
            }
        }
       
        if (getProject().getTargetSettings().getMxmlChildrenAsData())
            return;

        // if we didn't find any state dependent instance nodes, then leave
        if (instanceNodeCounter==0)
            return;
               
        // stack: ..., arg[0], arg[1],.., arg[n-1]
        context.addInstruction(OP_newarray, instanceNodeCounter);
        context.addInstruction(OP_setlocal3);
       
        // now local3= array of deferredInstanceFromFunctionName
       
        // make a dependency on the sdk class DeferredInstanceFromFunction
        IWorkspace workspace = project.getWorkspace();
        IResolvedQualifiersReference ref = ReferenceFactory.packageQualifiedReference(workspace, deferredInstanceFromFunctionClass);
      
        IScopedNode scopedNode = anInstanceNode.getContainingScope();
        IASScope iscope = scopedNode.getScope();
        ASScope scope = (ASScope)iscope;
View Full Code Here

     */
    // TODO Can we put this in the special MXML private namespace?
    // If not, what happens if there is already a variable with the same name?
    private void createDocumentDescriptorVariable(IMXMLClassDefinitionNode node)
    {
        FlexProject project = getProject();
        Name uiComponentDescriptorName = project.getUIComponentDescriptorClassName();
        addVariableTrait(NAME_DOCUMENT_DESCRIPTOR, uiComponentDescriptorName);
    }
View Full Code Here

     */
    private void buildDescriptor(IMXMLClassReferenceNode node, Context context)
    {
        context.startUsing(IL.DESCRIPTOR);
       
        FlexProject project = getProject();
        IClassDefinition instanceClass = node.getClassReference(project);
       
        Name type = ((ClassDefinition)instanceClass).getMName(project);
       
        String id = node instanceof IMXMLInstanceNode ?
                    ((IMXMLInstanceNode)node).getEffectiveID() :
                    null;
       
        // var temp = new UIComponentDescriptor({...});
        // Note: temp is top-of-stack.
        Name uiComponentDescriptorName = project.getUIComponentDescriptorClassName();
        context.addInstruction(OP_findpropstrict, uiComponentDescriptorName);
        pushDescriptorConstructorArgument(type, id, context);
        context.addInstruction(OP_constructprop, new Object[] { uiComponentDescriptorName, 1 });
       
        context.stopUsing(IL.DESCRIPTOR, 0);
View Full Code Here

     * </pre>
     */
    private void setCurrentState(InstructionList insns)
    {
        // Check if the class being generated implements IStateClient.
        FlexProject project = getProject();
        String stateClientInterface = project.getStateClientInterface();
        if (classDefinition.isInstanceOf(stateClientInterface, project))
        {
            // Check if there is an initial state.
            String initialState = classDefinitionNode.getInitialState();
            if (initialState != null)
View Full Code Here

    private void executeBindingsForInstance(IMXMLInstanceNode instanceNode, Context context)
    {       
        if (!instanceNode.getClassDefinitionNode().getHasDataBindings())
            return;
       
        FlexProject project = getProject();
       
        // Get the Name for the mx.binding.BindingManager class.
        Name bindingManagerName = project.getBindingManagerClassName();
       
        // Get the id (possibly a generated one) for the instance.
        String id = instanceNode.getEffectiveID();
        if (id == null)
            return;
View Full Code Here

     */
    void processMXMLResource(IMXMLResourceNode node, Context context)
    {
        ITypeDefinition type = node.getType();
       
        FlexProject project = getProject();

        try
        {
            String bundleName = node.getBundleName();
            String key = node.getKey();
            if(bundleName != null && key != null)
            {
                //compilation unit of the file that has the compiler directive
                final ICompilationUnit refCompUnit = project.getScope(
                ).getCompilationUnitForScope(((NodeBase)node).getASScope());
                assert refCompUnit != null;

                ResourceBundleUtils.resolveDependencies(bundleName, refCompUnit, project, node, getProblems());
            }
        }
        catch(InterruptedException ie)
        {
            throw new CodegenInterruptedException(ie);
        }
       
        //Based on the type of the identifier which its value is set with this compiler
        //directive, we are figuring out which method we need to call on ResourceManager instance.
        String methodName = null;       
        if (type.isInstanceOf((ITypeDefinition)project.getBuiltinType(
                BuiltinType.STRING), project))
        {
            methodName = "getString";
        }
        else if (type.isInstanceOf((ITypeDefinition)project.getBuiltinType(
                BuiltinType.BOOLEAN), project))
        {
            methodName = "getBoolean";
        }
        else if (type.isInstanceOf((ITypeDefinition)project.getBuiltinType(
                BuiltinType.NUMBER), project))
        {
            methodName = "getNumber";
        }
        else if (type.isInstanceOf((ITypeDefinition)project.getBuiltinType(
                BuiltinType.INT), project))
        {
            methodName = "getInt";
        }
        else if (type.isInstanceOf(project.getBuiltinType(
                BuiltinType.UINT).resolveType(project), project))
        {
            methodName = "getUint";
        }
        else if (type.isInstanceOf((ITypeDefinition)project.getBuiltinType(
                BuiltinType.CLASS), project))
        {
            methodName = "getClass";
        }
        else if (type.isInstanceOf((ITypeDefinition)project.getBuiltinType(
                BuiltinType.ARRAY), project))
        {
            methodName = "getStringArray";
        }
        else
        {
            methodName = "getObject";
        }
       
        Name resourceManagerName = project.getResourceManagerClassName();
       
        // Call the method to get the value, such as
        //   ResourceManager.getInstance().getString("bundle", "key")
        // for String type.
        context.addInstruction(ABCConstants.OP_getlex, resourceManagerName);
View Full Code Here

     * with its <code>target</code>, <code>name</code>,
     * and <code>value</code> properties set.
     */
    void processPropertyOverride(IMXMLPropertySpecifierNode propertyNode, Context context)
    {
        FlexProject project = getProject();
        Name propertyOverride = project.getPropertyOverrideClassName();
        processPropertyOrStyleOverride(propertyOverride, propertyNode, context);
    }
View Full Code Here

TOP

Related Classes of org.apache.flex.compiler.internal.projects.FlexProject

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.