diff --git a/jps/jps-builders/src/org/jetbrains/jps/incremental/CompileContext.java b/jps/jps-builders/src/org/jetbrains/jps/incremental/CompileContext.java index c4e7022a076a..6b8840f2cffd 100644 --- a/jps/jps-builders/src/org/jetbrains/jps/incremental/CompileContext.java +++ b/jps/jps-builders/src/org/jetbrains/jps/incremental/CompileContext.java @@ -6,7 +6,6 @@ import com.intellij.util.containers.SLRUCache; import org.jetbrains.annotations.NotNull; import org.jetbrains.ether.dependencyView.ClassRepr; import org.jetbrains.ether.dependencyView.Mappings; -import org.jetbrains.ether.dependencyView.StringCache; import org.jetbrains.jps.*; import org.jetbrains.jps.incremental.messages.BuildMessage; import org.jetbrains.jps.incremental.storage.BuildDataManager; @@ -162,12 +161,12 @@ public class CompileContext extends UserDataHolderBase implements MessageHandler if (isMake() && !sources.isEmpty()) { final Mappings mappings = getMappings(); for (File file : sources) { - final Set classes = mappings.getClasses(StringCache.get(FileUtil.toSystemIndependentName(file.getPath()))); + final Set classes = mappings.getClasses(FileUtil.toSystemIndependentName(file.getPath())); if (classes != null) { for (ClassRepr aClass : classes) { - final StringCache.S fileName = aClass.fileName; + final String fileName = aClass.getFileName(); if (fileName != null) { - FileUtil.delete(new File(fileName.value)); + FileUtil.delete(new File(fileName)); } } } diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/Callbacks.java b/jps/model/src/org/jetbrains/ether/dependencyView/Callbacks.java index 1116d95b5329..664d437b08c6 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/Callbacks.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/Callbacks.java @@ -1,10 +1,7 @@ package org.jetbrains.ether.dependencyView; -import com.intellij.openapi.util.Pair; import org.objectweb.asm.ClassReader; - import java.util.Collection; -import java.util.Set; /** * Created by IntelliJ IDEA. @@ -27,9 +24,8 @@ public class Callbacks { } public interface Backend { - Collection getClassFiles(); - + Collection getClassFiles(); void associate(String classFileName, SourceFileNameLookup sourceLookup, ClassReader cr); - void associateForm(StringCache.S formName, StringCache.S className); + void associateForm(String formName, String className); } } diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/ClassRepr.java b/jps/model/src/org/jetbrains/ether/dependencyView/ClassRepr.java index bbdf47cecc1a..442809079224 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/ClassRepr.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/ClassRepr.java @@ -33,6 +33,10 @@ public class ClassRepr extends Proto { public final StringCache.S outerClassName; public final boolean isLocal; + public String getFileName () { + return fileName.value; + } + public abstract class Diff extends Difference { public abstract Specifier interfaces(); diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java index b45396d51a32..340849fdc97a 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/Mappings.java @@ -99,19 +99,19 @@ public class Mappings implements RW.Writable { } public Mappings(final BufferedReader r) { // Temporary - this.rootFile = null; - stringCacheFile = null; - stringCache = null; + this.rootFile = null; + stringCacheFile = null; + stringCache = null; - classToSubclasses = FoxyMap.read(r, StringCache.reader, StringCache.reader, stringSetConstructor); - sourceFileToClasses = FoxyMap.read(r, StringCache.reader, ClassRepr.reader, classSetConstructor); - sourceFileToUsages = RW.readMap(r, StringCache.reader, UsageRepr.clusterReader, new HashMap()); - sourceFileToAnnotationUsages = FoxyMap.read(r, StringCache.reader, UsageRepr.reader, usageSetConstructor); - classToSourceFile = RW.readMap(r, StringCache.reader, StringCache.reader, new HashMap()); - classToClassDependency = FoxyMap.read(r, StringCache.reader, StringCache.reader, stringSetConstructor); - formToClass = new HashMap(); - classToForm = new HashMap(); - } + classToSubclasses = FoxyMap.read(r, StringCache.reader, StringCache.reader, stringSetConstructor); + sourceFileToClasses = FoxyMap.read(r, StringCache.reader, ClassRepr.reader, classSetConstructor); + sourceFileToUsages = RW.readMap(r, StringCache.reader, UsageRepr.clusterReader, new HashMap()); + sourceFileToAnnotationUsages = FoxyMap.read(r, StringCache.reader, UsageRepr.reader, usageSetConstructor); + classToSourceFile = RW.readMap(r, StringCache.reader, StringCache.reader, new HashMap()); + classToClassDependency = FoxyMap.read(r, StringCache.reader, StringCache.reader, stringSetConstructor); + formToClass = new HashMap(); + classToForm = new HashMap(); + } public Mappings(final File rootFile, final BufferedReader r) throws IOException { this.rootFile = rootFile; @@ -131,10 +131,11 @@ public class Mappings implements RW.Writable { classToForm = new HashMap(); } - private void compensateRemovedContent(final Collection compiled) { - for (StringCache.S name : compiled) { - if (!sourceFileToClasses.containsKey(name)) { - sourceFileToClasses.put(name, new HashSet()); + private void compensateRemovedContent(final Collection compiled) { + for (File file : compiled) { + final StringCache.S key = StringCache.get(FileUtil.toSystemIndependentName(file.getAbsolutePath())); + if (!sourceFileToClasses.containsKey(key)) { + sourceFileToClasses.put(key, new HashSet()); } } } @@ -348,9 +349,9 @@ public class Mappings implements RW.Writable { } void affectSubclasses(final StringCache.S className, - final Set affectedFiles, - final Set affectedUsages, - final Set dependants, + final Collection affectedFiles, + final Collection affectedUsages, + final Collection dependants, final boolean usages) { final StringCache.S fileName = classToSourceFile.get(className); @@ -372,7 +373,7 @@ public class Mappings implements RW.Writable { dependants.addAll(depClasses); } - affectedFiles.add(fileName); + affectedFiles.add(new File(fileName.value)); final Collection directSubclasses = classToSubclasses.foxyGet(className); @@ -419,14 +420,14 @@ public class Mappings implements RW.Writable { } } - void affectAll(final StringCache.S className, final Set affectedFiles) { + void affectAll(final StringCache.S className, final Collection affectedFiles) { final Set dependants = (Set)classToClassDependency.foxyGet(className); if (dependants != null) { for (StringCache.S depClass : dependants) { final StringCache.S depFile = classToSourceFile.get(depClass); if (depFile != null) { - affectedFiles.add(depFile); + affectedFiles.add(new File(depFile.value)); } } } @@ -508,29 +509,19 @@ public class Mappings implements RW.Writable { } public boolean differentiate(final Mappings delta, - final Collection removed, - final Collection successfullyCompiled, - final Collection allCompiledFiles, - final Collection allAffectedFiles) { - final Set affectedCache = cacheFiles(allAffectedFiles); - - final boolean result = - differentiate(delta, cachePaths(removed), cacheFiles(successfullyCompiled), cacheFiles(allCompiledFiles), affectedCache, - Collections.emptySet()); - - for (StringCache.S a : affectedCache) { - allAffectedFiles.add(new File(a.value)); - } - - return result; + final Collection removed, + final Collection filesToCompile, + final Collection compiledFiles, + final Collection affectedFiles){ + return differentiate(delta, removed, filesToCompile, compiledFiles, affectedFiles, null); } - + public boolean differentiate(final Mappings delta, - final Set removed, - final Collection filesToCompile, - final Set compiledFiles, - final Set affectedFiles, - final Set safeFiles) { + final Collection removed, + final Collection filesToCompile, + final Collection compiledFiles, + final Collection affectedFiles, + @Nullable final Collection safeFiles) { delta.compensateRemovedContent(filesToCompile); final Util u = new Util(delta); @@ -538,8 +529,8 @@ public class Mappings implements RW.Writable { final Util o = new Util(); if (removed != null) { - for (StringCache.S file : removed) { - final Collection classes = sourceFileToClasses.foxyGet(file); + for (String file : removed) { + final Collection classes = sourceFileToClasses.foxyGet(StringCache.get(file)); if (classes != null) { for (ClassRepr c : classes) { @@ -550,7 +541,7 @@ public class Mappings implements RW.Writable { } for (StringCache.S fileName : delta.sourceFileToClasses.keySet()) { - if (safeFiles.contains(fileName)) { + if (safeFiles != null && safeFiles.contains(fileName.value)) { continue; } @@ -687,7 +678,7 @@ public class Mappings implements RW.Writable { final StringCache.S source = classToSourceFile.get(p); if (source != null) { - affectedFiles.add(source); + affectedFiles.add(new File(source.value)); } } } @@ -770,14 +761,14 @@ public class Mappings implements RW.Writable { if (r != null && sourceFileName != null) { if (r.isLocal) { - affectedFiles.add(sourceFileName); + affectedFiles.add(new File(sourceFileName.value)); } else { final StringCache.S outerClass = r.outerClassName; if (outerClass.value != null) { if (u.fieldVisible(outerClass, f)) { - affectedFiles.add(sourceFileName); + affectedFiles.add(new File(sourceFileName.value)); } } } @@ -837,7 +828,6 @@ public class Mappings implements RW.Writable { affectedUsages.addAll(localUsages); } } - } for (FieldRepr f : diff.fields().removed()) { @@ -905,7 +895,7 @@ public class Mappings implements RW.Writable { final StringCache.S fName = classToSourceFile.get(depClass); if (fName != null) { - affectedFiles.add(fName); + affectedFiles.add(new File(fName.value)); } } } @@ -943,14 +933,14 @@ public class Mappings implements RW.Writable { final Util.UsageConstraint constraint = usageConstraints.get(usage); if (constraint == null) { - affectedFiles.add(depFile); + affectedFiles.add(new File(depFile.value)); continue filewise; } else { final Set residenceClasses = depCluster.getResidence(usage); for (StringCache.S residentName : residenceClasses) { if (constraint.checkResidence(residentName)) { - affectedFiles.add(depFile); + affectedFiles.add(new File(depFile.value)); continue filewise; } } @@ -965,7 +955,7 @@ public class Mappings implements RW.Writable { for (UsageRepr.Usage usage : annotationUsages) { for (UsageRepr.AnnotationUsage query : annotationQuery) { if (query.satisfies(usage)) { - affectedFiles.add(depFile); + affectedFiles.add(new File(depFile.value)); continue filewise; } } @@ -980,14 +970,11 @@ public class Mappings implements RW.Writable { } public void integrate(final Mappings delta, final Collection compiled, final Collection removed) { - integrate(delta, cacheFiles(compiled), cachePaths(removed)); - } - - public void integrate(final Mappings delta, final Collection compiled, final Set removed) { if (removed != null) { - for (StringCache.S file : removed) { - final Set classes = (Set)sourceFileToClasses.foxyGet(file); - final UsageRepr.Cluster cluster = sourceFileToUsages.get(file); + for (String file : removed) { + final StringCache.S key = StringCache.get(file); + final Set classes = (Set)sourceFileToClasses.foxyGet(key); + final UsageRepr.Cluster cluster = sourceFileToUsages.get(key); final Set usages = cluster == null ? null : cluster.getUsages(); if (classes != null) { @@ -1014,8 +1001,8 @@ public class Mappings implements RW.Writable { } } - sourceFileToClasses.remove(file); - sourceFileToUsages.remove(file); + sourceFileToClasses.remove(key); + sourceFileToUsages.remove(key); } } @@ -1035,7 +1022,11 @@ public class Mappings implements RW.Writable { classToClassDependency.put(file, now); } else { - final Collection removeSet = new HashSet(compiled); + final Collection removeSet = new HashSet(); + + for (File c : compiled) { + removeSet.add(StringCache.get(FileUtil.toSystemIndependentName(c.getAbsolutePath()))); + } removeSet.removeAll(now); @@ -1070,8 +1061,14 @@ public class Mappings implements RW.Writable { public Callbacks.Backend getCallback() { return new Callbacks.Backend() { - public Collection getClassFiles() { - return classToSourceFile.keySet(); + public Collection getClassFiles() { + final HashSet result = new HashSet(); + + for (StringCache.S s : classToSourceFile.keySet()) { + result.add(s.value); + } + + return result; } public void associate(final String classFileName, final Callbacks.SourceFileNameLookup sourceFileName, final ClassReader cr) { @@ -1110,28 +1107,28 @@ public class Mappings implements RW.Writable { } } - public void associateForm(StringCache.S formName, StringCache.S className) { - updateFormToClass(formName, className); + public void associateForm(String formName, String className) { + updateFormToClass(StringCache.get(formName), StringCache.get(className)); } }; } @Nullable - public Set getClasses(final StringCache.S sourceFileName) { - return (Set)sourceFileToClasses.foxyGet(sourceFileName); + public Set getClasses(final String sourceFileName) { + return (Set)sourceFileToClasses.foxyGet(StringCache.get(sourceFileName)); } @Nullable - public StringCache.S getJavaByForm(final StringCache.S formFileName) { - final StringCache.S classFileName = formToClass.get(formFileName); + public String getJavaByForm(final String formFileName) { + final StringCache.S classFileName = formToClass.get(StringCache.get(formFileName)); assert classFileName != null; - return classToSourceFile.get(classFileName); + return classToSourceFile.get(classFileName).value; } @Nullable - public StringCache.S getFormByJava(final StringCache.S javaFileName) { + public String getFormByJava(final String javaFileName) { final Set classes = getClasses(javaFileName); if (classes != null) { @@ -1139,7 +1136,7 @@ public class Mappings implements RW.Writable { final StringCache.S formName = classToForm.get(c.name); if (formName != null) { - return formName; + return formName.value; } } } diff --git a/jps/model/src/org/jetbrains/ether/dependencyView/StringCache.java b/jps/model/src/org/jetbrains/ether/dependencyView/StringCache.java index 796967c70310..3d984c012439 100644 --- a/jps/model/src/org/jetbrains/ether/dependencyView/StringCache.java +++ b/jps/model/src/org/jetbrains/ether/dependencyView/StringCache.java @@ -14,7 +14,7 @@ import java.util.Map; * Time: 2:03 * To change this template use File | Settings | File Templates. */ -public class StringCache { +class StringCache { public static class S implements Comparable, RW.Writable, KeyDescriptor { public final int index; diff --git a/jps/src/org/jetbrains/ether/ProjectWrapper.java b/jps/src/org/jetbrains/ether/ProjectWrapper.java index 36b96bd5e80f..bdde43ddc773 100644 --- a/jps/src/org/jetbrains/ether/ProjectWrapper.java +++ b/jps/src/org/jetbrains/ether/ProjectWrapper.java @@ -1,10 +1,11 @@ package org.jetbrains.ether; -import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.io.FileUtil; import org.codehaus.gant.GantBinding; import org.codehaus.groovy.runtime.DefaultGroovyMethods; -import org.jetbrains.ether.dependencyView.*; +import org.jetbrains.ether.dependencyView.Callbacks; +import org.jetbrains.ether.dependencyView.ClassRepr; +import org.jetbrains.ether.dependencyView.Mappings; import org.jetbrains.jps.*; import org.jetbrains.jps.idea.IdeaProjectLoader; import org.jetbrains.jps.resolvers.PathEntry; @@ -56,10 +57,10 @@ public class ProjectWrapper { this.stream = flags.logStream(); } - public void logFilePaths(PrintStream stream, Collection paths) { + public void logFilePaths(PrintStream stream, Collection paths) { List strings = new ArrayList(paths.size()); - for (StringCache.S path : paths) { - strings.add(FileUtil.toSystemIndependentName(getRelativePath(path.toString()))); + for (String path : paths) { + strings.add(FileUtil.toSystemIndependentName(getRelativePath(path))); } logMany(stream, strings); } @@ -279,20 +280,20 @@ public class ProjectWrapper { }; public class FileWrapper implements RW.Writable { - final StringCache.S myName; + final String myName; final long myModificationTime; FileWrapper(final File f) { - myName = StringCache.get(f.getAbsolutePath()); + myName = f.getAbsolutePath(); myModificationTime = f.lastModified(); } FileWrapper(final BufferedReader r) { - myName = StringCache.get(RW.readString(r)); + myName = RW.readString(r); myModificationTime = RW.readLong(r); } - public StringCache.S getName() { + public String getName() { return myName; } @@ -301,9 +302,9 @@ public class ProjectWrapper { } public void write(final BufferedWriter w) { - final StringCache.S name = getName(); + final String name = getName(); - RW.writeln(w, name.value); + RW.writeln(w, name); RW.writeln(w, Long.toString(getStamp())); } @@ -340,8 +341,8 @@ public class ProjectWrapper { final String myOutput; String myOutputStatus; - public Set getFiles() { - final Set result = new HashSet(); + public Set getFiles() { + final Set result = new HashSet(); for (FileWrapper f : mySources.keySet()) { result.add(f.getName()); @@ -350,8 +351,8 @@ public class ProjectWrapper { return result; } - public Set getOutdatedFiles(final Properties past) { - final Set result = new HashSet(); + public Set getOutdatedFiles(final Properties past) { + final Set result = new HashSet(); for (FileWrapper now : mySources.keySet()) { final FileWrapper than = past == null ? null : past.mySources.get(now); @@ -364,8 +365,8 @@ public class ProjectWrapper { return result; } - public Set getRemovedFiles(final Properties past) { - final Set result = new HashSet(); + public Set getRemovedFiles(final Properties past) { + final Set result = new HashSet(); if (past != null) { for (FileWrapper was : past.mySources.keySet()) { @@ -485,19 +486,19 @@ public class ProjectWrapper { final Module myModule; final Set myLibraries; - public Set getOutdatedSources() { + public Set getOutdatedSources() { return mySource.getOutdatedFiles(myHistory == null ? null : myHistory.getModule(myName).mySource); } - public Set getOutdatedTests() { + public Set getOutdatedTests() { return myTest.getOutdatedFiles(myHistory == null ? null : myHistory.getModule(myName).myTest); } - public Set getRemovedSources() { + public Set getRemovedSources() { return mySource.getRemovedFiles(myHistory == null ? null : myHistory.getModule(myName).mySource); } - public Set getRemovedTests() { + public Set getRemovedTests() { return myTest.getRemovedFiles(myHistory == null ? null : myHistory.getModule(myName).myTest); } @@ -579,7 +580,7 @@ public class ProjectWrapper { myDependsOn = null; myTestDependsOn = null; myName = m.getName(); - myExcludes = new HashSet (m.getExcludes()); + myExcludes = new HashSet(m.getExcludes()); mySource = new Properties(m.getSourceRoots(), m.getOutputPath(), myExcludes); myTest = new Properties(m.getTestRoots(), m.getTestOutputPath(), myExcludes); @@ -594,7 +595,7 @@ public class ProjectWrapper { return myName; } - public Set getOutdatedFiles(final boolean tests) { + public Set getOutdatedFiles(final boolean tests) { if (tests) { return myTest.outputEmpty() ? getTests() : getOutdatedTests(); } @@ -602,7 +603,7 @@ public class ProjectWrapper { return mySource.outputEmpty() ? getSources() : getOutdatedSources(); } - public Set getRemovedFiles(final boolean tests) { + public Set getRemovedFiles(final boolean tests) { if (tests) { return getRemovedTests(); } @@ -610,7 +611,7 @@ public class ProjectWrapper { return getRemovedSources(); } - public Set getSources(final boolean tests) { + public Set getSources(final boolean tests) { if (tests) { return myTest.getFiles(); } @@ -630,11 +631,11 @@ public class ProjectWrapper { return myTest.getSources(); } - public Set getSources() { + public Set getSources() { return mySource.getFiles(); } - public Set getTests() { + public Set getTests() { return myTest.getFiles(); } @@ -814,7 +815,7 @@ public class ProjectWrapper { Mappings dependencyMapping; final Callbacks.Backend backendCallback; - final Set affectedFiles; + final Set affectedFiles; final ProjectWrapper myHistory; @@ -840,7 +841,7 @@ public class ProjectWrapper { throw new RuntimeException(e); } backendCallback = dependencyMapping.getCallback(); - affectedFiles = new HashSet(); + affectedFiles = new HashSet(); myProject = new GantBasedProject(binding == null ? new GantBinding() : binding); myProjectBuilder = myProject.getBuilder(); @@ -873,16 +874,16 @@ public class ProjectWrapper { } } - private static File getMapDir () { + private static File getMapDir() { try { - return FileUtil.createTempDirectory(new File(myHomeDir + File.separator + myJPSDir), "mappings", "dir"); + return FileUtil.createTempDirectory(new File(myHomeDir + File.separator + myJPSDir), "mappings", "dir"); } catch (IOException e) { throw new RuntimeException(e); } } - private ProjectWrapper(final BufferedReader r, final Set affected) { + private ProjectWrapper(final BufferedReader r, final Set affected) { affectedFiles = affected; myProject = null; myProjectBuilder = null; @@ -906,7 +907,7 @@ public class ProjectWrapper { myModules.put(m.getName(), m); } - RW.readMany(r, StringCache.reader, affectedFiles); + RW.readMany(r, RW.myStringReader, affectedFiles); try { dependencyMapping = new Mappings(getMapDir(), r); @@ -914,7 +915,7 @@ public class ProjectWrapper { catch (IOException e) { throw new RuntimeException(e); } - + backendCallback = dependencyMapping.getCallback(); } @@ -949,7 +950,7 @@ public class ProjectWrapper { RW.writeln(w, "Modules:"); RW.writeln(w, getModules()); - RW.writeln(w, affectedFiles, StringCache.fromS); + RW.writeln(w, affectedFiles, RW.fromString); dependencyMapping.write(w); } @@ -958,7 +959,7 @@ public class ProjectWrapper { return myProjectSnapshot; } - private ProjectWrapper loadSnapshot(final Set affectedFiles) { + private ProjectWrapper loadSnapshot(final Set affectedFiles) { initJPSDirectory(); try { @@ -1059,7 +1060,7 @@ public class ProjectWrapper { class BusyBeaver { final ProjectBuilder builder; - final Set compiledFiles = new HashSet(); + final Set compiledFiles = new HashSet(); final Set cleared = new HashSet(); BusyBeaver(ProjectBuilder builder) { @@ -1067,31 +1068,31 @@ public class ProjectWrapper { } BuildStatus iterativeCompile(final ModuleChunk chunk, - final Set sources, - final Set outdated, - final Set removed, + final Set sources, + final Set outdated, + final Set removed, final Flags flags) { - final Collection filesToCompile = DefaultGroovyMethods.intersect(affectedFiles, sources); - final Set safeFiles = new HashSet(); + final Collection filesToCompile = DefaultGroovyMethods.intersect(affectedFiles, sources); + final Set safeFiles = new HashSet(); if (outdated != null) { - for (StringCache.S s : outdated) { + for (String s : outdated) { assert (s != null); } filesToCompile.addAll(outdated); - for (StringCache.S f : outdated) { - if (f.value.endsWith(".form")) { - final StringCache.S sourceFileName = dependencyMapping.getJavaByForm(f); + for (String f : outdated) { + if (f.endsWith(".form")) { + final String sourceFileName = dependencyMapping.getJavaByForm(f); if (sourceFileName != null && !filesToCompile.contains(sourceFileName)) { safeFiles.add(sourceFileName); filesToCompile.add(sourceFileName); } } - else if (f.value.endsWith(".java")) { - final StringCache.S formFileName = dependencyMapping.getFormByJava(f); + else if (f.endsWith(".java")) { + final String formFileName = dependencyMapping.getFormByJava(f); if (formFileName != null) { filesToCompile.add(formFileName); @@ -1103,24 +1104,24 @@ public class ProjectWrapper { filesToCompile.removeAll(compiledFiles); if (!filesToCompile.isEmpty() || removed != null) { - final Set outputFiles = new HashSet(); + final Set outputFiles = new HashSet(); - for (StringCache.S f : filesToCompile) { + for (String f : filesToCompile) { final Set classes = dependencyMapping.getClasses(f); if (classes != null) { for (ClassRepr cr : classes) { - outputFiles.add(cr.fileName); + outputFiles.add(cr.fileName.value); } } } if (removed != null) { - for (StringCache.S f : removed) { + for (String f : removed) { final Set classes = dependencyMapping.getClasses(f); if (classes != null) { for (ClassRepr cr : classes) { - outputFiles.add(cr.fileName); + outputFiles.add(cr.fileName.value); } } } @@ -1172,10 +1173,26 @@ public class ProjectWrapper { compiledFiles.addAll(filesToCompile); affectedFiles.removeAll(filesToCompile); - final boolean incremental = - dependencyMapping.differentiate(delta, removed, filesToCompile, compiledFiles, affectedFiles, safeFiles); + final Collection files = new HashSet(); + final Collection compiled = new HashSet(); - dependencyMapping.integrate(delta, filesToCompile, removed); + for (String f : filesToCompile) { + files.add(new File(f)); + } + + for (String f : compiledFiles) { + compiled.add(new File(f)); + } + + final Collection affected = new HashSet(); + + final boolean incremental = dependencyMapping.differentiate(delta, removed, files, compiled, affected, safeFiles); + + for (File a : affected) { + affectedFiles.add(FileUtil.toSystemIndependentName(a.getAbsolutePath())); + } + + dependencyMapping.integrate(delta, files, removed); if (!incremental) { affectedFiles.addAll(sources); @@ -1213,11 +1230,11 @@ public class ProjectWrapper { final Set chunkModules = c.getElements(); if (!DefaultGroovyMethods.intersect(modules, chunkModules).isEmpty()) { - final Set removedSources = new HashSet(); + final Set removedSources = new HashSet(); if (incremental) { - final Set chunkSources = new HashSet(); - final Set outdatedSources = new HashSet(); + final Set chunkSources = new HashSet(); + final Set outdatedSources = new HashSet(); for (Module m : chunkModules) { final ModuleWrapper mw = getModule(m.getName()); @@ -1280,7 +1297,7 @@ public class ProjectWrapper { return BuildStatus.FAILURE; } - final Set allFiles = new HashSet(); + final Set allFiles = new HashSet(); for (Module m : c.getElements()) { final ModuleWrapper module = getModule(m.getName()); @@ -1288,7 +1305,13 @@ public class ProjectWrapper { allFiles.addAll(module.getSources(flags.tests())); } - dependencyMapping.integrate(delta, allFiles, removedSources); + final Collection files = new HashSet(); + + for (String f : allFiles) { + files.add(new File(f)); + } + + dependencyMapping.integrate(delta, files, removedSources); for (Module m : chunkModules) { Reporter.reportBuildSuccess(m, flags.tests()); diff --git a/jps/src/org/jetbrains/jps/ProjectBuilder.groovy b/jps/src/org/jetbrains/jps/ProjectBuilder.groovy index 219165956580..162ce385f280 100644 --- a/jps/src/org/jetbrains/jps/ProjectBuilder.groovy +++ b/jps/src/org/jetbrains/jps/ProjectBuilder.groovy @@ -5,7 +5,6 @@ import org.codehaus.gant.GantBinding import org.jetbrains.ether.ProjectWrapper import org.jetbrains.ether.Reporter import org.jetbrains.ether.dependencyView.Callbacks.Backend -import org.jetbrains.ether.dependencyView.StringCache import org.jetbrains.jps.artifacts.ArtifactBuilder import org.jetbrains.jps.idea.OwnServiceLoader @@ -270,7 +269,7 @@ class ProjectBuilder { buildModules(dependencies, includeTests) } - def clearChunk(ModuleChunk chunk, Collection files, ProjectWrapper pw) { + def clearChunk(ModuleChunk chunk, Collection files, ProjectWrapper pw) { if (!dryRun) { if (files == null) { stage("Cleaning module ${chunk.name}") @@ -280,7 +279,7 @@ class ProjectBuilder { stage("Cleaning output files for module ${chunk.name}") files.each { - binding.ant.delete(file: pw.getAbsolutePath(it.value)) + binding.ant.delete(file: pw.getAbsolutePath(it)) } chunk.modules.each { @@ -299,7 +298,7 @@ class ProjectBuilder { buildChunk(chunk, tests, null, null, null) } - def buildChunk(ModuleChunk chunk, boolean tests, Collection files, Backend callback, ProjectWrapper pw) { + def buildChunk(ModuleChunk chunk, boolean tests, Collection files, Backend callback, ProjectWrapper pw) { Set compiledSet = tests ? compiledTestChunks : compiledChunks if (compiledSet.contains(chunk) && files == null) return compiledSet.add(chunk) @@ -316,7 +315,7 @@ class ProjectBuilder { return getProjectPaths().getModuleOutputDir(module, tests)?.absolutePath } - private def compile(ModuleChunk chunk, boolean tests, Collection files, Backend callback, ProjectWrapper pw) { + private def compile(ModuleChunk chunk, boolean tests, Collection files, Backend callback, ProjectWrapper pw) { List chunkSources = filterNonExistingFiles(tests ? chunk.testRoots : chunk.sourceRoots, true) if (chunkSources.isEmpty()) return @@ -324,7 +323,7 @@ class ProjectBuilder { if (files != null) { files.each { - sourceFiles << pw.getAbsolutePath(it.value) + sourceFiles << pw.getAbsolutePath(it) } } diff --git a/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy b/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy index b7519ab06d75..9c326160a20f 100644 --- a/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy +++ b/jps/src/org/jetbrains/jps/builders/StandardBuilders.groovy @@ -6,8 +6,6 @@ import com.intellij.ant.PrefixedPath import org.apache.tools.ant.BuildListener import org.jetbrains.ether.ProjectWrapper import org.jetbrains.ether.dependencyView.AntListener -import org.jetbrains.ether.dependencyView.StringCache -import org.jetbrains.ether.dependencyView.StringCache.S import org.jetbrains.jps.builders.javacApi.Java16ApiCompilerRunner import org.jetbrains.jps.* @@ -292,7 +290,7 @@ class JetBrainsInstrumentations implements ModuleBuilder { final String formRelPath = state.projectWrapper.getRelativePath(formFile); final String classRelPath = state.projectWrapper.getRelativePath(classFile); - state.callback.associateForm(StringCache.get(formRelPath), StringCache.get(classRelPath)); + state.callback.associateForm(formRelPath, classRelPath); } } @@ -349,10 +347,10 @@ class JetBrainsInstrumentations implements ModuleBuilder { if (pw != null) { for (Module m: moduleChunk.elements) { - final Set names = state.tests ? pw.getModule(m.getName()).getTests() : pw.getModule(m.getName()).getSources(); - for (S name: names) { - if (name.value.endsWith(".form")) { - formFiles.add(new File(pw.getAbsolutePath(name.value))); + final Set names = state.tests ? pw.getModule(m.getName()).getTests() : pw.getModule(m.getName()).getSources(); + for (String name: names) { + if (name.endsWith(".form")) { + formFiles.add(new File(pw.getAbsolutePath(name))) } } } @@ -403,10 +401,10 @@ class JetBrainsInstrumentations implements ModuleBuilder { }.traverse(new File(state.targetFolder)) } else { - final Collection classes = state.callback.getClassFiles() + final Collection classes = state.callback.getClassFiles() classes.each { - InstrumentationUtil.instrumentNotNull(new File(state.targetFolder + File.separator + it.value + ".class"), state.loader) + InstrumentationUtil.instrumentNotNull(new File(state.targetFolder + File.separator + it + ".class"), state.loader) } } }