Package flex2.compiler.io

Examples of flex2.compiler.io.VirtualFile


    String name = (String) pool[readU32(in)];
    String relativePath = (String) pool[readU32(in)];
    String shortName = (String) pool[readU32(in)];
    int owner = readU8(in);

    VirtualFile pathRoot = null;
    // 1 == SourceList
    // 2 == SourcePath
    // 4 == ResourceBundlePath
    if ((owner == 1 ) || (owner == 2) || (owner == 4))
    {
      // C: Unfortunately, PathResolver itself is not a complete solution. For each type
      //    of VirtualFile, there must be a mechanism to recognize the name format and
      //    construct an appropriate VirtualFile instance.
      pathRoot = resolver.resolve((String) pool[readU32(in)]);
    }

    boolean isInternal = (readU8(in) == 1);
    boolean isRoot = (readU8(in) == 1);
    boolean isDebuggable = (readU8(in) == 1);
    boolean hasUnit = (readU8(in) == 1);
    long fileTime = readLong(in);
       
        final boolean hasSignatureChecksum = (readU8(in) == 1);
        Long signatureChecksum = null;
        if (hasSignatureChecksum)
        {
            assert hasUnit;
            signatureChecksum = new Long(readLong(in));
            // SignatureExtension.debug("READ      CRC32: " + signatureChecksum + "\t--> " + name);
        }

    int size = readU32(in);
        Set<VirtualFile> includes = new HashSet<VirtualFile>(size);
    Map<VirtualFile, Long> includeTimes = new HashMap<VirtualFile, Long>(size);

    for (int i = 0; i < size; i++)
    {
      String fileName = (String) pool[readU32(in)];
      VirtualFile f = resolver.resolve(fileName);
      long ts = readLong(in);

      if (f == null)
      {
        // C: create an instance of DeletedFile...
        f = new DeletedFile(fileName);
      }

      includes.add(f);
      includeTimes.put(f, new Long(ts));
    }

    size = readU32(in);
    LocalLogger logger = size == 0 ? null : new LocalLogger(null);

    for (int i = 0; i < size; i++)
    {
      String path = (String) pool[readU32(in)];
      if (path.length() == 0)
      {
        path = null;
      }
      String warning = (String) pool[readU32(in)];
      if (warning.length() == 0)
      {
        warning = null;
      }
      String source = (String) pool[readU32(in)];
      if (source.length() == 0)
      {
        source = null;
      }
      int line = readU32(in);
      int col = readU32(in);
      int errorCode = readU32(in);

      logger.recordWarning(path,
                           line == -1 ? null : IntegerPool.getNumber(line),
                           col == -1 ? null : IntegerPool.getNumber(col),
                           warning,
                           source,
                           errorCode == -1 ? null : IntegerPool.getNumber(errorCode));
    }


    byte[] abc = (hasUnit) ? (byte[]) pool[readU32(in)] : null;
    Source s = null;

    if (owner == 0) // FileSpec
    {
      Collection<Source> c = fileSpec.sources();
      for (Iterator<Source> i = c.iterator(); i.hasNext();)
      {
        s = i.next();
        if (s.getName().equals(name))
        {
          Source.populateSource(s, fileTime, pathRoot, relativePath, shortName, fileSpec, isInternal, isRoot, isDebuggable,
                                includes, includeTimes, logger);
          break;
        }
      }
    }
    else if (owner == 1) // SourceList
    {
      Collection<Source> c = sourceList.sources().values();
      for (Iterator<Source> i = c.iterator(); i.hasNext();)
      {
        s = i.next();
        if (s.getName().equals(name))
        {
          Source.populateSource(s, fileTime, pathRoot, relativePath, shortName, sourceList, isInternal, isRoot, isDebuggable,
                                includes, includeTimes, logger);
          break;
        }
      }
    }
    else if (owner == 2) // SourcePath
    {
      Map<String, Source> c = sourcePath.sources();
      String className = mappings.get(name);

      if ((className != null) && !c.containsKey(className))
      {
        VirtualFile f = resolver.resolve(name);

        if (f == null)
        {
          f = new DeletedFile(name);
        }

        s = Source.newSource(f, fileTime, pathRoot, relativePath, shortName, sourcePath, isInternal, isRoot, isDebuggable,
                             includes, includeTimes, logger);
        c.put(className, s);
      }
      else
      {
        assert false : name;
      }
    }
    else if (owner == 3) // ResourceContainer
    {
      if (resources == null)
      {
        LocalizationManager l10n = ThreadLocalToolkit.getLocalizationManager();
        throw new IOException(l10n.getLocalizedTextString(new NoResourceContainer()));
      }

      s = Source.newSource(abc, name, fileTime, pathRoot, relativePath, shortName, resources, isInternal, isRoot, isDebuggable,
                           includes, includeTimes, logger);
      s = resources.addResource(s);
    }
    else if (owner == 4) // ResourceBundlePath
    {
      Map<String, Source> c = bundlePath.sources();
      Object[] value = (Object[]) rbMappings.get(name);
      String bundleName = (String) value[0];
      String[] rNames = (String[]) value[1];
      String[] rRoots = (String[]) value[2];

      if (bundleName != null)
      {
        VirtualFile[] rFiles = new VirtualFile[rNames.length];

        for (int i = 0; i < rFiles.length; i++)
        {
          if (rNames[i] != null)
          {
            rFiles[i] = resolver.resolve(rNames[i]);
            if (rFiles[i] == null)
            {
              rFiles[i] = new DeletedFile(rNames[i]);
            }
          }
        }

        VirtualFile[] rRootFiles = new VirtualFile[rRoots.length];

        for (int i = 0; i < rRootFiles.length; i++)
        {
          if (rRoots[i] != null)
          {
            rRootFiles[i] = resolver.resolve(rRoots[i]);
            if (rRootFiles[i] == null)
            {
              rRootFiles[i] = new DeletedFile(rRoots[i]);
            }
          }
        }

        VirtualFile f = new ResourceFile(name, bundlePath.getLocales(), rFiles, rRootFiles);
        s = Source.newSource(f, fileTime, pathRoot, relativePath, shortName, bundlePath, isInternal, isRoot, isDebuggable,
                             includes, includeTimes, logger);
        c.put(bundleName, s);
      }
      else
View Full Code Here


      for (int i = 0; i < size; i++)
      {
        String className = (String) pool[readU32(in)];
        String pathName = (String) pool[readU32(in)];

        VirtualFile f = null;
        if (pathName.length() == 0)
        {
          f = null;
        }
        else
        {
          f = resolver.resolve(pathName);
          if (f == null)
          {
            f = new DeletedFile(pathName);
          }
        }

        assets.put(className, new AssetInfo(null, f, readLong(in), null));
      }

      int swfSize = readU32(in);
      SizeLimitingInputStream in2 = new SizeLimitingInputStream(in, swfSize);

      Movie movie = new Movie();
      MovieDecoder movieDecoder = new MovieDecoder(movie);
      TagDecoder tagDecoder = new TagDecoder(in2);
      tagDecoder.parse(movieDecoder);

      // For some reason, sometimes the process of decoding the movie does not read
      // all that bytes that had been written previously.  So, skip to the end.
      in2.skipToEnd();

      for (Frame frame : movie.frames)
            {
          for (Entry<String, Tag> e : frame.symbolClass.class2tag.entrySet())
                {
          String className = e.getKey();
          DefineTag tag = (DefineTag) e.getValue();
          AssetInfo assetInfo = assets.get(className);
          assetInfo.setDefineTag(tag);

          u.getAssets().add(className, assetInfo);

                    // We special case DefineFont tags so that the FontManager
          // can cache them and avoid re-creating them on subsequent
                    // compiles.
                    if (fontManager != null && tag instanceof DefineFont)
                    {
                        VirtualFile f = assetInfo.getPath();
                        String path = null;
                        if (f != null)
                        {
                            path = f.getURL();
                        }

                        fontManager.loadDefineFont((DefineFont)tag, path);
                    }
        }
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

    {
      Object obj = s == null ? null : s.getSourceFragment(filespec);

      if (obj instanceof VirtualFile)
      {
        VirtualFile f = (VirtualFile) obj;
        if (f.getParent().equals(parentPath))
        {
          FileInclude incl = new FileInclude();
          try
          {
            if (f.isTextBased())
            {
              incl.text = f.toString();
            }
            else
            {
              incl.in = f.getInputStream();
            }
            incl.parentPath = parentPath;
            // If asc ever reports a problem, it will use the name for reporting...
            incl.fixed_filespec = f.getNameForReporting();
            return incl;
          }
          catch (IOException ex)
          {
            return null;
View Full Code Here

                String ns = entry.getKey();
                List<VirtualFile> files = entry.getValue();
                Iterator<VirtualFile> filesIterator = files.iterator();
                while (filesIterator.hasNext())
                {
                    VirtualFile file = filesIterator.next();
                    ManifestParser.parse(ns, file, mappings);
                }
            }
        }
        return mappings;
View Full Code Here

            }

            // collect the names of all the update file includes...
            for (Iterator j = source.getUpdatedFileIncludes(); j != null && j.hasNext();)
            {
                VirtualFile f = (VirtualFile) j.next();
                includeUpdated.add(f.getNameForReporting());
            }

            // register QName --> VirtualFile.getName()
            for (QName qName : u.topLevelDefinitions)
            {
View Full Code Here

            String name = entry.getKey();
            Source s = entry.getValue();

            for (Iterator j = s.getFileIncludes(); j.hasNext();)
            {
                VirtualFile f = (VirtualFile) j.next();
                if (!includeUpdated.contains(f.getNameForReporting()))
                {
                    ThreadLocalToolkit.getLogger().includedFileAffected(f.getNameForReporting());
                }
            }

            CompilationUnit compilationUnit = s.getCompilationUnit();
View Full Code Here

    private static int findResourceBundle(List<Source> sources, SourceList sourceList, SourcePathBase sourcePath, CompilerSwcContext swcContext,
                                          String[] locales, String namespaceURI, String localPart)
        throws CompilerException
    {
        Source s1, s2, s3;
        VirtualFile o1, o2, o3;
        ResourceFile rf1, rf2, rf3;

        s1 = (sourceList != null) ? sourceList.findSource(namespaceURI, localPart) : null;
        o1 = (s1 != null) ? s1.getBackingFile() : null;
View Full Code Here

            LinkedList tempExcludedPaths = new LinkedList();
            Iterator iterator = excludedPaths.iterator();
            while (iterator.hasNext())
            {
                String path = (String)iterator.next();
                VirtualFile file = getVirtualFile(path);
                tempExcludedPaths.add(file);
            }

            excludedPaths = tempExcludedPaths;
        }

    List<VirtualFile> list = new ArrayList<VirtualFile>(fileSetFromPaths(paths, true, mimeTypes, null, excludedPaths));
    for (int i = 0, len = list == null ? 0 : list.size(); i < len; i++)
    {
      VirtualFile f = list.get(i);
      array[(SourceList.calculatePathRoot(f, directories) == null) ? 0 : 1].add(f);
    }
    for (Iterator<VirtualFile> j = stylesheets.iterator(); j.hasNext(); )
    {
      VirtualFile f = j.next();
      array[(SourceList.calculatePathRoot(f, directories) == null) ? 0 : 1].add(f);
    }

        return array;
    }
View Full Code Here

      fileSet = new HashSet<VirtualFile>(paths.size());
    }
    for (Iterator<? extends Object> iter = paths.iterator(); iter.hasNext(); )
    {
      Object next = iter.next();
      VirtualFile file;
      if (next instanceof VirtualFile)
      {
        file = (VirtualFile) next;
      }
      else
      {
        String path = (next instanceof File) ? ((File)next).getAbsolutePath() : (String)next;

        file = getVirtualFile(path);

                if(excludedPaths != null && excludedPaths.contains(file)) {
                    excludedPaths.remove(file);
                    file = null;
                }
      }

      if (file != null)
      {
        if (recurse && file.isDirectory())
        {
          File dir = FileUtil.openFile(file.getName());
          if (dir == null)
          {
            throw new ConfigurationException.IOError(file.getName());
          }
                    fileSetFromPaths(Arrays.asList(dir.listFiles()), true, mimeTypes, fileSet, excludedPaths);
                }
                else if (topLevel || mimeTypes == null || mimeTypes.contains(file.getMimeType()))
                {
                    fileSet.add(file);
                }
            }
        }
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.