mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
nullability
GitOrigin-RevId: 7fca257306cc93461ffe872d9a53acf830c88235
This commit is contained in:
committed by
intellij-monorepo-bot
parent
03c7bc7a26
commit
346f3fe6aa
+3
-3
@@ -31,12 +31,12 @@ public abstract class CompletionResultSet implements Consumer<LookupElement> {
|
||||
private final java.util.function.Consumer<? super CompletionResult> consumer;
|
||||
protected final CompletionService myCompletionService = CompletionService.getCompletionService();
|
||||
@ApiStatus.Internal
|
||||
public final CompletionContributor contributor;
|
||||
public final @Nullable CompletionContributor contributor;
|
||||
private boolean myStopped;
|
||||
|
||||
protected CompletionResultSet(@NotNull PrefixMatcher prefixMatcher,
|
||||
java.util.function.Consumer<? super CompletionResult> consumer,
|
||||
CompletionContributor contributor) {
|
||||
@NotNull java.util.function.Consumer<? super CompletionResult> consumer,
|
||||
@Nullable CompletionContributor contributor) {
|
||||
this.prefixMatcher = prefixMatcher;
|
||||
this.consumer = consumer;
|
||||
this.contributor = contributor;
|
||||
|
||||
+16
-14
@@ -51,14 +51,14 @@ public abstract class CompletionService {
|
||||
*/
|
||||
public void getVariantsFromContributors(@NotNull CompletionParameters parameters,
|
||||
@Nullable CompletionContributor from,
|
||||
Consumer<? super CompletionResult> consumer) {
|
||||
@NotNull Consumer<? super CompletionResult> consumer) {
|
||||
getVariantsFromContributors(parameters, from, createMatcher(suggestPrefix(parameters), false), consumer);
|
||||
}
|
||||
|
||||
protected void getVariantsFromContributors(@NotNull CompletionParameters parameters,
|
||||
@Nullable CompletionContributor from,
|
||||
PrefixMatcher matcher,
|
||||
Consumer<? super CompletionResult> consumer) {
|
||||
@NotNull PrefixMatcher matcher,
|
||||
@NotNull Consumer<? super CompletionResult> consumer) {
|
||||
getVariantsFromContributors(parameters, from, matcher, consumer, null);
|
||||
}
|
||||
|
||||
@@ -106,8 +106,8 @@ public abstract class CompletionService {
|
||||
|
||||
protected void getVariantsFromContributors(@NotNull CompletionParameters parameters,
|
||||
@Nullable CompletionContributor from,
|
||||
PrefixMatcher matcher,
|
||||
Consumer<? super CompletionResult> consumer,
|
||||
@NotNull PrefixMatcher matcher,
|
||||
@NotNull Consumer<? super CompletionResult> consumer,
|
||||
@Nullable CompletionSorter customSorter) {
|
||||
List<CompletionContributor> contributors = CompletionContributor.forParameters(parameters);
|
||||
boolean groupEnabledInApp = GroupedCompletionContributor.isGroupEnabledInApp();
|
||||
@@ -137,17 +137,19 @@ public abstract class CompletionService {
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public void getVariantsFromContributor(CompletionParameters params, CompletionContributor contributor, CompletionResultSet result) {
|
||||
public void getVariantsFromContributor(@NotNull CompletionParameters params,
|
||||
@NotNull CompletionContributor contributor,
|
||||
@NotNull CompletionResultSet result) {
|
||||
contributor.fillCompletionVariants(params, result);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public abstract @NotNull CompletionResultSet createResultSet(CompletionParameters parameters,
|
||||
Consumer<? super CompletionResult> consumer,
|
||||
public abstract @NotNull CompletionResultSet createResultSet(@NotNull CompletionParameters parameters,
|
||||
@NotNull Consumer<? super CompletionResult> consumer,
|
||||
@NotNull CompletionContributor contributor,
|
||||
PrefixMatcher matcher);
|
||||
@NotNull PrefixMatcher matcher);
|
||||
|
||||
protected abstract String suggestPrefix(CompletionParameters parameters);
|
||||
protected abstract @NotNull String suggestPrefix(@NotNull CompletionParameters parameters);
|
||||
|
||||
protected abstract @NotNull PrefixMatcher createMatcher(String prefix, boolean typoTolerant);
|
||||
|
||||
@@ -199,17 +201,17 @@ public abstract class CompletionService {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract CompletionSorter defaultSorter(CompletionParameters parameters, PrefixMatcher matcher);
|
||||
public abstract @NotNull CompletionSorter defaultSorter(@NotNull CompletionParameters parameters, @NotNull PrefixMatcher matcher);
|
||||
|
||||
public abstract CompletionSorter emptySorter();
|
||||
public abstract @NotNull CompletionSorter emptySorter();
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static boolean isStartMatch(LookupElement element, WeighingContext context) {
|
||||
public static boolean isStartMatch(@NotNull LookupElement element, @NotNull WeighingContext context) {
|
||||
return getItemMatcher(element, context).isStartMatch(element);
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static PrefixMatcher getItemMatcher(LookupElement element, WeighingContext context) {
|
||||
public static PrefixMatcher getItemMatcher(@NotNull LookupElement element, @NotNull WeighingContext context) {
|
||||
PrefixMatcher itemMatcher = context.itemMatcher(element);
|
||||
String pattern = context.itemPattern(element);
|
||||
if (!pattern.equals(itemMatcher.getPrefix())) {
|
||||
|
||||
+10
-10
@@ -62,7 +62,7 @@ public class BaseCompletionService extends CompletionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String suggestPrefix(@NotNull CompletionParameters parameters) {
|
||||
protected @NotNull String suggestPrefix(@NotNull CompletionParameters parameters) {
|
||||
final PsiElement position = parameters.getPosition();
|
||||
final int offset = parameters.getOffset();
|
||||
TextRange range = position.getTextRange();
|
||||
@@ -82,10 +82,10 @@ public class BaseCompletionService extends CompletionService {
|
||||
|
||||
@Override
|
||||
@ApiStatus.Internal
|
||||
public @NotNull CompletionResultSet createResultSet(CompletionParameters parameters,
|
||||
Consumer<? super CompletionResult> consumer,
|
||||
public @NotNull CompletionResultSet createResultSet(@NotNull CompletionParameters parameters,
|
||||
@NotNull Consumer<? super CompletionResult> consumer,
|
||||
@NotNull CompletionContributor contributor,
|
||||
PrefixMatcher matcher) {
|
||||
@NotNull PrefixMatcher matcher) {
|
||||
return new BaseCompletionResultSet(consumer, matcher, contributor, parameters, null, null);
|
||||
}
|
||||
|
||||
@@ -100,10 +100,10 @@ public class BaseCompletionService extends CompletionService {
|
||||
protected final @Nullable BaseCompletionService.BaseCompletionResultSet myOriginal;
|
||||
private int itemCounter = 0;
|
||||
|
||||
protected BaseCompletionResultSet(java.util.function.Consumer<? super CompletionResult> consumer,
|
||||
PrefixMatcher prefixMatcher,
|
||||
CompletionContributor contributor,
|
||||
CompletionParameters parameters,
|
||||
protected BaseCompletionResultSet(@NotNull java.util.function.Consumer<? super CompletionResult> consumer,
|
||||
@NotNull PrefixMatcher prefixMatcher,
|
||||
@Nullable CompletionContributor contributor,
|
||||
@NotNull CompletionParameters parameters,
|
||||
@Nullable CompletionSorter sorter,
|
||||
@Nullable BaseCompletionService.BaseCompletionResultSet original) {
|
||||
super(prefixMatcher, consumer, contributor);
|
||||
@@ -200,7 +200,7 @@ public class BaseCompletionService extends CompletionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionSorter defaultSorter(CompletionParameters parameters, PrefixMatcher matcher) {
|
||||
public @NotNull CompletionSorter defaultSorter(@NotNull CompletionParameters parameters, @NotNull PrefixMatcher matcher) {
|
||||
|
||||
CompletionLocation location = new CompletionLocation(parameters);
|
||||
CompletionSorterImpl sorter = emptySorter();
|
||||
@@ -235,7 +235,7 @@ public class BaseCompletionService extends CompletionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompletionSorterImpl emptySorter() {
|
||||
public @NotNull CompletionSorterImpl emptySorter() {
|
||||
return new CompletionSorterImpl(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.intellij.psi.meta.PsiMetaData;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -122,7 +123,9 @@ public class CompletionData {
|
||||
}
|
||||
};
|
||||
|
||||
private static String findPrefixStatic(final PsiElement insertedElement, final int offsetInFile, ElementPattern<Character> prefixStartTrim) {
|
||||
private static @NotNull String findPrefixStatic(@Nullable PsiElement insertedElement,
|
||||
int offsetInFile,
|
||||
@NotNull ElementPattern<Character> prefixStartTrim) {
|
||||
if(insertedElement == null) return "";
|
||||
|
||||
final Document document = insertedElement.getContainingFile().getViewProvider().getDocument();
|
||||
@@ -143,11 +146,11 @@ public class CompletionData {
|
||||
* @deprecated Use {@link CompletionUtil} methods instead
|
||||
*/
|
||||
@Deprecated(forRemoval = true)
|
||||
public static String findPrefixStatic(final PsiElement insertedElement, final int offsetInFile) {
|
||||
public static @NotNull String findPrefixStatic(final PsiElement insertedElement, final int offsetInFile) {
|
||||
return findPrefixStatic(insertedElement, offsetInFile, NOT_JAVA_ID);
|
||||
}
|
||||
|
||||
private static String findPrefixDefault(final PsiElement insertedElement, final int offset, final @NotNull ElementPattern trimStart) {
|
||||
private static @NotNull String findPrefixDefault(@NotNull PsiElement insertedElement, int offset, @NotNull ElementPattern trimStart) {
|
||||
String substr = insertedElement.getText().substring(0, offset - insertedElement.getTextRange().getStartOffset());
|
||||
if (substr.isEmpty() || Character.isWhitespace(substr.charAt(substr.length() - 1))) return "";
|
||||
|
||||
|
||||
+2
-3
@@ -60,7 +60,7 @@ public class CompletionSorterImpl extends CompletionSorter {
|
||||
return enhanced(classifierFactory, myMembers.size());
|
||||
}
|
||||
|
||||
public CompletionSorterImpl withClassifier(@NotNull String anchorId,
|
||||
public @NotNull CompletionSorterImpl withClassifier(@NotNull String anchorId,
|
||||
boolean beforeAnchor, ClassifierFactory<LookupElement> classifierFactory) {
|
||||
final int i = idIndex(anchorId);
|
||||
return enhanced(classifierFactory, beforeAnchor ? Math.max(0, i) : i + 1);
|
||||
@@ -70,13 +70,12 @@ public class CompletionSorterImpl extends CompletionSorter {
|
||||
return new CompletionSorterImpl(ContainerUtil.filter(myMembers, t -> !removeCondition.test(t)));
|
||||
}
|
||||
|
||||
private CompletionSorterImpl enhanced(ClassifierFactory<LookupElement> classifierFactory, int index) {
|
||||
private @NotNull CompletionSorterImpl enhanced(ClassifierFactory<LookupElement> classifierFactory, int index) {
|
||||
final List<ClassifierFactory<LookupElement>> copy = new ArrayList<>(myMembers);
|
||||
copy.add(index, classifierFactory);
|
||||
return new CompletionSorterImpl(copy);
|
||||
}
|
||||
|
||||
|
||||
private int idIndex(final String id) {
|
||||
return ContainerUtil.indexOf(myMembers, factory -> id.equals(factory.getId()));
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class FilteringResultSet(
|
||||
companion object {
|
||||
private fun CompletionService.getVariantsFromContributors(
|
||||
parameters: CompletionParameters,
|
||||
from: CompletionContributor,
|
||||
from: CompletionContributor?,
|
||||
matcher: PrefixMatcher,
|
||||
consumer: Consumer<in CompletionResult?>,
|
||||
customSorter: CompletionSorter?,
|
||||
|
||||
+3
-3
@@ -136,10 +136,10 @@ open class CompletionServiceImpl : BaseCompletionService() {
|
||||
return if (isCurrentlyUnderLocalId) apiCompletionProcess else null
|
||||
}
|
||||
|
||||
private class CompletionResultSetImpl(consumer: java.util.function.Consumer<in CompletionResult>?,
|
||||
prefixMatcher: PrefixMatcher?,
|
||||
private class CompletionResultSetImpl(consumer: java.util.function.Consumer<in CompletionResult>,
|
||||
prefixMatcher: PrefixMatcher,
|
||||
contributor: CompletionContributor?,
|
||||
parameters: CompletionParameters?,
|
||||
parameters: CompletionParameters,
|
||||
sorter: CompletionSorter?,
|
||||
original: CompletionResultSetImpl?) :
|
||||
BaseCompletionResultSet(consumer, prefixMatcher, contributor, parameters, sorter, original) {
|
||||
|
||||
Reference in New Issue
Block a user