mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
notnull
This commit is contained in:
+2
-1
@@ -1198,7 +1198,8 @@ public class HighlightMethodUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static TextRange getFixRange(PsiElement element) {
|
||||
@NotNull
|
||||
public static TextRange getFixRange(@NotNull PsiElement element) {
|
||||
TextRange range = element.getTextRange();
|
||||
int start = range.getStartOffset();
|
||||
int end = range.getEndOffset();
|
||||
|
||||
+3
-3
@@ -28,12 +28,12 @@ import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.EnumMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DefaultQuickFixProvider extends UnresolvedReferenceQuickFixProvider<PsiJavaCodeReferenceElement> {
|
||||
@Override
|
||||
public void registerFixes(PsiJavaCodeReferenceElement ref, QuickFixActionRegistrar registrar) {
|
||||
public void registerFixes(@NotNull PsiJavaCodeReferenceElement ref, @NotNull QuickFixActionRegistrar registrar) {
|
||||
registrar.register(new ImportClassFix(ref));
|
||||
registrar.register(SetupJDKFix.getInstance());
|
||||
|
||||
@@ -80,7 +80,7 @@ public class DefaultQuickFixProvider extends UnresolvedReferenceQuickFixProvider
|
||||
@NotNull PsiReferenceExpression refExpr) {
|
||||
final JavaCodeStyleManager styleManager = JavaCodeStyleManager.getInstance(refExpr.getProject());
|
||||
|
||||
final Map<VariableKind, IntentionAction> map = new HashMap<VariableKind, IntentionAction>();
|
||||
final Map<VariableKind, IntentionAction> map = new EnumMap<VariableKind, IntentionAction>(VariableKind.class);
|
||||
map.put(VariableKind.FIELD, new CreateFieldFromUsageFix(refExpr));
|
||||
map.put(VariableKind.STATIC_FINAL_FIELD, new CreateConstantFieldFromUsageFix(refExpr));
|
||||
if (!refExpr.isQualified()) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class FindJarQuickFixProvider extends UnresolvedReferenceQuickFixProvider<PsiJavaCodeReferenceElement> {
|
||||
@Override
|
||||
public void registerFixes(PsiJavaCodeReferenceElement ref, QuickFixActionRegistrar registrar) {
|
||||
public void registerFixes(@NotNull PsiJavaCodeReferenceElement ref, @NotNull QuickFixActionRegistrar registrar) {
|
||||
registrar.register(new JavaFindJarFix(ref));
|
||||
}
|
||||
|
||||
|
||||
@@ -19,15 +19,16 @@ package com.intellij.codeInsight.daemon;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface QuickFixActionRegistrar {
|
||||
void register(IntentionAction action);
|
||||
void register(TextRange fixRange, IntentionAction action, HighlightDisplayKey key);
|
||||
void register(@NotNull IntentionAction action);
|
||||
void register(@NotNull TextRange fixRange, @NotNull IntentionAction action, HighlightDisplayKey key);
|
||||
|
||||
/**
|
||||
* Allows to replace some of the built-in quickfixes.
|
||||
* @param condition condition for quickfixes to remove
|
||||
* @since 9.0
|
||||
*/
|
||||
void unregister(Condition<IntentionAction> condition);
|
||||
void unregister(@NotNull Condition<IntentionAction> condition);
|
||||
}
|
||||
|
||||
+9
-5
@@ -22,26 +22,30 @@ import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class QuickFixActionRegistrarImpl implements QuickFixActionRegistrar {
|
||||
private final HighlightInfo myInfo;
|
||||
|
||||
public QuickFixActionRegistrarImpl(HighlightInfo info) {
|
||||
public QuickFixActionRegistrarImpl(@Nullable HighlightInfo info) {
|
||||
myInfo = info;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(IntentionAction action) {
|
||||
public void register(@NotNull IntentionAction action) {
|
||||
QuickFixAction.registerQuickFixAction(myInfo, action);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(TextRange fixRange, IntentionAction action, HighlightDisplayKey key) {
|
||||
public void register(@NotNull TextRange fixRange, @NotNull IntentionAction action, HighlightDisplayKey key) {
|
||||
QuickFixAction.registerQuickFixAction(myInfo, fixRange, action, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister(Condition<IntentionAction> condition) {
|
||||
QuickFixAction.unregisterQuickFixAction(myInfo, condition);
|
||||
public void unregister(@NotNull Condition<IntentionAction> condition) {
|
||||
if (myInfo != null) {
|
||||
QuickFixAction.unregisterQuickFixAction(myInfo, condition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-6
@@ -24,9 +24,7 @@ import com.intellij.util.ReflectionCache;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class UnresolvedReferenceQuickFixProvider<T extends PsiReference> {
|
||||
|
||||
public static <T extends PsiReference> void registerReferenceFixes(T ref, QuickFixActionRegistrar registrar) {
|
||||
|
||||
public static <T extends PsiReference> void registerReferenceFixes(@NotNull T ref, @NotNull QuickFixActionRegistrar registrar) {
|
||||
final boolean dumb = DumbService.getInstance(ref.getElement().getProject()).isDumb();
|
||||
UnresolvedReferenceQuickFixProvider[] fixProviders = Extensions.getExtensions(EXTENSION_NAME);
|
||||
Class<? extends PsiReference> referenceClass = ref.getClass();
|
||||
@@ -40,10 +38,9 @@ public abstract class UnresolvedReferenceQuickFixProvider<T extends PsiReference
|
||||
}
|
||||
}
|
||||
|
||||
private static final ExtensionPointName<UnresolvedReferenceQuickFixProvider> EXTENSION_NAME =
|
||||
ExtensionPointName.create("com.intellij.codeInsight.unresolvedReferenceQuickFixProvider");
|
||||
private static final ExtensionPointName<UnresolvedReferenceQuickFixProvider> EXTENSION_NAME = ExtensionPointName.create("com.intellij.codeInsight.unresolvedReferenceQuickFixProvider");
|
||||
|
||||
public abstract void registerFixes(T ref, QuickFixActionRegistrar registrar);
|
||||
public abstract void registerFixes(@NotNull T ref, @NotNull QuickFixActionRegistrar registrar);
|
||||
|
||||
@NotNull
|
||||
public abstract Class<T> getReferenceClass();
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class AntUnresolvedRefsFixProvider extends UnresolvedReferenceQuickFixProvider<PsiReference> {
|
||||
|
||||
public void registerFixes(PsiReference ref, QuickFixActionRegistrar registrar) {
|
||||
public void registerFixes(@NotNull PsiReference ref, @NotNull QuickFixActionRegistrar registrar) {
|
||||
if (ref instanceof TagNameReference || ref instanceof AntDomReference) {
|
||||
registrar.register(new AntChangeContextFix());
|
||||
}
|
||||
|
||||
+3
-3
@@ -682,18 +682,18 @@ public class GrUnresolvedAccessInspection extends GroovySuppressableInspectionTo
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(IntentionAction action) {
|
||||
public void register(@NotNull IntentionAction action) {
|
||||
myKey = HighlightDisplayKey.find(SHORT_NAME);
|
||||
QuickFixAction.registerQuickFixAction(myInfo, action, myKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register(TextRange fixRange, IntentionAction action, HighlightDisplayKey key) {
|
||||
public void register(@NotNull TextRange fixRange, @NotNull IntentionAction action, HighlightDisplayKey key) {
|
||||
QuickFixAction.registerQuickFixAction(myInfo, fixRange, action, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregister(Condition<IntentionAction> condition) {
|
||||
public void unregister(@NotNull Condition<IntentionAction> condition) {
|
||||
if (myInfo != null) {
|
||||
QuickFixAction.unregisterQuickFixAction(myInfo, condition);
|
||||
}
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.types.GrCodeReferenceElement;
|
||||
*/
|
||||
public class GroovyFindJarQuickFixProvider extends UnresolvedReferenceQuickFixProvider<GrReferenceElement> {
|
||||
@Override
|
||||
public void registerFixes(GrReferenceElement ref, QuickFixActionRegistrar registrar) {
|
||||
public void registerFixes(@NotNull GrReferenceElement ref, @NotNull QuickFixActionRegistrar registrar) {
|
||||
registrar.register(new GroovyFindJarFix(ref));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -93,7 +93,7 @@ public class JavaFxEventHandlerReference extends PsiReferenceBase<XmlAttributeVa
|
||||
public static class JavaFxUnresolvedReferenceHandlerQuickfixProvider extends UnresolvedReferenceQuickFixProvider<JavaFxEventHandlerReference> {
|
||||
|
||||
@Override
|
||||
public void registerFixes(final JavaFxEventHandlerReference ref, final QuickFixActionRegistrar registrar) {
|
||||
public void registerFixes(@NotNull final JavaFxEventHandlerReference ref, @NotNull final QuickFixActionRegistrar registrar) {
|
||||
if (ref.myController != null && ref.myEventHandler == null) {
|
||||
final CreateMethodQuickFix quickFix = CreateMethodQuickFix.createFix(ref.myController, getHandlerSignature(ref), "");
|
||||
if (quickFix != null) {
|
||||
|
||||
+1
-1
@@ -60,7 +60,7 @@ public class JavaFxTagNameReference extends TagNameReference{
|
||||
|
||||
public static class JavaFxUnresolvedTagRefsProvider extends UnresolvedReferenceQuickFixProvider<JavaFxTagNameReference> {
|
||||
@Override
|
||||
public void registerFixes(JavaFxTagNameReference ref, QuickFixActionRegistrar registrar) {
|
||||
public void registerFixes(@NotNull JavaFxTagNameReference ref, @NotNull QuickFixActionRegistrar registrar) {
|
||||
XmlTag element = ref.getTagElement();
|
||||
if (element != null) {
|
||||
registrar.register(new JavaFxImportClassFix(ref, element) {
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public class ResolveReferenceQuickFixProvider extends UnresolvedReferenceQuickFixProvider<PsiJavaCodeReferenceElement> {
|
||||
|
||||
public void registerFixes(PsiJavaCodeReferenceElement ref, QuickFixActionRegistrar registrar) {
|
||||
public void registerFixes(@NotNull PsiJavaCodeReferenceElement ref, @NotNull QuickFixActionRegistrar registrar) {
|
||||
registrar.register(new AddMavenDependencyQuickFix(ref));
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class DependentNSReferenceQuickFixProvider extends UnresolvedReferenceQuickFixProvider<DependentNSReference> {
|
||||
@Override
|
||||
public void registerFixes(DependentNSReference ref, QuickFixActionRegistrar registrar) {
|
||||
public void registerFixes(@NotNull DependentNSReference ref, @NotNull QuickFixActionRegistrar registrar) {
|
||||
registrar.register(new FetchExtResourceAction(ref.isForceFetchResultValid()));
|
||||
registrar.register(new ManuallySetupExtResourceAction());
|
||||
registrar.register(new IgnoreExtResourceAction());
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.PropertyKey;
|
||||
*/
|
||||
public class SchemaReferenceQuickFixProvider extends UnresolvedReferenceQuickFixProvider<SchemaReferencesProvider.TypeOrElementOrAttributeReference> {
|
||||
@Override
|
||||
public void registerFixes(SchemaReferencesProvider.TypeOrElementOrAttributeReference ref, QuickFixActionRegistrar registrar) {
|
||||
public void registerFixes(@NotNull SchemaReferencesProvider.TypeOrElementOrAttributeReference ref, @NotNull QuickFixActionRegistrar registrar) {
|
||||
if (ref.getType() == SchemaReferencesProvider.TypeOrElementOrAttributeReference.ReferenceType.TypeReference) {
|
||||
registrar.register(
|
||||
new CreateXmlElementIntentionAction("xml.schema.create.complex.type.intention.name", SchemaReferencesProvider.COMPLEX_TYPE_TAG_NAME, ref)
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
*/
|
||||
public class URLReferenceQuickFixProvider extends UnresolvedReferenceQuickFixProvider<URLReference> {
|
||||
@Override
|
||||
public void registerFixes(URLReference ref, QuickFixActionRegistrar registrar) {
|
||||
public void registerFixes(@NotNull URLReference ref, @NotNull QuickFixActionRegistrar registrar) {
|
||||
registrar.register(new FetchExtResourceAction());
|
||||
registrar.register(new ManuallySetupExtResourceAction());
|
||||
registrar.register(new IgnoreExtResourceAction());
|
||||
|
||||
Reference in New Issue
Block a user