Remove obsolete logic for updating source root URL

This commit is contained in:
Dmitry Jemerov
2017-03-31 18:48:44 +02:00
parent 291e888802
commit 06e8f8e5be
3 changed files with 0 additions and 50 deletions
@@ -71,11 +71,6 @@ open class KotlinJavaModuleConfigurator internal constructor() : KotlinWithLibra
LibraryJarDescriptor.RUNTIME_SRC_JAR, LibraryJarDescriptor.RUNTIME_SRC_JAR,
LibraryJarDescriptor.TEST_JAR) LibraryJarDescriptor.TEST_JAR)
override fun getOldSourceRootUrl(library: Library): String? {
val runtimeJarPath = LibraryJarDescriptor.RUNTIME_JAR.findExistingJar(library)
return if (runtimeJarPath != null) runtimeJarPath.url + "src" else null
}
override fun isKotlinLibrary(project: Project, library: Library): Boolean { override fun isKotlinLibrary(project: Project, library: Library): Boolean {
if (super.isKotlinLibrary(project, library)) { if (super.isKotlinLibrary(project, library)) {
return true return true
@@ -17,10 +17,7 @@
package org.jetbrains.kotlin.idea.configuration; package org.jetbrains.kotlin.idea.configuration;
import com.intellij.openapi.module.Module; import com.intellij.openapi.module.Module;
import com.intellij.openapi.roots.libraries.Library;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.idea.framework.JSLibraryStdDescription; import org.jetbrains.kotlin.idea.framework.JSLibraryStdDescription;
import org.jetbrains.kotlin.idea.versions.LibraryJarDescriptor; import org.jetbrains.kotlin.idea.versions.LibraryJarDescriptor;
import org.jetbrains.kotlin.js.JavaScript; import org.jetbrains.kotlin.js.JavaScript;
@@ -102,11 +99,4 @@ public class KotlinJsModuleConfigurator extends KotlinWithLibraryConfigurator {
KotlinJsModuleConfigurator() { KotlinJsModuleConfigurator() {
} }
@Nullable
@Override
protected String getOldSourceRootUrl(@NotNull Library library) {
VirtualFile jsStdLibJar = LibraryJarDescriptor.JS_STDLIB_JAR.findExistingJar(library);
return jsStdLibJar != null ? jsStdLibJar.getUrl() : null;
}
} }
@@ -50,8 +50,6 @@ abstract class KotlinWithLibraryConfigurator internal constructor() : KotlinProj
abstract val existingJarFiles: RuntimeLibraryFiles abstract val existingJarFiles: RuntimeLibraryFiles
protected abstract fun getOldSourceRootUrl(library: Library): String?
override fun getStatus(module: Module): ConfigureKotlinStatus { override fun getStatus(module: Module): ConfigureKotlinStatus {
if (!isApplicable(module)) { if (!isApplicable(module)) {
return ConfigureKotlinStatus.NON_APPLICABLE return ConfigureKotlinStatus.NON_APPLICABLE
@@ -424,39 +422,6 @@ abstract class KotlinWithLibraryConfigurator internal constructor() : KotlinProj
return file return file
} }
fun copySourcesToPathFromLibrary(library: Library, collector: NotificationMessageCollector) {
val dirToJarFromLibrary = getPathFromLibrary(library, OrderRootType.SOURCES) ?: error("Directory to file from library should be non null")
copyFileToDir(existingJarFiles.runtimeSourcesJar, dirToJarFromLibrary, collector)
}
fun changeOldSourcesPathIfNeeded(library: Library, collector: NotificationMessageCollector): Boolean {
if (!removeOldSourcesRootIfNeeded(library, collector)) {
return false
}
val parentDir = getPathFromLibrary(library, OrderRootType.CLASSES) ?: error("Parent dir for classes jar should exists for Kotlin library")
return addSourcesToLibraryIfNeeded(library, existingJarFiles.getRuntimeSourcesDestination(parentDir), collector)
}
protected fun removeOldSourcesRootIfNeeded(library: Library, collector: NotificationMessageCollector): Boolean {
val oldLibrarySourceRoot = getOldSourceRootUrl(library)
val librarySourceRoots = library.getUrls(OrderRootType.SOURCES)
for (sourceRoot in librarySourceRoots) {
if (sourceRoot == oldLibrarySourceRoot) {
val model = library.modifiableModel
model.removeRoot(oldLibrarySourceRoot!!, OrderRootType.SOURCES)
ApplicationManager.getApplication().runWriteAction { model.commit() }
collector.addMessage("Source root '" + oldLibrarySourceRoot + "' was removed for " + library.name + " library")
return true
}
}
return false
}
abstract val libraryJarDescriptors: List<LibraryJarDescriptor> abstract val libraryJarDescriptors: List<LibraryJarDescriptor>
companion object { companion object {