Teach index working with source roots with package prefix

#KT-9167 Fixed

Original commit: 23e35ab112
This commit is contained in:
Nikolay Krasko
2015-11-08 20:58:55 +03:00
committed by Nikolay Krasko
parent 048725c3f0
commit b77f4ffe9f
16 changed files with 162 additions and 0 deletions
@@ -225,6 +225,19 @@ public class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
checkWhen(touch("src/test1.kt"), null, packageClasses("kotlinProject", "src/test1.kt", "Test1Kt"))
}
public fun testSourcePackagePrefix() {
doTest()
}
public fun testSourcePackageLongPrefix() {
initProject()
val buildResult = makeAll()
buildResult.assertSuccessful()
val warnings = buildResult.getMessages(BuildMessage.Kind.WARNING)
assertEquals("Warning about invalid package prefix in module 2 is expected: $warnings", 2, warnings.size)
assertEquals("Invalid package prefix name is ignored: invalid-prefix.test", warnings.first().messageText)
}
public fun testKotlinJavaScriptProject() {
initProject()
addKotlinJavaScriptStdlibDependency()
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<annotationProcessing>
<profile default="true" name="Default" enabled="false">
<processorPath useClasspath="true" />
</profile>
</annotationProcessing>
</component>
<component name="CopyrightManager" default="">
<module2copyright />
</component>
<component name="DependencyValidationManager">
<option name="SKIP_IMPORT_STATEMENTS" value="false" />
</component>
<component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/module1/module1.iml" filepath="$PROJECT_DIR$/module1/module1.iml" />
<module fileurl="file://$PROJECT_DIR$/module2/module2.iml" filepath="$PROJECT_DIR$/module2/module2.iml" />
</modules>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA_JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="" />
</component>
</project>
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="good.prefix" />
</content>
<orderEntry type="jdk" jdkName="IDEA_JDK" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="KotlinRuntime" level="project" />
</component>
</module>
@@ -0,0 +1,6 @@
package good.prefix;
public class JavaDependency {
public void bar() {}
}
@@ -0,0 +1,6 @@
package good.prefix;
public class JavaTest extends JavaDependency {
}
@@ -0,0 +1,4 @@
package bad.prefix
class KotlinTestInBadPrefix
@@ -0,0 +1,3 @@
package good.prefix
class KotlinTestInGoodPrefix
@@ -0,0 +1,9 @@
package test.other
import bad.prefix.KotlinTestInBadPrefix
import good.prefix.KotlinTestInGoodPrefix
import good.prefix.JavaTest;
val goodTest = KotlinTestInGoodPrefix()
val badTest = KotlinTestInBadPrefix()
val javaTest = JavaTest().bar()
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="invalid-prefix.test"/>
</content>
<orderEntry type="jdk" jdkName="IDEA_JDK" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="module1" />
<orderEntry type="library" name="KotlinRuntime" level="project" />
</component>
</module>
@@ -0,0 +1,13 @@
package some
import bad.prefix.KotlinTestInBadPrefix
import good.prefix.KotlinTestInGoodPrefix
import good.prefix.JavaTest;
import test.JavaRef
val goodTest = KotlinTestInGoodPrefix()
val badTest = KotlinTestInBadPrefix()
val javaTest = JavaTest().bar()
val javaRef = JavaRef().foo(null)
@@ -0,0 +1,9 @@
package test;
import good.prefix.JavaTest;
public class JavaRef {
public void foo(JavaTest javaTest) {
}
}
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="xxx"/>
</content>
<orderEntry type="jdk" jdkName="IDEA_JDK" jdkType="JavaSDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module" module-name="kotlinProject" />
</component>
</module>
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
</component>
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/kotlinProject.iml" filepath="$PROJECT_DIR$/kotlinProject.iml" />
</modules>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="IDEA_JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
@@ -0,0 +1,4 @@
package xxx;
public class OtherJava {
}
@@ -0,0 +1,7 @@
package xxx;
public class Test {
String test(OtherJava otherJava) {
return "";
}
}
@@ -0,0 +1,3 @@
package xxx
val test = Test().test(null)