mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] refactoring: get rid of access to protected members in production not from subclasses in test code (IJPL-205216)
This is needed to avoid IllegalAccessError if tests are loaded by a different classloader and to allow enabling 'Suspicious Package-Private Access' for tests as well. Separate test-only public accessor methods for are added. GitOrigin-RevId: 36fde4112e67c9aab42097aa70ffbfbab1ec4ceb
This commit is contained in:
committed by
intellij-monorepo-bot
parent
45ca8e3542
commit
32dd2dfc26
@@ -19,6 +19,7 @@ import org.intellij.lang.annotations.MagicConstant;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
@@ -448,4 +449,9 @@ public class SuspendManagerImpl implements SuspendManager {
|
||||
|
||||
return thread == resumeOneSteppingIn.getThreadReference();
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public void addExplicitlyResumedThread(@NotNull ThreadReferenceProxyImpl thread) {
|
||||
myExplicitlyResumedThreads.add(thread);
|
||||
}
|
||||
}
|
||||
|
||||
+7
-3
@@ -9,15 +9,14 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.refactoring.classMembers.MemberInfoBase;
|
||||
import com.intellij.refactoring.ui.AbstractMemberSelectionPanel;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.TableModelEvent;
|
||||
import javax.swing.event.TableModelListener;
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Nikolay.Tropin
|
||||
@@ -161,6 +160,11 @@ public abstract class AbstractGenerateEqualsWizard <C extends PsiElement, M exte
|
||||
return true;
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public Set<Map.Entry<M,I>> getFieldsToNonNull() {
|
||||
return new LinkedHashSet<>(myFieldsToNonNull.entrySet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public JComponent getPreferredFocusedComponent() {
|
||||
final Component stepComponent = getCurrentStepComponent();
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ class CreateFilePathFixTest : CreateFileQuickFixTestCase() {
|
||||
assertEquals(expectedFileName, fileReference.fileNameToCreate)
|
||||
val intention = fileReference.quickFixes!![0]
|
||||
|
||||
val options = (intention as AbstractCreateFileFix).myDirectories
|
||||
val options = (intention as AbstractCreateFileFix).directories
|
||||
|
||||
assertEquals(expectedOptions.size, options.size)
|
||||
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ public class GenerateEqualsWizardTest extends LightJavaCodeInsightFixtureTestCas
|
||||
GenerateEqualsWizard wizard = new GenerateEqualsWizard(getProject(), aClass, true, true);
|
||||
NonBlockingReadActionImpl.waitForAsyncTaskCompletion();
|
||||
try {
|
||||
Set<Map.Entry<PsiMember, MemberInfo>> entries = wizard.myFieldsToNonNull.entrySet();
|
||||
Set<Map.Entry<PsiMember, MemberInfo>> entries = wizard.getFieldsToNonNull();
|
||||
assertEquals(2, entries.size());
|
||||
for (Map.Entry<PsiMember, MemberInfo> entry : entries) {
|
||||
PsiMember member = entry.getKey();
|
||||
|
||||
@@ -45,7 +45,7 @@ public class ToDoTreeStructureTest extends BaseProjectViewTestCase {
|
||||
try {
|
||||
all.init();
|
||||
//second rebuild, e.g. switching scope in scope based t.o.d.o panel
|
||||
CompletableFuture<?> rebuildCache = all.rebuildCache();
|
||||
CompletableFuture<?> rebuildCache = all.rebuildCacheTestAccessor();
|
||||
while (!rebuildCache.isDone()) {
|
||||
IdeEventQueue.getInstance().flushQueue();
|
||||
}
|
||||
|
||||
+6
@@ -293,6 +293,12 @@ public abstract class AbstractCreateFileFix extends LocalQuickFixAndIntentionAct
|
||||
.showInBestPositionFor(editor);
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@ApiStatus.Internal
|
||||
public List<TargetDirectory> getDirectories() {
|
||||
return myDirectories;
|
||||
}
|
||||
|
||||
private static @Unmodifiable @NotNull List<TargetDirectoryListItem> getTargetDirectoryListItems(List<? extends TargetDirectory> directories) {
|
||||
return ContainerUtil.map(directories, targetDirectory -> {
|
||||
PsiDirectory d = targetDirectory.getDirectory();
|
||||
|
||||
@@ -37,10 +37,7 @@ import com.intellij.util.concurrency.annotations.RequiresEdt;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.VisibleForTesting;
|
||||
import org.jetbrains.annotations.*;
|
||||
import org.jetbrains.concurrency.Promise;
|
||||
import org.jetbrains.concurrency.Promises;
|
||||
|
||||
@@ -674,6 +671,12 @@ public abstract class TodoTreeBuilder implements Disposable {
|
||||
return myFileTree.isDirectoryEmpty(psiDirectory.getVirtualFile());
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
@ApiStatus.Internal
|
||||
public @NotNull CompletableFuture<?> rebuildCacheTestAccessor() {
|
||||
return rebuildCache();
|
||||
}
|
||||
|
||||
private final class MyPsiTreeChangeListener extends PsiTreeChangeAdapter {
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user