Package flex2.compiler

Examples of flex2.compiler.Source


                    QName qName = (QName) entry.getKey();
            Long dataSignatureChecksum = (Long)entry.getValue();
            Long swcSignatureChecksum = swcContext.getChecksum(qName);
                    if (swcSignatureChecksum == null && qName != null)
                    {
                        Source source = swcContext.getSource(qName.getNamespace(), qName.getLocalPart());
                        if (source != null)
                        {
                            swcSignatureChecksum = new Long(source.getLastModified());
                        }
                    }
            if (Trace.swcChecksum)
            {
              if (dataSignatureChecksum == null)
View Full Code Here


     *
     */
    private Source createSource(String fileName, String shortName, long lastModified,
                  PathResolver resolver, SourceCodeBuffer sourceCodeBuffer)
    {
        Source result = null;

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

            if (generatedOutputDirectory != null)
            {
                try
                {
                    FileUtil.writeFile(generatedOutputDirectory + File.separatorChar + fileName, sourceCode);
                }
                catch (IOException e)
                {
                    ThreadLocalToolkit.log(new VelocityException.UnableToWriteGeneratedFile(fileName, e.getMessage()));
                }
            }

      VirtualFile generatedFile = new TextFile(sourceCode, fileName, null, MimeMappings.AS, lastModified);

            result = new Source(generatedFile,
                                "",
                                shortName,
                                null,
                                false,
                                false,
                                false);
            result.setPathResolver(resolver);
        }

        return result;
    }
View Full Code Here

        String className = dataBindingInfo.getWatcherSetupUtilClassName();
        String shortName = className.substring(className.lastIndexOf(DOT) + 1);
        String fileName = className.replace('.', File.separatorChar) + DOT_AS;
        VirtualFile emptyFile = new TextFile(EMPTY_STRING, fileName, null, MimeMappings.AS,
                                             compilationUnit.getSource().getLastModified());
        Source result = new Source(emptyFile, EMPTY_STRING, shortName, null, false, false, false);

        Context cx = AbstractSyntaxTreeUtil.generateContext(symbolTable.perCompileData, result,
                                                            symbolTable.emitter, defines);
        NodeFactory nodeFactory = cx.getNodeFactory();

        HashSet<String> configNamespaces = new HashSet<String>();
        StatementListNode configVars = AbstractSyntaxTreeUtil.parseConfigVars(cx, configNamespaces);
        ProgramNode program = AbstractSyntaxTreeUtil.generateProgram(cx, configVars, EMPTY_STRING);
        StatementListNode programStatementList = program.statements;

        String[] watcherImports = compilationUnit.getStandardDefs().getImports();
        for (int i = 0; i < watcherImports.length; i++)
        {
            ImportDirectiveNode importDirective = AbstractSyntaxTreeUtil.generateImport(cx, watcherImports[i]);
            programStatementList = nodeFactory.statementList(programStatementList, importDirective);
        }

        MetaDataNode metaDataNode = AbstractSyntaxTreeUtil.generateMetaData(nodeFactory, EXCLUDE_CLASS);
        programStatementList = nodeFactory.statementList(programStatementList, metaDataNode);

        ClassDefinitionNode classDefinition = generateClassDefinition(cx, configNamespaces, shortName,
                                                                      dataBindingInfo, compilationUnit.getStandardDefs());
        programStatementList = nodeFactory.statementList(programStatementList, classDefinition);
        program.statements = programStatementList;

        PackageDefinitionNode packageDefinition = nodeFactory.finishPackage(cx, null);
        nodeFactory.statementList(programStatementList, packageDefinition);

    CompilerContext context = new CompilerContext();
    context.setAscContext(cx);
    result.newCompilationUnit(program, context).setSyntaxTree(program);

        // Useful when comparing abstract syntax trees
        //flash.swf.tools.SyntaxTreeDumper.dump(program, "/tmp/" + className + "New.xml");

        As3Compiler.cleanNodeFactory(nodeFactory);
