fix: choose correct library from plugin for new Kotlin/Javascript projects

This commit is contained in:
Michael Nedzelsky
2014-12-05 19:44:47 +03:00
parent 0992b4c0f1
commit 2d1029cb29
3 changed files with 8 additions and 5 deletions
@@ -35,7 +35,6 @@ import kotlin.Function1;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.plugin.configuration.ConfigureKotlinInProjectUtils;
import org.jetbrains.jet.plugin.configuration.KotlinJavaModuleConfigurator;
import org.jetbrains.jet.plugin.configuration.KotlinWithLibraryConfigurator;
import org.jetbrains.jet.plugin.framework.ui.CreateLibraryDialog;
import org.jetbrains.jet.plugin.framework.ui.FileUIUtils;
@@ -53,6 +52,7 @@ public abstract class CustomLibraryDescriptorWithDefferConfig extends CustomLibr
private static final String DEFAULT_LIB_DIR_NAME = "lib";
private final String configuratorName;
private final String libraryName;
private final String dialogTitle;
private final String modulesSeparatorCaption;
@@ -67,6 +67,7 @@ public abstract class CustomLibraryDescriptorWithDefferConfig extends CustomLibr
*/
public CustomLibraryDescriptorWithDefferConfig(
@Nullable Project project,
@NotNull String configuratorName,
@NotNull String libraryName,
@NotNull String dialogTitle,
@NotNull String modulesSeparatorCaption,
@@ -74,6 +75,7 @@ public abstract class CustomLibraryDescriptorWithDefferConfig extends CustomLibr
@NotNull Set<? extends LibraryKind> suitableLibraryKinds
) {
useRelativePaths = project == null;
this.configuratorName = configuratorName;
this.libraryName = libraryName;
this.dialogTitle = dialogTitle;
this.modulesSeparatorCaption = modulesSeparatorCaption;
@@ -162,8 +164,8 @@ public abstract class CustomLibraryDescriptorWithDefferConfig extends CustomLibr
@Override
public NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, @Nullable VirtualFile contextDirectory) {
KotlinWithLibraryConfigurator configurator =
(KotlinWithLibraryConfigurator) ConfigureKotlinInProjectUtils.getConfiguratorByName(KotlinJavaModuleConfigurator.NAME);
assert configurator != null : "Configurator with name " + KotlinJavaModuleConfigurator.NAME + " should exists";
(KotlinWithLibraryConfigurator) ConfigureKotlinInProjectUtils.getConfiguratorByName(configuratorName);
assert configurator != null : "Configurator with name " + configuratorName + " should exists";
deferredCopyFileRequests = new DeferredCopyFileRequests(configurator);
@@ -42,7 +42,7 @@ public class JSLibraryStdDescription extends CustomLibraryDescriptorWithDefferCo
* @param project null when project doesn't exist yet (called from project wizard)
*/
public JSLibraryStdDescription(@Nullable Project project) {
super(project, LIBRARY_NAME, DIALOG_TITLE, LIBRARY_CAPTION, KOTLIN_JAVASCRIPT_KIND, SUITABLE_LIBRARY_KINDS);
super(project, KotlinJsModuleConfigurator.NAME, LIBRARY_NAME, DIALOG_TITLE, LIBRARY_CAPTION, KOTLIN_JAVASCRIPT_KIND, SUITABLE_LIBRARY_KINDS);
}
@TestOnly
@@ -20,6 +20,7 @@ import com.google.common.collect.Sets;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.roots.libraries.LibraryKind;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.plugin.configuration.KotlinJavaModuleConfigurator;
import java.util.Set;
@@ -36,6 +37,6 @@ public class JavaRuntimeLibraryDescription extends CustomLibraryDescriptorWithDe
* @param project null when project doesn't exist yet (called from project wizard)
*/
public JavaRuntimeLibraryDescription(@Nullable Project project) {
super(project, LIBRARY_NAME, DIALOG_TITLE, LIBRARY_CAPTION, KOTLIN_JAVA_RUNTIME_KIND, SUITABLE_LIBRARY_KINDS);
super(project, KotlinJavaModuleConfigurator.NAME, LIBRARY_NAME, DIALOG_TITLE, LIBRARY_CAPTION, KOTLIN_JAVA_RUNTIME_KIND, SUITABLE_LIBRARY_KINDS);
}
}