Package flex2.compiler

Examples of flex2.compiler.Source


         * @throws IOException
         */
        private Source generateMainSource(CompilationUnit unit,
                String packageName, String className, FXGSymbolClass asset) throws IOException
        {
            Source originalSource = unit.getSource();

            String generatedName = getGeneratedFileName(packageName, className, "-generated.as");

            if (generatedOutputDir != null)
            {
                new File(generatedName).getParentFile().mkdirs();
                FileUtil.writeFile(generatedName, asset.getGeneratedSource());
            }

            // Create a TextFile for our generated source
            TextFile generatedFile = new TextFile(asset.getGeneratedSource(), generatedName,
                    originalSource.getParent(), MimeMappings.AS,
                    originalSource.getLastModified());

            // Create an AssetInfo for our DefineSprite symbol
            AssetInfo assetInfo = new AssetInfo(asset.getSymbol(), generatedFile,
                    originalSource.getLastModified(), null);
            unit.getAssets().add(asset.getQualifiedClassName(), assetInfo);

            // Create a Source and associate our symbol's AssetInfo
            Source generatedSource = new Source(generatedFile, originalSource);
            generatedSource.setAssetInfo(assetInfo);

            return generatedSource;
        }
View Full Code Here


         * @throws IOException
         */
        private Source generateAdditionalSource(CompilationUnit unit,
                FXGSymbolClass asset) throws IOException
        {
            Source originalSource = unit.getSource();

            String packageName = asset.getPackageName();
            String className = asset.getClassName();
            String generatedName = getGeneratedFileName(packageName, className, ".as");

            if (generatedOutputDir != null)
            {
                new File(generatedName).getParentFile().mkdirs();
                FileUtil.writeFile(generatedName, asset.getGeneratedSource());
            }

            // Create a TextFile for our additional generated source
            TextFile generatedFile = new TextFile(asset.getGeneratedSource(),
                    generatedName, originalSource.getParent(), MimeMappings.AS,
                    originalSource.getLastModified());

            // Create an AssetInfo for our DefineSprite symbol
            AssetInfo assetInfo = new AssetInfo(asset.getSymbol(),
                    generatedFile, originalSource.getLastModified(), null);
            unit.getAssets().add(asset.getQualifiedClassName(), assetInfo);

            String relativePath = "";
            if (packageName != null)
            {
                relativePath = packageName.replace( '.', '/' );
            }

            // Create a Source and associate our symbol's AssetInfo
            Source generatedSource = new Source(generatedFile, relativePath,
                    className, null, false, false, false);
            generatedSource.setAssetInfo(assetInfo);
            generatedSource.setPathResolver(unit.getSource().getPathResolver());

            return generatedSource;
        }
View Full Code Here

        if (ThreadLocalToolkit.errorCount() > 0)
        {
          return null;
        }

        Source transSource = transform(source, translations);

        if (ThreadLocalToolkit.errorCount() > 0)
        {
            return null;
        }
View Full Code Here

        {
          ThreadLocalToolkit.logError(ioe.toString());
        }
      }
     
      return new Source(new TextFile(code.toString(), name, source.getParent(),
                       MimeMappings.AS, source.getLastModified()), source);
    }