View Full Code Here

            // Now we can generate the concrete implementation for the FXG DOM
            // saved in the CompilationUnit's context from the parse1() phase
            // of SkeletonCompiler.
            try
            {
                Source generatedSource = generateSource(unit, symbolTable);
                if (generatedSource != null)
                    generatedSource.addFileIncludes(source);

                // Then we delegate to ASC to process our generated source.
                CompilationUnit implementationUnit = delegateSubCompiler.parse1(generatedSource, symbolTable);
                if (implementationUnit != null)
                {
View Full Code Here

         * CompilationUnit. Additional symbols will be generated for child
         * sprites corresponding to &lt;TextGraphic&gt; nodes.
         */
        private Source generateSource(CompilationUnit unit, SymbolTable symbolTable) throws IOException
        {
            Source originalSource = unit.getSource();

            // package/class is derived from source name and location
            String className = originalSource.getShortName();
            String packageName = originalSource.getRelativePath().replace('/','.');

            // TypeTable will be used to determine if an text related FXG
            // attribute apply to a property or style of the associated
            // ActionScript API.
            TypeTable typeTable = new TypeTable(symbolTable, nameMappings, unit.getStandardDefs(),
                                                themeNames);

            // Transcode the FXG DOM to SWF graphics primitives
            FXGSymbolClass asset = transcodeFXG(unit, packageName, className, typeTable);

            // Generate the main source and associate the top level DefineSprite
            Source generatedSource = generateMainSource(unit, packageName, className, asset);

            // Handle any additional generated child sprite classes
            List<FXGSymbolClass> additionalAssets = asset.getAdditionalSymbolClasses();
            if (additionalAssets != null && additionalAssets.size() > 0)
            {
                Map<QName, Source> additionalSources = new HashMap<QName, Source>(additionalAssets.size());
                for (FXGSymbolClass additionalAsset : additionalAssets)
                {
                    if (additionalAsset.getSymbol() != null)
                    {
                        Source additionalSource = generateAdditionalSource(unit, additionalAsset);
                        if (additionalSource != null)
                        {
                            QName additionalQName = new QName(additionalAsset.getPackageName(), additionalAsset.getClassName());
                            additionalSources.put(additionalQName, additionalSource);
                        }
View Full Code Here

         * @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

      acc.setHeight(Integer.toString(config.getDefaultHeight()));
        acc.setWidth(Integer.toString(config.getDefaultWidth()));
        acc.setSwfVersion(config.getSwfVersion());
        acc.setScriptRecursionLimit(config.getScriptRecursionLimit());
        acc.setScriptTimeLimit(config.getScriptTimeLimit());
        CompilerConfiguration cc = acc.getCompilerConfiguration();
        cc.setAccessible(config.getCompilerAccessible());
        List<String> externalLibraries = config.getCompilerExternalLibraryPath();
        String[] extlibs = new String[externalLibraries.size()];
        externalLibraries.toArray(extlibs);
        try
        {
            cc.cfgExternalLibraryPath(null, extlibs);
        }
        catch (ConfigurationException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
View Full Code Here

  }

  private static ApplicationCompilerConfiguration processMXMLCConfiguration(org.apache.flex.compiler.config.Configuration config)
  {
      ApplicationCompilerConfiguration acc = new ApplicationCompilerConfiguration();
        ConfigurationPathResolver resolver = new ConfigurationPathResolver();
      acc.setConfigPathResolver(resolver);
      acc.setBackgroundColor(config.getDefaultBackgroundColor());
      acc.setDebug(config.debug());
      acc.setFrameRate(config.getDefaultFrameRate());
      acc.setHeight(Integer.toString(config.getDefaultHeight()));
View Full Code Here

        if ( args == null )
        {
            throw new ConfigurationException.CannotOpen( null, cfgval.getVar(), cfgval.getSource(), cfgval.getLine() );
        }

        PathResolver resolver = new PathResolver();

        if ( resolver == null || configResolver == null )
        {
            throw new ConfigurationException.CannotOpen( null, cfgval.getVar(), cfgval.getSource(), cfgval.getLine() );
        }
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.