Package flex2.compiler.io

Examples of flex2.compiler.io.VirtualFile


    public TranscodingResults doTranscode( PathResolver context, SymbolTable symbolTable,
                                           Map args, String className, boolean generateSource )
        throws TranscoderException
    {
        VirtualFile source = resolveSource( context, args );
        TranscodingResults results = new TranscodingResults(source);

        if (generateSource)
        {
            generateSource( results, className, args );
        }
        else
        {
            throw new EmbedRequiresCodegen( source.getName(), className );
        }

        return results;
    }
View Full Code Here


    for (Iterator i = files.keySet().iterator(); ext != null && i.hasNext();)
    {
      String name = (String) i.next();
      if (name.startsWith("locale/") && name.endsWith(ext))
      {
        VirtualFile file = (VirtualFile) files.get(name);
        int prefixLength = "locale/".length(), index = name.indexOf('/', prefixLength);
        if (index != -1)
        {
          String locale = name.substring(prefixLength, index);
          QName rbName = new QName(NameFormatter.toColon(name.substring(index + 1, name.length() - ext.length()).replace('/', '.')));
View Full Code Here

      }
    }
    else
    {
      // generate AS3 code
      VirtualFile genFile = generateImplementation(document);
      // obtain the line number map...
      DualModeLineNumberMap lineMap = document.getLineNumberMap();

      if (genFile != null && ThreadLocalToolkit.errorCount() == 0)
      {
View Full Code Here

                       BytecodeEmitter bytecodeEmitter)
  {
    String genFileName = MxmlCompiler.getGeneratedName(mxmlConfiguration, mxmlDocument.getPackageName(),
                                                           mxmlDocument.getClassName(), "-generated.as");
    Source source = mxmlDocument.getCompilationUnit().getSource();
    VirtualFile emptyFile = new TextFile(EMPTY_STRING, genFileName, source.getParent(), MimeMappings.AS,
                       System.currentTimeMillis());
    Source result = new Source(emptyFile, source);

    ImplementationGenerator implementationGenerator =
      new ImplementationGenerator(mxmlDocument, generateDocComments, contextStatics,
View Full Code Here

    {
        String p = path;
        if (path.startsWith( "file:"))
            p = p.substring( "file:".length() );    // hate hate hate hate

        VirtualFile f = context.resolve( p );
        if (f == null)
        {
            throw new UnableToResolve( path );
        }
        if (f instanceof NetworkFile)
View Full Code Here

        return f;
    }

    public VirtualFile resolveSource( PathResolver context, Map args ) throws TranscoderException
    {
        VirtualFile result = null;
        String resolvedSource = (String) args.get( Transcoder.RESOLVED_SOURCE );

        if (resolvedSource != null)
        {
            result = ThreadLocalToolkit.getResolvedPath(resolvedSource);
View Full Code Here

        swfOut.close();

        String libPath = libname + ".swf";

        SwcLibrary lib = new SwcLibrary( this, libPath );
        VirtualFile swfFile = new InMemoryFile(swf, libPath,
                                               MimeMappings.getMimeType(libPath), new Date().getTime());
        archive.putFile( swfFile );
        libraries.put( libPath, lib );

        // check if we should compute the digest.
View Full Code Here

        if (unit.icon != null)
        {
            // We used to resolve the icon here, but that was moved
            // upstream to SyntaxTreeEvaluator.processIconFileMetaData(),
            // so we don't have to hang on to the PathResolver until now.
            VirtualFile iconFile = unit.iconFile;
            Source source = unit.getSource();

            // If the source came from a SWC, try looking for the icon in the SWC.
            if ((iconFile == null) && source.isSwcScriptOwner())
            {
                for (int i = 0, s = unit.topLevelDefinitions.size();i < s; i++)
                {
                    String def = unit.topLevelDefinitions.get(i).toString();
                    if (components.containsKey(def))
                    {
                        String swcIcon = components.get(def).getIcon();
                        if (swcIcon != null)
                        {
                            iconFile = (((SwcScript) source.getOwner()).getLibrary().getSwc().getFile(swcIcon));
                            if (iconFile != null)
                            {
                                // we then put the resolved file into an InMemoryFile so that we can changed its name
                                VirtualFile inMemFile = new InMemoryFile(iconFile.getInputStream(), swcIcon,
                                                                         MimeMappings.getMimeType(swcIcon),
                                                                         iconFile.getLastModified());
                                archive.putFile( inMemFile );
                                return;
                            }
                        }
                    }
                }

                // It seems like this will never be true, because if
                // the icon was missing when the original SWC was
                // created, a MissingIconFile would have been thrown.
                if (iconFile == null)
                {
                    return;
                }
            }

            if (iconFile == null)
            {
                throw new SwcException.MissingIconFile(unit.icon, sourceName);
            }

            // yes using both toDot and toColon here feels very wacky
            String workingSourceName = NameFormatter.toColon(NameFormatter.toDot(sourceName, '/'));
            SwcComponent comp = components.get(workingSourceName);
            String rel = source.getRelativePath();
            String iconName = (rel == null || rel.length() == 0) ? unit.icon : rel + "/" + unit.icon;
            if (comp != null)
            {
                comp.setIcon(iconName);
            }

            // we then put the resolved file into an InMemoryFile so that we can changed its name
            VirtualFile inMemFile = new InMemoryFile(iconFile.getInputStream(), iconName,
                                                     MimeMappings.getMimeType(iconName),
                                                     iconFile.getLastModified());
            archive.putFile( inMemFile );
        }
    }
View Full Code Here

    }

    // changed from private to protected to support Flash Authoring - jkamerer 2007.07.30
    protected void read() throws Exception
    {
        VirtualFile catalogFile = null;
      InputStream stream = null;

      try
      {
        catalogFile = archive.getFile( CATALOG_XML );

        if (catalogFile == null)
        {
          throw new SwcException.CatalogNotFound();
        }
        stream = catalogFile.getInputStream();
        CatalogReader reader = new CatalogReader(new BufferedInputStream(stream), this, archive);
        reader.read();

        versions = reader.getVersions();
        swcFeatures = reader.getFeatures();
        components = reader.getComponents();
        libraries = reader.getLibraries();

      /**
       * version checking:
       * - a failure results in a warning, not an error
       * - we do an across-the-board check for SWC major lib version <= compiler major lib version
       * - all other checks are ad-hoc and will accumulate as we rev lib version
       * - see VersionInfo for more version info
       */
        // double swcLibVersion = versions.getLibVersion();
        // double compilerLibVersion = VersionInfo.getLibVersion();

      //  System.out.println("read(): swcLibVersion=" + swcLibVersion + ", compilerLibVersion=" + compilerLibVersion);

      //  Warn if the SWC was built with a newer compiler
      // if (Math.floor(swcLibVersion) > Math.floor(compilerLibVersion))
        if (versions.getLibVersion() != null && VersionInfo.IsNewerLibVersion(versions.getLibVersion(), true))
        {
          OldVersion oldVersion = new OldVersion(archive.getLocation(), versions.getLibVersion(),
            VersionInfo.getLibVersion());
          ThreadLocalToolkit.log(oldVersion);
        }

      /**
       * Other major-version-specific range tests would go here
       */
    }
      finally
      {
        if (stream != null)
        {
          try
                {
            stream.close();
          }
          catch (IOException ioe)
                {
            // ignore
          }
        }

            if (catalogFile != null)
            {
                // Null out any cached bytes, because we won't need them again.
                catalogFile.close();
      }
    }
    }
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()));
View Full Code Here

TOP

Related Classes of flex2.compiler.io.VirtualFile

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.