move javac reference collector to jps-builders-6

This commit is contained in:
Dmitry Batkovich
2016-12-28 13:20:27 +03:00
parent fda0373248
commit 30eb3ad623
9 changed files with 24 additions and 22 deletions
@@ -19,9 +19,6 @@ import com.intellij.util.Consumer;
import com.sun.source.tree.*;
import com.sun.source.util.*;
import com.sun.tools.javac.util.ClientCodeException;
import gnu.trove.THashMap;
import gnu.trove.THashSet;
import gnu.trove.TObjectHashingStrategy;
import org.jetbrains.jps.javac.ast.api.JavacDef;
import org.jetbrains.jps.javac.ast.api.JavacFileData;
import org.jetbrains.jps.javac.ast.api.JavacNameTable;
@@ -48,7 +45,7 @@ final class JavacReferenceCollectorListener implements TaskListener {
private final Trees myTreeUtility;
private final JavacNameTable myNameTableCache;
private final Map<String, ReferenceCollector> myIncompletelyProcessedFiles = new THashMap<String, ReferenceCollector>(10);
private final Map<String, ReferenceCollector> myIncompletelyProcessedFiles = new HashMap<String, ReferenceCollector>(10);
static void installOn(JavaCompiler.CompilationTask task,
boolean divideImportRefs,
@@ -245,17 +242,7 @@ final class JavacReferenceCollectorListener implements TaskListener {
}
private static Set<JavacRef> createReferenceHolder() {
return new THashSet<JavacRef>(new TObjectHashingStrategy<JavacRef>() {
@Override
public int computeHashCode(JavacRef ref) {
return ((JavacRef.JavacElementRefBase) ref).getOriginalElement().hashCode();
}
@Override
public boolean equals(JavacRef r1, JavacRef r2) {
return ((JavacRef.JavacElementRefBase) r1).getOriginalElement() == ((JavacRef.JavacElementRefBase) r2).getOriginalElement();
}
});
return new HashSet<JavacRef>();
}
private static List<JavacDef> createDefinitionHolder() {
@@ -16,8 +16,8 @@
package org.jetbrains.jps.javac.ast.api;
import com.intellij.openapi.util.ThrowableComputable;
import com.intellij.openapi.util.io.DataInputOutputUtilRt;
import com.intellij.util.ThrowableConsumer;
import com.intellij.util.io.DataInputOutputUtil;
import org.jetbrains.annotations.NotNull;
import javax.lang.model.element.Modifier;
@@ -96,7 +96,7 @@ public class JavacFileData {
}
private static void saveRefs(final DataOutput out, Collection<JavacRef> refs) throws IOException {
DataInputOutputUtil.writeSeq(out, refs, new ThrowableConsumer<JavacRef, IOException>() {
DataInputOutputUtilRt.writeSeq(out, refs, new ThrowableConsumer<JavacRef, IOException>() {
@Override
public void consume(JavacRef ref) throws IOException {
writeJavacRef(out, ref);
@@ -105,7 +105,7 @@ public class JavacFileData {
}
private static Collection<JavacRef> readRefs(final DataInput in) throws IOException {
return DataInputOutputUtil.readSeq(in, new ThrowableComputable<JavacRef, IOException>() {
return DataInputOutputUtilRt.readSeq(in, new ThrowableComputable<JavacRef, IOException>() {
@Override
public JavacRef compute() throws IOException {
return readJavacRef(in);
@@ -114,7 +114,7 @@ public class JavacFileData {
}
private static void saveDefs(final DataOutput out, List<JavacDef> defs) throws IOException {
DataInputOutputUtil.writeSeq(out, defs, new ThrowableConsumer<JavacDef, IOException>() {
DataInputOutputUtilRt.writeSeq(out, defs, new ThrowableConsumer<JavacDef, IOException>() {
@Override
public void consume(JavacDef def) throws IOException {
writeJavacDef(out, def);
@@ -123,7 +123,7 @@ public class JavacFileData {
}
private static List<JavacDef> readDefs(final DataInput in) throws IOException {
return DataInputOutputUtil.readSeq(in, new ThrowableComputable<JavacDef, IOException>() {
return DataInputOutputUtilRt.readSeq(in, new ThrowableComputable<JavacDef, IOException>() {
@Override
public JavacDef compute() throws IOException {
return readJavacDef(in);
@@ -202,7 +202,7 @@ public class JavacFileData {
}
private static void writeModifiers(final DataOutput output, Set<Modifier> modifiers) throws IOException {
DataInputOutputUtil.writeSeq(output, modifiers, new ThrowableConsumer<Modifier, IOException>() {
DataInputOutputUtilRt.writeSeq(output, modifiers, new ThrowableConsumer<Modifier, IOException>() {
@Override
public void consume(Modifier modifier) throws IOException {
output.writeUTF(modifier.name());
@@ -211,7 +211,7 @@ public class JavacFileData {
}
private static Set<Modifier> readModifiers(final DataInput input) throws IOException {
final List<Modifier> modifierList = DataInputOutputUtil.readSeq(input, new ThrowableComputable<Modifier, IOException>() {
final List<Modifier> modifierList = DataInputOutputUtilRt.readSeq(input, new ThrowableComputable<Modifier, IOException>() {
@Override
public Modifier compute() throws IOException {
return Modifier.valueOf(input.readUTF());
@@ -161,6 +161,21 @@ public interface JavacRef {
}
throw new AssertionError("unexpected element: " + element + " class: " + element.getClass());
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
JavacElementRefBase base = (JavacElementRefBase)o;
return myOriginalElement == base.myOriginalElement;
}
@Override
public int hashCode() {
return myOriginalElement.hashCode();
}
}
class JavacElementClassImpl extends JavacElementRefBase implements JavacClass {