mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-76629: Introduce new argument typeCharIfOnlyOneCompletion for completeBasicAllCarets.
There are a few tests that provides `charToTypeAfterCompletion = "\t"` to complete the first variant. It makes tests "ditry" - somewhere in tests you have to check that "\t" is present after completion, somewhere "\t" is not present because it completed the first variant. This argument allows to avoid adding unnecessary `charToTypeAfterCompletion` when there is only one completion variant that is already completed. GitOrigin-RevId: 3ed977930b92cedd04ea73764613a55616c291d4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b71309e42d
commit
bb96ca528e
+4
@@ -771,9 +771,13 @@ public interface CodeInsightTestFixture extends IdeaProjectTestFixture {
|
||||
*
|
||||
* @param charToTypeAfterCompletion after completion, this char will be typed if not {@code null}.
|
||||
* It could be used to complete the suggestion with {@code '\t'} for example.
|
||||
* @param typeCharIfOnlyOneCompletion if charToTypeAfterCompletion should be placed if code is completed by {@link #completeBasic()}
|
||||
* @return list of all completion elements just like in {@link #completeBasic()}
|
||||
* @see #completeBasic()
|
||||
*/
|
||||
@NotNull
|
||||
List<LookupElement> completeBasicAllCarets(@Nullable Character charToTypeAfterCompletion, boolean typeCharIfOnlyOneCompletion);
|
||||
|
||||
@NotNull
|
||||
List<LookupElement> completeBasicAllCarets(@Nullable Character charToTypeAfterCompletion);
|
||||
|
||||
|
||||
+5
-2
@@ -228,7 +228,7 @@ public class EditorTestFixture {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public final List<LookupElement> completeBasicAllCarets(@Nullable final Character charToTypeAfterCompletion) {
|
||||
public final List<LookupElement> completeBasicAllCarets(@Nullable final Character charToTypeAfterCompletion, boolean typeCharIfOnlyOneCompletion) {
|
||||
final CaretModel caretModel = myEditor.getCaretModel();
|
||||
final List<Caret> carets = caretModel.getAllCarets();
|
||||
|
||||
@@ -247,7 +247,10 @@ public class EditorTestFixture {
|
||||
caretModel.moveToOffset(originalOffset);
|
||||
final LookupElement[] lookupElements = completeBasic();
|
||||
if (charToTypeAfterCompletion != null) {
|
||||
type(charToTypeAfterCompletion);
|
||||
var alwaysCompleteWithChar = !typeCharIfOnlyOneCompletion;
|
||||
if (alwaysCompleteWithChar || lookupElements != null && lookupElements.length > 0) {
|
||||
type(charToTypeAfterCompletion);
|
||||
}
|
||||
}
|
||||
if (lookupElements != null) {
|
||||
result.addAll(Arrays.asList(lookupElements));
|
||||
|
||||
+7
-1
@@ -1289,10 +1289,16 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig
|
||||
return myEditorTestFixture.completeBasic();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public final List<LookupElement> completeBasicAllCarets(@Nullable Character charToTypeAfterCompletion, boolean typeCharIfOnlyOneCompletion) {
|
||||
return myEditorTestFixture.completeBasicAllCarets(charToTypeAfterCompletion, typeCharIfOnlyOneCompletion);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public final List<LookupElement> completeBasicAllCarets(@Nullable Character charToTypeAfterCompletion) {
|
||||
return myEditorTestFixture.completeBasicAllCarets(charToTypeAfterCompletion);
|
||||
return completeBasicAllCarets(charToTypeAfterCompletion, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user