Made "Remove Explicitly Specified Type" available on property type.

This commit is contained in:
Evgeny Gerashchenko
2012-05-03 21:15:55 +04:00
parent d9fc85f6f5
commit 5846123de1
4 changed files with 20 additions and 0 deletions
@@ -56,6 +56,10 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
@Override
public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
JetTypeReference typeRefParent = PsiTreeUtil.getTopmostParentOfType(element, JetTypeReference.class);
if (typeRefParent != null) {
element = typeRefParent;
}
PsiElement parent = element.getParent();
JetType type = getTypeForDeclaration((JetNamedDeclaration) parent);
if (ErrorUtils.isErrorType(type)) {
@@ -91,6 +95,10 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
JetTypeReference typeRefParent = PsiTreeUtil.getTopmostParentOfType(element, JetTypeReference.class);
if (typeRefParent != null) {
element = typeRefParent;
}
PsiElement parent = element.getParent();
if (!(parent instanceof JetNamedDeclaration)) {
return false;
@@ -0,0 +1,4 @@
// "Remove Explicitly Specified Type" "true"
import java.util.Map
val x = null
@@ -0,0 +1,4 @@
// "Remove Explicitly Specified Type" "true"
import java.util.Map
val x : Map.Entry<Stri<caret>ng, Int>? = null
@@ -53,6 +53,10 @@ public class SpecifyTypeExplicitlyTest extends LightIntentionActionTestCase {
doTest();
}
public void testOnType() {
doTest();
}
@Override
protected String getTestDataPath() {
return PluginTestCaseBase.getTestDataPathBase() + "/intentions/";