mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-03-28 00:21:29 +00:00
Compare commits
133 Commits
rr/mitropo
...
1.2-Beta2_
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1cda2cbeff | ||
|
|
0801cc12da | ||
|
|
ba045e44fb | ||
|
|
6193b9951b | ||
|
|
69f3059eef | ||
|
|
6d654a0711 | ||
|
|
d9fbb62dc3 | ||
|
|
65770b9a5a | ||
|
|
07b2250cc8 | ||
|
|
99ddd42c97 | ||
|
|
a68072dab2 | ||
|
|
9c2677a6f5 | ||
|
|
fde043fa61 | ||
|
|
b1cd98245c | ||
|
|
c167e7735b | ||
|
|
d2978182b8 | ||
|
|
e5dfb3ee06 | ||
|
|
a158d34d13 | ||
|
|
c7163fe124 | ||
|
|
30aa7ae77a | ||
|
|
85a001bc5a | ||
|
|
69d8a5cae9 | ||
|
|
34bcca1a95 | ||
|
|
3992398be3 | ||
|
|
728febaf21 | ||
|
|
1568f3ad0c | ||
|
|
189aff5138 | ||
|
|
511b55e397 | ||
|
|
6f5a3c5101 | ||
|
|
2c6b5ec905 | ||
|
|
661813556f | ||
|
|
4202a65510 | ||
|
|
36a9670800 | ||
|
|
492d191fc8 | ||
|
|
1a1fbdbe83 | ||
|
|
7f4519ba28 | ||
|
|
e65d41d33f | ||
|
|
03ae8c8442 | ||
|
|
bc23043d96 | ||
|
|
a85dd13753 | ||
|
|
95ff751fe4 | ||
|
|
c21aff0ced | ||
|
|
c5d97c55ed | ||
|
|
dddc700cce | ||
|
|
f1ae903e6a | ||
|
|
5a21c11806 | ||
|
|
08bc3cbf0d | ||
|
|
c075a5ff75 | ||
|
|
1fec7c6358 | ||
|
|
e6b989b84a | ||
|
|
efd1300d0c | ||
|
|
fbd61a895d | ||
|
|
d60b13002c | ||
|
|
72801d0810 | ||
|
|
bbbd789f1b | ||
|
|
06951e3dbc | ||
|
|
d818d5e9c3 | ||
|
|
95d154cfe9 | ||
|
|
b7fd941468 | ||
|
|
f8453b7696 | ||
|
|
f6f5bc1274 | ||
|
|
2bcc6aaff8 | ||
|
|
b7d9480cdf | ||
|
|
bb70f582d0 | ||
|
|
eab5312387 | ||
|
|
6c42942753 | ||
|
|
6e6569f378 | ||
|
|
6335ec6d21 | ||
|
|
3333a6b596 | ||
|
|
30bae3dc83 | ||
|
|
ec47cd4c5e | ||
|
|
dae3d4fdb8 | ||
|
|
53aadf955a | ||
|
|
09e6e65071 | ||
|
|
ffd1bad6f5 | ||
|
|
198d44cc00 | ||
|
|
b42fc74411 | ||
|
|
787838dcac | ||
|
|
f2882bac06 | ||
|
|
3b36c29b1b | ||
|
|
01f6afe562 | ||
|
|
54fb4e0701 | ||
|
|
2bef6f2443 | ||
|
|
f14a8a51ca | ||
|
|
f41b12123d | ||
|
|
f8f294fa5c | ||
|
|
576d7fc112 | ||
|
|
2caf79ea33 | ||
|
|
ca128161f3 | ||
|
|
8c7b24b87d | ||
|
|
404dc24805 | ||
|
|
1bfa324fb0 | ||
|
|
2951d4563c | ||
|
|
c30564ae6b | ||
|
|
4044e66554 | ||
|
|
892423f3a0 | ||
|
|
a797d59fa5 | ||
|
|
6f3da6087f | ||
|
|
3bc5dab252 | ||
|
|
c4c951f7ad | ||
|
|
971d974f4a | ||
|
|
572062c1bf | ||
|
|
7187492ef8 | ||
|
|
3ed45f43b7 | ||
|
|
1646ab1388 | ||
|
|
899d259176 | ||
|
|
25bb5b74f1 | ||
|
|
c8c8a92e8d | ||
|
|
cd5515c0f5 | ||
|
|
979c7c06ef | ||
|
|
6e0e4a634e | ||
|
|
c7bc8b280c | ||
|
|
d363f5be7e | ||
|
|
e8b944ebbf | ||
|
|
ead2cb374a | ||
|
|
ba040ebd61 | ||
|
|
f3921a3d24 | ||
|
|
2d50bef4f7 | ||
|
|
323ec39ac6 | ||
|
|
acb2850260 | ||
|
|
0da4bf4c08 | ||
|
|
765fe92165 | ||
|
|
ed4f3d3bf6 | ||
|
|
7e49e17ce5 | ||
|
|
5052ae5cf8 | ||
|
|
24e218afc8 | ||
|
|
ab6360a7d5 | ||
|
|
058b832b71 | ||
|
|
b460b89df5 | ||
|
|
c7253584c5 | ||
|
|
c4e4298eac | ||
|
|
e4b4475235 | ||
|
|
7cddd345f8 |
10
.idea/libraries/uast_android_studio.xml
generated
Normal file
10
.idea/libraries/uast_android_studio.xml
generated
Normal file
@@ -0,0 +1,10 @@
|
||||
<component name="libraryTable">
|
||||
<library name="uast-android-studio">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/ideaSDK/lib/openapi.jar!/" />
|
||||
<root url="jar://$PROJECT_DIR$/ideaSDK/lib/idea.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
||||
@@ -155,7 +155,7 @@
|
||||
<print-file-size-statistic path="${basedir}/libraries/stdlib/js/build/classes/main" file-name="kotlin.meta.js"/>
|
||||
</target>
|
||||
|
||||
<target name="post_build" depends="zipArtifacts, revertTemplateFiles, printStatistics, remove_internal_artifacts, dont_remove_internal_artifacts"/>
|
||||
<target name="post_build" depends="patchXmlForAndroidStudio, zipArtifacts, revertTemplateFiles, printStatistics, remove_internal_artifacts, dont_remove_internal_artifacts"/>
|
||||
|
||||
<target name="none">
|
||||
<fail message="Either specify pre_build or post_build"/>
|
||||
@@ -193,4 +193,28 @@
|
||||
<target name="dont_remove_internal_artifacts" unless="need.remove.artifacts">
|
||||
<echo message="Internal artifacts left untouched"/>
|
||||
</target>
|
||||
|
||||
<macrodef name="patch_plugin_xml">
|
||||
<attribute name="plugin.xml" />
|
||||
<sequential>
|
||||
<replace file="@{plugin.xml}" token="<!-- DEPENDS-ON-AS-PLACEHOLDER -->" value="<depends>com.intellij.modules.androidstudio</depends>"/>
|
||||
</sequential>
|
||||
</macrodef>
|
||||
|
||||
<target name="patchXmlForAndroidStudio">
|
||||
<unzip src="${artifact.output.path}/Kotlin/lib/kotlin-plugin.jar" dest="tmpAndroidStudio">
|
||||
<patternset>
|
||||
<include name="META-INF/plugin.xml"/>
|
||||
</patternset>
|
||||
</unzip>
|
||||
|
||||
<patch_plugin_xml plugin.xml="tmpAndroidStudio/META-INF/plugin.xml"/>
|
||||
|
||||
<jar destfile="${artifact.output.path}/Kotlin/lib/kotlin-plugin.jar" update="true">
|
||||
<fileset dir="tmpAndroidStudio"/>
|
||||
<file file="META-INF/plugin.xml"/>
|
||||
</jar>
|
||||
|
||||
<delete file="tmpAndroidStudio"/>
|
||||
</target>
|
||||
</project>
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.config.ApiVersion
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.config.shouldWritePreReleaseFlag
|
||||
import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
|
||||
|
||||
@@ -58,18 +59,23 @@ data class JvmBuildMetaInfo(
|
||||
}
|
||||
}
|
||||
|
||||
fun JvmBuildMetaInfo(args: CommonCompilerArguments): JvmBuildMetaInfo =
|
||||
JvmBuildMetaInfo(isEAP = KotlinCompilerVersion.isPreRelease(),
|
||||
compilerBuildVersion = KotlinCompilerVersion.VERSION,
|
||||
languageVersionString = args.languageVersion ?: LanguageVersion.LATEST_STABLE.versionString,
|
||||
apiVersionString = args.apiVersion ?: ApiVersion.LATEST_STABLE.versionString,
|
||||
coroutinesEnable = args.coroutinesState == CommonCompilerArguments.ENABLE,
|
||||
coroutinesWarn = args.coroutinesState == CommonCompilerArguments.WARN,
|
||||
coroutinesError = args.coroutinesState == CommonCompilerArguments.ERROR,
|
||||
multiplatformEnable = args.multiPlatform,
|
||||
metadataVersionMajor = JvmMetadataVersion.INSTANCE.major,
|
||||
metadataVersionMinor = JvmMetadataVersion.INSTANCE.minor,
|
||||
metadataVersionPatch = JvmMetadataVersion.INSTANCE.patch,
|
||||
bytecodeVersionMajor = JvmBytecodeBinaryVersion.INSTANCE.major,
|
||||
bytecodeVersionMinor = JvmBytecodeBinaryVersion.INSTANCE.minor,
|
||||
bytecodeVersionPatch = JvmBytecodeBinaryVersion.INSTANCE.patch)
|
||||
fun JvmBuildMetaInfo(args: CommonCompilerArguments): JvmBuildMetaInfo {
|
||||
val languageVersion = args.languageVersion?.let((LanguageVersion)::fromVersionString) ?: LanguageVersion.LATEST_STABLE
|
||||
|
||||
return JvmBuildMetaInfo(
|
||||
isEAP = languageVersion.shouldWritePreReleaseFlag(),
|
||||
compilerBuildVersion = KotlinCompilerVersion.VERSION,
|
||||
languageVersionString = languageVersion.versionString,
|
||||
apiVersionString = args.apiVersion ?: ApiVersion.LATEST_STABLE.versionString,
|
||||
coroutinesEnable = args.coroutinesState == CommonCompilerArguments.ENABLE,
|
||||
coroutinesWarn = args.coroutinesState == CommonCompilerArguments.WARN,
|
||||
coroutinesError = args.coroutinesState == CommonCompilerArguments.ERROR,
|
||||
multiplatformEnable = args.multiPlatform,
|
||||
metadataVersionMajor = JvmMetadataVersion.INSTANCE.major,
|
||||
metadataVersionMinor = JvmMetadataVersion.INSTANCE.minor,
|
||||
metadataVersionPatch = JvmMetadataVersion.INSTANCE.patch,
|
||||
bytecodeVersionMajor = JvmBytecodeBinaryVersion.INSTANCE.major,
|
||||
bytecodeVersionMinor = JvmBytecodeBinaryVersion.INSTANCE.minor,
|
||||
bytecodeVersionPatch = JvmBytecodeBinaryVersion.INSTANCE.patch
|
||||
)
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ extra["versions.ant"] = "1.8.2"
|
||||
extra["versions.android"] = "2.3.1"
|
||||
|
||||
extra["ideaCoreSdkJars"] = arrayOf("annotations", "asm-all", "guava", "intellij-core", "jdom", "jna", "log4j", "picocontainer",
|
||||
"snappy-in-java", "streamex", "trove4j", "xpp3-1.1.4-min", "xstream")
|
||||
"snappy-in-java", "trove4j", "xpp3-1.1.4-min", "xstream")
|
||||
|
||||
extra["compilerModules"] = arrayOf(":compiler:util",
|
||||
":compiler:container",
|
||||
@@ -478,6 +478,7 @@ fun jdkPath(version: String): String = jdkPathIfFound(version)
|
||||
fun Project.configureJvmProject(javaHome: String, javaVersion: String) {
|
||||
|
||||
tasks.withType<JavaCompile> {
|
||||
options.isFork = true
|
||||
options.forkOptions.javaHome = file(javaHome)
|
||||
}
|
||||
|
||||
|
||||
@@ -387,20 +387,19 @@
|
||||
<zipgroupfileset dir="${basedir}/lib" includes="*.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/annotations.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/asm-all.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/guava-21.0.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/guava-19.0.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/intellij-core.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/jdom.jar" excludes="META-INF/jb/** META-INF/LICENSE"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/jna.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/log4j.jar" excludes="META-INF/jb/** META-INF/LICENSE"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/picocontainer.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/snappy-in-java-0.5.1.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/streamex-0.6.2.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/trove4j.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/xpp3-1.1.4-min.jar"/>
|
||||
<zipfileset src="${basedir}/ideaSDK/core/xstream-1.4.8.jar"/>
|
||||
<zipfileset src="${idea.sdk}/lib/jna-platform.jar"/>
|
||||
<zipfileset src="${idea.sdk}/lib/oromatcher.jar" excludes="META-INF/jb/** META-INF/LICENSE"/>
|
||||
<zipfileset src="${idea.sdk}/jps/jps-model.jar" excludes="META-INF/services/**"/>
|
||||
<zipfileset src="${idea.sdk}/jps/jps-model.jar"/>
|
||||
<zipfileset src="${dependencies}/jline3.jar"/>
|
||||
<zipfileset src="${dependencies}/jansi.jar"/>
|
||||
<zipfileset src="${dependencies}/javaslang-2.0.6.jar"/>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
buildscript {
|
||||
val buildSrcKotlinVersion: String by extra(findProperty("buildSrc.kotlin.version")?.toString() ?: embeddedKotlinVersion)
|
||||
extra["buildSrcKotlinRepo"] = findProperty("buildSrc.kotlin.repo")
|
||||
extra["versions.shadow"] = "2.0.1"
|
||||
|
||||
repositories {
|
||||
extra["buildSrcKotlinRepo"]?.let {
|
||||
@@ -34,6 +35,7 @@ repositories {
|
||||
}
|
||||
maven(url = "https://dl.bintray.com/kotlin/kotlin-dev") // for dex-method-list
|
||||
// maven { setUrl("https://repo.gradle.org/gradle/libs-releases-local") }
|
||||
jcenter()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
@@ -42,6 +44,7 @@ dependencies {
|
||||
// compile("net.rubygrapefruit:native-platform:0.14")
|
||||
// TODO: adding the dep to the plugin breaks the build unexpectedly, resolve and uncomment
|
||||
// compile("org.jetbrains.kotlin:kotlin-gradle-plugin:${rootProject.extra["bootstrap_kotlin_version"]}")
|
||||
compile("com.github.jengelman.gradle.plugins:shadow:${property("versions.shadow")}")
|
||||
}
|
||||
|
||||
samWithReceiver {
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
@file:Suppress("unused") // usages in build scripts are not tracked properly
|
||||
|
||||
import org.gradle.api.*
|
||||
import org.gradle.api.artifacts.ConfigurablePublishArtifact
|
||||
import org.gradle.api.artifacts.*
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.api.artifacts.Configuration
|
||||
import org.gradle.api.artifacts.ConfigurationContainer
|
||||
import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.file.DuplicatesStrategy
|
||||
import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.internal.artifacts.publish.ArchivePublishArtifact
|
||||
import org.gradle.api.plugins.BasePluginConvention
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.tasks.javadoc.Javadoc
|
||||
@@ -61,18 +59,13 @@ fun<T> Project.runtimeJarArtifactBy(task: Task, artifactRef: T, body: Configurab
|
||||
addArtifact("runtimeJar", task, artifactRef, body)
|
||||
}
|
||||
|
||||
fun Project.buildVersion(): Dependency {
|
||||
val cfg = configurations.create("build-version")
|
||||
return dependencies.add(cfg.name, dependencies.project(":prepare:build.version", configuration = "buildVersion"))
|
||||
}
|
||||
|
||||
fun<T: Jar> Project.runtimeJar(task: T, body: T.() -> Unit = {}): T {
|
||||
val buildVersionCfg = configurations.create("buildVersion")
|
||||
dependencies.add(buildVersionCfg.name, dependencies.project(":prepare:build.version", configuration = "buildVersion"))
|
||||
extra["runtimeJarTask"] = task
|
||||
tasks.findByName("jar")?.let { defaultJarTask ->
|
||||
configurations.getOrCreate("archives").artifacts.removeAll { (it as? ArchivePublishArtifact)?.archiveTask?.let { it == defaultJarTask } ?: false }
|
||||
}
|
||||
return task.apply {
|
||||
setupPublicJar()
|
||||
from(buildVersionCfg) { into("META-INF") }
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
body()
|
||||
project.runtimeJarArtifactBy(this, this)
|
||||
@@ -139,7 +132,7 @@ fun Project.ideaPlugin(subdir: String = "lib", body: AbstractCopyTask.() -> Unit
|
||||
|
||||
task("idea-plugin") {
|
||||
dependsOn(pluginTask)
|
||||
}
|
||||
}
|
||||
|
||||
return pluginTask
|
||||
}
|
||||
|
||||
130
buildSrc/src/main/kotlin/embeddable.kt
Normal file
130
buildSrc/src/main/kotlin/embeddable.kt
Normal file
@@ -0,0 +1,130 @@
|
||||
@file:Suppress("unused") // usages in build scripts are not tracked properly
|
||||
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
import org.gradle.api.GradleException
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.DuplicatesStrategy
|
||||
import org.gradle.api.tasks.bundling.Zip
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.kotlin.dsl.task
|
||||
import org.gradle.kotlin.dsl.*
|
||||
|
||||
val kotlinEmbeddableRootPackage = "org.jetbrains.kotlin"
|
||||
|
||||
val packagesToRelocate =
|
||||
listOf( "com.intellij",
|
||||
"com.google",
|
||||
"com.sampullara",
|
||||
"org.apache",
|
||||
"org.jdom",
|
||||
"org.picocontainer",
|
||||
"jline",
|
||||
"gnu",
|
||||
"org.fusesource")
|
||||
|
||||
// The shaded compiler "dummy" is used to rewrite dependencies in projects that are used with the embeddable compiler
|
||||
// on the runtime and use some shaded dependencies from the compiler
|
||||
// To speed-up rewriting process we want to have this dummy as small as possible.
|
||||
// But due to the shadow plugin bug (https://github.com/johnrengelman/shadow/issues/262) it is not possible to use
|
||||
// packagesToRelocate list to for the include list. Therefore the exclude list has to be created.
|
||||
val packagesToExcludeFromDummy =
|
||||
listOf("org/jetbrains/kotlin/**",
|
||||
"org/intellij/lang/annotations/**",
|
||||
"org/jetbrains/jps/**",
|
||||
"META-INF/**",
|
||||
"com/sun/jna/**",
|
||||
"com/thoughtworks/xstream/**",
|
||||
"javaslang/**",
|
||||
"*.proto",
|
||||
"messages/**",
|
||||
"net/sf/cglib/**",
|
||||
"one/util/streamex/**",
|
||||
"org/iq80/snappy/**",
|
||||
"org/jline/**",
|
||||
"org/json/**",
|
||||
"org/xmlpull/**",
|
||||
"*.txt")
|
||||
|
||||
private fun ShadowJar.configureEmbeddableCompilerRelocation(withJavaxInject: Boolean = true) {
|
||||
relocate("com.google.protobuf", "org.jetbrains.kotlin.protobuf")
|
||||
packagesToRelocate.forEach {
|
||||
relocate(it, "$kotlinEmbeddableRootPackage.$it")
|
||||
}
|
||||
if (withJavaxInject) {
|
||||
relocate("javax.inject", "$kotlinEmbeddableRootPackage.javax.inject")
|
||||
}
|
||||
relocate("org.fusesource", "$kotlinEmbeddableRootPackage.org.fusesource") {
|
||||
// TODO: remove "it." after #KT-12848 get addressed
|
||||
exclude("org.fusesource.jansi.internal.CLibrary")
|
||||
}
|
||||
}
|
||||
|
||||
private fun Project.compilerShadowJar(taskName: String, body: ShadowJar.() -> Unit): Jar {
|
||||
|
||||
val compilerJar = configurations.getOrCreate("compilerJar")
|
||||
dependencies.add(compilerJar.name, dependencies.project(":kotlin-compiler", configuration = "runtimeJar"))
|
||||
|
||||
return task<ShadowJar>(taskName) {
|
||||
destinationDir = File(buildDir, "libs")
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
from(compilerJar)
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.embeddableCompiler(taskName: String = "embeddable", body: ShadowJar.() -> Unit = {}): Jar =
|
||||
compilerShadowJar(taskName) {
|
||||
configureEmbeddableCompilerRelocation()
|
||||
body()
|
||||
}
|
||||
|
||||
fun Project.compilerDummyForDependenciesRewriting(taskName: String = "compilerDummy", body: ShadowJar.() -> Unit = {}): Jar =
|
||||
compilerShadowJar(taskName) {
|
||||
exclude(packagesToExcludeFromDummy)
|
||||
body()
|
||||
}
|
||||
|
||||
const val COMPILER_DUMMY_JAR_CONFIGURATION_NAME = "compilerDummyJar"
|
||||
|
||||
fun Project.compilerDummyJar(task: Jar, body: Jar.() -> Unit = {}) {
|
||||
task.body()
|
||||
addArtifact(COMPILER_DUMMY_JAR_CONFIGURATION_NAME, task, task)
|
||||
}
|
||||
|
||||
fun Project.embeddableCompilerDummyForDependenciesRewriting(taskName: String = "embeddable", body: Jar.() -> Unit = {}): Jar {
|
||||
val compilerDummyJar = configurations.getOrCreate("compilerDummyJar")
|
||||
dependencies.add(compilerDummyJar.name,
|
||||
dependencies.project(":kotlin-compiler-embeddable", configuration = COMPILER_DUMMY_JAR_CONFIGURATION_NAME))
|
||||
|
||||
return task<ShadowJar>(taskName) {
|
||||
destinationDir = File(buildDir, "libs")
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
from(compilerDummyJar)
|
||||
configureEmbeddableCompilerRelocation(withJavaxInject = false)
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.rewriteDepsToShadedJar(originalJarTask: Jar, shadowJarTask: Zip, body: Jar.() -> Unit = {}): Jar {
|
||||
val originalFiles by lazy {
|
||||
val jarContents = zipTree(originalJarTask.outputs.files.singleFile).files
|
||||
val basePath = jarContents.find { it.name == "MANIFEST.MF" }?.parentFile?.parentFile ?: throw GradleException("cannot determine the jar root dir")
|
||||
jarContents.map { it.relativeTo(basePath).path }.toSet()
|
||||
}
|
||||
return task<Jar>("rewrittenDepsJar") {
|
||||
originalJarTask.apply {
|
||||
classifier = "original"
|
||||
}
|
||||
shadowJarTask.apply {
|
||||
dependsOn(originalJarTask)
|
||||
from(originalJarTask)// { include("**") }
|
||||
classifier = "shadow"
|
||||
}
|
||||
dependsOn(shadowJarTask)
|
||||
from(project.zipTree(shadowJarTask.outputs.files.singleFile)) { include { originalFiles.any { originalFile -> it.file.canonicalPath.endsWith(originalFile) } } }
|
||||
body()
|
||||
}
|
||||
}
|
||||
|
||||
fun Project.rewriteDepsToShadedCompiler(originalJarTask: Jar, body: Jar.() -> Unit = {}): Jar =
|
||||
rewriteDepsToShadedJar(originalJarTask, embeddableCompilerDummyForDependenciesRewriting(), body)
|
||||
@@ -18,7 +18,7 @@ dependencies {
|
||||
testCompile(ideaSdkDeps("jps-model.jar", subdir = "jps"))
|
||||
testCompile(ideaSdkDeps("groovy-all"))
|
||||
testCompile(ideaSdkDeps("openapi", "idea"))
|
||||
testCompile(ideaSdkDeps("jps-build-test", subdir = "jps/test"))
|
||||
//testCompile(ideaSdkDeps("jps-build-test", subdir = "jps/test"))
|
||||
testCompile(ideaSdkDeps("jps-builders"))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.android.tests;
|
||||
|
||||
import org.jetbrains.kotlin.jps.build.BaseKotlinJpsBuildTestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AndroidJpsBuildTestCase extends BaseKotlinJpsBuildTestCase {
|
||||
private static final String PROJECT_NAME = "android-module";
|
||||
private static final String SDK_NAME = "Android_SDK";
|
||||
|
||||
private final File workDir = new File(AndroidRunner.getPathManager().getTmpFolder());
|
||||
|
||||
public void doTest() {
|
||||
initProject();
|
||||
rebuildAllModules();
|
||||
buildAllModules().assertSuccessful();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getProjectName() {
|
||||
return "android-module";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
doTest();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "AndroidJpsTest";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected File doGetProjectDir() throws IOException {
|
||||
return workDir;
|
||||
}
|
||||
|
||||
private void initProject() {
|
||||
addJdk(SDK_NAME, AndroidRunner.getPathManager().getPlatformFolderInAndroidSdk() + "/android.jar");
|
||||
loadProject(workDir.getAbsolutePath() + File.separator + PROJECT_NAME + ".ipr");
|
||||
}
|
||||
}
|
||||
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.android.tests;
|
||||
|
||||
import com.google.common.io.Files;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AndroidRunner extends TestSuite {
|
||||
|
||||
private static PathManager pathManager;
|
||||
|
||||
@NotNull
|
||||
public static PathManager getPathManager() {
|
||||
if (pathManager == null) {
|
||||
File tmpFolder = Files.createTempDir();
|
||||
System.out.println("Created temporary folder for running android tests: " + tmpFolder.getAbsolutePath());
|
||||
File rootFolder = new File("");
|
||||
pathManager = new PathManager(rootFolder.getAbsolutePath(), tmpFolder.getAbsolutePath());
|
||||
}
|
||||
return pathManager;
|
||||
}
|
||||
|
||||
public static TestSuite suite() throws Throwable {
|
||||
PathManager pathManager = getPathManager();
|
||||
|
||||
FileUtil.copyDir(new File(pathManager.getAndroidModuleRoot()), new File(pathManager.getTmpFolder()));
|
||||
writeAndroidSkdToLocalProperties();
|
||||
|
||||
CodegenTestsOnAndroidGenerator.generate(pathManager);
|
||||
|
||||
System.out.println("Run tests on android...");
|
||||
TestSuite suite = CodegenTestsOnAndroidRunner.getTestSuite(pathManager);
|
||||
//AndroidJpsBuildTestCase indirectly depends on UsefulTestCase which compiled against java 8
|
||||
//TODO: Need add separate run configuration for AndroidJpsBuildTestCase
|
||||
//suite.addTest(new AndroidJpsBuildTestCase());
|
||||
return suite;
|
||||
}
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
// Clear tmp folder where we run android tests
|
||||
FileUtil.delete(new File(pathManager.getTmpFolder()));
|
||||
}
|
||||
|
||||
private static void writeAndroidSkdToLocalProperties() throws IOException {
|
||||
System.out.println("Writing android sdk to local.properties: " + pathManager.getAndroidSdkRoot());
|
||||
File file = new File(pathManager.getTmpFolder() + "/local.properties");
|
||||
try (FileWriter fw = new FileWriter(file)) {
|
||||
fw.write("sdk.dir=" + pathManager.getAndroidSdkRoot());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,8 +17,7 @@
|
||||
package org.jetbrains.kotlin.codegen
|
||||
|
||||
import org.jetbrains.kotlin.codegen.state.GenerationState
|
||||
import org.jetbrains.kotlin.config.KotlinCompilerVersion
|
||||
import org.jetbrains.kotlin.config.LanguageVersion
|
||||
import org.jetbrains.kotlin.config.shouldWritePreReleaseFlag
|
||||
import org.jetbrains.kotlin.load.java.JvmAnnotationNames
|
||||
import org.jetbrains.kotlin.load.java.JvmBytecodeBinaryVersion
|
||||
import org.jetbrains.kotlin.load.kotlin.JvmMetadataVersion
|
||||
@@ -37,7 +36,7 @@ fun writeKotlinMetadata(
|
||||
av.visit(JvmAnnotationNames.BYTECODE_VERSION_FIELD_NAME, JvmBytecodeBinaryVersion.INSTANCE.toArray())
|
||||
av.visit(JvmAnnotationNames.KIND_FIELD_NAME, kind.id)
|
||||
var flags = extraFlags
|
||||
if (KotlinCompilerVersion.isPreRelease() && state.languageVersionSettings.languageVersion == LanguageVersion.LATEST_STABLE) {
|
||||
if (state.languageVersionSettings.shouldWritePreReleaseFlag()) {
|
||||
flags = flags or JvmAnnotationNames.METADATA_PRE_RELEASE_FLAG
|
||||
}
|
||||
if (flags != 0) {
|
||||
@@ -51,4 +50,4 @@ fun writeSyntheticClassMetadata(cb: ClassBuilder, state: GenerationState) {
|
||||
writeKotlinMetadata(cb, state, KotlinClassHeader.Kind.SYNTHETIC_CLASS, 0) { _ ->
|
||||
// Do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.intellij.openapi.vfs.StandardFileSystems
|
||||
import com.intellij.openapi.vfs.VfsUtilCore
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiJavaModule
|
||||
import com.intellij.openapi.vfs.VirtualFileManager
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.impl.light.LightJavaModule
|
||||
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
|
||||
@@ -91,22 +92,22 @@ class ClasspathRootsResolver(
|
||||
|
||||
for ((root, packagePrefix) in javaSourceRoots) {
|
||||
val modularRoot = modularSourceRoot(root, hasOutputDirectoryInClasspath)
|
||||
if (modularRoot != null) {
|
||||
modules += modularRoot
|
||||
}
|
||||
else {
|
||||
result += JavaRoot(root, JavaRoot.RootType.SOURCE, packagePrefix?.let { prefix ->
|
||||
if (isValidJavaFqName(prefix)) FqName(prefix)
|
||||
else null.also {
|
||||
report(STRONG_WARNING, "Invalid package prefix name is ignored: $prefix")
|
||||
if (modularRoot != null) {
|
||||
modules += modularRoot
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
else {
|
||||
result += JavaRoot(root, JavaRoot.RootType.SOURCE, packagePrefix?.let { prefix ->
|
||||
if (isValidJavaFqName(prefix)) FqName(prefix)
|
||||
else null.also {
|
||||
report(STRONG_WARNING, "Invalid package prefix name is ignored: $prefix")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
for (root in jvmClasspathRoots) {
|
||||
result += JavaRoot(root, JavaRoot.RootType.BINARY)
|
||||
}
|
||||
result += JavaRoot(root, JavaRoot.RootType.BINARY)
|
||||
}
|
||||
|
||||
val outputDirectoryAddedAsPartOfModule = modules.any { module -> module.moduleRoots.any { it.file == outputDirectory } }
|
||||
|
||||
@@ -116,16 +117,17 @@ class ClasspathRootsResolver(
|
||||
if (outputDirectoryAddedAsPartOfModule && root == outputDirectory) continue
|
||||
|
||||
val module = modularBinaryRoot(root)
|
||||
if (module != null) {
|
||||
modules += module
|
||||
}
|
||||
}
|
||||
if (module != null) {
|
||||
modules += module
|
||||
}
|
||||
}
|
||||
|
||||
addModularRoots(modules, result)
|
||||
|
||||
return RootsAndModules(result, modules)
|
||||
}
|
||||
|
||||
/*
|
||||
private fun findSourceModuleInfo(root: VirtualFile): Pair<VirtualFile, PsiJavaModule>? {
|
||||
val moduleInfoFile =
|
||||
when {
|
||||
@@ -139,8 +141,10 @@ class ClasspathRootsResolver(
|
||||
|
||||
return moduleInfoFile to psiJavaModule
|
||||
}
|
||||
*/
|
||||
|
||||
private fun modularSourceRoot(root: VirtualFile, hasOutputDirectoryInClasspath: Boolean): JavaModule.Explicit? {
|
||||
/*
|
||||
val (moduleInfoFile, psiJavaModule) = findSourceModuleInfo(root) ?: return null
|
||||
val sourceRoot = JavaModule.Root(root, isBinary = false)
|
||||
val roots =
|
||||
@@ -148,12 +152,15 @@ class ClasspathRootsResolver(
|
||||
listOf(sourceRoot, JavaModule.Root(outputDirectory!!, isBinary = true))
|
||||
else listOf(sourceRoot)
|
||||
return JavaModule.Explicit(JavaModuleInfo.create(psiJavaModule), roots, moduleInfoFile)
|
||||
*/
|
||||
return null
|
||||
}
|
||||
|
||||
private fun modularBinaryRoot(root: VirtualFile): JavaModule? {
|
||||
val isJar = root.fileSystem.protocol == StandardFileSystems.JAR_PROTOCOL
|
||||
val manifest: Attributes? by lazy(NONE) { readManifestAttributes(root) }
|
||||
|
||||
/*
|
||||
val moduleInfoFile =
|
||||
root.findChild(PsiJavaModule.MODULE_INFO_CLS_FILE)
|
||||
?: root.takeIf { isJar }?.findFileByRelativePath(MULTI_RELEASE_MODULE_INFO_CLS_FILE)?.takeIf {
|
||||
@@ -164,6 +171,7 @@ class ClasspathRootsResolver(
|
||||
val moduleInfo = JavaModuleInfo.read(moduleInfoFile) ?: return null
|
||||
return JavaModule.Explicit(moduleInfo, listOf(JavaModule.Root(root, isBinary = true)), moduleInfoFile)
|
||||
}
|
||||
*/
|
||||
|
||||
// Only .jar files can be automatic modules
|
||||
if (isJar) {
|
||||
|
||||
@@ -245,10 +245,12 @@ class KotlinCliJavaFileManagerImpl(private val myPsiManager: PsiManager) : CoreJ
|
||||
return result
|
||||
}
|
||||
|
||||
/*
|
||||
override fun findModules(moduleName: String, scope: GlobalSearchScope): Collection<PsiJavaModule> {
|
||||
// TODO
|
||||
return emptySet()
|
||||
}
|
||||
*/
|
||||
|
||||
override fun getNonTrivialPackagePrefixes(): Collection<String> = emptyList()
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiJavaModule
|
||||
import com.intellij.psi.PsiManager
|
||||
import com.intellij.psi.impl.PsiModificationTrackerImpl
|
||||
import com.intellij.psi.search.DelegatingGlobalSearchScope
|
||||
@@ -191,14 +190,14 @@ object KotlinToJVMBytecodeCompiler {
|
||||
}
|
||||
}
|
||||
|
||||
val isJava9Module = chunk.any { module ->
|
||||
val isJava9Module = false /*chunk.any { module ->
|
||||
module.getJavaSourceRoots().any { (path, packagePrefix) ->
|
||||
val file = File(path)
|
||||
packagePrefix == null &&
|
||||
(file.name == PsiJavaModule.MODULE_INFO_FILE ||
|
||||
(file.isDirectory && file.listFiles().any { it.name == PsiJavaModule.MODULE_INFO_FILE }))
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
for (module in chunk) {
|
||||
for (classpathRoot in module.getClasspathRoots()) {
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.jetbrains.kotlin.cli.jvm.compiler
|
||||
|
||||
import com.intellij.codeInsight.ExternalAnnotationsManager
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.*
|
||||
|
||||
class MockExternalAnnotationsManager : ExternalAnnotationsManager() {
|
||||
@@ -41,8 +40,4 @@ class MockExternalAnnotationsManager : ExternalAnnotationsManager() {
|
||||
override fun editExternalAnnotation(listOwner: PsiModifierListOwner, annotationFQN: String, value: Array<out PsiNameValuePair>?): Boolean {
|
||||
throw UnsupportedOperationException("not implemented")
|
||||
}
|
||||
|
||||
override fun hasAnnotationRootsForFile(file: VirtualFile): Boolean {
|
||||
throw UnsupportedOperationException("not implemented")
|
||||
}
|
||||
}
|
||||
@@ -17,10 +17,8 @@
|
||||
package org.jetbrains.kotlin.cli.jvm.modules
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiJavaModule
|
||||
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModule
|
||||
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleFinder
|
||||
import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleInfo
|
||||
|
||||
class CliJavaModuleFinder(jrtFileSystemRoot: VirtualFile?) : JavaModuleFinder {
|
||||
private val modulesRoot = jrtFileSystemRoot?.findChild("modules")
|
||||
@@ -40,8 +38,11 @@ class CliJavaModuleFinder(jrtFileSystemRoot: VirtualFile?) : JavaModuleFinder {
|
||||
modulesRoot?.findChild(name)?.let(this::findSystemModule) ?: userModules[name]
|
||||
|
||||
private fun findSystemModule(moduleRoot: VirtualFile): JavaModule.Explicit? {
|
||||
/*
|
||||
val file = moduleRoot.findChild(PsiJavaModule.MODULE_INFO_CLS_FILE) ?: return null
|
||||
val moduleInfo = JavaModuleInfo.read(file) ?: return null
|
||||
return JavaModule.Explicit(moduleInfo, listOf(JavaModule.Root(moduleRoot, isBinary = true)), file)
|
||||
*/
|
||||
return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
|
||||
description = "Compiler runner + daemon client"
|
||||
|
||||
apply { plugin("kotlin") }
|
||||
@@ -13,6 +15,7 @@ dependencies {
|
||||
compileOnly(project(":compiler:daemon-common"))
|
||||
compile(project(":kotlin-daemon-client"))
|
||||
compileOnly(project(":compiler:util"))
|
||||
runtime(projectRuntimeJar(":kotlin-compiler-embeddable"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
@@ -20,10 +23,13 @@ sourceSets {
|
||||
"test" {}
|
||||
}
|
||||
|
||||
runtimeJar {
|
||||
val jar: Jar by tasks
|
||||
jar.apply {
|
||||
from(getSourceSetsFrom(":kotlin-daemon-client")["main"].output.classesDirs)
|
||||
from(getSourceSetsFrom(":compiler:daemon-common")["main"].output.classesDirs)
|
||||
}
|
||||
|
||||
runtimeJar(rewriteDepsToShadedCompiler(jar))
|
||||
sourcesJar()
|
||||
javadocJar()
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@ enum class JvmTarget(override val description: String) : TargetPlatformVersion {
|
||||
val bytecodeVersion: Int by lazy {
|
||||
when (this) {
|
||||
JVM_1_6 -> Opcodes.V1_6
|
||||
JVM_1_8 ->
|
||||
if (java.lang.Boolean.valueOf(System.getProperty("kotlin.test.substitute.bytecode.1.8.to.1.9"))) Opcodes.V1_9 else Opcodes.V1_8
|
||||
JVM_1_8 -> Opcodes.V1_8
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +41,7 @@ enum class JvmTarget(override val description: String) : TargetPlatformVersion {
|
||||
val platformDescription = values().find { it.bytecodeVersion == bytecodeVersion }?.description ?:
|
||||
when (bytecodeVersion) {
|
||||
Opcodes.V1_7 -> "1.7"
|
||||
Opcodes.V1_9 -> "1.9"
|
||||
Opcodes.V1_8 + 1 -> "1.9"
|
||||
else -> null
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.load.java.structure.*
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.psi.KtPsiUtil
|
||||
import org.jetbrains.kotlin.psi.psiUtil.contains
|
||||
|
||||
class JavaClassImpl(psiClass: PsiClass) : JavaClassifierImpl<PsiClass>(psiClass), VirtualFileBoundJavaClass, JavaAnnotationOwnerImpl, JavaModifierListOwnerImpl {
|
||||
init {
|
||||
@@ -114,7 +115,7 @@ class JavaClassImpl(psiClass: PsiClass) : JavaClassifierImpl<PsiClass>(psiClass)
|
||||
override val virtualFile: VirtualFile?
|
||||
get() = psi.containingFile?.virtualFile
|
||||
|
||||
override fun isFromSourceCodeInScope(scope: SearchScope): Boolean = psi.containingFile.virtualFile in scope
|
||||
override fun isFromSourceCodeInScope(scope: SearchScope): Boolean = psi.containingFile in scope
|
||||
|
||||
override fun getAnnotationOwnerPsi() = psi.modifierList
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.util.Computable
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiJavaModule
|
||||
|
||||
class KotlinBinaryClassCache : Disposable {
|
||||
private class RequestCache {
|
||||
@@ -56,8 +55,6 @@ class KotlinBinaryClassCache : Disposable {
|
||||
fun getKotlinBinaryClass(file: VirtualFile, fileContent: ByteArray? = null): KotlinJvmBinaryClass? {
|
||||
if (file.fileType !== JavaClassFileType.INSTANCE) return null
|
||||
|
||||
if (file.name == PsiJavaModule.MODULE_INFO_CLS_FILE) return null
|
||||
|
||||
val service = ServiceManager.getService(KotlinBinaryClassCache::class.java)
|
||||
val requestCache = service.cache.get()
|
||||
|
||||
|
||||
@@ -17,15 +17,15 @@
|
||||
package org.jetbrains.kotlin.resolve.jvm.modules
|
||||
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import com.intellij.psi.PsiJavaModule
|
||||
//import com.intellij.psi.PsiJavaModule
|
||||
import com.intellij.psi.PsiModifier
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.utils.compact
|
||||
import org.jetbrains.org.objectweb.asm.ClassReader
|
||||
import org.jetbrains.org.objectweb.asm.ClassVisitor
|
||||
import org.jetbrains.org.objectweb.asm.ModuleVisitor
|
||||
//import org.jetbrains.org.objectweb.asm.ModuleVisitor
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes
|
||||
import org.jetbrains.org.objectweb.asm.Opcodes.ACC_TRANSITIVE
|
||||
//import org.jetbrains.org.objectweb.asm.Opcodes.ACC_TRANSITIVE
|
||||
import java.io.IOException
|
||||
|
||||
class JavaModuleInfo(
|
||||
@@ -41,7 +41,7 @@ class JavaModuleInfo(
|
||||
"Module $moduleName (${requires.size} requires, ${exports.size} exports)"
|
||||
|
||||
companion object {
|
||||
fun create(psiJavaModule: PsiJavaModule): JavaModuleInfo {
|
||||
/*fun create(psiJavaModule: PsiJavaModule): JavaModuleInfo {
|
||||
return JavaModuleInfo(
|
||||
psiJavaModule.name,
|
||||
psiJavaModule.requires.mapNotNull { statement ->
|
||||
@@ -55,9 +55,9 @@ class JavaModuleInfo(
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}*/
|
||||
|
||||
fun read(file: VirtualFile): JavaModuleInfo? {
|
||||
/*fun read(file: VirtualFile): JavaModuleInfo? {
|
||||
val contents = try { file.contentsToByteArray() } catch (e: IOException) { return null }
|
||||
|
||||
var moduleName: String? = null
|
||||
@@ -84,6 +84,6 @@ class JavaModuleInfo(
|
||||
return if (moduleName != null)
|
||||
JavaModuleInfo(moduleName!!, requires.compact(), exports.compact())
|
||||
else null
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,12 @@ import org.jetbrains.kotlin.config.LanguageVersionSettings
|
||||
import org.jetbrains.kotlin.serialization.deserialization.DeserializationConfiguration
|
||||
|
||||
class CompilerDeserializationConfiguration(languageVersionSettings: LanguageVersionSettings) : DeserializationConfiguration {
|
||||
override val typeAliasesAllowed = languageVersionSettings.supportsFeature(LanguageFeature.TypeAliases)
|
||||
|
||||
override val skipMetadataVersionCheck = languageVersionSettings.getFlag(AnalysisFlag.skipMetadataVersionCheck)
|
||||
|
||||
override val skipPreReleaseCheck = skipMetadataVersionCheck || !languageVersionSettings.languageVersion.isStable
|
||||
|
||||
override val typeAliasesAllowed = languageVersionSettings.supportsFeature(LanguageFeature.TypeAliases)
|
||||
|
||||
override val isJvmPackageNameSupported = languageVersionSettings.supportsFeature(LanguageFeature.JvmPackageName)
|
||||
|
||||
override val returnsEffectAllowed: Boolean = languageVersionSettings.supportsFeature(LanguageFeature.ReturnsEffect)
|
||||
|
||||
@@ -180,12 +180,25 @@ class GenericCandidateResolver(
|
||||
|
||||
private fun getBinaryWithTypeParent(calleeExpression: KtExpression?): KtBinaryExpressionWithTypeRHS? {
|
||||
val callExpression = calleeExpression?.parent.safeAs<KtCallExpression>() ?: return null
|
||||
val parent = callExpression.parent
|
||||
return when (parent) {
|
||||
is KtBinaryExpressionWithTypeRHS -> parent
|
||||
is KtQualifiedExpression -> parent.parent.safeAs<KtBinaryExpressionWithTypeRHS>().takeIf { parent.selectorExpression == callExpression }
|
||||
else -> null
|
||||
val possibleQualifiedExpression = callExpression.parent
|
||||
|
||||
val targetExpression = if (possibleQualifiedExpression is KtQualifiedExpression) {
|
||||
if (possibleQualifiedExpression.selectorExpression != callExpression) return null
|
||||
possibleQualifiedExpression
|
||||
}
|
||||
else {
|
||||
callExpression
|
||||
}
|
||||
|
||||
return targetExpression.topParenthesizedParentOrMe().parent.safeAs<KtBinaryExpressionWithTypeRHS>()
|
||||
}
|
||||
|
||||
private fun KtExpression.topParenthesizedParentOrMe(): KtExpression {
|
||||
var result: KtExpression = this
|
||||
while (KtPsiUtil.deparenthesizeOnce(result.parent.safeAs()) == result) {
|
||||
result = result.parent.safeAs() ?: break
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
private fun addValidityConstraintsForConstituentTypes(builder: ConstraintSystem.Builder, type: KotlinType) {
|
||||
|
||||
@@ -96,9 +96,12 @@ internal class DelegatingDataFlowInfo private constructor(
|
||||
nullability: Nullability,
|
||||
languageVersionSettings: LanguageVersionSettings,
|
||||
typeInfo: SetMultimap<DataFlowValue, KotlinType>? = null,
|
||||
affectReceiver: Boolean = true
|
||||
affectReceiver: Boolean = true,
|
||||
recordUnstable: Boolean = true
|
||||
): Boolean {
|
||||
map.put(value, nullability)
|
||||
if (value.isStable || recordUnstable) {
|
||||
map.put(value, nullability)
|
||||
}
|
||||
|
||||
val identifierInfo = value.identifierInfo
|
||||
if (affectReceiver && !nullability.canBeNull() &&
|
||||
@@ -108,7 +111,8 @@ internal class DelegatingDataFlowInfo private constructor(
|
||||
val receiverType = identifierInfo.receiverType
|
||||
if (identifierInfo.safe && receiverType != null) {
|
||||
val receiverValue = DataFlowValue(identifierInfo.receiverInfo, receiverType)
|
||||
putNullabilityAndTypeInfo(map, receiverValue, nullability, languageVersionSettings, typeInfo)
|
||||
putNullabilityAndTypeInfo(map, receiverValue, nullability,
|
||||
languageVersionSettings, typeInfo, recordUnstable = recordUnstable)
|
||||
}
|
||||
}
|
||||
is IdentifierInfo.SafeCast -> {
|
||||
@@ -118,12 +122,16 @@ internal class DelegatingDataFlowInfo private constructor(
|
||||
languageVersionSettings.supportsFeature(LanguageFeature.SafeCastCheckBoundSmartCasts)) {
|
||||
|
||||
val subjectValue = DataFlowValue(identifierInfo.subjectInfo, subjectType)
|
||||
putNullabilityAndTypeInfo(map, subjectValue, nullability, languageVersionSettings, typeInfo)
|
||||
typeInfo?.put(subjectValue, targetType)
|
||||
putNullabilityAndTypeInfo(map, subjectValue, nullability,
|
||||
languageVersionSettings, typeInfo, recordUnstable = false)
|
||||
if (subjectValue.isStable) {
|
||||
typeInfo?.put(subjectValue, targetType)
|
||||
}
|
||||
}
|
||||
}
|
||||
is IdentifierInfo.Variable -> identifierInfo.bound?.let {
|
||||
putNullabilityAndTypeInfo(map, it, nullability, languageVersionSettings, typeInfo)
|
||||
putNullabilityAndTypeInfo(map, it, nullability,
|
||||
languageVersionSettings, typeInfo, recordUnstable = recordUnstable)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
21
compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt
vendored
Normal file
21
compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
// !LANGUAGE: +ExpectedTypeFromCast
|
||||
|
||||
@Target(AnnotationTarget.EXPRESSION)
|
||||
annotation class bar
|
||||
|
||||
fun <T> foo(): T = TODO()
|
||||
|
||||
fun <V> id(value: V) = value
|
||||
|
||||
val par1 = (foo()) as String
|
||||
val par2 = ((foo())) as String
|
||||
|
||||
val par3 = (dd@ (foo())) as String
|
||||
|
||||
val par4 = ( @bar() (foo())) as String
|
||||
|
||||
object X {
|
||||
fun <T> foo(): T = TODO()
|
||||
}
|
||||
|
||||
val par5 = ( @bar() X.foo()) as String
|
||||
24
compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.txt
vendored
Normal file
24
compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.txt
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
package
|
||||
|
||||
public val par1: kotlin.String
|
||||
public val par2: kotlin.String
|
||||
public val par3: kotlin.String
|
||||
public val par4: kotlin.String
|
||||
public val par5: kotlin.String
|
||||
public fun </*0*/ T> foo(): T
|
||||
public fun </*0*/ V> id(/*0*/ value: V): V
|
||||
|
||||
public object X {
|
||||
private constructor X()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun </*0*/ T> foo(): T
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
@kotlin.annotation.Target(allowedTargets = {AnnotationTarget.EXPRESSION}) public final annotation class bar : kotlin.Annotation {
|
||||
public constructor bar()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
19
compiler/testData/diagnostics/tests/j+k/annotationsInheritance.kt
vendored
Normal file
19
compiler/testData/diagnostics/tests/j+k/annotationsInheritance.kt
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
// FILE: MyAnnotation.java
|
||||
public @interface MyAnnotation {
|
||||
}
|
||||
// FILE: MyAnnoClass.java
|
||||
public class MyAnnoClass implements MyAnnotation {
|
||||
//...
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
|
||||
val ann: MyAnnotation = MyAnnoClass()
|
||||
|
||||
fun foo(x: MyAnnoClass) {
|
||||
bar(x)
|
||||
}
|
||||
|
||||
fun bar(y: MyAnnotation) {
|
||||
y.hashCode()
|
||||
}
|
||||
19
compiler/testData/diagnostics/tests/j+k/annotationsInheritance.txt
vendored
Normal file
19
compiler/testData/diagnostics/tests/j+k/annotationsInheritance.txt
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
package
|
||||
|
||||
public val ann: MyAnnotation
|
||||
public fun bar(/*0*/ y: MyAnnotation): kotlin.Unit
|
||||
public fun foo(/*0*/ x: MyAnnoClass): kotlin.Unit
|
||||
|
||||
public open class MyAnnoClass : MyAnnotation {
|
||||
public constructor MyAnnoClass()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final annotation class MyAnnotation : kotlin.Annotation {
|
||||
public constructor MyAnnotation()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
25
compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.kt
vendored
Normal file
25
compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.kt
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// !LANGUAGE: +SafeCastCheckBoundSmartCasts
|
||||
// See KT-20752
|
||||
|
||||
class Unstable {
|
||||
val first: String? get() = null
|
||||
}
|
||||
|
||||
class StringList {
|
||||
fun remove(s: String) = s
|
||||
}
|
||||
|
||||
fun StringList.remove(s: String?) = s ?: ""
|
||||
|
||||
fun foo(list: StringList, arg: Unstable) {
|
||||
list.remove(arg.first)
|
||||
if (arg.first <!USELESS_CAST!>as? String<!> != null) {
|
||||
// Ideally should have smart cast impossible here
|
||||
list.remove(arg.first)
|
||||
}
|
||||
val s = arg.first <!USELESS_CAST!>as? String<!>
|
||||
if (s != null) {
|
||||
// Ideally should have smart cast impossible here
|
||||
list.remove(arg.first)
|
||||
}
|
||||
}
|
||||
20
compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.txt
vendored
Normal file
20
compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.txt
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
package
|
||||
|
||||
public fun foo(/*0*/ list: StringList, /*1*/ arg: Unstable): kotlin.Unit
|
||||
public fun StringList.remove(/*0*/ s: kotlin.String?): kotlin.String
|
||||
|
||||
public final class StringList {
|
||||
public constructor StringList()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun remove(/*0*/ s: kotlin.String): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Unstable {
|
||||
public constructor Unstable()
|
||||
public final val first: kotlin.String?
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
40
compiler/testData/diagnostics/tests/smartCasts/elvis/impossible.kt
vendored
Normal file
40
compiler/testData/diagnostics/tests/smartCasts/elvis/impossible.kt
vendored
Normal file
@@ -0,0 +1,40 @@
|
||||
// !LANGUAGE: +BooleanElvisBoundSmartCasts
|
||||
// See KT-20752
|
||||
|
||||
class Unstable {
|
||||
val first: String? get() = null
|
||||
}
|
||||
|
||||
class StringList {
|
||||
fun remove(s: String) = s
|
||||
}
|
||||
|
||||
fun StringList.remove(s: String?) = s ?: ""
|
||||
|
||||
fun String.isEmpty() = this == ""
|
||||
|
||||
fun foo(list: StringList, arg: Unstable) {
|
||||
list.remove(arg.first)
|
||||
if (arg.first?.isEmpty() ?: false) {
|
||||
// Ideally should have smart cast impossible here
|
||||
list.remove(<!SMARTCAST_IMPOSSIBLE!>arg.first<!>)
|
||||
}
|
||||
}
|
||||
|
||||
class UnstableBoolean {
|
||||
val first: Boolean? get() = null
|
||||
}
|
||||
|
||||
class BooleanList {
|
||||
fun remove(b: Boolean) = b
|
||||
}
|
||||
|
||||
fun BooleanList.remove(b: Boolean?) = b ?: false
|
||||
|
||||
fun bar(list: BooleanList, arg: UnstableBoolean) {
|
||||
list.remove(arg.first)
|
||||
if (arg.first ?: false) {
|
||||
// Ideally should have smart cast impossible here
|
||||
list.remove(<!SMARTCAST_IMPOSSIBLE!>arg.first<!>)
|
||||
}
|
||||
}
|
||||
39
compiler/testData/diagnostics/tests/smartCasts/elvis/impossible.txt
vendored
Normal file
39
compiler/testData/diagnostics/tests/smartCasts/elvis/impossible.txt
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
package
|
||||
|
||||
public fun bar(/*0*/ list: BooleanList, /*1*/ arg: UnstableBoolean): kotlin.Unit
|
||||
public fun foo(/*0*/ list: StringList, /*1*/ arg: Unstable): kotlin.Unit
|
||||
public fun kotlin.String.isEmpty(): kotlin.Boolean
|
||||
public fun BooleanList.remove(/*0*/ b: kotlin.Boolean?): kotlin.Boolean
|
||||
public fun StringList.remove(/*0*/ s: kotlin.String?): kotlin.String
|
||||
|
||||
public final class BooleanList {
|
||||
public constructor BooleanList()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun remove(/*0*/ b: kotlin.Boolean): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class StringList {
|
||||
public constructor StringList()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun remove(/*0*/ s: kotlin.String): kotlin.String
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class Unstable {
|
||||
public constructor Unstable()
|
||||
public final val first: kotlin.String?
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class UnstableBoolean {
|
||||
public constructor UnstableBoolean()
|
||||
public final val first: kotlin.Boolean?
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
25
compiler/testData/diagnostics/testsWithJsStdLib/wrongMultipleInheritance.kt
vendored
Normal file
25
compiler/testData/diagnostics/testsWithJsStdLib/wrongMultipleInheritance.kt
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
open class A {
|
||||
fun get(index: Int): Char = '*'
|
||||
}
|
||||
|
||||
abstract class <!WRONG_MULTIPLE_INHERITANCE!>B<!> : A(), CharSequence
|
||||
|
||||
interface I {
|
||||
fun nextChar(): Char
|
||||
}
|
||||
|
||||
abstract class <!WRONG_MULTIPLE_INHERITANCE!>C<!> : CharIterator(), I {
|
||||
override fun nextChar(): Char = '*'
|
||||
}
|
||||
|
||||
class <!WRONG_MULTIPLE_INHERITANCE!>CC(val s: CharSequence)<!> : CharSequence by s, MyCharSequence {}
|
||||
|
||||
interface MyCharSequence {
|
||||
val length: Int
|
||||
|
||||
operator fun get(index: Int): Char
|
||||
|
||||
fun subSequence(startIndex: Int, endIndex: Int): CharSequence
|
||||
}
|
||||
56
compiler/testData/diagnostics/testsWithJsStdLib/wrongMultipleInheritance.txt
vendored
Normal file
56
compiler/testData/diagnostics/testsWithJsStdLib/wrongMultipleInheritance.txt
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
package
|
||||
|
||||
public open class A {
|
||||
public constructor A()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun get(/*0*/ index: kotlin.Int): kotlin.Char
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public abstract class B : A, kotlin.CharSequence {
|
||||
public constructor B()
|
||||
public abstract override /*1*/ /*fake_override*/ val length: kotlin.Int
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final override /*2*/ /*fake_override*/ fun get(/*0*/ index: kotlin.Int): kotlin.Char
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract override /*1*/ /*fake_override*/ fun subSequence(/*0*/ startIndex: kotlin.Int, /*1*/ endIndex: kotlin.Int): kotlin.CharSequence
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public abstract class C : kotlin.collections.CharIterator, I {
|
||||
public constructor C()
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract override /*1*/ /*fake_override*/ fun hasNext(): kotlin.Boolean
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final override /*1*/ /*fake_override*/ fun next(): kotlin.Char
|
||||
public open override /*2*/ fun nextChar(): kotlin.Char
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final class CC : kotlin.CharSequence, MyCharSequence {
|
||||
public constructor CC(/*0*/ s: kotlin.CharSequence)
|
||||
public open override /*2*/ /*delegation*/ val length: kotlin.Int
|
||||
public final val s: kotlin.CharSequence
|
||||
public open override /*2*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*2*/ /*delegation*/ fun get(/*0*/ index: kotlin.Int): kotlin.Char
|
||||
public open override /*2*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*2*/ /*delegation*/ fun subSequence(/*0*/ startIndex: kotlin.Int, /*1*/ endIndex: kotlin.Int): kotlin.CharSequence
|
||||
public open override /*2*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface I {
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun nextChar(): kotlin.Char
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public interface MyCharSequence {
|
||||
public abstract val length: kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public abstract operator fun get(/*0*/ index: kotlin.Int): kotlin.Char
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public abstract fun subSequence(/*0*/ startIndex: kotlin.Int, /*1*/ endIndex: kotlin.Int): kotlin.CharSequence
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
@@ -86,6 +86,7 @@ import org.jetbrains.kotlin.util.slicedMap.ReadOnlySlice;
|
||||
import org.jetbrains.kotlin.util.slicedMap.SlicedMap;
|
||||
import org.jetbrains.kotlin.util.slicedMap.WritableSlice;
|
||||
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
|
||||
import org.jetbrains.kotlin.utils.PathUtil;
|
||||
import org.junit.Assert;
|
||||
|
||||
import javax.tools.*;
|
||||
@@ -532,8 +533,8 @@ public class KotlinTestUtils {
|
||||
configuration.put(JVMConfigurationKeys.JDK_HOME, home);
|
||||
}
|
||||
}
|
||||
else if (SystemInfo.IS_AT_LEAST_JAVA9) {
|
||||
configuration.put(JVMConfigurationKeys.JDK_HOME, new File(System.getProperty("java.home")));
|
||||
else {
|
||||
JvmContentRootsKt.addJvmClasspathRoots(configuration, PathUtil.getJdkClassesRootsFromCurrentJre());
|
||||
}
|
||||
|
||||
if (configurationKind.getWithRuntime()) {
|
||||
|
||||
@@ -19,7 +19,6 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.editor.EditorKind;
|
||||
import com.intellij.openapi.editor.event.EditorEventMulticaster;
|
||||
import com.intellij.openapi.editor.event.EditorFactoryListener;
|
||||
import com.intellij.openapi.editor.impl.DocumentImpl;
|
||||
@@ -28,7 +27,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.text.CharArrayCharSequence;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class MockEditorFactory extends EditorFactory {
|
||||
@Override
|
||||
@@ -61,27 +59,6 @@ public class MockEditorFactory extends EditorFactory {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor createEditor(
|
||||
@NotNull Document document, @Nullable Project project, @NotNull EditorKind kind
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor createEditor(
|
||||
@NotNull Document document, Project project, @NotNull VirtualFile file, boolean isViewer, @NotNull EditorKind kind
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Editor createViewer(
|
||||
@NotNull Document document, @Nullable Project project, @NotNull EditorKind kind
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void releaseEditor(@NotNull Editor editor) {
|
||||
}
|
||||
|
||||
@@ -190,8 +190,4 @@ public class MockPsiManager extends PsiManagerEx {
|
||||
@Override
|
||||
public void beforeChildAddition(@NotNull PsiTreeChangeEventImpl event) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropPsiCaches() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10240,6 +10240,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("expectedTypeFromCastParenthesized.kt")
|
||||
public void testExpectedTypeFromCastParenthesized() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("expectedTypeWithGenerics.kt")
|
||||
public void testExpectedTypeWithGenerics() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/expectedTypeWithGenerics.kt");
|
||||
@@ -12256,6 +12262,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("annotationsInheritance.kt")
|
||||
public void testAnnotationsInheritance() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/annotationsInheritance.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayOfStarParametrized.kt")
|
||||
public void testArrayOfStarParametrized() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/arrayOfStarParametrized.kt");
|
||||
@@ -20892,6 +20904,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("impossible.kt")
|
||||
public void testImpossible() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("insideCall.kt")
|
||||
public void testInsideCall() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/castchecks/insideCall.kt");
|
||||
@@ -20924,6 +20942,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/elvis/basicOn.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("impossible.kt")
|
||||
public void testImpossible() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/elvis/impossible.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/inference")
|
||||
|
||||
@@ -66,6 +66,12 @@ public class DiagnosticsTestWithJsStdLibGenerated extends AbstractDiagnosticsTes
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("wrongMultipleInheritance.kt")
|
||||
public void testWrongMultipleInheritance() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/wrongMultipleInheritance.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
@@ -10240,6 +10240,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("expectedTypeFromCastParenthesized.kt")
|
||||
public void testExpectedTypeFromCastParenthesized() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/expectedTypeFromCastParenthesized.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("expectedTypeWithGenerics.kt")
|
||||
public void testExpectedTypeWithGenerics() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/expectedTypeWithGenerics.kt");
|
||||
@@ -12256,6 +12262,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("annotationsInheritance.kt")
|
||||
public void testAnnotationsInheritance() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/annotationsInheritance.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayOfStarParametrized.kt")
|
||||
public void testArrayOfStarParametrized() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/arrayOfStarParametrized.kt");
|
||||
@@ -20892,6 +20904,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("impossible.kt")
|
||||
public void testImpossible() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/castchecks/impossible.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("insideCall.kt")
|
||||
public void testInsideCall() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/castchecks/insideCall.kt");
|
||||
@@ -20924,6 +20942,12 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/elvis/basicOn.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("impossible.kt")
|
||||
public void testImpossible() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/elvis/impossible.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/inference")
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||
import org.jetbrains.kotlin.config.CompilerConfiguration
|
||||
import org.jetbrains.kotlin.config.addKotlinSourceRoots
|
||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||
import org.jetbrains.kotlin.descriptors.impl.ModuleDescriptorImpl
|
||||
import org.jetbrains.kotlin.incremental.components.LookupTracker
|
||||
import org.jetbrains.kotlin.js.analyze.TopDownAnalyzerFacadeForJS
|
||||
@@ -78,7 +79,9 @@ class KotlinJavascriptSerializerTest : TestCaseWithTmpdir() {
|
||||
imported = listOf(),
|
||||
data = analysisResult.moduleDescriptor
|
||||
)
|
||||
FileUtil.writeToFile(metaFile, KotlinJavascriptSerializationUtil.metadataAsString(analysisResult.bindingContext, description))
|
||||
FileUtil.writeToFile(metaFile, KotlinJavascriptSerializationUtil.metadataAsString(
|
||||
analysisResult.bindingContext, description, configuration.languageVersionSettings
|
||||
))
|
||||
}
|
||||
finally {
|
||||
Disposer.dispose(rootDisposable)
|
||||
|
||||
@@ -55,7 +55,6 @@ enum class LanguageFeature(
|
||||
DeprecatedFieldForInvisibleCompanionObject(KOTLIN_1_2),
|
||||
NullabilityAssertionOnExtensionReceiver(KOTLIN_1_2),
|
||||
SafeCastCheckBoundSmartCasts(KOTLIN_1_2),
|
||||
BooleanElvisBoundSmartCasts(KOTLIN_1_2),
|
||||
CapturedInClosureSmartCasts(KOTLIN_1_2),
|
||||
LateinitTopLevelProperties(KOTLIN_1_2),
|
||||
LateinitLocalVariables(KOTLIN_1_2),
|
||||
@@ -66,6 +65,7 @@ enum class LanguageFeature(
|
||||
AssigningArraysToVarargsInNamedFormInAnnotations(KOTLIN_1_2),
|
||||
ExpectedTypeFromCast(KOTLIN_1_2),
|
||||
|
||||
BooleanElvisBoundSmartCasts(KOTLIN_1_3),
|
||||
ReturnsEffect(KOTLIN_1_3),
|
||||
CallsInPlaceEffect(KOTLIN_1_3),
|
||||
RestrictionOfValReassignmentViaBackingField(KOTLIN_1_3),
|
||||
@@ -184,3 +184,12 @@ class LanguageVersionSettingsImpl @JvmOverloads constructor(
|
||||
val DEFAULT = LanguageVersionSettingsImpl(LanguageVersion.LATEST_STABLE, ApiVersion.LATEST_STABLE)
|
||||
}
|
||||
}
|
||||
|
||||
fun LanguageVersionSettings.shouldWritePreReleaseFlag(): Boolean =
|
||||
languageVersion.shouldWritePreReleaseFlag()
|
||||
|
||||
fun LanguageVersion.shouldWritePreReleaseFlag(): Boolean {
|
||||
if (!isStable) return true
|
||||
|
||||
return KotlinCompilerVersion.isPreRelease() && this == LanguageVersion.LATEST_STABLE
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class DeserializedDescriptorResolver {
|
||||
}
|
||||
|
||||
private val KotlinJvmBinaryClass.isPreReleaseInvisible: Boolean
|
||||
get() = !skipMetadataVersionCheck &&
|
||||
get() = !components.configuration.skipPreReleaseCheck &&
|
||||
!KotlinCompilerVersion.isPreRelease() &&
|
||||
(classHeader.isPreRelease || classHeader.metadataVersion == KOTLIN_1_1_EAP_METADATA_VERSION)
|
||||
|
||||
|
||||
@@ -320,7 +320,7 @@ object NewKotlinTypeChecker : KotlinTypeChecker {
|
||||
}
|
||||
|
||||
private val ClassDescriptor.isCommonFinalClass: Boolean
|
||||
get() = isFinalClass && kind != ClassKind.ENUM_ENTRY
|
||||
get() = isFinalClass && kind != ClassKind.ENUM_ENTRY && kind != ClassKind.ANNOTATION_CLASS
|
||||
|
||||
/**
|
||||
* If we have several paths to some interface, we should prefer pure kotlin path.
|
||||
|
||||
@@ -20,6 +20,9 @@ interface DeserializationConfiguration {
|
||||
val skipMetadataVersionCheck: Boolean
|
||||
get() = false
|
||||
|
||||
val skipPreReleaseCheck: Boolean
|
||||
get() = false
|
||||
|
||||
val typeAliasesAllowed: Boolean
|
||||
get() = true
|
||||
|
||||
|
||||
@@ -21,10 +21,11 @@ public class KotlinCompilerVersion {
|
||||
// DON'T MODIFY IT
|
||||
public static final String VERSION = "@snapshot@";
|
||||
|
||||
// True if this compiler is of a non-stable (EAP or Beta) version.
|
||||
// Binaries produced by this compiler can not be loaded by release versions of the compiler.
|
||||
// True if the latest stable language version supported by this compiler has not yet been released.
|
||||
// Binaries produced by this compiler with that language version (or any future language version) are going to be marked
|
||||
// as "pre-release" and will not be loaded by release versions of the compiler.
|
||||
// Change this value before and after every major release
|
||||
private static final boolean IS_PRE_RELEASE = false;
|
||||
private static final boolean IS_PRE_RELEASE = true;
|
||||
|
||||
public static final String TEST_IS_PRE_RELEASE_SYSTEM_PROPERTY = "kotlin.test.is.pre.release";
|
||||
|
||||
@@ -38,6 +39,7 @@ public class KotlinCompilerVersion {
|
||||
}
|
||||
|
||||
static {
|
||||
//noinspection ConstantConditions
|
||||
if (!VERSION.equals("@snapshot@") && !VERSION.contains("-") && IS_PRE_RELEASE) {
|
||||
throw new IllegalStateException(
|
||||
"IS_PRE_RELEASE cannot be true for a compiler without '-' in its version.\n" +
|
||||
|
||||
@@ -32,7 +32,7 @@ dependencies {
|
||||
compile(projectTests(":kotlin-annotation-processing"))
|
||||
compile(projectTests(":plugins:uast-kotlin"))
|
||||
compile(projectTests(":js:js.tests"))
|
||||
compile(ideaSdkDeps("jps-build-test", subdir = "jps/test"))
|
||||
//compile(ideaSdkDeps("jps-build-test", subdir = "jps/test"))
|
||||
testCompile(project(":compiler.tests-common"))
|
||||
testCompile(project(":idea:idea-test-framework")) { isTransitive = false }
|
||||
testCompile(project(":compiler:incremental-compilation-impl"))
|
||||
@@ -49,7 +49,7 @@ dependencies {
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "Groovy"))
|
||||
testRuntime(ideaPluginDeps("coverage", "jacocoant", plugin = "coverage"))
|
||||
testRuntime(ideaPluginDeps("java-decompiler", plugin = "java-decompiler"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "maven"))
|
||||
//testRuntime(ideaPluginDeps("*.jar", plugin = "maven"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "android"))
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.jetbrains.kotlin.android.configure.AbstractConfigureProjectTest
|
||||
import org.jetbrains.kotlin.android.folding.AbstractAndroidResourceFoldingTest
|
||||
import org.jetbrains.kotlin.android.intention.AbstractAndroidIntentionTest
|
||||
import org.jetbrains.kotlin.android.intention.AbstractAndroidResourceIntentionTest
|
||||
import org.jetbrains.kotlin.android.lint.AbstractKotlinLintTest
|
||||
import org.jetbrains.kotlin.android.parcel.AbstractParcelBytecodeListingTest
|
||||
import org.jetbrains.kotlin.android.quickfix.AbstractAndroidLintQuickfixTest
|
||||
import org.jetbrains.kotlin.android.quickfix.AbstractAndroidQuickFixMultiFileTest
|
||||
@@ -115,8 +114,6 @@ import org.jetbrains.kotlin.idea.intentions.declarations.AbstractJoinLinesTest
|
||||
import org.jetbrains.kotlin.idea.internal.AbstractBytecodeToolWindowTest
|
||||
import org.jetbrains.kotlin.idea.kdoc.AbstractKDocHighlightingTest
|
||||
import org.jetbrains.kotlin.idea.kdoc.AbstractKDocTypingTest
|
||||
import org.jetbrains.kotlin.idea.maven.AbstractKotlinMavenInspectionTest
|
||||
import org.jetbrains.kotlin.idea.maven.configuration.AbstractMavenConfigureProjectByChangingFileTest
|
||||
import org.jetbrains.kotlin.idea.navigation.*
|
||||
import org.jetbrains.kotlin.idea.parameterInfo.AbstractParameterInfoTest
|
||||
import org.jetbrains.kotlin.idea.quickfix.AbstractQuickFixMultiFileTest
|
||||
@@ -152,10 +149,6 @@ import org.jetbrains.kotlin.ir.AbstractIrTextTestCase
|
||||
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterForWebDemoTest
|
||||
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterMultiFileTest
|
||||
import org.jetbrains.kotlin.j2k.AbstractJavaToKotlinConverterSingleFileTest
|
||||
import org.jetbrains.kotlin.jps.build.*
|
||||
import org.jetbrains.kotlin.jps.build.android.AbstractAndroidJpsTestCase
|
||||
import org.jetbrains.kotlin.jps.incremental.AbstractJsProtoComparisonTest
|
||||
import org.jetbrains.kotlin.jps.incremental.AbstractJvmProtoComparisonTest
|
||||
import org.jetbrains.kotlin.js.test.AbstractDceTest
|
||||
import org.jetbrains.kotlin.js.test.AbstractJsLineNumberTest
|
||||
import org.jetbrains.kotlin.js.test.semantics.*
|
||||
@@ -1123,23 +1116,26 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Maven and Gradle are not relevent for AS branch
|
||||
|
||||
testGroup("idea/idea-maven/test", "idea/idea-maven/testData") {
|
||||
testClass<AbstractMavenConfigureProjectByChangingFileTest> {
|
||||
model("configurator/jvm", extension = null, recursive = false, testMethod = "doTestWithMaven")
|
||||
model("configurator/js", extension = null, recursive = false, testMethod = "doTestWithJSMaven")
|
||||
}
|
||||
|
||||
testClass<AbstractKotlinMavenInspectionTest> {
|
||||
model("maven-inspections", pattern = "^([\\w\\-]+).xml$", singleClass = true)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("idea/idea-gradle/tests", "idea/testData") {
|
||||
testClass<AbstractGradleConfigureProjectByChangingFileTest> {
|
||||
model("configuration/gradle", extension = null, recursive = false, testMethod = "doTestGradle")
|
||||
model("configuration/gsk", extension = null, recursive = false, testMethod = "doTestGradle")
|
||||
model("configuration/gradle", pattern = """(\w+)_before\.gradle$""", testMethod = "doTestGradle")
|
||||
model("configuration/gsk", pattern = """(\w+)_before\.gradle.kts$""", testMethod = "doTestGradle")
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
testGroup("idea/tests", "compiler/testData") {
|
||||
testClass<AbstractResolveByStubTest> {
|
||||
@@ -1266,70 +1262,6 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("jps-plugin/jps-tests/test", "jps-plugin/testData") {
|
||||
testClass<AbstractIncrementalJpsTest> {
|
||||
model("incremental/multiModule", extension = null, excludeParentDirs = true)
|
||||
model("incremental/pureKotlin", extension = null, recursive = false)
|
||||
model("incremental/withJava", extension = null, excludeParentDirs = true)
|
||||
model("incremental/inlineFunCallSite", extension = null, excludeParentDirs = true)
|
||||
model("incremental/classHierarchyAffected", extension = null, excludeParentDirs = true)
|
||||
}
|
||||
|
||||
testClass<AbstractJvmLookupTrackerTest> {
|
||||
model("incremental/lookupTracker/jvm", extension = null, recursive = false)
|
||||
}
|
||||
testClass<AbstractJsLookupTrackerTest> {
|
||||
model("incremental/lookupTracker/js", extension = null, recursive = false)
|
||||
}
|
||||
|
||||
testClass(AbstractIncrementalLazyCachesTest::class.java) {
|
||||
model("incremental/lazyKotlinCaches", extension = null, excludeParentDirs = true)
|
||||
model("incremental/changeIncrementalOption", extension = null, excludeParentDirs = true)
|
||||
}
|
||||
|
||||
testClass(AbstractIncrementalCacheVersionChangedTest::class.java) {
|
||||
model("incremental/cacheVersionChanged", extension = null, excludeParentDirs = true)
|
||||
}
|
||||
|
||||
testClass<AbstractDataContainerVersionChangedTest> {
|
||||
model("incremental/cacheVersionChanged", extension = null, excludeParentDirs = true)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("jps-plugin/jps-tests/test", "jps-plugin/testData") {
|
||||
fun TestGroup.TestClass.commonProtoComparisonTests() {
|
||||
model("comparison/classSignatureChange", extension = null, excludeParentDirs = true)
|
||||
model("comparison/classPrivateOnlyChange", extension = null, excludeParentDirs = true)
|
||||
model("comparison/classMembersOnlyChanged", extension = null, excludeParentDirs = true)
|
||||
model("comparison/packageMembers", extension = null, excludeParentDirs = true)
|
||||
model("comparison/unchanged", extension = null, excludeParentDirs = true)
|
||||
}
|
||||
|
||||
testClass<AbstractJvmProtoComparisonTest> {
|
||||
commonProtoComparisonTests()
|
||||
model("comparison/jvmOnly", extension = null, excludeParentDirs = true)
|
||||
}
|
||||
|
||||
testClass<AbstractJsProtoComparisonTest> {
|
||||
commonProtoComparisonTests()
|
||||
model("comparison/jsOnly", extension = null, excludeParentDirs = true)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("compiler/incremental-compilation-impl/test", "jps-plugin/testData") {
|
||||
testClass<AbstractIncrementalJvmCompilerRunnerTest> {
|
||||
model("incremental/pureKotlin", extension = null, recursive = false)
|
||||
model("incremental/classHierarchyAffected", extension = null, recursive = false)
|
||||
model("incremental/inlineFunCallSite", extension = null, excludeParentDirs = true)
|
||||
model("incremental/withJava", extension = null, excludeParentDirs = true)
|
||||
}
|
||||
|
||||
testClass<AbstractIncrementalJsCompilerRunnerTest> {
|
||||
model("incremental/pureKotlin", extension = null, recursive = false)
|
||||
model("incremental/classHierarchyAffected", extension = null, recursive = false)
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("plugins/plugins-tests/tests", "plugins/android-extensions/android-extensions-compiler/testData") {
|
||||
testClass<AbstractAndroidSyntheticPropertyDescriptorTest> {
|
||||
model("descriptors", recursive = false, extension = null)
|
||||
@@ -1446,10 +1378,6 @@ fun main(args: Array<String>) {
|
||||
model("android/quickfix", pattern = """^(\w+)\.((before\.Main\.\w+)|(test))$""", testMethod = "doTestWithExtraFile")
|
||||
}
|
||||
|
||||
testClass<AbstractKotlinLintTest> {
|
||||
model("android/lint", excludeParentDirs = true)
|
||||
}
|
||||
|
||||
testClass<AbstractAndroidLintQuickfixTest> {
|
||||
model("android/lintQuickfix", pattern = "^([\\w\\-_]+)\\.kt$")
|
||||
}
|
||||
@@ -1463,14 +1391,7 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
}
|
||||
|
||||
testGroup("plugins/plugins-tests/tests", "plugins/android-extensions/android-extensions-jps/testData") {
|
||||
testClass<AbstractAndroidJpsTestCase> {
|
||||
model("android", recursive = false, extension = null)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: repair these tests
|
||||
//generateTestDataForReservedWords()
|
||||
generateTestDataForReservedWords()
|
||||
|
||||
testGroup("js/js.tests/test", "js/js.translator/testData") {
|
||||
testClass<AbstractBoxJsTest> {
|
||||
|
||||
@@ -39,7 +39,8 @@ val runIde by task<JavaExec> {
|
||||
"-Dsun.io.useCanonCaches=false",
|
||||
"-Dplugin.path=${ideaPluginDir.absolutePath}",
|
||||
"-Dkotlin.internal.mode.enabled=true",
|
||||
"-Didea.additional.classpath=../idea-kotlin-runtime/kotlin-runtime.jar,../idea-kotlin-runtime/kotlin-reflect.jar"
|
||||
"-Didea.additional.classpath=../idea-kotlin-runtime/kotlin-runtime.jar,../idea-kotlin-runtime/kotlin-reflect.jar",
|
||||
"-Didea.platform.prefix=AndroidStudio"
|
||||
)
|
||||
|
||||
if (project.hasProperty("noPCE")) {
|
||||
|
||||
@@ -50,7 +50,7 @@ dependencies {
|
||||
|
||||
testCompileOnly(ideaPluginDeps("gradle-base-services", "gradle-tooling-extension-impl", "gradle-wrapper", plugin = "gradle"))
|
||||
testCompileOnly(ideaPluginDeps("Groovy", plugin = "Groovy"))
|
||||
testCompileOnly(ideaPluginDeps("maven", "maven-server-api", plugin = "maven"))
|
||||
//testCompileOnly(ideaPluginDeps("maven", "maven-server-api", plugin = "maven"))
|
||||
|
||||
testCompileOnly(ideaSdkDeps("groovy-all", "velocity", "gson", "jsr305"))
|
||||
|
||||
@@ -61,7 +61,7 @@ dependencies {
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "gradle"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "Groovy"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "coverage"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "maven"))
|
||||
//testRuntime(ideaPluginDeps("*.jar", plugin = "maven"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "android"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "testng"))
|
||||
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
<?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" />
|
||||
</content>
|
||||
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="backend" />
|
||||
<orderEntry type="module" module-name="frontend" />
|
||||
<orderEntry type="module" module-name="frontend.java" />
|
||||
<orderEntry type="module" module-name="light-classes" />
|
||||
<orderEntry type="module" module-name="eval4j" />
|
||||
<orderEntry type="module-library">
|
||||
<library>
|
||||
<CLASSES>
|
||||
<root url="jar://$MODULE_DIR$/../../ideaSDK/core/annotations.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="library" name="guava" level="project" />
|
||||
<orderEntry type="module" module-name="js.frontend" />
|
||||
<orderEntry type="module" module-name="js.serializer" />
|
||||
<orderEntry type="library" name="trove4j" level="project" />
|
||||
<orderEntry type="module" module-name="ide-common" exported="" />
|
||||
<orderEntry type="module" module-name="util" />
|
||||
<orderEntry type="module" module-name="idea-core" />
|
||||
<orderEntry type="module" module-name="idea-jps-common" />
|
||||
<orderEntry type="module" module-name="cli-common" />
|
||||
<orderEntry type="module" module-name="descriptors" />
|
||||
<orderEntry type="library" exported="" name="idea-full" level="project" />
|
||||
<orderEntry type="library" name="uast-java" level="project" />
|
||||
<orderEntry type="module" module-name="frontend.script" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -19,9 +19,11 @@ package org.jetbrains.kotlin.idea.stubindex.resolve
|
||||
import com.intellij.openapi.components.service
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import com.intellij.psi.stubs.StubIndex
|
||||
import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.idea.caches.PerModulePackageCacheService
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.ModuleSourceInfo
|
||||
import org.jetbrains.kotlin.idea.stubindex.KotlinExactPackagesIndex
|
||||
import org.jetbrains.kotlin.idea.stubindex.PackageIndexUtil
|
||||
import org.jetbrains.kotlin.idea.stubindex.SubpackagesIndexService
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -70,11 +72,18 @@ class PluginDeclarationProviderFactory(
|
||||
override fun diagnoseMissingPackageFragment(file: KtFile) {
|
||||
val packageFqName = file.packageFqName
|
||||
val subpackagesIndex = SubpackagesIndexService.getInstance(project)
|
||||
throw IllegalStateException("Cannot find package fragment for file ${file.name} with package $packageFqName, " +
|
||||
"vFile ${file.virtualFile}, nonIndexed ${file in nonIndexedFiles} " +
|
||||
"packageExists=${PackageIndexUtil.packageExists(packageFqName, indexedFilesScope, project)} in $indexedFilesScope," +
|
||||
"SPI.packageExists=${subpackagesIndex.packageExists(packageFqName)} SPI=$subpackagesIndex " +
|
||||
"OOCB count ${file.manager.modificationTracker.outOfCodeBlockModificationCount}}")
|
||||
val moduleSourceInfo = moduleInfo as? ModuleSourceInfo
|
||||
val virtualFile = file.virtualFile
|
||||
throw IllegalStateException("""
|
||||
Cannot find package fragment for file ${file.name} with package '$packageFqName':
|
||||
vFile: $virtualFile,
|
||||
nonIndexed files: $nonIndexedFiles, isNonIndexed: ${file in nonIndexedFiles},
|
||||
scope = $indexedFilesScope, isInScope = ${virtualFile in indexedFilesScope},
|
||||
packageExists = ${PackageIndexUtil.packageExists(packageFqName, indexedFilesScope, project)}, cachedPackageExists = ${moduleSourceInfo?.let { project.service<PerModulePackageCacheService>().packageExists(packageFqName, it) }},
|
||||
oldPackageExists = ${oldPackageExists(packageFqName) ?: "threw exception"},
|
||||
SPI.packageExists = ${subpackagesIndex.packageExists(packageFqName)}, SPI = $subpackagesIndex, OOCB count ${file.manager.modificationTracker.outOfCodeBlockModificationCount},
|
||||
ModuleModificationCount = ${moduleSourceInfo?.createModificationTracker()?.modificationCount},
|
||||
packageFqNameByTree = '${file.packageFqNameByTree}', packageDirectiveText = '${file.packageDirective?.text}'""")
|
||||
}
|
||||
|
||||
// trying to diagnose org.jetbrains.kotlin.resolve.lazy.NoDescriptorForDeclarationException in completion
|
||||
@@ -84,6 +93,20 @@ class PluginDeclarationProviderFactory(
|
||||
return "PluginDeclarationProviderFactory\nOn failure:\n${debugInfo()}On creation:\n$onCreationDebugInfo"
|
||||
}
|
||||
|
||||
private fun oldPackageExists(packageFqName: FqName): Boolean? = try {
|
||||
var result = false
|
||||
StubIndex.getInstance().processElements<String, KtFile>(
|
||||
KotlinExactPackagesIndex.getInstance().key, packageFqName.asString(), project, indexedFilesScope, KtFile::class.java
|
||||
) {
|
||||
result = true
|
||||
false
|
||||
}
|
||||
result
|
||||
}
|
||||
catch (e: Throwable) {
|
||||
null
|
||||
}
|
||||
|
||||
private fun debugInfo(): String {
|
||||
if (nonIndexedFiles.isEmpty()) return "-no synthetic files-\n"
|
||||
|
||||
|
||||
@@ -14,8 +14,9 @@ dependencies {
|
||||
|
||||
compile(ideaSdkDeps("openapi", "idea"))
|
||||
compile(ideaPluginDeps("gradle-tooling-api", plugin = "gradle"))
|
||||
compile(ideaPluginDeps("android", "android-common", "sdklib", "sdk-common", "layoutlib-api", plugin = "android"))
|
||||
compile(ideaPluginDeps("android", "android-common", "sdklib", "sdk-common", "layoutlib-api", "sdk-tools", "adt-ui", /*"common",*/ plugin = "android"))
|
||||
compile(preloadedDeps("dx", subdir = "android-5.0/lib"))
|
||||
compile(ideaSdkDeps("android-base-common"))
|
||||
|
||||
testCompile(projectDist(":kotlin-test:kotlin-test-jvm"))
|
||||
testCompile(project(":compiler.tests-common"))
|
||||
@@ -27,6 +28,7 @@ dependencies {
|
||||
testCompile(ideaPluginDeps("properties", plugin = "properties"))
|
||||
testCompile(ideaSdkDeps("gson"))
|
||||
testCompile(commonDep("junit:junit"))
|
||||
testCompile(ideaPluginDeps("build-common", plugin = "android"))
|
||||
|
||||
testRuntime(project(":plugins:android-extensions-ide"))
|
||||
testRuntime(project(":sam-with-receiver-ide-plugin"))
|
||||
@@ -43,7 +45,7 @@ dependencies {
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "Groovy"))
|
||||
testRuntime(ideaPluginDeps("coverage", "jacocoant", plugin = "coverage"))
|
||||
testRuntime(ideaPluginDeps("java-decompiler", plugin = "java-decompiler"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "maven"))
|
||||
//testRuntime(ideaPluginDeps("*.jar", plugin = "maven"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "android"))
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@ dependencies {
|
||||
compile(project(":compiler:util"))
|
||||
compile(ideaSdkCoreDeps("intellij-core"))
|
||||
compile(ideaPluginDeps("gradle-tooling-api", plugin = "gradle"))
|
||||
compile(ideaPluginDeps("android", "android-common", "sdk-common", plugin = "android"))
|
||||
compile(ideaPluginDeps("android", "android-common", "sdk-common", /*"common",*/ plugin = "android"))
|
||||
compile(ideaSdkDeps("android-base-common"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.android
|
||||
|
||||
import com.android.tools.idea.npw.template.ConvertJavaToKotlinProvider
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.PsiJavaFile
|
||||
import org.jetbrains.kotlin.android.configure.KotlinAndroidGradleModuleConfigurator
|
||||
import org.jetbrains.kotlin.idea.actions.JavaToKotlinAction
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinProjectConfigurator
|
||||
import org.jetbrains.kotlin.idea.configuration.getCanBeConfiguredModules
|
||||
import org.jetbrains.kotlin.idea.versions.bundledRuntimeVersion
|
||||
|
||||
class ConvertJavaToKotlinProviderImpl : ConvertJavaToKotlinProvider {
|
||||
override fun configureKotlin(project: Project) {
|
||||
val configurator = KotlinProjectConfigurator.EP_NAME.findExtension(KotlinAndroidGradleModuleConfigurator::class.java)
|
||||
val nonConfiguredModules = getCanBeConfiguredModules(project, configurator)
|
||||
configurator.configureSilently(project, nonConfiguredModules, bundledRuntimeVersion())
|
||||
}
|
||||
|
||||
override fun getKotlinVersion(): String {
|
||||
return bundledRuntimeVersion()
|
||||
}
|
||||
|
||||
override fun convertToKotlin(project: Project, files: List<PsiJavaFile>): List<PsiFile> {
|
||||
return JavaToKotlinAction.convertFiles(files, project, askExternalCodeProcessing = false)
|
||||
}
|
||||
}
|
||||
@@ -34,6 +34,7 @@ import com.intellij.ui.awt.RelativePoint
|
||||
import com.intellij.util.Function
|
||||
import org.jetbrains.android.dom.manifest.Manifest
|
||||
import org.jetbrains.android.facet.AndroidFacet
|
||||
import org.jetbrains.android.resourceManagers.ModuleResourceManagers
|
||||
import org.jetbrains.kotlin.descriptors.ClassDescriptor
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.unsafeResolveToDescriptor
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -95,7 +96,8 @@ class KotlinAndroidLineMarkerProvider : LineMarkerProvider {
|
||||
return
|
||||
}
|
||||
|
||||
val files = androidFacet
|
||||
val files = ModuleResourceManagers
|
||||
.getInstance(androidFacet)
|
||||
.localResourceManager
|
||||
.findResourcesByFieldName(resClassName, info.fieldName)
|
||||
.filterIsInstance<PsiFile>()
|
||||
|
||||
@@ -23,8 +23,8 @@ import com.android.ide.common.resources.ResourceRepository;
|
||||
import com.android.ide.common.resources.ResourceResolver;
|
||||
import com.android.resources.ResourceType;
|
||||
import com.android.tools.idea.configurations.Configuration;
|
||||
import com.android.tools.idea.configurations.ConfigurationManager;
|
||||
import com.android.tools.idea.res.AppResourceRepository;
|
||||
import com.android.tools.idea.res.LocalResourceRepository;
|
||||
import com.android.tools.idea.res.ResourceHelper;
|
||||
import com.android.tools.idea.ui.resourcechooser.ColorPicker;
|
||||
import com.android.utils.XmlUtils;
|
||||
@@ -61,10 +61,7 @@ import java.awt.*;
|
||||
import java.io.File;
|
||||
|
||||
import static com.android.SdkConstants.*;
|
||||
import static com.android.SdkConstants.ANDROID_URI;
|
||||
import static com.android.SdkConstants.ATTR_DRAWABLE;
|
||||
import static com.android.tools.idea.uibuilder.property.renderer.NlDefaultRenderer.ICON_SIZE;
|
||||
import static org.jetbrains.android.AndroidColorAnnotator.pickLayoutFile;
|
||||
|
||||
/**
|
||||
* Contains copied privates from AndroidColorAnnotator, so we could use them for Kotlin AndroidResourceReferenceAnnotator
|
||||
@@ -146,7 +143,7 @@ public class ResourceReferenceAnnotatorUtil {
|
||||
ResourceItem item = frameworkResources.getResourceItem(type, name);
|
||||
return item.getResourceValue(type, configuration.getFullConfig(), false);
|
||||
} else {
|
||||
LocalResourceRepository appResources = AppResourceRepository.getAppResources(module, true);
|
||||
AppResourceRepository appResources = AppResourceRepository.getOrCreateInstance(module);
|
||||
if (appResources == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -161,26 +158,27 @@ public class ResourceReferenceAnnotatorUtil {
|
||||
@Nullable
|
||||
public static Configuration pickConfiguration(AndroidFacet facet, Module module, PsiFile file) {
|
||||
VirtualFile virtualFile = file.getVirtualFile();
|
||||
if (virtualFile == null) {
|
||||
if(virtualFile == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
VirtualFile parent = virtualFile.getParent();
|
||||
if (parent == null) {
|
||||
return null;
|
||||
}
|
||||
VirtualFile layout;
|
||||
String parentName = parent.getName();
|
||||
if (!parentName.startsWith(FD_RES_LAYOUT)) {
|
||||
layout = pickLayoutFile(module, facet);
|
||||
if (layout == null) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
layout = virtualFile;
|
||||
}
|
||||
VirtualFile parent = virtualFile.getParent();
|
||||
if(parent == null) {
|
||||
return null;
|
||||
} else {
|
||||
String parentName = parent.getName();
|
||||
VirtualFile layout;
|
||||
if(!parentName.startsWith("layout")) {
|
||||
layout = ResourceHelper.pickAnyLayoutFile(module, facet);
|
||||
if(layout == null) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
layout = virtualFile;
|
||||
}
|
||||
|
||||
return facet.getConfigurationManager().getConfiguration(layout);
|
||||
return ConfigurationManager.getOrCreateInstance(module).getConfiguration(layout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class ColorRenderer extends GutterIconRenderer {
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.android.configure
|
||||
|
||||
import com.android.tools.idea.gradle.project.model.AndroidModuleModel
|
||||
import com.android.tools.idea.gradle.project.sync.setup.post.ModuleSetupStep
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import org.jetbrains.android.facet.AndroidFacet
|
||||
import org.jetbrains.kotlin.idea.configuration.compilerArgumentsBySourceSet
|
||||
import org.jetbrains.kotlin.idea.configuration.configureFacetByCompilerArguments
|
||||
import org.jetbrains.kotlin.idea.configuration.sourceSetName
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
|
||||
class KotlinAndroidModuleSetupStep : ModuleSetupStep() {
|
||||
override fun setUpModule(module: Module, progressIndicator: ProgressIndicator?) {
|
||||
val facet = AndroidFacet.getInstance(module) ?: return
|
||||
val androidModel = AndroidModuleModel.get(facet) ?: return
|
||||
val sourceSetName = androidModel.selectedVariant.name
|
||||
if (module.sourceSetName == sourceSetName) return
|
||||
val argsInfo = module.compilerArgumentsBySourceSet?.get(sourceSetName) ?: return
|
||||
val kotlinFacet = KotlinFacet.get(module) ?: return
|
||||
module.sourceSetName = sourceSetName
|
||||
configureFacetByCompilerArguments(kotlinFacet, argsInfo, null)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.android.configure
|
||||
|
||||
import com.android.tools.idea.gradle.project.model.AndroidModuleModel
|
||||
import com.intellij.openapi.externalSystem.model.DataNode
|
||||
import com.intellij.openapi.externalSystem.model.Key
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData
|
||||
import com.intellij.openapi.externalSystem.service.project.IdeModifiableModelsProvider
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.AbstractProjectDataService
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.idea.configuration.GradleProjectImportHandler
|
||||
import org.jetbrains.kotlin.idea.configuration.configureFacetByGradleModule
|
||||
|
||||
class KotlinGradleAndroidModuleModelProjectDataService : AbstractProjectDataService<AndroidModuleModel, Void>() {
|
||||
companion object {
|
||||
val KEY = Key<AndroidModuleModel>(AndroidModuleModel::class.qualifiedName!!, 0)
|
||||
}
|
||||
|
||||
override fun getTargetDataKey() = KEY
|
||||
|
||||
override fun postProcess(
|
||||
toImport: MutableCollection<DataNode<AndroidModuleModel>>,
|
||||
projectData: ProjectData?,
|
||||
project: Project,
|
||||
modelsProvider: IdeModifiableModelsProvider
|
||||
) {
|
||||
super.postProcess(toImport, projectData, project, modelsProvider)
|
||||
for (moduleModelNode in toImport) {
|
||||
val moduleNode = ExternalSystemApiUtil.findParent(moduleModelNode, ProjectKeys.MODULE) ?: continue
|
||||
val moduleData = moduleNode.data
|
||||
val ideModule = modelsProvider.findIdeModule(moduleData) ?: continue
|
||||
val sourceSetName = moduleModelNode.data.selectedVariant.name
|
||||
val kotlinFacet = configureFacetByGradleModule(moduleNode, sourceSetName, ideModule, modelsProvider) ?: continue
|
||||
GradleProjectImportHandler.getInstances(project).forEach { it.importByModule(kotlinFacet, moduleNode) }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.android.configure
|
||||
|
||||
import com.android.tools.idea.gradle.project.sync.idea.data.service.AndroidProjectKeys
|
||||
import com.intellij.openapi.externalSystem.model.DataNode
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import org.jetbrains.kotlin.idea.inspections.gradle.KotlinPlatformGradleDetector
|
||||
|
||||
class PlatformAndroidGradleDetector : KotlinPlatformGradleDetector {
|
||||
override fun getResolvedKotlinStdlibVersionByModuleData(moduleData: DataNode<*>, libraryIds: List<String>): String? {
|
||||
ExternalSystemApiUtil
|
||||
.findAllRecursively(moduleData, AndroidProjectKeys.JAVA_MODULE_MODEL).asSequence()
|
||||
.flatMap { it.data.jarLibraryDependencies.asSequence() }
|
||||
.forEach {
|
||||
val libraryName = it.name
|
||||
for (libraryId in libraryIds) {
|
||||
val prefix = "$libraryId-"
|
||||
if (libraryName.startsWith(prefix)) return libraryName.substringAfter(prefix)
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import com.intellij.openapi.roots.ProjectRootModificationTracker
|
||||
import com.intellij.psi.util.CachedValueProvider
|
||||
import com.intellij.psi.util.CachedValuesManager
|
||||
import org.jetbrains.android.facet.AndroidFacet
|
||||
import org.jetbrains.android.sdk.AndroidSdkData
|
||||
import org.jetbrains.kotlin.idea.debugger.evaluate.classLoading.AndroidDexer
|
||||
import org.jetbrains.kotlin.idea.debugger.evaluate.classLoading.ClassToLoad
|
||||
import java.io.File
|
||||
@@ -56,7 +57,7 @@ class AndroidDexerImpl(val project: Project) : AndroidDexer {
|
||||
private fun doGetAndroidDexFile(): File? {
|
||||
for (module in ModuleManager.getInstance(project).modules) {
|
||||
val androidFacet = AndroidFacet.getInstance(module) ?: continue
|
||||
val sdkData = androidFacet.sdkData ?: continue
|
||||
val sdkData = AndroidSdkData.getSdkData(androidFacet) ?: continue
|
||||
val latestBuildTool = sdkData.getLatestBuildTool(/* allowPreview = */ false)
|
||||
?: sdkData.getLatestBuildTool(/* allowPreview = */ true)
|
||||
?: continue
|
||||
|
||||
@@ -47,7 +47,6 @@ class ResourceFoldingBuilder : FoldingBuilderEx() {
|
||||
// See lint's StringFormatDetector
|
||||
private val FORMAT = Pattern.compile("%(\\d+\\$)?([-+#, 0(<]*)?(\\d+)?(\\.\\d+)?([tT])?([a-zA-Z%])")
|
||||
private val FOLD_MAX_LENGTH = 60
|
||||
private val FORCE_PROJECT_RESOURCE_LOADING = true
|
||||
private val UNIT_TEST_MODE: Boolean = ApplicationManager.getApplication().isUnitTestMode
|
||||
private val RESOURCE_TYPES = listOf(ResourceType.STRING,
|
||||
ResourceType.DIMEN,
|
||||
@@ -254,6 +253,6 @@ class ResourceFoldingBuilder : FoldingBuilderEx() {
|
||||
}
|
||||
|
||||
private fun getAppResources(element: PsiElement): LocalResourceRepository? = ModuleUtilCore.findModuleForPsiElement(element)?.let {
|
||||
AppResourceRepository.getAppResources(it, FORCE_PROJECT_RESOURCE_LOADING)
|
||||
AppResourceRepository.findExistingInstance(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
|
||||
|
||||
class TypeParameterFindViewByIdInspection : AbstractKotlinInspection(), CleanupLocalInspectionTool {
|
||||
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): PsiElementVisitor {
|
||||
return KtVisitorVoid()
|
||||
/*
|
||||
val compileSdk = AndroidFacet.getInstance(session.file)?.androidModuleInfo?.buildSdkVersion?.apiLevel
|
||||
if (compileSdk == null || compileSdk < 26) {
|
||||
return KtVisitorVoid()
|
||||
@@ -53,7 +55,7 @@ class TypeParameterFindViewByIdInspection : AbstractKotlinInspection(), CleanupL
|
||||
"Can be converted to findViewById<$typeText>(...)",
|
||||
ConvertCastToFindViewByIdWithTypeParameter())
|
||||
}
|
||||
}
|
||||
} */
|
||||
}
|
||||
|
||||
class ConvertCastToFindViewByIdWithTypeParameter : LocalQuickFix {
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.jetbrains.android.dom.resources.Attr;
|
||||
import org.jetbrains.android.dom.resources.DeclareStyleable;
|
||||
import org.jetbrains.android.facet.AndroidFacet;
|
||||
import org.jetbrains.android.resourceManagers.LocalResourceManager;
|
||||
import org.jetbrains.android.resourceManagers.ModuleResourceManagers;
|
||||
import org.jetbrains.android.resourceManagers.ResourceManager;
|
||||
import org.jetbrains.android.util.AndroidResourceUtil;
|
||||
import org.jetbrains.android.util.AndroidUtils;
|
||||
@@ -68,9 +69,10 @@ public class KotlinAndroidGotoDeclarationHandler implements GotoDeclarationHandl
|
||||
collectManifestElements(nestedClassName, fieldName, facet, resourceList);
|
||||
}
|
||||
else {
|
||||
ModuleResourceManagers managers = ModuleResourceManagers.getInstance(facet);
|
||||
ResourceManager manager = info.isSystem()
|
||||
? facet.getSystemResourceManager(false)
|
||||
: facet.getLocalResourceManager();
|
||||
? managers.getSystemResourceManager(false)
|
||||
: managers.getLocalResourceManager();
|
||||
if (manager == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.intellij.psi.util.PsiTreeUtil
|
||||
import com.intellij.psi.PsiClass
|
||||
import org.jetbrains.android.util.AndroidUtils
|
||||
import com.android.SdkConstants
|
||||
import com.intellij.openapi.module.ModuleUtil
|
||||
import org.jetbrains.android.augment.AndroidPsiElementFinder
|
||||
import org.jetbrains.kotlin.idea.references.mainReference
|
||||
import org.jetbrains.kotlin.psi.KtDotQualifiedExpression
|
||||
@@ -68,7 +67,6 @@ private fun getReferredInfo(
|
||||
val firstPart = getReceiverAsSimpleNameExpression(middlePart) ?: return null
|
||||
|
||||
val resolvedClass = firstPart.mainReference.resolve() as? PsiClass ?: return null
|
||||
val resolvedModule = ModuleUtil.findModuleForPsiElement(resolvedClass)
|
||||
|
||||
//the following code is copied from
|
||||
// org.jetbrains.android.util.AndroidResourceUtil.getReferredResourceOrManifestField
|
||||
@@ -83,7 +81,7 @@ private fun getReferredInfo(
|
||||
val qName = resolvedClass.qualifiedName
|
||||
|
||||
if (SdkConstants.CLASS_R == qName || AndroidPsiElementFinder.INTERNAL_R_CLASS_QNAME == qName) {
|
||||
return AndroidResourceUtil.MyReferredResourceFieldInfo(resClassName, resFieldName, resolvedModule, true, false)
|
||||
return AndroidResourceUtil.MyReferredResourceFieldInfo(resClassName, resFieldName, facet.module, true, false)
|
||||
}
|
||||
val containingFile = resolvedClass.containingFile ?: return null
|
||||
|
||||
@@ -95,7 +93,7 @@ private fun getReferredInfo(
|
||||
return null
|
||||
}
|
||||
|
||||
return AndroidResourceUtil.MyReferredResourceFieldInfo(resClassName, resFieldName, resolvedModule, false, fromManifest)
|
||||
return AndroidResourceUtil.MyReferredResourceFieldInfo(resClassName, resFieldName, facet.module, false, fromManifest)
|
||||
}
|
||||
|
||||
private fun getReceiverAsSimpleNameExpression(exp: KtSimpleNameExpression): KtSimpleNameExpression? {
|
||||
|
||||
@@ -14,13 +14,15 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.android.inspections.klint
|
||||
package org.jetbrains.kotlin.android.quickfix
|
||||
|
||||
import com.android.SdkConstants
|
||||
import com.android.tools.klint.checks.ApiDetector.REQUIRES_API_ANNOTATION
|
||||
import com.android.tools.lint.checks.ApiDetector.REQUIRES_API_ANNOTATION
|
||||
import com.intellij.codeInsight.FileModificationService
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.android.inspections.lint.AndroidLintQuickFix
|
||||
import org.jetbrains.android.inspections.lint.AndroidQuickfixContexts
|
||||
import org.jetbrains.android.util.AndroidBundle
|
||||
import org.jetbrains.kotlin.android.hasBackingField
|
||||
import org.jetbrains.kotlin.idea.util.addAnnotation
|
||||
@@ -14,12 +14,14 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.android.inspections.klint
|
||||
package org.jetbrains.kotlin.android.quickfix
|
||||
|
||||
import com.intellij.codeInsight.FileModificationService
|
||||
import com.intellij.psi.PsiDocumentManager
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.android.inspections.lint.AndroidLintQuickFix
|
||||
import org.jetbrains.android.inspections.lint.AndroidQuickfixContexts
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.codeInsight.surroundWith.statement.KotlinIfSurrounder
|
||||
import org.jetbrains.kotlin.idea.core.ShortenReferences
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.android.inspections.klint
|
||||
package org.jetbrains.kotlin.android.quickfix
|
||||
|
||||
import com.android.sdklib.SdkVersionInfo
|
||||
import com.android.sdklib.SdkVersionInfo.*
|
||||
|
||||
|
||||
fun getVersionField(api: Int, fullyQualified: Boolean): String = SdkVersionInfo.getBuildCode(api)?.let {
|
||||
fun getVersionField(api: Int, fullyQualified: Boolean): String = getBuildCode(api)?.let {
|
||||
if (fullyQualified) "android.os.Build.VERSION_CODES.$it" else it
|
||||
} ?: api.toString()
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.android.quickfix
|
||||
|
||||
import com.android.SdkConstants.SUPPORT_ANNOTATIONS_PREFIX
|
||||
import com.android.tools.lint.checks.ApiDetector
|
||||
import com.android.tools.lint.checks.CommentDetector
|
||||
import com.android.tools.lint.checks.ParcelDetector
|
||||
import com.android.tools.lint.detector.api.Issue
|
||||
import com.intellij.psi.JavaPsiFacade
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.search.GlobalSearchScope
|
||||
import org.jetbrains.android.inspections.lint.AndroidLintQuickFix
|
||||
import org.jetbrains.android.inspections.lint.AndroidLintQuickFixProvider
|
||||
import java.util.regex.Pattern
|
||||
|
||||
|
||||
class KotlinAndroidQuickFixProvider : AndroidLintQuickFixProvider {
|
||||
override fun getQuickFixes(
|
||||
issue: Issue,
|
||||
startElement: PsiElement,
|
||||
endElement: PsiElement,
|
||||
message: String,
|
||||
data: Any?
|
||||
): Array<AndroidLintQuickFix> {
|
||||
val fixes: Array<AndroidLintQuickFix> = when (issue) {
|
||||
ApiDetector.UNSUPPORTED, ApiDetector.INLINED -> getApiQuickFixes(issue, startElement, message)
|
||||
ParcelDetector.ISSUE -> arrayOf(ParcelableQuickFix())
|
||||
else -> emptyArray()
|
||||
}
|
||||
|
||||
if (issue != CommentDetector.STOP_SHIP) {
|
||||
return fixes + SuppressLintQuickFix(issue.id)
|
||||
}
|
||||
|
||||
return fixes
|
||||
}
|
||||
|
||||
fun getApiQuickFixes(issue: Issue, element: PsiElement, message: String): Array<AndroidLintQuickFix> {
|
||||
val api = getRequiredVersion(message)
|
||||
if (api == -1) {
|
||||
return AndroidLintQuickFix.EMPTY_ARRAY
|
||||
}
|
||||
|
||||
val project = element.project
|
||||
if (JavaPsiFacade.getInstance(project).findClass(REQUIRES_API_ANNOTATION, GlobalSearchScope.allScope(project)) != null) {
|
||||
return arrayOf(AddTargetApiQuickFix(api, true), AddTargetApiQuickFix(api, false), AddTargetVersionCheckQuickFix(api))
|
||||
}
|
||||
|
||||
return arrayOf(AddTargetApiQuickFix(api, false), AddTargetVersionCheckQuickFix(api))
|
||||
}
|
||||
|
||||
private fun getRequiredVersion(errorMessage: String): Int {
|
||||
val pattern = Pattern.compile("\\s(\\d+)\\s")
|
||||
val matcher = pattern.matcher(errorMessage)
|
||||
if (matcher.find()) {
|
||||
return Integer.parseInt(matcher.group(1))
|
||||
}
|
||||
|
||||
return -1
|
||||
}
|
||||
|
||||
companion object {
|
||||
val REQUIRES_API_ANNOTATION = SUPPORT_ANNOTATIONS_PREFIX + "RequiresApi"
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.android.inspections.klint
|
||||
package org.jetbrains.kotlin.android.quickfix
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.android.inspections.lint.AndroidLintQuickFix
|
||||
import org.jetbrains.android.inspections.lint.AndroidQuickfixContexts
|
||||
import org.jetbrains.android.util.AndroidBundle
|
||||
import org.jetbrains.kotlin.android.canAddParcelable
|
||||
import org.jetbrains.kotlin.android.implementParcelable
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,52 +14,26 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.android.inspections.klint
|
||||
package org.jetbrains.kotlin.android.quickfix
|
||||
|
||||
import com.android.SdkConstants.FQCN_SUPPRESS_LINT
|
||||
import com.android.SdkConstants
|
||||
import com.intellij.codeInsight.FileModificationService
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.icons.AllIcons
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.Iconable
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.psi.util.PsiTreeUtil
|
||||
import org.jetbrains.android.inspections.lint.AndroidLintQuickFix
|
||||
import org.jetbrains.android.inspections.lint.AndroidQuickfixContexts
|
||||
import org.jetbrains.android.util.AndroidBundle
|
||||
import org.jetbrains.kotlin.android.hasBackingField
|
||||
import org.jetbrains.kotlin.idea.util.addAnnotation
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import javax.swing.Icon
|
||||
|
||||
|
||||
class SuppressLintIntentionAction(val id: String, val element: PsiElement) : IntentionAction, Iconable {
|
||||
|
||||
private companion object {
|
||||
val INTENTION_NAME_PREFIX = "AndroidKLint"
|
||||
val SUPPRESS_LINT_MESSAGE = "android.lint.fix.suppress.lint.api.annotation"
|
||||
val FQNAME_SUPPRESS_LINT = FqName(FQCN_SUPPRESS_LINT)
|
||||
}
|
||||
|
||||
class SuppressLintQuickFix(id: String) : AndroidLintQuickFix {
|
||||
private val lintId = getLintId(id)
|
||||
|
||||
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?) = true
|
||||
|
||||
override fun getText(): String = AndroidBundle.message(SUPPRESS_LINT_MESSAGE, lintId)
|
||||
|
||||
override fun getFamilyName() = text
|
||||
|
||||
override fun getIcon(flags: Int): Icon? = AllIcons.Actions.Cancel
|
||||
|
||||
override fun startInWriteAction() = true
|
||||
|
||||
override fun invoke(project: Project, editor: Editor?, file: PsiFile?) {
|
||||
if (file !is KtFile) {
|
||||
return
|
||||
}
|
||||
|
||||
val annotationContainer = PsiTreeUtil.findFirstParent(element, true) { it.isSuppressLintTarget() } ?: return
|
||||
override fun apply(startElement: PsiElement, endElement: PsiElement, context: AndroidQuickfixContexts.Context) {
|
||||
val annotationContainer = PsiTreeUtil.findFirstParent(startElement, true) { it.isSuppressLintTarget() } ?: return
|
||||
if (!FileModificationService.getInstance().preparePsiElementForWrite(annotationContainer)) {
|
||||
return
|
||||
}
|
||||
@@ -67,14 +41,24 @@ class SuppressLintIntentionAction(val id: String, val element: PsiElement) : Int
|
||||
val argument = "\"$lintId\""
|
||||
|
||||
when (annotationContainer) {
|
||||
is KtModifierListOwner -> annotationContainer.addAnnotation(
|
||||
FQNAME_SUPPRESS_LINT,
|
||||
argument,
|
||||
whiteSpaceText = if (annotationContainer.isNewLineNeededForAnnotation()) "\n" else " ",
|
||||
addToExistingAnnotation = { entry -> addArgumentToAnnotation(entry, argument) })
|
||||
is KtModifierListOwner -> {
|
||||
annotationContainer.addAnnotation(
|
||||
FQNAME_SUPPRESS_LINT,
|
||||
argument,
|
||||
whiteSpaceText = if (annotationContainer.isNewLineNeededForAnnotation()) "\n" else " ",
|
||||
addToExistingAnnotation = { entry -> addArgumentToAnnotation(entry, argument) })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getName(): String = AndroidBundle.message(SUPPRESS_LINT_MESSAGE, lintId)
|
||||
|
||||
override fun isApplicable(
|
||||
startElement: PsiElement,
|
||||
endElement: PsiElement,
|
||||
contextType: AndroidQuickfixContexts.ContextType
|
||||
): Boolean = true
|
||||
|
||||
private fun addArgumentToAnnotation(entry: KtAnnotationEntry, argument: String): Boolean {
|
||||
// add new arguments to an existing entry
|
||||
val args = entry.valueArgumentList
|
||||
@@ -107,4 +91,9 @@ class SuppressLintIntentionAction(val id: String, val element: PsiElement) : Int
|
||||
this !is KtFunctionLiteral &&
|
||||
this !is KtDestructuringDeclaration
|
||||
}
|
||||
private companion object {
|
||||
val INTENTION_NAME_PREFIX = "AndroidLint"
|
||||
val SUPPRESS_LINT_MESSAGE = "android.lint.fix.suppress.lint.api.annotation"
|
||||
val FQNAME_SUPPRESS_LINT = FqName(SdkConstants.FQCN_SUPPRESS_LINT)
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.android.lint
|
||||
|
||||
import com.intellij.codeInspection.InspectionProfileEntry
|
||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl
|
||||
import com.intellij.util.PathUtil
|
||||
import org.jetbrains.android.inspections.klint.AndroidLintInspectionBase
|
||||
import org.jetbrains.kotlin.android.KotlinAndroidTestCase
|
||||
import org.jetbrains.kotlin.idea.test.ConfigLibraryUtil
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils.findStringWithPrefixes
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractKotlinLintTest : KotlinAndroidTestCase() {
|
||||
|
||||
override fun setUp() {
|
||||
super.setUp()
|
||||
AndroidLintInspectionBase.invalidateInspectionShortName2IssueMap()
|
||||
(myFixture as CodeInsightTestFixtureImpl).setVirtualFileFilter { false } // Allow access to tree elements.
|
||||
ConfigLibraryUtil.configureKotlinRuntime(myModule)
|
||||
}
|
||||
|
||||
override fun tearDown() {
|
||||
ConfigLibraryUtil.unConfigureKotlinRuntime(myModule)
|
||||
super.tearDown()
|
||||
}
|
||||
|
||||
fun doTest(path: String) {
|
||||
val ktFile = File(path)
|
||||
val fileText = ktFile.readText()
|
||||
val mainInspectionClassName = findStringWithPrefixes(fileText, "// INSPECTION_CLASS: ") ?: error("Empty class name")
|
||||
val dependencies = InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, "// DEPENDENCY: ")
|
||||
|
||||
val inspectionClassNames = mutableListOf(mainInspectionClassName)
|
||||
for (i in 2..100) {
|
||||
val className = findStringWithPrefixes(ktFile.readText(), "// INSPECTION_CLASS$i: ") ?: break
|
||||
inspectionClassNames += className
|
||||
}
|
||||
|
||||
myFixture.enableInspections(*inspectionClassNames.map { className ->
|
||||
val inspectionClass = Class.forName(className)
|
||||
inspectionClass.newInstance() as InspectionProfileEntry
|
||||
}.toTypedArray())
|
||||
|
||||
val additionalResourcesDir = File(ktFile.parentFile, getTestName(true))
|
||||
if (additionalResourcesDir.exists()) {
|
||||
for (file in additionalResourcesDir.listFiles()) {
|
||||
if (file.isFile) {
|
||||
myFixture.copyFileToProject(file.absolutePath, file.name)
|
||||
}
|
||||
else if (file.isDirectory) {
|
||||
myFixture.copyDirectoryToProject(file.absolutePath, file.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
val virtualFile = myFixture.copyFileToProject(ktFile.absolutePath, "src/${PathUtil.getFileName(path)}")
|
||||
myFixture.configureFromExistingVirtualFile(virtualFile)
|
||||
|
||||
dependencies.forEach { dependency ->
|
||||
val (dependencyFile, dependencyTargetPath) = dependency.split(" -> ").map(String::trim)
|
||||
myFixture.copyFileToProject("${PathUtil.getParentPath(path)}/$dependencyFile", "src/$dependencyTargetPath")
|
||||
}
|
||||
|
||||
myFixture.checkHighlighting(true, false, true)
|
||||
}
|
||||
}
|
||||
@@ -1,206 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.android.lint;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/testData/android/lint")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class KotlinLintTestGenerated extends AbstractKotlinLintTest {
|
||||
@TestMetadata("alarm.kt")
|
||||
public void testAlarm() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/alarm.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInLint() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/android/lint"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("apiCheck.kt")
|
||||
public void testApiCheck() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/apiCheck.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("callSuper.kt")
|
||||
public void testCallSuper() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/callSuper.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("closeCursor.kt")
|
||||
public void testCloseCursor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/closeCursor.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("commitFragment.kt")
|
||||
public void testCommitFragment() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/commitFragment.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("findViewById.kt")
|
||||
public void testFindViewById() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/findViewById.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("javaPerformance.kt")
|
||||
public void testJavaPerformance() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/javaPerformance.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("javaScriptInterface.kt")
|
||||
public void testJavaScriptInterface() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/javaScriptInterface.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("layoutInflation.kt")
|
||||
public void testLayoutInflation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/layoutInflation.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("log.kt")
|
||||
public void testLog() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/log.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("noInternationalSms.kt")
|
||||
public void testNoInternationalSms() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/noInternationalSms.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("overrideConcrete.kt")
|
||||
public void testOverrideConcrete() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/overrideConcrete.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("parcel.kt")
|
||||
public void testParcel() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/parcel.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("sdCardTest.kt")
|
||||
public void testSdCardTest() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/sdCardTest.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("setJavaScriptEnabled.kt")
|
||||
public void testSetJavaScriptEnabled() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/setJavaScriptEnabled.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("sharedPrefs.kt")
|
||||
public void testSharedPrefs() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/sharedPrefs.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("showDiagnosticsWhenFileIsRed.kt")
|
||||
public void testShowDiagnosticsWhenFileIsRed() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/showDiagnosticsWhenFileIsRed.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("sqlite.kt")
|
||||
public void testSqlite() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/sqlite.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("supportAnnotation.kt")
|
||||
public void testSupportAnnotation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/supportAnnotation.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("systemServices.kt")
|
||||
public void testSystemServices() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/systemServices.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("toast.kt")
|
||||
public void testToast() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/toast.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("valueOf.kt")
|
||||
public void testValueOf() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/valueOf.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("velocityTrackerRecycle.kt")
|
||||
public void testVelocityTrackerRecycle() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/velocityTrackerRecycle.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("viewConstructor.kt")
|
||||
public void testViewConstructor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/viewConstructor.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("viewHolder.kt")
|
||||
public void testViewHolder() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/viewHolder.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("wrongAnnotation.kt")
|
||||
public void testWrongAnnotation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/wrongAnnotation.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("wrongImport.kt")
|
||||
public void testWrongImport() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/wrongImport.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("wrongViewCall.kt")
|
||||
public void testWrongViewCall() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/android/lint/wrongViewCall.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
@@ -19,7 +19,7 @@ package org.jetbrains.kotlin.android.quickfix
|
||||
import com.intellij.codeInspection.InspectionProfileEntry
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.util.PathUtil
|
||||
import org.jetbrains.android.inspections.klint.AndroidLintInspectionBase
|
||||
import org.jetbrains.android.inspections.lint.AndroidLintInspectionBase
|
||||
import org.jetbrains.kotlin.android.KotlinAndroidTestCase
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import java.io.File
|
||||
|
||||
@@ -41,7 +41,7 @@ abstract class AbstractCompletionHandlerTest(private val defaultCompletionType:
|
||||
|
||||
val settingManager = CodeStyleSettingsManager.getInstance()
|
||||
val tempSettings = settingManager.currentSettings.clone()
|
||||
settingManager.setTemporarySettings(tempSettings)
|
||||
settingManager.temporarySettings = tempSettings
|
||||
try {
|
||||
val fileText = FileUtil.loadFile(File(testPath))
|
||||
assertTrue("\"<caret>\" is missing in file \"$testPath\"", fileText.contains("<caret>"));
|
||||
|
||||
@@ -15,6 +15,7 @@ dependencies {
|
||||
compile(ideaSdkCoreDeps("intellij-core", "util"))
|
||||
compile(ideaSdkDeps("openapi", "idea"))
|
||||
compile(ideaPluginDeps("gradle-tooling-api", "gradle", plugin = "gradle"))
|
||||
//compileOnly(preloadedDeps("uast-common"))
|
||||
compile(preloadedDeps("kotlinx-coroutines-core", "kotlinx-coroutines-jdk8"))
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.ModalityState
|
||||
import com.intellij.openapi.components.ServiceManager
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.project.isProjectOrWorkspaceFile
|
||||
import com.intellij.openapi.project.ProjectUtil
|
||||
import com.intellij.openapi.roots.ProjectRootManager
|
||||
import com.intellij.openapi.roots.ex.ProjectRootManagerEx
|
||||
import com.intellij.openapi.util.EmptyRunnable
|
||||
@@ -254,7 +254,7 @@ internal class ScriptDependenciesUpdater(
|
||||
it.file?.takeIf {
|
||||
// the isUnitTestMode check fixes ScriptConfigurationHighlighting & Navigation tests, since they are not trigger proper update mechanims
|
||||
// TODO: find out the reason, then consider to fix tests and remove this check
|
||||
(application.isUnitTestMode || projectFileIndex.isInContent(it)) && !isProjectOrWorkspaceFile(it)
|
||||
(application.isUnitTestMode || projectFileIndex.isInContent(it)) && !ProjectUtil.isProjectOrWorkspaceFile(it)
|
||||
}
|
||||
})) {
|
||||
notifyRootsChanged()
|
||||
|
||||
@@ -39,7 +39,7 @@ dependencies {
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "gradle"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "Groovy"))
|
||||
testRuntime(ideaPluginDeps("jacocoant", plugin = "coverage"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "maven"))
|
||||
//testRuntime(ideaPluginDeps("*.jar", plugin = "maven"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "android"))
|
||||
}
|
||||
|
||||
|
||||
@@ -28,13 +28,10 @@ import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.components.StorageScheme;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.externalSystem.importing.ImportSpec;
|
||||
import com.intellij.openapi.externalSystem.importing.ImportSpecBuilder;
|
||||
import com.intellij.openapi.externalSystem.model.ExternalSystemDataKeys;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectId;
|
||||
import com.intellij.openapi.externalSystem.service.execution.ProgressExecutionMode;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ExternalProjectsManagerImpl;
|
||||
import com.intellij.openapi.externalSystem.service.project.wizard.AbstractExternalModuleBuilder;
|
||||
import com.intellij.openapi.externalSystem.service.project.wizard.ExternalModuleSettingsStep;
|
||||
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
|
||||
@@ -252,12 +249,9 @@ public class GradleModuleBuilder extends AbstractExternalModuleBuilder<GradlePro
|
||||
settings.linkProject(gradleProjectSettings);
|
||||
}
|
||||
|
||||
ImportSpec importSpec = new ImportSpecBuilder(project, GradleConstants.SYSTEM_ID)
|
||||
.use(ProgressExecutionMode.IN_BACKGROUND_ASYNC)
|
||||
.createDirectoriesForEmptyContentRoots()
|
||||
.useDefaultCallback()
|
||||
.build();
|
||||
ExternalSystemUtil.refreshProject(rootProjectPath, importSpec);
|
||||
ExternalSystemUtil.refreshProject(
|
||||
project, GradleConstants.SYSTEM_ID, rootProjectPath, false,
|
||||
ProgressExecutionMode.IN_BACKGROUND_ASYNC);
|
||||
|
||||
final PsiFile psiFile;
|
||||
if (finalBuildScriptFile != null) {
|
||||
@@ -477,15 +471,4 @@ public class GradleModuleBuilder extends AbstractExternalModuleBuilder<GradlePro
|
||||
public static BuildScriptDataBuilder getBuildScriptData(@Nullable Module module) {
|
||||
return module == null ? null : module.getUserData(BUILD_SCRIPT_DATA);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public Project createProject(String name, String path) {
|
||||
Project project = super.createProject(name, path);
|
||||
if (project != null) {
|
||||
GradleProjectSettings settings = getExternalProjectSettings();
|
||||
ExternalProjectsManagerImpl.getInstance(project).setStoreExternally(settings.isStoreProjectFilesExternally());
|
||||
}
|
||||
return project;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,16 +24,20 @@ import com.intellij.openapi.externalSystem.model.project.ProjectData
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.roots.DependencyScope
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import org.gradle.tooling.model.idea.IdeaModule
|
||||
import org.gradle.tooling.model.idea.IdeaModuleDependency
|
||||
import org.jetbrains.kotlin.gradle.CompilerArgumentsBySourceSet
|
||||
import org.jetbrains.kotlin.gradle.KotlinGradleModel
|
||||
import org.jetbrains.kotlin.gradle.KotlinGradleModelBuilder
|
||||
import org.jetbrains.kotlin.psi.NotNullableUserDataProperty
|
||||
import org.jetbrains.kotlin.psi.UserDataProperty
|
||||
import org.jetbrains.plugins.gradle.model.ExternalProject
|
||||
import org.jetbrains.plugins.gradle.model.ExternalProjectDependency
|
||||
import org.jetbrains.plugins.gradle.model.FileCollectionDependency
|
||||
import org.jetbrains.plugins.gradle.model.data.GradleSourceSetData
|
||||
import org.jetbrains.plugins.gradle.service.project.AbstractProjectResolverExtension
|
||||
import org.jetbrains.plugins.gradle.service.project.GradleProjectResolverUtil.getModuleId
|
||||
import org.jetbrains.plugins.gradle.service.project.GradleProjectResolver
|
||||
import java.util.*
|
||||
|
||||
var DataNode<ModuleData>.isResolved
|
||||
by NotNullableUserDataProperty(Key.create<Boolean>("IS_RESOLVED"), false)
|
||||
@@ -60,10 +64,103 @@ class KotlinGradleProjectResolverExtension : AbstractProjectResolverExtension()
|
||||
override fun populateModuleDependencies(gradleModule: IdeaModule,
|
||||
ideModule: DataNode<ModuleData>,
|
||||
ideProject: DataNode<ProjectData>) {
|
||||
val outputToSourceSet = ideProject.getUserData(GradleProjectResolver.MODULES_OUTPUTS)
|
||||
val sourceSetByName = ideProject.getUserData(GradleProjectResolver.RESOLVED_SOURCE_SETS)
|
||||
|
||||
val gradleModel = resolverCtx.getExtraProject(gradleModule, KotlinGradleModel::class.java)
|
||||
?: return super.populateModuleDependencies(gradleModule, ideModule, ideProject)
|
||||
|
||||
importTransitiveCommonDependencies(gradleModel, ideProject, gradleModule, ideModule)
|
||||
val gradleIdeaProject = gradleModule.project
|
||||
|
||||
fun DataNode<out ModuleData>.getGradleModule() =
|
||||
if (this != ideModule) gradleIdeaProject.modules.firstOrNull { it.gradleProject.path == data.id } else gradleModule
|
||||
|
||||
fun DataNode<out ModuleData>.getDependencies(): Set<DataNode<out ModuleData>> {
|
||||
if (resolverCtx.isResolveModulePerSourceSet) {
|
||||
if (sourceSetByName == null) return emptySet()
|
||||
val externalSourceSet = sourceSetByName[data.id]?.second ?: return emptySet()
|
||||
return externalSourceSet.dependencies.mapNotNullTo(LinkedHashSet()) { dependency ->
|
||||
when (dependency) {
|
||||
is ExternalProjectDependency -> {
|
||||
val targetModuleNode = ExternalSystemApiUtil.findFirstRecursively(ideProject) {
|
||||
(it.data as? ModuleData)?.id == dependency.projectPath
|
||||
} as DataNode<ModuleData>? ?: return@mapNotNullTo null
|
||||
ExternalSystemApiUtil.findAll(targetModuleNode, GradleSourceSetData.KEY).firstOrNull { it.sourceSetName == "main" }
|
||||
}
|
||||
is FileCollectionDependency -> {
|
||||
dependency.files
|
||||
.mapTo(HashSet()) {
|
||||
val path = FileUtil.toSystemIndependentName(it.path)
|
||||
val targetSourceSetId = outputToSourceSet?.get(path)?.first ?: return@mapTo null
|
||||
sourceSetByName[targetSourceSetId]?.first
|
||||
}
|
||||
.singleOrNull()
|
||||
}
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return getGradleModule()?.dependencies?.mapNotNullTo(LinkedHashSet()) {
|
||||
val targetModuleName = (it as? IdeaModuleDependency)?.targetModuleName ?: return@mapNotNullTo null
|
||||
val targetGradleModule = gradleIdeaProject.modules.firstOrNull { it.name == targetModuleName } ?: return@mapNotNullTo null
|
||||
ExternalSystemApiUtil.findFirstRecursively(ideProject) {
|
||||
(it.data as? ModuleData)?.id == targetGradleModule.gradleProject.path
|
||||
} as DataNode<ModuleData>?
|
||||
} ?: emptySet()
|
||||
}
|
||||
|
||||
fun addTransitiveDependenciesOnImplementedModules() {
|
||||
val moduleNodesToProcess = if (resolverCtx.isResolveModulePerSourceSet) {
|
||||
ExternalSystemApiUtil.findAll(ideModule, GradleSourceSetData.KEY)
|
||||
}
|
||||
else listOf(ideModule)
|
||||
|
||||
for (currentModuleNode in moduleNodesToProcess) {
|
||||
val toProcess = LinkedList<DataNode<out ModuleData>>()
|
||||
val processed = HashSet<DataNode<out ModuleData>>()
|
||||
toProcess.add(currentModuleNode)
|
||||
|
||||
while (toProcess.isNotEmpty()) {
|
||||
val moduleNode = toProcess.pollFirst()
|
||||
processed.add(moduleNode)
|
||||
|
||||
val moduleNodeForGradleModel = if (resolverCtx.isResolveModulePerSourceSet) {
|
||||
ExternalSystemApiUtil.findParent(moduleNode, ProjectKeys.MODULE)
|
||||
}
|
||||
else moduleNode
|
||||
val ideaModule = if (moduleNodeForGradleModel != ideModule) {
|
||||
gradleIdeaProject.modules.firstOrNull { it.gradleProject.path == moduleNodeForGradleModel?.data?.id }
|
||||
}
|
||||
else gradleModule
|
||||
|
||||
val implementsInfo = resolverCtx.getExtraProject(ideaModule, KotlinGradleModel::class.java)?.implements
|
||||
val targetModule = implementsInfo?.let { findModule(ideProject, it) }
|
||||
if (targetModule != null) {
|
||||
if (resolverCtx.isResolveModulePerSourceSet) {
|
||||
val targetSourceSetsByName = ExternalSystemApiUtil
|
||||
.findAll(targetModule, GradleSourceSetData.KEY)
|
||||
.associateBy { it.sourceSetName }
|
||||
val targetMainSourceSet = targetSourceSetsByName["main"] ?: targetModule
|
||||
val targetSourceSet = targetSourceSetsByName[currentModuleNode.sourceSetName]
|
||||
if (targetSourceSet != null) {
|
||||
addDependency(currentModuleNode, targetSourceSet)
|
||||
}
|
||||
if (currentModuleNode.sourceSetName == "test" && targetMainSourceSet != targetSourceSet) {
|
||||
addDependency(currentModuleNode, targetMainSourceSet)
|
||||
}
|
||||
}
|
||||
else {
|
||||
addDependency(currentModuleNode, targetModule)
|
||||
}
|
||||
}
|
||||
|
||||
moduleNode.getDependencies().filterTo(toProcess) { it !in processed }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
addTransitiveDependenciesOnImplementedModules()
|
||||
|
||||
ideModule.isResolved = true
|
||||
ideModule.hasKotlinPlugin = gradleModel.hasKotlinPlugin
|
||||
@@ -75,17 +172,8 @@ class KotlinGradleProjectResolverExtension : AbstractProjectResolverExtension()
|
||||
super.populateModuleDependencies(gradleModule, ideModule, ideProject)
|
||||
}
|
||||
|
||||
private fun importTransitiveCommonDependencies(gradleModel: KotlinGradleModel, ideProject: DataNode<ProjectData>, gradleModule: IdeaModule, ideModule: DataNode<ModuleData>) {
|
||||
gradleModel.transitiveCommonDependencies.forEach { implementsModuleId ->
|
||||
val targetModule = findModule(ideProject, implementsModuleId) ?: return
|
||||
if (resolverCtx.isResolveModulePerSourceSet) {
|
||||
populateSourceSetDependencies(gradleModule, ideModule, targetModule)
|
||||
}
|
||||
else {
|
||||
addDependency(ideModule, targetModule)
|
||||
}
|
||||
}
|
||||
}
|
||||
private val DataNode<out ModuleData>.sourceSetName
|
||||
get() = (data as? GradleSourceSetData)?.id?.substringAfterLast(':')
|
||||
|
||||
private fun addDependency(ideModule: DataNode<out ModuleData>, targetModule: DataNode<out ModuleData>) {
|
||||
val moduleDependencyData = ModuleDependencyData(ideModule.data, targetModule.data)
|
||||
@@ -97,23 +185,4 @@ class KotlinGradleProjectResolverExtension : AbstractProjectResolverExtension()
|
||||
private fun findModule(ideProject: DataNode<ProjectData>, moduleId: String): DataNode<ModuleData>? {
|
||||
return ideProject.children.find { (it.data as? ModuleData)?.id == moduleId } as DataNode<ModuleData>?
|
||||
}
|
||||
|
||||
private fun populateSourceSetDependencies(gradleModule: IdeaModule,
|
||||
fromModule: DataNode<ModuleData>,
|
||||
targetModule: DataNode<ModuleData>) {
|
||||
val fromSourceSets = ExternalSystemApiUtil.findAll(fromModule, GradleSourceSetData.KEY)
|
||||
.associateBy { it.data.id }
|
||||
val targetSourceSets = ExternalSystemApiUtil.findAll(targetModule, GradleSourceSetData.KEY)
|
||||
.associateBy { it.data.id.substringAfterLast(':') }
|
||||
|
||||
val externalProject = resolverCtx.getExtraProject(gradleModule, ExternalProject::class.java) ?: return
|
||||
for (sourceSet in externalProject.sourceSets.values) {
|
||||
if (sourceSet == null || sourceSet.sources.isEmpty()) continue
|
||||
|
||||
val moduleId = getModuleId(externalProject, sourceSet)
|
||||
val fromModuleDataNode = (if (fromSourceSets.isEmpty()) fromModule else fromSourceSets[moduleId]) ?: continue
|
||||
val targetModuleDataNode = (if (targetSourceSets.isEmpty()) targetModule else targetSourceSets[sourceSet.name]) ?: continue
|
||||
addDependency(fromModuleDataNode, targetModuleDataNode)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,6 +32,7 @@ import com.intellij.openapi.roots.OrderRootType
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryEx
|
||||
import com.intellij.openapi.roots.impl.libraries.LibraryImpl
|
||||
import com.intellij.openapi.roots.libraries.PersistentLibraryKind
|
||||
import com.intellij.openapi.util.Key
|
||||
import com.intellij.util.PathUtil
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
||||
import org.jetbrains.kotlin.config.CoroutineSupport
|
||||
@@ -39,6 +40,8 @@ import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||
import org.jetbrains.kotlin.extensions.ProjectExtensionDescriptor
|
||||
import org.jetbrains.kotlin.gradle.ArgsInfo
|
||||
import org.jetbrains.kotlin.gradle.CompilerArgumentsBySourceSet
|
||||
import org.jetbrains.kotlin.idea.facet.*
|
||||
import org.jetbrains.kotlin.idea.framework.CommonLibraryKind
|
||||
import org.jetbrains.kotlin.idea.framework.JSLibraryKind
|
||||
@@ -46,11 +49,18 @@ import org.jetbrains.kotlin.idea.framework.detectLibraryKind
|
||||
import org.jetbrains.kotlin.idea.inspections.gradle.findAll
|
||||
import org.jetbrains.kotlin.idea.inspections.gradle.findKotlinPluginVersion
|
||||
import org.jetbrains.kotlin.idea.inspections.gradle.getResolvedKotlinStdlibVersionByModuleData
|
||||
import org.jetbrains.kotlin.psi.UserDataProperty
|
||||
import org.jetbrains.plugins.gradle.model.data.BuildScriptClasspathData
|
||||
import org.jetbrains.plugins.gradle.model.data.GradleSourceSetData
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
var Module.compilerArgumentsBySourceSet
|
||||
by UserDataProperty(Key.create<CompilerArgumentsBySourceSet>("CURRENT_COMPILER_ARGUMENTS"))
|
||||
|
||||
var Module.sourceSetName
|
||||
by UserDataProperty(Key.create<String>("SOURCE_SET_NAME"))
|
||||
|
||||
interface GradleProjectImportHandler {
|
||||
companion object : ProjectExtensionDescriptor<GradleProjectImportHandler>(
|
||||
"org.jetbrains.kotlin.gradleProjectImportHandler",
|
||||
@@ -75,7 +85,8 @@ class KotlinGradleSourceSetDataService : AbstractProjectDataService<GradleSource
|
||||
val ideModule = modelsProvider.findIdeModule(sourceSetData) ?: continue
|
||||
|
||||
val moduleNode = ExternalSystemApiUtil.findParent(sourceSetNode, ProjectKeys.MODULE) ?: continue
|
||||
val kotlinFacet = configureFacetByGradleModule(moduleNode, sourceSetNode, ideModule, modelsProvider) ?: continue
|
||||
val sourceSetName = sourceSetNode.data.id.let { it.substring(it.lastIndexOf(':') + 1) }
|
||||
val kotlinFacet = configureFacetByGradleModule(moduleNode, sourceSetName, ideModule, modelsProvider) ?: continue
|
||||
GradleProjectImportHandler.getInstances(project).forEach { it.importBySourceSet(kotlinFacet, sourceSetNode) }
|
||||
}
|
||||
}
|
||||
@@ -165,9 +176,9 @@ private fun detectPlatformByLibrary(moduleNode: DataNode<ModuleData>): TargetPla
|
||||
return detectedPlatforms.singleOrNull() ?: detectedPlatforms.firstOrNull { it != TargetPlatformKind.Common }
|
||||
}
|
||||
|
||||
private fun configureFacetByGradleModule(
|
||||
fun configureFacetByGradleModule(
|
||||
moduleNode: DataNode<ModuleData>,
|
||||
sourceSetNode: DataNode<GradleSourceSetData>?,
|
||||
sourceSetName: String?,
|
||||
ideModule: Module,
|
||||
modelsProvider: IdeModifiableModelsProvider
|
||||
): KotlinFacet? {
|
||||
@@ -192,17 +203,12 @@ private fun configureFacetByGradleModule(
|
||||
val kotlinFacet = ideModule.getOrCreateFacet(modelsProvider, false)
|
||||
kotlinFacet.configureFacet(compilerVersion, coroutinesProperty, platformKind, modelsProvider)
|
||||
|
||||
val sourceSetName = sourceSetNode?.data?.id?.let { it.substring(it.lastIndexOf(':') + 1) }
|
||||
ideModule.compilerArgumentsBySourceSet = moduleNode.compilerArgumentsBySourceSet
|
||||
ideModule.sourceSetName = sourceSetName
|
||||
|
||||
val argsInfo = moduleNode.compilerArgumentsBySourceSet?.get(sourceSetName ?: "main")
|
||||
if (argsInfo != null) {
|
||||
val currentCompilerArguments = argsInfo.currentArguments
|
||||
val defaultCompilerArguments = argsInfo.defaultArguments
|
||||
val dependencyClasspath = argsInfo.dependencyClasspath.map { PathUtil.toSystemIndependentName(it) }
|
||||
if (currentCompilerArguments.isNotEmpty()) {
|
||||
parseCompilerArgumentsToFacet(currentCompilerArguments, defaultCompilerArguments, kotlinFacet, modelsProvider)
|
||||
}
|
||||
adjustClasspath(kotlinFacet, dependencyClasspath)
|
||||
configureFacetByCompilerArguments(kotlinFacet, argsInfo, modelsProvider)
|
||||
}
|
||||
|
||||
kotlinFacet.configuration.settings.implementedModuleName = getImplementedModuleName(moduleNode, sourceSetName)
|
||||
@@ -210,6 +216,16 @@ private fun configureFacetByGradleModule(
|
||||
return kotlinFacet
|
||||
}
|
||||
|
||||
fun configureFacetByCompilerArguments(kotlinFacet: KotlinFacet, argsInfo: ArgsInfo, modelsProvider: IdeModifiableModelsProvider?) {
|
||||
val currentCompilerArguments = argsInfo.currentArguments
|
||||
val defaultCompilerArguments = argsInfo.defaultArguments
|
||||
val dependencyClasspath = argsInfo.dependencyClasspath.map { PathUtil.toSystemIndependentName(it) }
|
||||
if (currentCompilerArguments.isNotEmpty()) {
|
||||
parseCompilerArgumentsToFacet(currentCompilerArguments, defaultCompilerArguments, kotlinFacet, modelsProvider)
|
||||
}
|
||||
adjustClasspath(kotlinFacet, dependencyClasspath)
|
||||
}
|
||||
|
||||
private fun getImplementedModuleName(moduleNode: DataNode<ModuleData>, sourceSetName: String?): String? {
|
||||
val baseModuleName = moduleNode.implementedModule?.data?.internalName
|
||||
if (baseModuleName == null || sourceSetName == null) return baseModuleName
|
||||
|
||||
@@ -103,14 +103,19 @@ abstract class KotlinWithGradleConfigurator : KotlinProjectConfigurator {
|
||||
dialog.show()
|
||||
if (!dialog.isOK) return
|
||||
|
||||
project.executeCommand("Configure Kotlin") {
|
||||
val collector = configureSilently(project, dialog.modulesToConfigure, dialog.kotlinVersion)
|
||||
collector.showNotification()
|
||||
}
|
||||
|
||||
fun configureSilently(project: Project, modules: List<Module>, version: String): NotificationMessageCollector {
|
||||
return project.executeCommand("Configure Kotlin") {
|
||||
val collector = createConfigureKotlinNotificationCollector(project)
|
||||
val changedFiles = configureWithVersion(project, dialog.modulesToConfigure, dialog.kotlinVersion, collector)
|
||||
val changedFiles = configureWithVersion(project, modules, version, collector)
|
||||
|
||||
for (file in changedFiles) {
|
||||
OpenFileAction.openFile(file.virtualFile, project)
|
||||
}
|
||||
collector.showNotification()
|
||||
collector
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.inspections.gradle
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.DataNode
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.roots.ProjectRootManager
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.kotlin.idea.versions.MAVEN_STDLIB_ID
|
||||
@@ -116,7 +117,13 @@ class DifferentStdlibGradleVersionInspection : GradleBaseInspection() {
|
||||
}
|
||||
|
||||
internal fun DataNode<*>.getResolvedKotlinStdlibVersionByModuleData(libraryIds: List<String>): String? {
|
||||
return KotlinPlatformGradleDetector.EP_NAME.extensions.asSequence()
|
||||
.mapNotNull { it.getResolvedKotlinStdlibVersionByModuleData(this, libraryIds) }
|
||||
.firstOrNull()
|
||||
for (libraryDependencyData in ExternalSystemApiUtil.findAllRecursively(this, ProjectKeys.LIBRARY_DEPENDENCY)) {
|
||||
for (libraryId in libraryIds) {
|
||||
val libraryNameMarker = "org.jetbrains.kotlin:$libraryId:"
|
||||
if (libraryDependencyData.data.externalName.startsWith(libraryNameMarker)) {
|
||||
return libraryDependencyData.data.externalName.substringAfter(libraryNameMarker)
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.inspections.gradle
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.openapi.externalSystem.model.DataNode
|
||||
import com.intellij.openapi.externalSystem.model.ProjectKeys
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
|
||||
interface KotlinPlatformGradleDetector {
|
||||
companion object {
|
||||
val EP_NAME: ExtensionPointName<KotlinPlatformGradleDetector> = ExtensionPointName.create("org.jetbrains.kotlin.platformGradleDetector")
|
||||
}
|
||||
|
||||
fun getResolvedKotlinStdlibVersionByModuleData(moduleData: DataNode<*>, libraryIds: List<String>): String?
|
||||
}
|
||||
|
||||
class DefaultPlatformGradleDetector : KotlinPlatformGradleDetector {
|
||||
override fun getResolvedKotlinStdlibVersionByModuleData(moduleData: DataNode<*>, libraryIds: List<String>): String? {
|
||||
for (libraryDependencyData in ExternalSystemApiUtil.findAllRecursively(moduleData, ProjectKeys.LIBRARY_DEPENDENCY)) {
|
||||
for (libraryId in libraryIds) {
|
||||
val libraryNameMarker = "org.jetbrains.kotlin:$libraryId:"
|
||||
if (libraryDependencyData.data.externalName.startsWith(libraryNameMarker)) {
|
||||
return libraryDependencyData.data.externalName.substringAfter(libraryNameMarker)
|
||||
}
|
||||
}
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
@@ -18,9 +18,9 @@ package org.jetbrains.kotlin.idea.run
|
||||
|
||||
import com.intellij.execution.configurations.JavaRunConfigurationModule
|
||||
import com.intellij.execution.configurations.ModuleBasedConfiguration
|
||||
import com.intellij.openapi.externalSystem.ExternalSystemModulePropertyManager
|
||||
import com.intellij.openapi.externalSystem.model.project.ExternalSystemSourceType
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemConstants
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.ModuleOrderEntry
|
||||
@@ -94,10 +94,10 @@ class MultiplatformGradleProjectTaskRunner : GradleProjectTaskRunner() {
|
||||
is ModuleFilesBuildTask -> this
|
||||
|
||||
is ModuleBuildTask ->
|
||||
if (module == origin)
|
||||
ModuleBuildTaskImpl(replacement, isIncrementalBuild, isIncludeDependentModules, isIncludeRuntimeDependencies)
|
||||
else
|
||||
this
|
||||
if (module == origin)
|
||||
ModuleBuildTaskImpl(replacement, isIncrementalBuild, isIncludeDependentModules, isIncludeRuntimeDependencies)
|
||||
else
|
||||
this
|
||||
|
||||
else -> this
|
||||
}
|
||||
@@ -109,7 +109,7 @@ class MultiplatformGradleOrderEnumeratorHandler : OrderEnumerationHandler() {
|
||||
if (!ExternalSystemApiUtil.isExternalSystemAwareModule(GradleConstants.SYSTEM_ID, rootModel.module)) return false
|
||||
|
||||
if (!GradleSystemRunningSettings.getInstance().isUseGradleAwareMake) {
|
||||
val gradleProjectPath = ExternalSystemModulePropertyManager.getInstance(rootModel.module).getRootProjectPath() ?: return false
|
||||
val gradleProjectPath = rootModel.module.getOptionValue(ExternalSystemConstants.ROOT_PROJECT_PATH_KEY);
|
||||
val externalProjectDataCache = ExternalProjectDataCache.getInstance(rootModel.module.project)!!
|
||||
val externalRootProject = externalProjectDataCache.getRootExternalProject(GradleConstants.SYSTEM_ID,
|
||||
File(gradleProjectPath)) ?: return false
|
||||
@@ -139,7 +139,11 @@ class MultiplatformGradleOrderEnumeratorHandler : OrderEnumerationHandler() {
|
||||
}
|
||||
|
||||
private fun addOutputModuleRoots(directorySet: ExternalSourceDirectorySet?, result: MutableCollection<String>) {
|
||||
directorySet?.gradleOutputDirs?.mapTo(result) { VfsUtilCore.pathToUrl(it.absolutePath) }
|
||||
if (directorySet == null) return;
|
||||
|
||||
if (directorySet.isCompilerOutputPathInherited) return
|
||||
val path = directorySet.outputDir.absolutePath
|
||||
result.add(VfsUtilCore.pathToUrl(path))
|
||||
}
|
||||
|
||||
class FactoryImpl : Factory() {
|
||||
@@ -149,7 +153,7 @@ class MultiplatformGradleOrderEnumeratorHandler : OrderEnumerationHandler() {
|
||||
}
|
||||
|
||||
override fun createHandler(module: Module): OrderEnumerationHandler =
|
||||
MultiplatformGradleOrderEnumeratorHandler()
|
||||
MultiplatformGradleOrderEnumeratorHandler()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,52 @@ class MultiplatformProjectImportingTest : GradleImportingTestCase() {
|
||||
assertModuleModuleDepScope("js_test", "common_test", DependencyScope.COMPILE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPlatformToCommonExpectedByDependency() {
|
||||
createProjectSubFile("settings.gradle", "include ':common', ':jvm', ':js'")
|
||||
|
||||
val kotlinVersion = "1.2.0-beta-74"
|
||||
|
||||
createProjectSubFile("build.gradle", """
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven { url 'http://dl.bintray.com/kotlin/kotlin-dev' }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
}
|
||||
}
|
||||
|
||||
project('common') {
|
||||
apply plugin: 'kotlin-platform-common'
|
||||
}
|
||||
|
||||
project('jvm') {
|
||||
apply plugin: 'kotlin-platform-jvm'
|
||||
|
||||
dependencies {
|
||||
expectedBy project(':common')
|
||||
}
|
||||
}
|
||||
|
||||
project('js') {
|
||||
apply plugin: 'kotlin-platform-js'
|
||||
|
||||
dependencies {
|
||||
expectedBy project(':common')
|
||||
}
|
||||
}
|
||||
""")
|
||||
|
||||
importProject()
|
||||
assertModuleModuleDepScope("jvm_main", "common_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("jvm_test", "common_test", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("js_main", "common_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("js_test", "common_test", DependencyScope.COMPILE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPlatformToCommonDependencyRoot() {
|
||||
createProjectSubFile("settings.gradle", "rootProject.name = 'foo'\ninclude ':jvm', ':js'")
|
||||
@@ -250,4 +296,93 @@ class MultiplatformProjectImportingTest : GradleImportingTestCase() {
|
||||
assertModuleModuleDepScope("jvm-app_test", "common-lib1_test", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("jvm-app_test", "common-lib2_test", DependencyScope.COMPILE)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testTransitiveImplement() {
|
||||
createProjectSubFile(
|
||||
"settings.gradle",
|
||||
"include ':project1', ':project2', ':project3'"
|
||||
)
|
||||
|
||||
val kotlinVersion = "1.1.51"
|
||||
|
||||
createProjectSubFile("build.gradle", """
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
|
||||
}
|
||||
}
|
||||
|
||||
project('project1') {
|
||||
apply plugin: 'kotlin-platform-common'
|
||||
|
||||
sourceSets {
|
||||
custom
|
||||
}
|
||||
}
|
||||
|
||||
project('project2') {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin-platform-jvm'
|
||||
|
||||
sourceSets {
|
||||
custom
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implement project(':project1')
|
||||
}
|
||||
}
|
||||
|
||||
project('project3') {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin-platform-jvm'
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
sourceSets {
|
||||
custom
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile project(':project2')
|
||||
customCompile project(':project2')
|
||||
testCompile(project(':project2').sourceSets.test.output)
|
||||
}
|
||||
}
|
||||
""")
|
||||
|
||||
importProject()
|
||||
|
||||
assertModuleModuleDepScope("project1_test", "project1_main", DependencyScope.COMPILE)
|
||||
|
||||
assertModuleModuleDepScope("project2_main", "project1_main", DependencyScope.COMPILE)
|
||||
|
||||
assertModuleModuleDepScope("project2_test", "project2_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project2_test", "project1_test", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project2_test", "project1_main", DependencyScope.COMPILE)
|
||||
|
||||
assertModuleModuleDepScope("project2_custom", "project1_custom", DependencyScope.COMPILE)
|
||||
|
||||
assertModuleModuleDepScope("project3_main", "project2_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project3_main", "project1_main", DependencyScope.COMPILE)
|
||||
|
||||
assertModuleModuleDepScope("project3_test", "project3_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project3_test", "project2_test", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project3_test", "project2_main", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project3_test", "project1_test", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project3_test", "project1_main", DependencyScope.COMPILE)
|
||||
|
||||
assertModuleModuleDepScope("project3_custom", "project1_custom", DependencyScope.COMPILE)
|
||||
assertModuleModuleDepScope("project3_custom", "project2_main", DependencyScope.COMPILE)
|
||||
}
|
||||
}
|
||||
@@ -24,7 +24,7 @@ import com.intellij.openapi.externalSystem.model.ProjectSystemId;
|
||||
import com.intellij.openapi.externalSystem.model.project.ProjectData;
|
||||
import com.intellij.openapi.externalSystem.service.execution.ProgressExecutionMode;
|
||||
import com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback;
|
||||
import com.intellij.openapi.externalSystem.service.project.ProjectDataManager;
|
||||
import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager;
|
||||
import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
|
||||
import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
|
||||
@@ -39,15 +39,15 @@ import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
|
||||
internal fun GradleImportingTestCase.facetSettings(moduleName: String) = KotlinFacet.get(getModule(moduleName))!!.configuration.settings
|
||||
|
||||
internal val GradleImportingTestCase.facetSettings: KotlinFacetSettings
|
||||
get() = facetSettings("project_main")
|
||||
|
||||
internal val GradleImportingTestCase.testFacetSettings: KotlinFacetSettings
|
||||
get() = facetSettings("project_test")
|
||||
|
||||
class GradleFacetImportTest : GradleImportingTestCase() {
|
||||
private fun facetSettings(moduleName: String) = KotlinFacet.get(getModule(moduleName))!!.configuration.settings
|
||||
|
||||
private val facetSettings: KotlinFacetSettings
|
||||
get() = facetSettings("project_main")
|
||||
|
||||
private val testFacetSettings: KotlinFacetSettings
|
||||
get() = facetSettings("project_test")
|
||||
|
||||
@Test
|
||||
fun testJvmImport() {
|
||||
createProjectSubFile("build.gradle", """
|
||||
|
||||
@@ -120,7 +120,7 @@ public abstract class GradleImportingTestCase extends ExternalSystemImportingTes
|
||||
}
|
||||
}.execute();
|
||||
Messages.setTestDialog(TestDialog.DEFAULT);
|
||||
FileUtil.delete(BuildManager.getInstance().getBuildSystemDirectory().toFile());
|
||||
FileUtil.delete(BuildManager.getInstance().getBuildSystemDirectory());
|
||||
}
|
||||
finally {
|
||||
super.tearDown();
|
||||
|
||||
@@ -3,7 +3,7 @@ apply { plugin("kotlin") }
|
||||
|
||||
dependencies {
|
||||
compileOnly(ideaSdkDeps("openapi", "idea", "gson"))
|
||||
compileOnly(ideaPluginDeps("maven", "maven-server-api", plugin = "maven"))
|
||||
//compileOnly(ideaPluginDeps("maven", "maven-server-api", plugin = "maven"))
|
||||
|
||||
compile(project(":core:util.runtime"))
|
||||
compile(project(":compiler:frontend"))
|
||||
@@ -21,7 +21,7 @@ dependencies {
|
||||
testCompile(project(":compiler.tests-common"))
|
||||
testCompile(project(":idea:idea-test-framework"))
|
||||
testCompileOnly(ideaSdkDeps("openapi", "idea", "gson"))
|
||||
testCompileOnly(ideaPluginDeps("maven", "maven-server-api", plugin = "maven"))
|
||||
//testCompileOnly(ideaPluginDeps("maven", "maven-server-api", plugin = "maven"))
|
||||
|
||||
testRuntime(project(":idea:idea-jvm"))
|
||||
testRuntime(project(":idea:idea-android"))
|
||||
@@ -37,13 +37,13 @@ dependencies {
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "gradle"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "Groovy"))
|
||||
testRuntime(ideaPluginDeps("jacocoant", plugin = "coverage"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "maven"))
|
||||
//testRuntime(ideaPluginDeps("*.jar", plugin = "maven"))
|
||||
testRuntime(ideaPluginDeps("*.jar", plugin = "android"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
"main" { projectDefault() }
|
||||
"test" { projectDefault() }
|
||||
"main" { /*projectDefault()*/ }
|
||||
"test" { /*projectDefault()*/ }
|
||||
}
|
||||
|
||||
testsJar()
|
||||
|
||||
@@ -97,11 +97,6 @@ class PomFile private constructor(val xmlFile: XmlFile, val domModel: MavenDomPr
|
||||
}
|
||||
}
|
||||
|
||||
fun findProperty(name: String): XmlTag? {
|
||||
val propertiesNode = nodesByName["properties"] ?: return null
|
||||
return propertiesNode.findFirstSubTag(name)
|
||||
}
|
||||
|
||||
fun addDependency(artifact: MavenId, scope: MavenArtifactScope? = null, classifier: String? = null, optional: Boolean = false, systemPath: String? = null): MavenDomDependency {
|
||||
require(systemPath == null || scope == MavenArtifactScope.SYSTEM) { "systemPath is only applicable for system scope dependency" }
|
||||
require(artifact.groupId != null) { "groupId shouldn't be null" }
|
||||
@@ -315,7 +310,7 @@ class PomFile private constructor(val xmlFile: XmlFile, val domModel: MavenDomPr
|
||||
return configurationTag.add(newTag) as XmlTag
|
||||
}
|
||||
|
||||
fun addPluginConfiguration(plugin: MavenDomPlugin, optionName: String, optionValue: String): XmlTag {
|
||||
fun addPluginConfiguration(plugin: MavenDomPlugin, optionName: String, optionValue: String) {
|
||||
val configurationTag = plugin.configuration.ensureTagExists()
|
||||
val existingTag = configurationTag.findFirstSubTag(optionName)
|
||||
if (existingTag != null) {
|
||||
@@ -324,7 +319,6 @@ class PomFile private constructor(val xmlFile: XmlFile, val domModel: MavenDomPr
|
||||
else {
|
||||
configurationTag.add(configurationTag.createChildTag(optionName, optionValue))
|
||||
}
|
||||
return configurationTag
|
||||
}
|
||||
|
||||
fun addPluginRepository(id: String, name: String, url: String, snapshots: Boolean = false, releases: Boolean = true): MavenDomRepository {
|
||||
@@ -580,48 +574,4 @@ class PomFile private constructor(val xmlFile: XmlFile, val domModel: MavenDomPr
|
||||
|
||||
val recommendedOrderAsList = recommendedElementsOrder.toList()
|
||||
}
|
||||
}
|
||||
|
||||
fun PomFile.changeLanguageVersion(languageVersion: String?, apiVersion: String?): PsiElement? {
|
||||
val kotlinPlugin = findPlugin(MavenId(KotlinMavenConfigurator.GROUP_ID,
|
||||
KotlinMavenConfigurator.MAVEN_PLUGIN_ID,
|
||||
null)) ?: return null
|
||||
val languageElement = languageVersion?.let {
|
||||
changeConfigurationOrProperty(kotlinPlugin, "languageVersion", "kotlin.compiler.languageVersion", it)
|
||||
}
|
||||
val apiElement = apiVersion?.let {
|
||||
changeConfigurationOrProperty(kotlinPlugin, "apiVersion", "kotlin.compiler.apiVersion", it)
|
||||
}
|
||||
return languageElement ?: apiElement
|
||||
}
|
||||
|
||||
private fun PomFile.changeConfigurationOrProperty(kotlinPlugin: MavenDomPlugin,
|
||||
configurationTagName: String,
|
||||
propertyName: String, value: String): XmlTag? {
|
||||
val configuration = kotlinPlugin.configuration
|
||||
if (configuration.exists()) {
|
||||
val subTag = configuration.xmlTag.findFirstSubTag(configurationTagName)
|
||||
if (subTag != null) {
|
||||
subTag.value.text = value
|
||||
return subTag
|
||||
}
|
||||
}
|
||||
|
||||
val propertyTag = findProperty(propertyName)
|
||||
if (propertyTag != null) {
|
||||
val textNode = propertyTag.children.filterIsInstance<XmlText>().firstOrNull()
|
||||
if (textNode != null) {
|
||||
textNode.value = value
|
||||
return propertyTag
|
||||
}
|
||||
}
|
||||
|
||||
return addPluginConfiguration(kotlinPlugin, configurationTagName, value)
|
||||
}
|
||||
|
||||
fun PomFile.changeCoroutineConfiguration(value: String): PsiElement? {
|
||||
val kotlinPlugin = findPlugin(MavenId(KotlinMavenConfigurator.GROUP_ID,
|
||||
KotlinMavenConfigurator.MAVEN_PLUGIN_ID,
|
||||
null)) ?: return null
|
||||
return changeConfigurationOrProperty(kotlinPlugin, "experimentalCoroutines", "kotlin.compiler.experimental.coroutines", value)
|
||||
}
|
||||
}
|
||||
@@ -291,7 +291,7 @@ abstract class KotlinMavenConfigurator
|
||||
return !FileTypeIndex.getFiles(JavaFileType.INSTANCE, GlobalSearchScope.moduleScope(module)).isEmpty()
|
||||
}
|
||||
|
||||
fun findModulePomFile(module: Module): PsiFile? {
|
||||
private fun findModulePomFile(module: Module): PsiFile? {
|
||||
val files = MavenProjectsManager.getInstance(module.project).projectsFiles
|
||||
for (file in files) {
|
||||
val fileModule = ModuleUtilCore.findModuleForFile(file, module.project)
|
||||
|
||||
@@ -89,7 +89,7 @@ public abstract class MavenImportingTestCase extends MavenTestCase {
|
||||
VfsRootAccess.disallowRootAccess(PathManager.getConfigPath());
|
||||
Messages.setTestDialog(TestDialog.DEFAULT);
|
||||
removeFromLocalRepository("test");
|
||||
FileUtil.delete(BuildManager.getInstance().getBuildSystemDirectory().toFile());
|
||||
FileUtil.delete(BuildManager.getInstance().getBuildSystemDirectory());
|
||||
}
|
||||
finally {
|
||||
super.tearDown();
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
package org.jetbrains.kotlin.idea.maven
|
||||
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
@@ -94,4 +95,5 @@ class MavenUpdateConfigurationQuickFixTest : MavenImportingTestCase() {
|
||||
throw FileComparisonFailure("pom.xml doesn't match", expectedContent, actualContent, expectedPath.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
@@ -1,56 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>maventest</groupId>
|
||||
<artifactId>maventest</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<properties>
|
||||
<kotlin.version>$VERSION$</kotlin.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jre8</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>wrong-goal</goal>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -1,59 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>maventest</groupId>
|
||||
<artifactId>maventest</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<properties>
|
||||
<kotlin.version>$VERSION$</kotlin.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jre8</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>wrong-goal</goal>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<experimentalCoroutines>enable</experimentalCoroutines>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -1,2 +0,0 @@
|
||||
suspend fun foo() {
|
||||
}
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>maventest</groupId>
|
||||
<artifactId>maventest</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<properties>
|
||||
<kotlin.version>$VERSION$</kotlin.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jre8</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>wrong-goal</goal>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<jvmTarget>1.8</jvmTarget>
|
||||
<apiVersion>1.0</apiVersion>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -1,60 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>maventest</groupId>
|
||||
<artifactId>maventest</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<properties>
|
||||
<kotlin.version>$VERSION$</kotlin.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-stdlib-jre8</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-test</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-maven-plugin</artifactId>
|
||||
<version>${kotlin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>compile</id>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>wrong-goal</goal>
|
||||
<goal>compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>test-compile</id>
|
||||
<phase>test-compile</phase>
|
||||
<goals>
|
||||
<goal>test-compile</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<jvmTarget>1.8</jvmTarget>
|
||||
<apiVersion>1.1</apiVersion>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
</project>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user