mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
javac ast indices: add tests for signature index
This commit is contained in:
@@ -13,4 +13,6 @@ java.lang.Thread.<init>(1) in Lambda occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Lambda in Lambda
|
||||
fun_expr(id=0) in Lambda
|
||||
fun_expr(id=0) in Lambda
|
||||
|
||||
Members Signatures:
|
||||
@@ -15,4 +15,6 @@ java.util.Collections.emptyList(0) in MethodReference occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
MethodReference in MethodReference
|
||||
fun_expr(id=0) in MethodReference
|
||||
fun_expr(id=0) in MethodReference
|
||||
|
||||
Members Signatures:
|
||||
@@ -17,4 +17,6 @@ java.lang.annotation.Target in Foo occurrences = 2
|
||||
java.lang.annotation.Target.value(0) in Foo occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Foo in Foo
|
||||
Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
@@ -13,4 +13,6 @@ java.lang.Runnable.run(0) in Anonymous occurrences = 2
|
||||
|
||||
Class Definitions:
|
||||
Anonymous in Anonymous
|
||||
anonymous(id=0) in Anonymous
|
||||
anonymous(id=0) in Anonymous
|
||||
|
||||
Members Signatures:
|
||||
@@ -14,4 +14,6 @@ java.lang.Object.<init>(0) in Array Bar Foo occurrences = 3
|
||||
Class Definitions:
|
||||
Array in Array
|
||||
Bar in Bar
|
||||
Foo in Foo
|
||||
Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
@@ -7,4 +7,6 @@ Foo.<init>(0) in Foo occurrences = 1
|
||||
java.lang.Object.<init>(0) in Foo occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Foo in Foo
|
||||
Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
@@ -14,4 +14,6 @@ java.lang.Runnable in Foo occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Foo in Foo
|
||||
Foo$Inner in Foo
|
||||
Foo$Inner in Foo
|
||||
|
||||
Members Signatures:
|
||||
+3
-1
@@ -15,4 +15,6 @@ java.util.Collections.emptySet(0) in Foo occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Boo in Foo
|
||||
Foo in Foo
|
||||
Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
@@ -13,4 +13,6 @@ java.util.LinkedList.<init>(0) in Foo occurrences = 2
|
||||
java.util.List in Foo occurrences = 5
|
||||
|
||||
Class Definitions:
|
||||
Foo in Foo
|
||||
Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
@@ -14,4 +14,6 @@ java.util.ArrayList in Bar occurrences = 1
|
||||
java.util.ArrayList.<init>(0) in Bar occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Bar in Bar
|
||||
Bar in Bar
|
||||
|
||||
Members Signatures:
|
||||
@@ -11,4 +11,6 @@ java.lang.System in bar occurrences = 1
|
||||
java.lang.System.out in bar occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Inner in bar
|
||||
Inner in bar
|
||||
|
||||
Members Signatures:
|
||||
@@ -11,4 +11,6 @@ java.lang.System in Bar occurrences = 1
|
||||
java.lang.System.out in Bar occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Inner in Bar
|
||||
Inner in Bar
|
||||
|
||||
Members Signatures:
|
||||
@@ -8,4 +8,6 @@ Foo.m(0) in Foo occurrences = 1
|
||||
java.lang.Object.<init>(0) in Foo occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Foo in Foo
|
||||
Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
@@ -12,4 +12,6 @@ java.lang.Object.<init>(0) in Bar Foo occurrences = 2
|
||||
|
||||
Class Definitions:
|
||||
Bar in Bar
|
||||
Foo in Foo
|
||||
Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
@@ -18,4 +18,8 @@ java.lang.String in Foo FooImpl occurrences = 3
|
||||
Class Definitions:
|
||||
Bar in Bar
|
||||
Foo in Foo
|
||||
FooImpl in FooImpl
|
||||
FooImpl in FooImpl
|
||||
|
||||
Members Signatures:
|
||||
java.lang.String <- Foo.getSomeText(0) FooImpl.getSomeText(0)
|
||||
static java.lang.String <- FooImpl.TITLE
|
||||
+5
-1
@@ -17,4 +17,8 @@ java.lang.String in Foo FooImpl occurrences = 3
|
||||
Class Definitions:
|
||||
Bar in Bar
|
||||
Foo in Foo
|
||||
FooImpl in FooImpl
|
||||
FooImpl in FooImpl
|
||||
|
||||
Members Signatures:
|
||||
java.lang.String <- Foo.getSomeText(0) FooImpl.getSomeText(0)
|
||||
static java.lang.String <- FooImpl.TITLE
|
||||
@@ -21,4 +21,8 @@ java.lang.System.out in Bar occurrences = 2
|
||||
Class Definitions:
|
||||
Bar in Bar
|
||||
Foo in Foo
|
||||
FooImpl in FooImpl
|
||||
FooImpl in FooImpl
|
||||
|
||||
Members Signatures:
|
||||
java.lang.String <- Foo.getSomeText(0) FooImpl.getSomeText(0)
|
||||
static java.lang.String <- FooImpl.TITLE
|
||||
+3
-1
@@ -10,4 +10,6 @@ java.util.Collections in Foo occurrences = 2
|
||||
java.util.Collections.emptySet(0) in Foo occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Foo in Foo
|
||||
Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
+3
-1
@@ -10,4 +10,6 @@ java.util.Collections in Bar occurrences = 2
|
||||
java.util.Collections.emptySet(0) in Bar occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Foo in Bar
|
||||
Foo in Bar
|
||||
|
||||
Members Signatures:
|
||||
@@ -12,4 +12,6 @@ java.util.Collections.emptyList(0) in Foo occurrences = 1
|
||||
java.util.List in Foo occurrences = 2
|
||||
|
||||
Class Definitions:
|
||||
Foo in Foo
|
||||
Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
+3
-1
@@ -15,4 +15,6 @@ java.util.Collections.emptySet(0) in Bar occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Bar in Bar
|
||||
Foo in Foo
|
||||
Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
@@ -15,4 +15,6 @@ java.util.Collections.emptySet(0) in Foo occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Bar in Foo
|
||||
Foo in Foo
|
||||
Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
+3
-1
@@ -32,4 +32,6 @@ Bar1 in Bar
|
||||
Boo0 in Boo
|
||||
Boo1 in Boo
|
||||
Foo0 in Foo
|
||||
Foo1 in Foo
|
||||
Foo1 in Foo
|
||||
|
||||
Members Signatures:
|
||||
@@ -25,4 +25,6 @@ Class Definitions:
|
||||
Boo in Foo
|
||||
Boo$Baz in Foo
|
||||
Foo in Foo
|
||||
Foo$Bar in Foo
|
||||
Foo$Bar in Foo
|
||||
|
||||
Members Signatures:
|
||||
@@ -19,4 +19,6 @@ java.util.ArrayList.size(0) in Bar Foo occurrences = 6
|
||||
|
||||
Class Definitions:
|
||||
Bar in Bar
|
||||
Foo in Foo
|
||||
Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
@@ -8,4 +8,6 @@ myPackage.A in package-info occurrences = 1
|
||||
myPackage.A.<init>(0) in package-info occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
myPackage.A in package-info
|
||||
myPackage.A in package-info
|
||||
|
||||
Members Signatures:
|
||||
@@ -4,4 +4,7 @@ Backward Hierarchy:
|
||||
Backward References:
|
||||
java.lang.Deprecated in package-info occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Class Definitions:
|
||||
|
||||
|
||||
Members Signatures:
|
||||
@@ -8,4 +8,6 @@ java.lang.Object.<init>(0) in PrivateMembers occurrences = 2
|
||||
|
||||
Class Definitions:
|
||||
PrivateMembers in PrivateMembers
|
||||
PrivateMembers$PrivateInnerClass in PrivateMembers
|
||||
PrivateMembers$PrivateInnerClass in PrivateMembers
|
||||
|
||||
Members Signatures:
|
||||
@@ -15,4 +15,6 @@ java.util.ArrayList.<init>(0) in Foo occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
ArrayListImpl in Foo
|
||||
Foo in Foo
|
||||
Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
@@ -0,0 +1,17 @@
|
||||
import java.util.List;
|
||||
|
||||
public class Foo {
|
||||
|
||||
public String m1() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<String> m2() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public List m3() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
Backward Hierarchy:
|
||||
java.lang.Object -> Foo
|
||||
|
||||
Backward References:
|
||||
Foo in Foo occurrences = 1
|
||||
Foo.<init>(0) in Foo occurrences = 1
|
||||
Foo.m1(0) in Foo occurrences = 1
|
||||
Foo.m2(0) in Foo occurrences = 1
|
||||
Foo.m3(0) in Foo occurrences = 1
|
||||
java.lang.Object.<init>(0) in Foo occurrences = 1
|
||||
java.lang.String in Foo occurrences = 2
|
||||
java.util.List in Foo occurrences = 3
|
||||
|
||||
Class Definitions:
|
||||
Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
java.lang.String <- Foo.m1(0)
|
||||
java.util.List <- Foo.m3(0)
|
||||
static java.util.List <- Foo.m2(0)
|
||||
+3
-1
@@ -14,4 +14,6 @@ pack.Foo.CONST in Bar Foo occurrences = 2
|
||||
|
||||
Class Definitions:
|
||||
pack.Bar in Bar
|
||||
pack.Foo in Foo
|
||||
pack.Foo in Foo
|
||||
|
||||
Members Signatures:
|
||||
@@ -10,4 +10,6 @@ java.lang.String in TypeParam occurrences = 1
|
||||
java.util.List in TypeParam occurrences = 2
|
||||
|
||||
Class Definitions:
|
||||
TypeParam in TypeParam
|
||||
TypeParam in TypeParam
|
||||
|
||||
Members Signatures:
|
||||
+3
-1
@@ -12,4 +12,6 @@ java.lang.Object.<init>(0) in Foo occurrences = 2
|
||||
|
||||
Class Definitions:
|
||||
A in Foo
|
||||
A$B in Foo
|
||||
A$B in Foo
|
||||
|
||||
Members Signatures:
|
||||
+3
-1
@@ -12,4 +12,6 @@ java.lang.Object.<init>(0) in Foo occurrences = 2
|
||||
|
||||
Class Definitions:
|
||||
A in Foo
|
||||
A$B in Foo
|
||||
A$B in Foo
|
||||
|
||||
Members Signatures:
|
||||
+3
-1
@@ -13,4 +13,6 @@ java.lang.Runnable.run(0) in Foo occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
A in Foo
|
||||
anonymous(id=0) in Foo
|
||||
anonymous(id=0) in Foo
|
||||
|
||||
Members Signatures:
|
||||
+3
-1
@@ -13,4 +13,6 @@ java.lang.Runnable.run(0) in Foo occurrences = 2
|
||||
|
||||
Class Definitions:
|
||||
A in Foo
|
||||
anonymous(id=0) in Foo
|
||||
anonymous(id=0) in Foo
|
||||
|
||||
Members Signatures:
|
||||
+3
-1
@@ -13,4 +13,6 @@ java.lang.Runnable.run(0) in Foo occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
A in Foo
|
||||
anonymous(id=0) in Foo
|
||||
anonymous(id=0) in Foo
|
||||
|
||||
Members Signatures:
|
||||
@@ -13,4 +13,6 @@ java.util.LinkedList in Bar occurrences = 1
|
||||
java.util.List in Bar occurrences = 1
|
||||
|
||||
Class Definitions:
|
||||
Bar in Bar
|
||||
Bar in Bar
|
||||
|
||||
Members Signatures:
|
||||
@@ -36,4 +36,6 @@ com.ru.Some$I1$I2$I3 in Some
|
||||
com.ru.Some2 in Some2
|
||||
com.ru.Some2$I1 in Some2
|
||||
com.ru.Some2$I1$I2 in Some2
|
||||
com.ru.Some3 in Some3
|
||||
com.ru.Some3 in Some3
|
||||
|
||||
Members Signatures:
|
||||
@@ -165,5 +165,9 @@ class ReferenceIndexTest : ReferenceIndexTestBase() {
|
||||
fun testQualifierResolution() {
|
||||
assertIndexOnRebuild("Foo.java")
|
||||
}
|
||||
|
||||
fun testSignatureDataIndex() {
|
||||
assertIndexOnRebuild("Foo.java")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,7 @@ import com.intellij.util.indexing.ID
|
||||
import com.intellij.util.indexing.impl.MapIndexStorage
|
||||
import com.intellij.util.indexing.impl.MapReduceIndex
|
||||
import com.intellij.util.io.PersistentStringEnumerator
|
||||
import org.jetbrains.jps.backwardRefs.BackwardReferenceIndexWriter
|
||||
import org.jetbrains.jps.backwardRefs.CompilerBackwardReferenceIndex
|
||||
import org.jetbrains.jps.backwardRefs.LightRef
|
||||
import org.jetbrains.jps.backwardRefs.NameEnumerator
|
||||
import org.jetbrains.jps.backwardRefs.*
|
||||
import org.jetbrains.jps.backwardRefs.index.CompiledFileData
|
||||
import org.jetbrains.jps.backwardRefs.index.CompilerIndices
|
||||
import org.jetbrains.jps.builders.JpsBuildTestCase
|
||||
@@ -145,6 +142,24 @@ abstract class ReferenceIndexTestBase : JpsBuildTestCase() {
|
||||
classDefs.sort()
|
||||
result.append(classDefs.joinToString(separator = "\n"))
|
||||
|
||||
result.append("\n\nMembers Signatures:\n")
|
||||
val signs = mutableListOf<String>()
|
||||
storage(index, CompilerIndices.BACK_MEMBER_SIGN).processKeys { sign ->
|
||||
val definedMembers = mutableListOf<String>()
|
||||
val valueIt = index[CompilerIndices.BACK_MEMBER_SIGN].getData(sign).valueIterator
|
||||
while (valueIt.hasNext()) {
|
||||
val nextRefs = valueIt.next()
|
||||
nextRefs.mapTo(definedMembers) { it.asText(nameEnumerator) }
|
||||
}
|
||||
if (!definedMembers.isEmpty()) {
|
||||
definedMembers.sort()
|
||||
signs.add(sign.asText(nameEnumerator) + " <- " + definedMembers.joinToString(separator = " "))
|
||||
}
|
||||
true
|
||||
}
|
||||
signs.sort()
|
||||
result.append(signs.joinToString(separator = "\n"))
|
||||
|
||||
return result.toString()
|
||||
}
|
||||
finally {
|
||||
@@ -169,5 +184,9 @@ abstract class ReferenceIndexTestBase : JpsBuildTestCase() {
|
||||
else -> throw UnsupportedOperationException()
|
||||
}
|
||||
|
||||
private fun SignatureData.asText(nameEnumerator: NameEnumerator): String {
|
||||
return (if (this.isStatic) "static " else "") + this.rawReturnType.asName(nameEnumerator)
|
||||
}
|
||||
|
||||
private fun Int.asFileName(fileNameEnumerator: PersistentStringEnumerator) = FileUtil.getNameWithoutExtension(File(fileNameEnumerator.valueOf(this)).canonicalFile)
|
||||
}
|
||||
Reference in New Issue
Block a user