mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Better storage dumper for better testing (compile server).
This commit is contained in:
@@ -221,13 +221,32 @@ public abstract class IncrementalTestCase extends TestCase {
|
||||
|
||||
new IncProjectBuilder(
|
||||
projectDescriptor, BuilderRegistry.getInstance(), projectDescriptor.timestamps.getStorage(), Collections.<String, String>emptyMap(), CanceledStatus.NULL,
|
||||
null).build(
|
||||
new AllProjectScope(project, Collections.<Artifact>emptySet(), false), true, false, false
|
||||
);
|
||||
null).build(new AllProjectScope(project, Collections.<Artifact>emptySet(), false), true, false, false);
|
||||
|
||||
final ByteArrayOutputStream makeDump = new ByteArrayOutputStream();
|
||||
|
||||
projectDescriptor.dataManager.getMappings().toStream(new PrintStream(makeDump));
|
||||
|
||||
makeDump.close();
|
||||
|
||||
final String expected = StringUtil.convertLineSeparators(FileUtil.loadFile(new File(getBaseDir() + ".log")));
|
||||
final String actual = javaBuilderLogger.myLog.toString();
|
||||
|
||||
assertEquals(expected, actual);
|
||||
|
||||
new IncProjectBuilder(
|
||||
projectDescriptor, BuilderRegistry.getInstance(), projectDescriptor.timestamps.getStorage(), Collections.<String, String>emptyMap(), CanceledStatus.NULL,
|
||||
null).build(
|
||||
new AllProjectScope(project, Collections.<Artifact>emptySet(), true), false, true, false
|
||||
);
|
||||
|
||||
final ByteArrayOutputStream rebuildDump = new ByteArrayOutputStream();
|
||||
|
||||
projectDescriptor.dataManager.getMappings().toStream(new PrintStream(rebuildDump));
|
||||
|
||||
rebuildDump.close();
|
||||
|
||||
//assertEquals(rebuildDump.toString(), makeDump.toString());
|
||||
}
|
||||
finally {
|
||||
projectDescriptor.release();
|
||||
|
||||
@@ -28,24 +28,41 @@ import java.io.PrintStream;
|
||||
*/
|
||||
abstract class IntIntMaplet implements Streamable {
|
||||
abstract boolean containsKey(final int key);
|
||||
|
||||
abstract int get(final int key);
|
||||
|
||||
abstract void put(final int key, final int value);
|
||||
|
||||
abstract void putAll(IntIntMaplet m);
|
||||
|
||||
abstract void remove(final int key);
|
||||
|
||||
abstract void close();
|
||||
|
||||
abstract void forEachEntry(TIntIntProcedure proc);
|
||||
|
||||
abstract void flush(boolean memoryCachesOnly);
|
||||
|
||||
public void toStream(final DependencyContext context, final PrintStream stream) {
|
||||
final OrderProvider op = new OrderProvider(context);
|
||||
|
||||
forEachEntry(new TIntIntProcedure() {
|
||||
@Override
|
||||
public boolean execute(final int a, final int b) {
|
||||
stream.print(" ");
|
||||
stream.print(context.getValue(a));
|
||||
stream.print(" -> ");
|
||||
stream.println(context.getValue(b));
|
||||
op.register(a);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final int[] keys = op.get();
|
||||
|
||||
for (final int a : keys) {
|
||||
final int b = get(a);
|
||||
|
||||
stream.print(" ");
|
||||
stream.print(context.getValue(a));
|
||||
stream.print(" -> ");
|
||||
stream.println(context.getValue(b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,33 +59,43 @@ abstract class IntIntMultiMaplet implements Streamable {
|
||||
abstract void flush(boolean memoryCachesOnly);
|
||||
|
||||
public void toStream(final DependencyContext context, final PrintStream stream) {
|
||||
final OrderProvider op = new OrderProvider(context);
|
||||
|
||||
forEachEntry(new TIntObjectProcedure<TIntHashSet>() {
|
||||
@Override
|
||||
public boolean execute(final int a, final TIntHashSet b) {
|
||||
stream.print(" Key: ");
|
||||
stream.println(context.getValue(a));
|
||||
stream.println(" Values:");
|
||||
|
||||
final List<String> list = new LinkedList<String>();
|
||||
|
||||
b.forEach(new TIntProcedure() {
|
||||
@Override
|
||||
public boolean execute(final int value) {
|
||||
list.add(context.getValue(value));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
Collections.sort(list);
|
||||
|
||||
for (final String l : list) {
|
||||
stream.print(" ");
|
||||
stream.println(l);
|
||||
}
|
||||
|
||||
stream.println(" End Of Values");
|
||||
op.register(a);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final int[] keys = op.get();
|
||||
|
||||
for (final int a : keys) {
|
||||
final TIntHashSet b = get(a);
|
||||
|
||||
stream.print(" Key: ");
|
||||
stream.println(context.getValue(a));
|
||||
stream.println(" Values:");
|
||||
|
||||
final List<String> list = new LinkedList<String>();
|
||||
|
||||
b.forEach(new TIntProcedure() {
|
||||
@Override
|
||||
public boolean execute(final int value) {
|
||||
list.add(context.getValue(value));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
Collections.sort(list);
|
||||
|
||||
for (final String l : list) {
|
||||
stream.print(" ");
|
||||
stream.println(l);
|
||||
}
|
||||
|
||||
stream.println(" End Of Values");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,33 +59,42 @@ abstract class IntObjectMultiMaplet<V extends Streamable> implements Streamable
|
||||
abstract void flush(boolean memoryCachesOnly);
|
||||
|
||||
public void toStream(final DependencyContext context, final PrintStream stream) {
|
||||
final OrderProvider op = new OrderProvider(context);
|
||||
|
||||
forEachEntry(new TIntObjectProcedure<Collection<V>>() {
|
||||
@Override
|
||||
public boolean execute(final int a, final Collection<V> b) {
|
||||
stream.print(" Key: ");
|
||||
stream.println(context.getValue(a));
|
||||
stream.println(" Values:");
|
||||
|
||||
final List<String> list = new LinkedList<String> ();
|
||||
|
||||
for (final V value : b) {
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final PrintStream s = new PrintStream(baos);
|
||||
|
||||
value.toStream(context, s);
|
||||
|
||||
list.add(baos.toString());
|
||||
}
|
||||
|
||||
Collections.sort(list);
|
||||
|
||||
for (final String l : list) {
|
||||
stream.print(l);
|
||||
}
|
||||
|
||||
stream.println(" End Of Values");
|
||||
op.register(a);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
final int[] keys = op.get();
|
||||
|
||||
for (final int a : keys) {
|
||||
final Collection<V> b = get(a);
|
||||
stream.print(" Key: ");
|
||||
stream.println(context.getValue(a));
|
||||
stream.println(" Values:");
|
||||
|
||||
final List<String> list = new LinkedList<String>();
|
||||
|
||||
for (final V value : b) {
|
||||
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
final PrintStream s = new PrintStream(baos);
|
||||
|
||||
value.toStream(context, s);
|
||||
|
||||
list.add(baos.toString());
|
||||
}
|
||||
|
||||
Collections.sort(list);
|
||||
|
||||
for (final String l : list) {
|
||||
stream.print(l);
|
||||
}
|
||||
|
||||
stream.println(" End Of Values");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1934,14 +1934,18 @@ public class Mappings {
|
||||
}
|
||||
}
|
||||
|
||||
private void cleanupRemovedClass(@NotNull ClassRepr cr,
|
||||
Collection<UsageRepr.Cluster> clusters,
|
||||
IntIntMultiMaplet subclassesTrashBin,
|
||||
IntIntMultiMaplet dependenciesTrashBin) {
|
||||
private void cleanupRemovedClass(final Mappings delta,
|
||||
@NotNull final ClassRepr cr,
|
||||
final Collection<UsageRepr.Cluster> clusters,
|
||||
final IntIntMultiMaplet dependenciesTrashBin) {
|
||||
final int className = cr.name;
|
||||
|
||||
//for (final int superSomething : cr.getSupers()) {
|
||||
// subclassesTrashBin.put(superSomething, className);
|
||||
//}
|
||||
|
||||
for (final int superSomething : cr.getSupers()) {
|
||||
subclassesTrashBin.put(superSomething, className);
|
||||
delta.registerRemovedSuperClass(className, superSomething);
|
||||
}
|
||||
|
||||
cleanupBackDependency(className, clusters, dependenciesTrashBin);
|
||||
@@ -1961,7 +1965,7 @@ public class Mappings {
|
||||
delta.runPostPasses();
|
||||
|
||||
final IntIntMultiMaplet dependenciesTrashBin = new IntIntTransientMultiMaplet();
|
||||
final IntIntMultiMaplet subclassesTrashBin = new IntIntTransientMultiMaplet();
|
||||
//final IntIntMultiMaplet subclassesTrashBin = new IntIntTransientMultiMaplet();
|
||||
|
||||
if (removed != null) {
|
||||
for (final String file : removed) {
|
||||
@@ -1971,7 +1975,7 @@ public class Mappings {
|
||||
|
||||
if (fileClasses != null) {
|
||||
for (final ClassRepr aClass : fileClasses) {
|
||||
cleanupRemovedClass(aClass, fileUsages, subclassesTrashBin, dependenciesTrashBin);
|
||||
cleanupRemovedClass(delta, aClass, fileUsages, dependenciesTrashBin);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1993,17 +1997,17 @@ public class Mappings {
|
||||
});
|
||||
|
||||
for (ClassRepr repr : delta.getDeletedClasses()) {
|
||||
cleanupRemovedClass(repr, null, subclassesTrashBin, dependenciesTrashBin);
|
||||
cleanupRemovedClass(delta, repr, null, dependenciesTrashBin);
|
||||
}
|
||||
|
||||
subclassesTrashBin.forEachEntry(new TIntObjectProcedure<TIntHashSet>() {
|
||||
@Override
|
||||
public boolean execute(int aClass, TIntHashSet deps) {
|
||||
myClassToSubclasses.removeAll(aClass, deps);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
subclassesTrashBin.close();
|
||||
//subclassesTrashBin.forEachEntry(new TIntObjectProcedure<TIntHashSet>() {
|
||||
// @Override
|
||||
// public boolean execute(int aClass, TIntHashSet deps) {
|
||||
// myClassToSubclasses.removeAll(aClass, deps);
|
||||
// return true;
|
||||
// }
|
||||
//});
|
||||
//subclassesTrashBin.close();
|
||||
|
||||
delta.getChangedClasses().forEach(new TIntProcedure() {
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.jetbrains.ether.dependencyView;
|
||||
|
||||
import org.intellij.lang.annotations.JdkConstants;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created with IntelliJ IDEA.
|
||||
* User: db
|
||||
* Date: 24.06.12
|
||||
* Time: 19:08
|
||||
* To change this template use File | Settings | File Templates.
|
||||
*/
|
||||
class OrderProvider {
|
||||
private class Entry implements Comparable<Entry> {
|
||||
final String myString;
|
||||
final int myInt;
|
||||
|
||||
private Entry(int anInt) {
|
||||
myInt = anInt;
|
||||
myString = myContext.getValue(anInt);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final Entry o) {
|
||||
return o.myString.compareTo(myString);
|
||||
}
|
||||
}
|
||||
private final DependencyContext myContext;
|
||||
private final List<Entry> myList = new LinkedList<Entry>();
|
||||
|
||||
OrderProvider(final DependencyContext context) {
|
||||
myContext = context;
|
||||
}
|
||||
|
||||
void register (final int key) {
|
||||
myList.add(new Entry(key));
|
||||
}
|
||||
|
||||
int[] get() {
|
||||
Collections.sort(myList);
|
||||
|
||||
final int[] result = new int[myList.size()];
|
||||
int i = 0;
|
||||
|
||||
for (final Entry e : myList) {
|
||||
result[i++] = e.myInt;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user