Package flex2.compiler.mxml.gen

Examples of flex2.compiler.mxml.gen.CodeFragmentList


        if (file != null && file.exists())
        {
            try
            {
                result = new LocalFile(file.getCanonicalFile());
            }
            catch (IOException e)
            {
                // TODO Auto-generated catch block
                e.printStackTrace();
View Full Code Here


    for (int i = 0, size = directories == null ? 0 : directories.size(); i < size; i++)
    {
      String dir = directories.get(i).getAbsolutePath();
      if (name.startsWith(dir))
      {
        return new LocalFile(FileUtil.openFile(dir));
      }
    }
    // return new LocalFile(FileUtil.openFile(f.getParent()));
    return null;
  }
View Full Code Here

            {
                File file = FileUtil.openFile(directory, relativePath);

                if ((file != null) && file.exists())
                {
                    return new LocalFile(file);
                }
            }
        }

        return null;
View Full Code Here

      {
        Class retType = info.getGetterMethod().getReturnType();

        if (VirtualFile.class.isAssignableFrom(retType))
        {
          VirtualFile file = (VirtualFile) info.getGetterMethod().invoke(targetConfig, (Object[])null);
          if (file != null)
          {
            if (info.doChecksum())
              compile_checksum.append(file.getName());
            link_checksum.append(file.getName());
          }
          continue;
        }
        else if (retType.isArray() && VirtualFile.class.isAssignableFrom(retType.getComponentType()))
        {
          VirtualFile[] files = (VirtualFile[]) info.getGetterMethod().invoke(targetConfig, (Object[])null);
          for (int j = 0; files != null && j < files.length; j++)
          {
            if (files[j] != null)
            {
              if (info.doChecksum())
                compile_checksum.append(files[j].getName());
              link_checksum.append(files[j].getName());
            }
          }
          continue;
        }
      }

      if (args[i] instanceof Object[])
      {
        Object[] a = (Object[]) args[i];
        for (int j = 0; j < a.length; j++)
        {
          if (info.doChecksum())
            compile_checksum.append(a[j]);
          link_checksum.append(a[j]);
        }
      }
      else if (args[i] instanceof List)
      {
        List l = (List) args[i];
        for (int j = 0; j < l.size(); j++)
        {
          if (info.doChecksum())
            compile_checksum.append(l.get(j));
          link_checksum.append(l.get(j));
        }
      }
      else
      {
        if (info.doChecksum())
          compile_checksum.append(args[i]);
        link_checksum.append(args[i]);
      }
    }

    if (info.getGetterMethod() == null)
    {
      // C: need to make sure that all the VirtualFile-based config values should have getters.
      return;
    }

    Class retType = info.getGetterMethod().getReturnType();

    if (VirtualFile.class.isAssignableFrom(retType))
    {
      VirtualFile file = (VirtualFile) info.getGetterMethod().invoke(targetConfig, (Object[])null);
      if (file != null && !file.isDirectory())
      {
        if (info.doChecksum())
          compile_checksum_ts.append(file.getLastModified());
        link_checksum_ts.append(file.getLastModified());
      }
    }
    else if (retType.isArray() && VirtualFile.class.isAssignableFrom(retType.getComponentType()))
    {
      VirtualFile[] files = (VirtualFile[]) info.getGetterMethod().invoke(targetConfig, (Object[])null);
View Full Code Here

    /**
     * Create virtual file for given file and throw configuration exception if not possible
     */
    public static VirtualFile getVirtualFile(String path, boolean reportError) throws ConfigurationException
    {
        VirtualFile result = null;
        File file = new File(path);

        if (file != null && file.exists())
        {
            try
View Full Code Here

    {
            // No need to check to see if the appPath is supported again.
      if ((appPath != null && files[i].getName().equals(appPath.getName())) || isSupported(files[i]))
      {
        String name = files[i].getName();
        VirtualFile pathRoot = calculatePathRoot(files[i]);
        if (pathRoot != null)
        {
                    String relativePath = calculateRelativePath(name);
                    String namespaceURI = relativePath.replace('/', '.');
                    String localPart = calculateLocalPart(name);
View Full Code Here

    if (targetFile == null)
    {
          throw new ConfigurationException.MustSpecifyTarget( null, null, -1);
    }

        VirtualFile virt = getVirtualFile(targetFile);
        if (virt == null && checkTargetFileInFileSystem())
        {
            throw new ConfigurationException.IOError(targetFile);
        }
  }
View Full Code Here

  }

  private CodeFragmentList getDefinitionBody()
  {
    int line = getLineRef();
    CodeFragmentList list = new CodeFragmentList();

    //  TODO public only for UIObjectDescriptor, which takes names rather than function refs
    list.add("/**", line);
    list.add(" * @private", line);
    list.add(" **/", line);
    list.add("public function ", handler.getDocumentFunctionName(), "(event:", NameFormatter.toDot(handler.getType().getName()), "):void", line);
    list.add("{", line);
    list.add("\t", handler.getEventHandlerText(), line);
    list.add("}", line);

    return list;
  }
View Full Code Here

        boolean isDeclared = self.isDeclared();
        String id = isDeclared ? self.getId() : varName;

        int line = getLineRef();

        CodeFragmentList list = new CodeFragmentList();

        //  function header
        list.add("private function ", getDefinitionName(), "() : ", selfTypeName, line);
        list.add("{", line);

        //  value creation
        StringBuilder stringBuilder = new StringBuilder("\tvar " + varName + " : " + selfTypeName + " = ");

        if (modelHasInlineRValue())
        {
            stringBuilder.append(getInlineRValue());
        }
        else if (value instanceof Vector)
        {
            Vector vector = (Vector) value;

            stringBuilder.append("new " + selfTypeName + "(" + vector.size());
           
            if (vector.isFixed())
            {
                stringBuilder.append(", true)");
            }
            else
            {
                stringBuilder.append(")");
            }
        }
        else
        {
            // TODO confirm the availability of a 0-arg ctor!! but do it upstream from here, like when Model is built
            stringBuilder.append("new " + selfTypeName + "()");
        }

        stringBuilder.append(";");
        list.add(stringBuilder.toString(), line);

        if (!modelHasInlineRValue())
        {
            if (value instanceof Vector)
            {
                Vector vector = (Vector) value;
                addAssignExprs(list, vector.getElementInitializerIterator(), varName);
            }
            else
            {
                // set properties
                addAssignExprs(list, self.getPropertyInitializerIterator(self.getType().hasDynamic()), varName);
            }
        }
       
        //  set styles
        addAssignExprs(list, self.getStyleInitializerIterator(), varName);

        //  set effects
        addAssignExprs(list, self.getEffectInitializerIterator(), varName);

        //  add event handlers
        addAssignExprs(list, self.getEventInitializerIterator(), varName);

        //  register effect names
        String effectEventNames = self.getEffectNames();
        if (effectEventNames.length() > 0)
        {
            list.add("\t", varName, ".registerEffects([ ", effectEventNames, " ]);", line);
        }

        //  post-init actions for values that are being assigned to properties (via id attribution)
        if (isDeclared && standardDefs.isIUIComponentWithIdProperty(selfType))
        {
            //  set id on IUIComponents that carry an id prop
            list.add("\t", varName, ".id = \"", id, "\";", line);
        }

        // Design layer related items
        if (self.layerParent != null)
        {
            if (self instanceof DesignLayer)
            {
                list.add("\t", self.layerParent.getId(), ".addLayer(", varName, ");", line);
            }
            else if (self.getType().isAssignableTo(standardDefs.INTERFACE_IVISUALELEMENT))
            {
                list.add("\t", varName, ".designLayer = ", self.layerParent.getId(), ";", line);
            }   
        }
       
        //  UIComponent-specific init steps
        if (standardDefs.isIUIComponent(selfType))
        {
            assert self instanceof MovieClip : "isIUIComponent(selfType) but !(self instanceof MovieClip)";
            MovieClip movieClip = (MovieClip) self;

            //  MXML implementations of IUIComponent initialize set their document property to themselves at
            //  construction time. Others need it set to the enclosing document (us).

            list.add("\tif (!", varName, ".document) ", varName, ".document = this;", line);

            //  add visual children
            if (!standardDefs.isRepeater(selfType))
            {
                if (standardDefs.isContainer(selfType))
                {
                    if (movieClip.hasChildren())
                    {
                        list.add("\t", varName, ".mx_internal::_documentDescriptor = ", line);
                        DescriptorGenerator.addDescriptorInitializerFragments(list, movieClip,
                                                                              Collections.<String>emptySet(),
                                                                              false, "\t\t");
                        list.add("\t;", line);
                        list.add("\t", varName, ".mx_internal::_documentDescriptor.document = this;", line);
                    }
                }
                else
                {
                    //  non-repeater - replicate DI child-creation sequence procedurally:
                    Iterator childIter = movieClip.getChildInitializerIterator();

                    while (childIter.hasNext())
                    {
                        VisualChildInitializer init = (VisualChildInitializer)childIter.next();

                        // Filter out state specific children.
                        if ( !((Model)init.getValue()).isStateSpecific())
                        {
                            list.add("\t", init.getAssignExpr(varName), ";", init.getLineRef());
                        }
                    }
                }
            }
            else
            {
                //  repeater-specific init sequence: don't add children directly, instead use existing DI setup
                //  initializing repeater's childDescriptors property, for now

                list.add("\tvar cd:Array = ", varName, ".childDescriptors = [", line);

                for (Iterator childIter = movieClip.children().iterator(); childIter.hasNext(); )
                {
                    VisualChildInitializer init = (VisualChildInitializer)childIter.next();
                    DescriptorGenerator.addDescriptorInitializerFragments(list, (MovieClip)init.getValue(), "\t\t");

                    if (childIter.hasNext())
                    {
                        list.add(",", 0);
                    }
                }

                list.add("\t];", line);
                list.add("\tfor (var i:int = 0; i < cd.length; i++) cd[i].document = this;", line);
            }
        }

        // TODO: Remove [IMXMLObject] metadata support once we have a
        // non-framework dependent swc to link in mx.core.IMXMLObject

        //  call IMXMLObject.initialized() on implementors
        if (self.getType().isAssignableTo(standardDefs.INTERFACE_IMXMLOBJECT)
                || self.getType().hasMetadata(StandardDefs.MD_IMXMLOBJECT, true))
        {
            String idParam = (isDeclared ? TextGen.quoteWord(id) : "null");
            list.add("\t", varName, ".initialized(this, ", idParam, ")", line);
        }

        // generate idAssigned dispatching logic for user declared instances.
        if (isDeclared)
        {
            if (self.getRepeaterLevel() == 0)
            {
                list.add("\t", id, " = ", varName, ";", line);
            }
            else
            {
                ThreadLocalToolkit.log(new DeclaredAndProceduralWithinRepeater(), self.getDocument().getSourcePath(), line);
            }

            //  evaluate all property bindings for this object - i.e. initialize properties of the object whose values
            //  are binding expressions. E.g. if we've just created <mx:Foo id="bar" x="100" y="{baz.z}"/>, then
            //  we need to evaluate (baz.z) and assign it to bar.y. This explicit evaluation pass is necessary because
            //  baz may already have been initialized, although the fact that we do it even when that's not the case is
            //  suboptimal.
            list.add("\t", NameFormatter.toDot(standardDefs.CLASS_BINDINGMANAGER),
                     ".executeBindings(this, ", TextGen.quoteWord(id), ", " + id + ");", line);
        }

        // If this is a stateful Halo Container, with itemCreationPolicy "immediate" we need to ensure
        // that the instance and all descendants are instantiated.
        if (standardDefs.isContainer(selfType) && self.isEarlyInit())
        {
            list.add("\t", varName,".initialize();", line);
        }
       
        //  return created value
        list.add("\treturn ", varName, ";", line);
        list.add("}", line);
       
        Type lvalueType = getLValueType();
        if (standardDefs.isITransientDeferredInstance(lvalueType) || self.getIsTransient())
          list = getDestructorBody(list, line);
View Full Code Here

    /**
     *
     */
    public CodeFragmentList getDescriptorDeclaration(String name)
    {
        CodeFragmentList fragList = new CodeFragmentList();

        DescriptorGenerator.addDescriptorInitializerFragments(fragList, getRoot(),
                                                              FrameworkDefs.requiredTopLevelDescriptorProperties, true, "");

        fragList.add(0, "private var " + name + " : " + NameFormatter.toDot(standardDefs.CLASS_UICOMPONENTDESCRIPTOR) + " = ", 0);

        return fragList;
    }
View Full Code Here

TOP

Related Classes of flex2.compiler.mxml.gen.CodeFragmentList

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.