Created SpecifyTypeExplicitlyFix which is subclass of SpecifyTypeExplictlyActions.
This commit is contained in:
@@ -48,16 +48,6 @@ import java.util.Collections;
|
|||||||
public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
||||||
private JetType targetType;
|
private JetType targetType;
|
||||||
|
|
||||||
private boolean disabledForError;
|
|
||||||
|
|
||||||
public SpecifyTypeExplicitlyAction() {
|
|
||||||
this(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpecifyTypeExplicitlyAction(boolean disabledForError) {
|
|
||||||
this.disabledForError = disabledForError;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String getFamilyName() {
|
public String getFamilyName() {
|
||||||
@@ -118,7 +108,7 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
|||||||
if (targetType == null || ErrorUtils.isErrorType(targetType)) {
|
if (targetType == null || ErrorUtils.isErrorType(targetType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (disabledForError) {
|
if (isDisabledForError()) {
|
||||||
for (Diagnostic diagnostic : bindingContext.getDiagnostics()) {
|
for (Diagnostic diagnostic : bindingContext.getDiagnostics()) {
|
||||||
if (Errors.PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE == diagnostic.getFactory() && element.getParent() == diagnostic.getPsiElement()) {
|
if (Errors.PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE == diagnostic.getFactory() && element.getParent() == diagnostic.getPsiElement()) {
|
||||||
return false;
|
return false;
|
||||||
@@ -128,6 +118,10 @@ public class SpecifyTypeExplicitlyAction extends PsiElementBaseIntentionAction {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected boolean isDisabledForError() {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public static void addTypeAnnotation(Project project, JetProperty property, @NotNull JetType exprType) {
|
public static void addTypeAnnotation(Project project, JetProperty property, @NotNull JetType exprType) {
|
||||||
if (property.getPropertyTypeRef() != null) return;
|
if (property.getPropertyTypeRef() != null) return;
|
||||||
PsiElement anchor = property.getNameIdentifier();
|
PsiElement anchor = property.getNameIdentifier();
|
||||||
|
|||||||
@@ -20,10 +20,8 @@ import com.google.common.collect.HashMultimap;
|
|||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import com.intellij.codeInsight.intention.IntentionAction;
|
import com.intellij.codeInsight.intention.IntentionAction;
|
||||||
import org.jetbrains.jet.lang.diagnostics.AbstractDiagnosticFactory;
|
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.lang.psi.JetClass;
|
||||||
import org.jetbrains.jet.plugin.codeInsight.ImplementMethodsHandler;
|
import org.jetbrains.jet.plugin.codeInsight.ImplementMethodsHandler;
|
||||||
import org.jetbrains.jet.plugin.intentions.SpecifyTypeExplicitlyAction;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@@ -136,6 +134,6 @@ public class QuickFixes {
|
|||||||
|
|
||||||
actions.put(UNNECESSARY_SAFE_CALL, new ReplaceCallFix(false));
|
actions.put(UNNECESSARY_SAFE_CALL, new ReplaceCallFix(false));
|
||||||
actions.put(UNSAFE_CALL, new ReplaceCallFix(true));
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user