Package flex2.compiler.io

Examples of flex2.compiler.io.TextFile


            // TODO ideally, we could just convert this in-place to a ClassNode for downstream processing
            // Good example of why an explicit type descriptor enum is generally more useful than subclassing
            node.setName(classQName);

            // 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
View Full Code Here


          }
          else
          {
            // use Source.getName() to construct the new VirtualFile name
            String n = source.getName().replace('\\', '/') + ":" + script.getXmlLineNumber() + "," + script.getEndXmlLineNumber();
            VirtualFile f = new TextFile(script.getText(), n, source.getParent(), MimeMappings.AS, source.getLastModified());

                        // line number map is for error reporting, so the names must come from error reporting...
                        LineNumberMap m = new LineNumberMap(source.getNameForReporting(), n);

                        m.put(script.getXmlLineNumber(), 1, (script.getEndXmlLineNumber() - script.getXmlLineNumber()));
                        // C: add this so that when unexpected EOF occurs, (last line + 1) maps to the last line
                        //    in the original XML Script block.
                        m.put(script.getEndXmlLineNumber(), script.getEndXmlLineNumber() - script.getXmlLineNumber() + 1, 1);

                        // 'n' must match 'n' in the include directive...
                        source.addSourceFragment(n, f, m);

                        // 'n' must match 'n' in the addSourceFragment call.
                        scriptSet.add(new SourceCode("include \"" + n + "\";", script.getXmlLineNumber(), out, map));
                    }
                }

                //  create SourceCode wrappers for metadata entries
                Set<SourceCode> metadataSet = new LinkedHashSet<SourceCode>();
                for (Iterator iter = info.getMetadata().iterator(); iter.hasNext(); )
                {
                    Script script = (Script)iter.next();
                    metadataSet.add(new SourceCode(script.getText(), script.getXmlLineNumber(), out, map));
                }

                //  create SourceCode wrappers for variable declarations
                Map<String, SourceCode> varDeclMap = new LinkedHashMap<String, SourceCode>();
                for (Iterator iter = info.getVarDecls().values().iterator(); iter.hasNext(); )
                {
                    DocumentInfo.VarDecl varDecl = (DocumentInfo.VarDecl)iter.next();
                    varDeclMap.put(varDecl.name, new SourceCode(varDecl.className, varDecl.line, out, map));
                }

                int superClassLineNumber = 1;

                Set<SourceCode> importNameSet = new LinkedHashSet<SourceCode>();
                for (Iterator i = info.getImportNames().iterator(); i.hasNext();)
                {
                    DocumentInfo.NameInfo importName = (DocumentInfo.NameInfo) i.next();
                    importNameSet.add(new SourceCode(importName.getName(), importName.getLine(), out, map));

                    if (importName.getName().equals(info.getQualifiedSuperClassName()))
                    {
                        superClassLineNumber = importName.getLine();
                    }
                }
                for (Iterator<String> i = bogusImports.iterator(); i.hasNext();)
                {
                    String importName = i.next();
                    importNameSet.add(new SourceCode(importName, 1, out, map));
                }

                Set<SourceCode> interfaceNameSet = new LinkedHashSet<SourceCode>();
                for (Iterator i = info.getInterfaceNames().iterator(); i.hasNext();)
                {
                    DocumentInfo.NameInfo interfaceName = (DocumentInfo.NameInfo) i.next();
                    interfaceNameSet.add(new SourceCode(interfaceName.getName(), interfaceName.getLine(), out, map));
                }

                // register values
                velocityContext.put("imports", importNameSet);
                velocityContext.put("variables", varDeclMap.entrySet());
                velocityContext.put("scripts", scriptSet);
                velocityContext.put("classMetaData", metadataSet);
                velocityContext.put("bindingManagementVariables", FrameworkDefs.bindingManagementVars);

                // C: should really give line number mappings to superclass name and interface names.
                velocityContext.put("superClassName", new SourceCode(info.getQualifiedSuperClassName(), superClassLineNumber, out, map));
                velocityContext.put("interfaceNames", interfaceNameSet);

                velocityContext.put("className", info.getClassName());
                velocityContext.put("packageName", info.getPackageName());

                // run the template!
                //long s2 = System.currentTimeMillis();
                //VelocityManager.parseTime += s2 - start;
                template.merge(velocityContext, out);
                //VelocityManager.mergeTime += System.currentTimeMillis() - s2;

                // Normalize line endings as a temporary work around for bug 149821
                String generated = out.toString().replaceAll("\r\n", "\n");
                String filename = writeGenerated(info, generated);
         TextFile textFile = new TextFile(generated, filename, source.getParent(),
                          MimeMappings.AS, source.getLastModified());
         return new Source(textFile, source);
            }
            catch (ResourceNotFoundException ex)
            {
View Full Code Here

  private Source generateSkeletonAST(DocumentInfo info, Set<String> bogusImports,
                     Source source, SymbolTable symbolTable)
  {
    String fileName = MxmlCompiler.getGeneratedName(mxmlConfiguration, info.getPackageName(),
                            info.getClassName(), "-interface.as");
    TextFile textFile = new TextFile(EMPTY_STRING, fileName, source.getName(), source.getParent(),
                     MimeMappings.MXML, source.getLastModified());

    Source result = new Source(textFile, source);

    InterfaceGenerator interfaceGenerator = new InterfaceGenerator(info, bogusImports,
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

        {
            relativePath = packageName.replace( '.', '/' );
        }

        long modified = asset.assetSource != null ? asset.assetSource.getLastModified() : -1;
        TextFile file = new TextFile(asset.generatedCode, generatedName, null, MimeMappings.AS, modified);
        Source source = new Source(file, relativePath, className, null, false, false, false);
        source.setAssetInfo(unit.getAssets().get(className));
        source.setPathResolver(unit.getSource().getPathResolver());

        if (source != null)
View Full Code Here

            if (configuration.getCompilerConfiguration().keepGeneratedActionScript())
            {
                saveGenerated(name, code, configuration.getCompilerConfiguration().getGeneratedDirectory());
            }

            Source s = new Source(new TextFile(code, name, null, MimeMappings.getMimeType(name)), "", flexInitClass, null, false, false, false);
            // C: It doesn't look like this Source needs any path resolution. null is fine...
            s.setPathResolver(null);
            extraSources.add(s);
            mixins.addFirst( flexInitClass );   // we already iterated, lets put this one at the head in any case
        }
View Full Code Here

                                                              swcContext,
                                                              false);

        String generatedLoaderFile = generateLoaderClass + ".as";

        TextFile genSource = new TextFile(generatedLoaderCode,
                generatedLoaderFile,
                mainUnit.getSource().getParent(),
                MimeMappings.AS);

        Source s = new Source(genSource, mainUnit.getSource(), generateLoaderClass, false, false);
View Full Code Here

        if (config.keepGeneratedActionScript())
        {
            saveGenerated(generatedFileName, code, config.getGeneratedDirectory());
        }

        Source s = new Source(new TextFile(code, generatedFileName, null,
                              MimeMappings.getMimeType(generatedFileName)),
                              "", className, null, false, false, false);
        s.setPathResolver(null);
        sources.add(s);
View Full Code Here

            buf.append("}\n");
            String generatedCode = buf.toString();
            buf = null;

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

            if (generatedOutputDir != null)
            {
View Full Code Here

                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,
View Full Code Here

TOP

Related Classes of flex2.compiler.io.TextFile

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.