View Full Code Here

            compilationUnit.mixins.add(className);

            // Determine whether we need to regenerate the style source based
            // on whether any new style definitions were included
            String genFileName = generateStyleSourceName(packageName, className);
            Source styleSource = resources.findSource(genFileName);
            if (styleSource != null)
            {
                if (styleSource.getCompilationUnit() == null)
                {
                    // if no compilationUnit, then we need to generate source so we can recompile.
                    styleSource = null;
                }
                else
View Full Code Here

  }

    private Source generateFontFaceRules(ResourceContainer resources)
    {
      String genFileName = generateFontFaceRuleSourceName();
      Source styleSource = resources.findSource(genFileName);
      if (styleSource != null)
      {
            if (styleSource.getCompilationUnit() == null)
            {
                // if no compilationUnit, then we need to generate source so we can recompile.
                styleSource = null;
            }
            else
View Full Code Here

    //
    //--------------------------------------------------------------------------

    private Source createSource(String fileName, SourceCodeBuffer sourceCodeBuffer, long lastModifiedTime)
    {
        Source result = null;

        if (sourceCodeBuffer.getBuffer() != null)
        {
            String sourceCode = sourceCodeBuffer.toString();

            if (mxmlConfiguration.keepGeneratedActionScript())
            {
                try
                {
                    FileUtil.writeFile(fileName, sourceCode);
                }
                catch (IOException e)
                {
                    ThreadLocalToolkit.log(new VelocityException.UnableToWriteGeneratedFile(fileName, e.getMessage()));
                }
            }

            VirtualFile genFile = new TextFile(sourceCode, fileName, null, MimeMappings.AS, lastModifiedTime);
            String shortName = fileName.substring(0, fileName.lastIndexOf('.'));

            result = new Source(genFile, "", shortName, null, false, false, false);
            result.setPathResolver(compilationUnit.getSource().getPathResolver());

            Iterator<VirtualFile> iterator = implicitIncludes.iterator();

            while ( iterator.hasNext() )
            {
                VirtualFile virtualFile = iterator.next();
                result.addFileInclude(virtualFile);
            }
        }

        return result;
    }
View Full Code Here

            // Create a new Source for the node.
            VirtualFile virtualFile = new TextFile("", unit.getSource().getName() + "$" + className,
                                                   unit.getSource().getName(), unit.getSource().getParent(),
                                                   MimeMappings.MXML, unit.getSource().getLastModified());
            Source source = new Source(virtualFile, unit.getSource(), className, false, false);

            // Set the Source's syntax tree to the DocumentNode
            // equivalent of the grandchild, so that the text
            // representation won't have to be recreated and reparsed.
            DocumentNode inlineDocumentNode =
                DocumentNode.inlineDocumentNode(componentRoot.getNamespace(), componentRoot.getLocalPart(),
                        NameFormatter.toDot(docInfo.getPackageName(), docInfo.getClassName()));

            inlineDocumentNode.beginLine = componentRoot.beginLine;
            inlineDocumentNode.beginColumn = componentRoot.beginColumn;
            inlineDocumentNode.endLine = componentRoot.endLine;
            inlineDocumentNode.endColumn = componentRoot.endColumn;
            inlineDocumentNode.image = componentRoot.image;
           
            // Inline components are line inner classes, so there need to be suppressed in the asdoc.
            if(generateAst)
            {
                inlineDocumentNode.comment = "<description><![CDATA[]]></description><private><![CDATA[]]></private>";   
            }
            else
            {
                inlineDocumentNode.comment = "@private";
            }
           
            componentRoot.copy(inlineDocumentNode);
            inlineDocumentNode.setLocalClassMappings(docInfo.getLocalClassMappings());
            inlineDocumentNode.setLanguageNamespace(docInfo.getLanguageNamespace());
            inlineDocumentNode.setVersion(docInfo.getVersion());

            addExcludeClassNode(inlineDocumentNode, componentRoot);
           
            source.addSourceFragment(AttrInlineComponentSyntaxTree, inlineDocumentNode, null);

            unit.addGeneratedSource(classQName, source);
        }
View Full Code Here

            // Create a new Source for the node.
            VirtualFile virtualFile = new TextFile("", unit.getSource().getName() + "$" + className,
                                                   unit.getSource().getName(), unit.getSource().getParent(),
                                                  MimeMappings.MXML, unit.getSource().getLastModified());
            Source source = new Source(virtualFile, unit.getSource(), className, false, false);

            // Set the Source's syntax tree to the DocumentNode
            // equivalent of the grandchild, so that the text
            // representation won't have to be recreated and reparsed.
            DocumentNode definitionDocumentNode = new DocumentNode(definitionRoot.getNamespace(), definitionRoot.getLocalPart());
            definitionDocumentNode.beginLine = definitionRoot.beginLine;
            definitionDocumentNode.beginColumn = definitionRoot.beginColumn;
            definitionDocumentNode.endLine = definitionRoot.endLine;
            definitionDocumentNode.endColumn = definitionRoot.endColumn;
            definitionDocumentNode.image = definitionRoot.image;
            // anything defined using the Library Definition is only accesible within the class. So it should always have a private comment.
            if(generateAst)
            {
                definitionDocumentNode.comment = "<description><![CDATA[]]></description><private><![CDATA[]]></private>";   
            }
            else
            {
                definitionDocumentNode.comment = "@private";
            }
           
            definitionRoot.copy(definitionDocumentNode);
            definitionDocumentNode.setLocalClassMappings(docInfo.getLocalClassMappings());
            definitionDocumentNode.setLanguageNamespace(docInfo.getLanguageNamespace());
            definitionDocumentNode.setVersion(docInfo.getVersion());

            source.addSourceFragment(AttrInlineComponentSyntaxTree, definitionDocumentNode, null);

            unit.addGeneratedSource(classQName, source);
        }
View Full Code Here

       
        Set<SwcLibrary> librariesProcessed = new HashSet<SwcLibrary>();

        for (CompilationUnit unit : movie.getExportedUnits())
        {
            Source unitSource = unit.getSource();

            SwcDependencySet depset = new SwcDependencySet();
            addDeps( depset, SwcDependencySet.INHERITANCE, unit.inheritance );
            addDeps( depset, SwcDependencySet.SIGNATURE, unit.types );
            addDeps( depset, SwcDependencySet.NAMESPACE, unit.namespaces );
            addDeps( depset, SwcDependencySet.EXPRESSION, unit.expressions );

            addExtraClassesDeps( depset, unit.extraClasses );

            Set<String> scriptDefs = unit.topLevelDefinitions.getStringSet();
            checkDefs(scriptDefs, unitSource.getName());

            String sourceName = NameFormatter.nameFromSource(unitSource);
            SwcScript newScript = lib.addScript(sourceName, scriptDefs, depset,
                                                unitSource.getLastModified(),
                                                unit.getSignatureChecksum());
            newScript.setCompilationUnit(unit);
            addIcons(unit, sourceName);
           
            // find the source and add the metadata
            if (unitSource.isSwcScriptOwner() && !unitSource.isInternal() &&
                !PreLink.isCompilationUnitExternal(unit, externs))
            {
                SwcScript script = (SwcScript)unitSource.getOwner();
                SwcLibrary library = script.getLibrary();
               
                // lots of scripts, but not many swcs, so avoid added the same metadata
                // over and over.
                if (!librariesProcessed.contains(library))
View Full Code Here

TOP

Related Classes of flex2.compiler.Source

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.