mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Eliminated StringCache.S in dependencyView client code (jps/incremental).
This commit is contained in:
@@ -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<ClassRepr> classes = mappings.getClasses(StringCache.get(FileUtil.toSystemIndependentName(file.getPath())));
|
||||
final Set<ClassRepr> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<StringCache.S> getClassFiles();
|
||||
|
||||
Collection<String> getClassFiles();
|
||||
void associate(String classFileName, SourceFileNameLookup sourceLookup, ClassReader cr);
|
||||
void associateForm(StringCache.S formName, StringCache.S className);
|
||||
void associateForm(String formName, String className);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<TypeRepr.AbstractType> interfaces();
|
||||
|
||||
|
||||
@@ -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<StringCache.S, UsageRepr.Cluster>());
|
||||
sourceFileToAnnotationUsages = FoxyMap.read(r, StringCache.reader, UsageRepr.reader, usageSetConstructor);
|
||||
classToSourceFile = RW.readMap(r, StringCache.reader, StringCache.reader, new HashMap<StringCache.S, StringCache.S>());
|
||||
classToClassDependency = FoxyMap.read(r, StringCache.reader, StringCache.reader, stringSetConstructor);
|
||||
formToClass = new HashMap<StringCache.S, StringCache.S>();
|
||||
classToForm = new HashMap<StringCache.S, StringCache.S>();
|
||||
}
|
||||
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<StringCache.S, UsageRepr.Cluster>());
|
||||
sourceFileToAnnotationUsages = FoxyMap.read(r, StringCache.reader, UsageRepr.reader, usageSetConstructor);
|
||||
classToSourceFile = RW.readMap(r, StringCache.reader, StringCache.reader, new HashMap<StringCache.S, StringCache.S>());
|
||||
classToClassDependency = FoxyMap.read(r, StringCache.reader, StringCache.reader, stringSetConstructor);
|
||||
formToClass = new HashMap<StringCache.S, StringCache.S>();
|
||||
classToForm = new HashMap<StringCache.S, StringCache.S>();
|
||||
}
|
||||
|
||||
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<StringCache.S, StringCache.S>();
|
||||
}
|
||||
|
||||
private void compensateRemovedContent(final Collection<StringCache.S> compiled) {
|
||||
for (StringCache.S name : compiled) {
|
||||
if (!sourceFileToClasses.containsKey(name)) {
|
||||
sourceFileToClasses.put(name, new HashSet<ClassRepr>());
|
||||
private void compensateRemovedContent(final Collection<File> compiled) {
|
||||
for (File file : compiled) {
|
||||
final StringCache.S key = StringCache.get(FileUtil.toSystemIndependentName(file.getAbsolutePath()));
|
||||
if (!sourceFileToClasses.containsKey(key)) {
|
||||
sourceFileToClasses.put(key, new HashSet<ClassRepr>());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,9 +349,9 @@ public class Mappings implements RW.Writable {
|
||||
}
|
||||
|
||||
void affectSubclasses(final StringCache.S className,
|
||||
final Set<StringCache.S> affectedFiles,
|
||||
final Set<UsageRepr.Usage> affectedUsages,
|
||||
final Set<StringCache.S> dependants,
|
||||
final Collection<File> affectedFiles,
|
||||
final Collection<UsageRepr.Usage> affectedUsages,
|
||||
final Collection<StringCache.S> 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<StringCache.S> directSubclasses = classToSubclasses.foxyGet(className);
|
||||
|
||||
@@ -419,14 +420,14 @@ public class Mappings implements RW.Writable {
|
||||
}
|
||||
}
|
||||
|
||||
void affectAll(final StringCache.S className, final Set<StringCache.S> affectedFiles) {
|
||||
void affectAll(final StringCache.S className, final Collection<File> affectedFiles) {
|
||||
final Set<StringCache.S> dependants = (Set<StringCache.S>)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<String> removed,
|
||||
final Collection<File> successfullyCompiled,
|
||||
final Collection<File> allCompiledFiles,
|
||||
final Collection<File> allAffectedFiles) {
|
||||
final Set<StringCache.S> affectedCache = cacheFiles(allAffectedFiles);
|
||||
|
||||
final boolean result =
|
||||
differentiate(delta, cachePaths(removed), cacheFiles(successfullyCompiled), cacheFiles(allCompiledFiles), affectedCache,
|
||||
Collections.<StringCache.S>emptySet());
|
||||
|
||||
for (StringCache.S a : affectedCache) {
|
||||
allAffectedFiles.add(new File(a.value));
|
||||
}
|
||||
|
||||
return result;
|
||||
final Collection<String> removed,
|
||||
final Collection<File> filesToCompile,
|
||||
final Collection<File> compiledFiles,
|
||||
final Collection<File> affectedFiles){
|
||||
return differentiate(delta, removed, filesToCompile, compiledFiles, affectedFiles, null);
|
||||
}
|
||||
|
||||
|
||||
public boolean differentiate(final Mappings delta,
|
||||
final Set<StringCache.S> removed,
|
||||
final Collection<StringCache.S> filesToCompile,
|
||||
final Set<StringCache.S> compiledFiles,
|
||||
final Set<StringCache.S> affectedFiles,
|
||||
final Set<StringCache.S> safeFiles) {
|
||||
final Collection<String> removed,
|
||||
final Collection<File> filesToCompile,
|
||||
final Collection<File> compiledFiles,
|
||||
final Collection<File> affectedFiles,
|
||||
@Nullable final Collection<String> 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<ClassRepr> classes = sourceFileToClasses.foxyGet(file);
|
||||
for (String file : removed) {
|
||||
final Collection<ClassRepr> 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<StringCache.S> 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<File> compiled, final Collection<String> removed) {
|
||||
integrate(delta, cacheFiles(compiled), cachePaths(removed));
|
||||
}
|
||||
|
||||
public void integrate(final Mappings delta, final Collection<StringCache.S> compiled, final Set<StringCache.S> removed) {
|
||||
if (removed != null) {
|
||||
for (StringCache.S file : removed) {
|
||||
final Set<ClassRepr> classes = (Set<ClassRepr>)sourceFileToClasses.foxyGet(file);
|
||||
final UsageRepr.Cluster cluster = sourceFileToUsages.get(file);
|
||||
for (String file : removed) {
|
||||
final StringCache.S key = StringCache.get(file);
|
||||
final Set<ClassRepr> classes = (Set<ClassRepr>)sourceFileToClasses.foxyGet(key);
|
||||
final UsageRepr.Cluster cluster = sourceFileToUsages.get(key);
|
||||
final Set<UsageRepr.Usage> 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<StringCache.S> removeSet = new HashSet<StringCache.S>(compiled);
|
||||
final Collection<StringCache.S> removeSet = new HashSet<StringCache.S>();
|
||||
|
||||
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<StringCache.S> getClassFiles() {
|
||||
return classToSourceFile.keySet();
|
||||
public Collection<String> getClassFiles() {
|
||||
final HashSet<String> result = new HashSet<String>();
|
||||
|
||||
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<ClassRepr> getClasses(final StringCache.S sourceFileName) {
|
||||
return (Set<ClassRepr>)sourceFileToClasses.foxyGet(sourceFileName);
|
||||
public Set<ClassRepr> getClasses(final String sourceFileName) {
|
||||
return (Set<ClassRepr>)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<ClassRepr> 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<S>, RW.Writable, KeyDescriptor<S> {
|
||||
public final int index;
|
||||
|
||||
@@ -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<StringCache.S> paths) {
|
||||
public void logFilePaths(PrintStream stream, Collection<String> paths) {
|
||||
List<String> strings = new ArrayList<String>(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<StringCache.S> getFiles() {
|
||||
final Set<StringCache.S> result = new HashSet<StringCache.S>();
|
||||
public Set<String> getFiles() {
|
||||
final Set<String> result = new HashSet<String>();
|
||||
|
||||
for (FileWrapper f : mySources.keySet()) {
|
||||
result.add(f.getName());
|
||||
@@ -350,8 +351,8 @@ public class ProjectWrapper {
|
||||
return result;
|
||||
}
|
||||
|
||||
public Set<StringCache.S> getOutdatedFiles(final Properties past) {
|
||||
final Set<StringCache.S> result = new HashSet<StringCache.S>();
|
||||
public Set<String> getOutdatedFiles(final Properties past) {
|
||||
final Set<String> result = new HashSet<String>();
|
||||
|
||||
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<StringCache.S> getRemovedFiles(final Properties past) {
|
||||
final Set<StringCache.S> result = new HashSet<StringCache.S>();
|
||||
public Set<String> getRemovedFiles(final Properties past) {
|
||||
final Set<String> result = new HashSet<String>();
|
||||
|
||||
if (past != null) {
|
||||
for (FileWrapper was : past.mySources.keySet()) {
|
||||
@@ -485,19 +486,19 @@ public class ProjectWrapper {
|
||||
final Module myModule;
|
||||
final Set<LibraryWrapper> myLibraries;
|
||||
|
||||
public Set<StringCache.S> getOutdatedSources() {
|
||||
public Set<String> getOutdatedSources() {
|
||||
return mySource.getOutdatedFiles(myHistory == null ? null : myHistory.getModule(myName).mySource);
|
||||
}
|
||||
|
||||
public Set<StringCache.S> getOutdatedTests() {
|
||||
public Set<String> getOutdatedTests() {
|
||||
return myTest.getOutdatedFiles(myHistory == null ? null : myHistory.getModule(myName).myTest);
|
||||
}
|
||||
|
||||
public Set<StringCache.S> getRemovedSources() {
|
||||
public Set<String> getRemovedSources() {
|
||||
return mySource.getRemovedFiles(myHistory == null ? null : myHistory.getModule(myName).mySource);
|
||||
}
|
||||
|
||||
public Set<StringCache.S> getRemovedTests() {
|
||||
public Set<String> 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<String> (m.getExcludes());
|
||||
myExcludes = new HashSet<String>(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<StringCache.S> getOutdatedFiles(final boolean tests) {
|
||||
public Set<String> 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<StringCache.S> getRemovedFiles(final boolean tests) {
|
||||
public Set<String> getRemovedFiles(final boolean tests) {
|
||||
if (tests) {
|
||||
return getRemovedTests();
|
||||
}
|
||||
@@ -610,7 +611,7 @@ public class ProjectWrapper {
|
||||
return getRemovedSources();
|
||||
}
|
||||
|
||||
public Set<StringCache.S> getSources(final boolean tests) {
|
||||
public Set<String> getSources(final boolean tests) {
|
||||
if (tests) {
|
||||
return myTest.getFiles();
|
||||
}
|
||||
@@ -630,11 +631,11 @@ public class ProjectWrapper {
|
||||
return myTest.getSources();
|
||||
}
|
||||
|
||||
public Set<StringCache.S> getSources() {
|
||||
public Set<String> getSources() {
|
||||
return mySource.getFiles();
|
||||
}
|
||||
|
||||
public Set<StringCache.S> getTests() {
|
||||
public Set<String> getTests() {
|
||||
return myTest.getFiles();
|
||||
}
|
||||
|
||||
@@ -814,7 +815,7 @@ public class ProjectWrapper {
|
||||
|
||||
Mappings dependencyMapping;
|
||||
final Callbacks.Backend backendCallback;
|
||||
final Set<StringCache.S> affectedFiles;
|
||||
final Set<String> affectedFiles;
|
||||
|
||||
final ProjectWrapper myHistory;
|
||||
|
||||
@@ -840,7 +841,7 @@ public class ProjectWrapper {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
backendCallback = dependencyMapping.getCallback();
|
||||
affectedFiles = new HashSet<StringCache.S>();
|
||||
affectedFiles = new HashSet<String>();
|
||||
|
||||
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<StringCache.S> affected) {
|
||||
private ProjectWrapper(final BufferedReader r, final Set<String> 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<StringCache.S> affectedFiles) {
|
||||
private ProjectWrapper loadSnapshot(final Set<String> affectedFiles) {
|
||||
initJPSDirectory();
|
||||
|
||||
try {
|
||||
@@ -1059,7 +1060,7 @@ public class ProjectWrapper {
|
||||
|
||||
class BusyBeaver {
|
||||
final ProjectBuilder builder;
|
||||
final Set<StringCache.S> compiledFiles = new HashSet<StringCache.S>();
|
||||
final Set<String> compiledFiles = new HashSet<String>();
|
||||
final Set<Module> cleared = new HashSet<Module>();
|
||||
|
||||
BusyBeaver(ProjectBuilder builder) {
|
||||
@@ -1067,31 +1068,31 @@ public class ProjectWrapper {
|
||||
}
|
||||
|
||||
BuildStatus iterativeCompile(final ModuleChunk chunk,
|
||||
final Set<StringCache.S> sources,
|
||||
final Set<StringCache.S> outdated,
|
||||
final Set<StringCache.S> removed,
|
||||
final Set<String> sources,
|
||||
final Set<String> outdated,
|
||||
final Set<String> removed,
|
||||
final Flags flags) {
|
||||
final Collection<StringCache.S> filesToCompile = DefaultGroovyMethods.intersect(affectedFiles, sources);
|
||||
final Set<StringCache.S> safeFiles = new HashSet<StringCache.S>();
|
||||
final Collection<String> filesToCompile = DefaultGroovyMethods.intersect(affectedFiles, sources);
|
||||
final Set<String> safeFiles = new HashSet<String>();
|
||||
|
||||
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<StringCache.S> outputFiles = new HashSet<StringCache.S>();
|
||||
final Set<String> outputFiles = new HashSet<String>();
|
||||
|
||||
for (StringCache.S f : filesToCompile) {
|
||||
for (String f : filesToCompile) {
|
||||
final Set<ClassRepr> 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<ClassRepr> 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<File> files = new HashSet<File>();
|
||||
final Collection<File> compiled = new HashSet<File>();
|
||||
|
||||
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<File> affected = new HashSet<File>();
|
||||
|
||||
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<Module> chunkModules = c.getElements();
|
||||
|
||||
if (!DefaultGroovyMethods.intersect(modules, chunkModules).isEmpty()) {
|
||||
final Set<StringCache.S> removedSources = new HashSet<StringCache.S>();
|
||||
final Set<String> removedSources = new HashSet<String>();
|
||||
|
||||
if (incremental) {
|
||||
final Set<StringCache.S> chunkSources = new HashSet<StringCache.S>();
|
||||
final Set<StringCache.S> outdatedSources = new HashSet<StringCache.S>();
|
||||
final Set<String> chunkSources = new HashSet<String>();
|
||||
final Set<String> outdatedSources = new HashSet<String>();
|
||||
|
||||
for (Module m : chunkModules) {
|
||||
final ModuleWrapper mw = getModule(m.getName());
|
||||
@@ -1280,7 +1297,7 @@ public class ProjectWrapper {
|
||||
return BuildStatus.FAILURE;
|
||||
}
|
||||
|
||||
final Set<StringCache.S> allFiles = new HashSet<StringCache.S>();
|
||||
final Set<String> allFiles = new HashSet<String>();
|
||||
|
||||
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<File> files = new HashSet<File>();
|
||||
|
||||
for (String f : allFiles) {
|
||||
files.add(new File(f));
|
||||
}
|
||||
|
||||
dependencyMapping.integrate(delta, files, removedSources);
|
||||
|
||||
for (Module m : chunkModules) {
|
||||
Reporter.reportBuildSuccess(m, flags.tests());
|
||||
|
||||
@@ -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<StringCache.S> files, ProjectWrapper pw) {
|
||||
def clearChunk(ModuleChunk chunk, Collection<String> 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<StringCache.S> files, Backend callback, ProjectWrapper pw) {
|
||||
def buildChunk(ModuleChunk chunk, boolean tests, Collection<String> files, Backend callback, ProjectWrapper pw) {
|
||||
Set<ModuleChunk> 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<StringCache.S> files, Backend callback, ProjectWrapper pw) {
|
||||
private def compile(ModuleChunk chunk, boolean tests, Collection<String> files, Backend callback, ProjectWrapper pw) {
|
||||
List<String> 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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<S> 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<String> 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<StringCache.S> classes = state.callback.getClassFiles()
|
||||
final Collection<String> 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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user