CompilerReferenceServiceImpl: allow multiple threads processing; do not search inheri...
[idea/community.git] / jps / jps-builders / testSrc / org / jetbrains / references / ReferenceIndexTest.kt
1 /*
2  * Copyright 2000-2016 JetBrains s.r.o.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.jetbrains.references
17
18 import com.intellij.openapi.application.ex.PathManagerEx
19 import com.intellij.openapi.util.io.FileUtil
20
21 class ReferenceIndexTest : ReferenceIndexTestBase() {
22   override fun getTestDataRootPath(): String {
23     return FileUtil.toCanonicalPath(PathManagerEx.findFileUnderCommunityHome("jps/jps-builders/testData/referencesIndex").absolutePath, '/')
24   }
25
26   fun testIncrementalIndexUpdate() {
27     assertIndexOnRebuild("Bar.java", "Foo.java", "FooImpl.java")
28     changeFileContent("Bar.java", "Bar_1.java")
29     buildAllModules()
30     assertIndexEquals("afterMakeIndex.txt")
31     changeFileContent("FooImpl.java", "FooImpl_2.java")
32     buildAllModules()
33     assertIndexEquals("afterSecondMakeIndex.txt")
34   }
35
36   fun testFileCaseOnlyRename() {
37     assertIndexOnRebuild("Bar.java")
38     renameFile("Bar.java", "bar.java")
39     buildAllModules()
40     assertIndexEquals("afterRename.txt")
41   }
42
43   fun testUnusedImports() {
44     assertIndexOnRebuild("Bar.java")
45   }
46
47   fun testUnusedImports2() {
48     assertIndexOnRebuild("Main.java",
49                          "com/ru/Some.java",
50                          "com/ru/Some2.java",
51                          "com/ru/Some3.java")
52   }
53
54   fun testDeadCode() {
55     assertIndexOnRebuild("Bar.java")
56   }
57
58   fun testPackageInfo() {
59     assertIndexOnRebuild("myPackage/package-info.java")
60   }
61
62   fun testArrayRefs() {
63     assertIndexOnRebuild("Array.java", "Foo.java", "Bar.java")
64   }
65
66   fun testTypeParameterRefs() {
67     assertIndexOnRebuild("TypeParam.java")
68   }
69
70   fun testAnonymous() {
71     assertIndexOnRebuild("Anonymous.java")
72   }
73
74   fun testPrivateMembers() {
75     assertIndexOnRebuild("PrivateMembers.java")
76   }
77
78   fun testClassDeleted() {
79     assertIndexOnRebuild("Foo.java")
80     changeFileContent("Foo.java", "Foo_1.java")
81     buildAllModules()
82     assertIndexEquals("classDeletedIndex.txt")
83   }
84
85   fun testFileDeleted() {
86     assertIndexOnRebuild("Foo.java", "Bar.java")
87     changeFileContent("Foo.java", "Foo_1.java")
88     deleteFile("m/Bar.java")
89     buildAllModules()
90     assertIndexEquals("fileDeletedIndex.txt")
91   }
92 }
93