diff --git a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java index 4ed08629d269..4999d42436c8 100644 --- a/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java +++ b/platform/testFramework/src/com/intellij/testFramework/fixtures/impl/CodeInsightTestFixtureImpl.java @@ -1089,10 +1089,16 @@ public class CodeInsightTestFixtureImpl extends BaseFixture implements CodeInsig @Override public @NotNull String getUsageViewTreeTextRepresentation(@NotNull @Unmodifiable List usageTargets, @NotNull Collection usages) { - UsageViewImpl usageView = (UsageViewImpl)UsageViewManager.getInstance(getProject()) - .createUsageView(usageTargets.toArray(UsageTarget.EMPTY_ARRAY), usages.toArray(Usage.EMPTY_ARRAY), new UsageViewPresentation(), null); + final Ref usageViewRef = new Ref<>(); + ApplicationManager.getApplication().invokeAndWait(() -> { + UsageView usageView = UsageViewManager.getInstance(getProject()) + .createUsageView(usageTargets.toArray(UsageTarget.EMPTY_ARRAY), usages.toArray(Usage.EMPTY_ARRAY), new UsageViewPresentation(), + null); - return getUsageViewTreeTextRepresentation(usageView); + usageViewRef.set((UsageViewImpl)usageView); + }); + + return getUsageViewTreeTextRepresentation(usageViewRef.get()); } @Override