Created SpecifyTypeExplicitlyFix which is subclass of SpecifyTypeExplictlyActions.

This commit is contained in:
Evgeny Gerashchenko
2012-05-03 18:34:07 +04:00
parent e17fa4a7cb
commit bd3e2c6f4e
3 changed files with 37 additions and 14 deletions
@@ -48,16 +48,6 @@ import java.util.Collections;
public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
private JetType targetType;
private boolean disabledForError;
public SpecifyTypeExplicitlyAction() {
this(true);
}
public SpecifyTypeExplicitlyAction(boolean disabledForError) {
this.disabledForError = disabledForError;
}
@NotNull
@Override
public String getFamilyName() {
@@ -118,7 +108,7 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
if (targetType == null || ErrorUtils.isErrorType(targetType)) {
return false;
}
if (disabledForError) {
if (isDisabledForError()) {
for (Diagnostic diagnostic : bindingContext.getDiagnostics()) {
if (Errors.PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE == diagnostic.getFactory() && element.getParent() == diagnostic.getPsiElement()) {
return false;
@@ -128,6 +118,10 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
return true;
}
protected boolean isDisabledForError() {
return true;
}
public static void addTypeAnnotation(Project project, JetProperty property, @NotNull JetType exprType) {
if (property.getPropertyTypeRef() != null) return;
PsiElement anchor = property.getNameIdentifier();
@@ -20,10 +20,8 @@ import com.google.common.collect.HashMultimap;
import com.google.common.collect.Multimap;
import com.intellij.codeInsight.intention.IntentionAction;
import org.jetbrains.jet.lang.diagnostics.AbstractDiagnosticFactory;
import org.jetbrains.jet.lang.diagnostics.Errors;
import org.jetbrains.jet.lang.psi.JetClass;
import org.jetbrains.jet.plugin.codeInsight.ImplementMethodsHandler;
import org.jetbrains.jet.plugin.intentions.SpecifyTypeExplicitlyAction;
import java.util.Collection;
@@ -136,6 +134,6 @@ public class QuickFixes {
actions.put(UNNECESSARY_SAFE_CALL, new ReplaceCallFix(false));
actions.put(UNSAFE_CALL, new ReplaceCallFix(true));
actions.put(PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE, new SpecifyTypeExplicitlyAction(false));
actions.put(PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE, new SpecifyTypeExplicitlyFix());
}
}
@@ -0,0 +1,31 @@
/*
* Copyright 2010-2012 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.jet.plugin.quickfix;
import org.jetbrains.jet.plugin.intentions.SpecifyTypeExplicitlyAction;
/**
* @author Evgeny Gerashchenko
* @since 5/3/12
*/
@SuppressWarnings("IntentionDescriptionNotFoundInspection")
public class SpecifyTypeExplicitlyFix extends SpecifyTypeExplicitlyAction {
@Override
protected boolean isDisabledForError() {
return false;
}
}