Introduce Type Alias: Suggest initial name based on extracted type
This commit is contained in:
+7
-1
@@ -105,7 +105,13 @@ fun IntroduceTypeAliasData.analyze(): IntroduceTypeAliasAnalysisResult {
|
||||
return IntroduceTypeAliasAnalysisResult.Error("Type alias cannot refer to types which aren't accessible in the scope where it's defined")
|
||||
}
|
||||
|
||||
return IntroduceTypeAliasAnalysisResult.Success(IntroduceTypeAliasDescriptor(this, "", null, typeParameters))
|
||||
val descriptor = IntroduceTypeAliasDescriptor(this, "Dummy", null, typeParameters)
|
||||
|
||||
val initialName = KotlinNameSuggester.suggestTypeAliasNameByPsi(descriptor.generateTypeAlias(true).getTypeReference()!!.typeElement!!) {
|
||||
targetScope.findClassifier(Name.identifier(it), NoLookupLocation.FROM_IDE) == null
|
||||
}
|
||||
|
||||
return IntroduceTypeAliasAnalysisResult.Success(descriptor.copy(name = initialName))
|
||||
}
|
||||
|
||||
fun IntroduceTypeAliasData.getApplicableVisibilities(): List<KtModifierKeywordToken>{
|
||||
|
||||
+1
-2
@@ -21,7 +21,6 @@ import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.ui.NameSuggestionsField;
|
||||
import com.intellij.ui.TitledSeparator;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import kotlin.Unit;
|
||||
import kotlin.jvm.functions.Function0;
|
||||
@@ -143,7 +142,7 @@ public class KotlinIntroduceTypeAliasDialog extends DialogWrapper {
|
||||
}
|
||||
);
|
||||
|
||||
aliasNameField = new NameSuggestionsField(ArrayUtil.EMPTY_STRING_ARRAY, project, KotlinFileType.INSTANCE);
|
||||
aliasNameField = new NameSuggestionsField(new String[]{originalDescriptor.getName()}, project, KotlinFileType.INSTANCE);
|
||||
aliasNameField.addDataChangedListener(
|
||||
new NameSuggestionsField.DataChanged() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user