/** Use previously compiled {@link CompilationUnit}s to pre-populate the unit cache. */ public static void addArchive( CompilerContext compilerContext, CompilationUnitArchive compilationUnitArchive) { UnitCache unitCache = compilerContext.getUnitCache(); for (CachedCompilationUnit archivedUnit : compilationUnitArchive.getUnits().values()) { if (archivedUnit.getTypesSerializedVersion() != GwtAstBuilder.getSerializationVersion()) { continue; } CompilationUnit cachedCompilationUnit = unitCache.find(archivedUnit.getResourcePath()); // A previously cached unit might be from the persistent cache or another // archive. if (cachedCompilationUnit == null || cachedCompilationUnit.getLastModified() < archivedUnit.getLastModified()) { unitCache.addArchivedUnit(archivedUnit); } } }
/** * Shallow copy of a CachedCompiliationUnit, replacing some parameters in the new copy. * * @param unit Unit to clone. * @param lastModified last modified date to replace in the clone * @param resourceLocation location to replace in the clone. */ public CachedCompilationUnit( CachedCompilationUnit unit, long lastModified, String resourceLocation) { assert unit != null; this.compiledClasses = unit.getCompiledClasses(); this.contentId = unit.getContentId(); this.dependencies = unit.getDependencies(); this.resourcePath = unit.getResourcePath(); this.jsniMethods = unit.getJsniMethods(); this.methodArgNamesLookup = unit.getMethodArgs(); this.typeName = unit.getTypeName(); this.isError = unit.isError(); this.isGenerated = unit.isGenerated(); this.isSuperSource = unit.isSuperSource(); this.problems = unit.problems; this.astToken = unit.astToken; this.astVersion = unit.astVersion; this.sourceToken = unit.sourceToken; // Override these fields this.lastModified = lastModified; this.resourceLocation = resourceLocation; }