Navigation Menu

Skip to content

Commit

Permalink
assert no PSI in EDT data providers
Browse files Browse the repository at this point in the history
Also fixes
EA-622304 - T: DirectoryIndexImpl.getInfoForFile

GitOrigin-RevId: 55a6a0fe0221a7c71d70c99d7a415205f9b4a630
  • Loading branch information
gregsh authored and intellij-monorepo-bot committed Aug 10, 2022
1 parent d2a3706 commit e99062b
Showing 1 changed file with 10 additions and 0 deletions.
Expand Up @@ -9,9 +9,13 @@
import com.intellij.openapi.extensions.ExtensionPoint;
import com.intellij.openapi.extensions.ExtensionPointName;
import com.intellij.openapi.util.Conditions;
import com.intellij.psi.PsiElement;
import com.intellij.psi.impl.FakePsiElement;
import com.intellij.util.KeyedLazyInstance;
import com.intellij.util.SlowOperations;
import com.intellij.util.containers.ContainerUtil;
import com.intellij.util.containers.FactoryMap;
import com.intellij.util.ui.EDT;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand Down Expand Up @@ -61,6 +65,12 @@ private static boolean isDataValid(@NotNull Object data, @NotNull String dataId,
//noinspection unchecked
Validator<Object>[] validators = (Validator<Object>[])getValidators(dataId);
if (validators == null) return true;
if (data instanceof PsiElement && !(data instanceof FakePsiElement) &&
EDT.isCurrentThreadEdt() &&
SlowOperations.isInsideActivity(SlowOperations.FORCE_ASSERT)) {
LOG.error(data.getClass().getName() + " is provided on EDT by " + source.getClass().getName() + ".getData(\"" + dataId + "\"). " +
"Please move that to a BGT data provider using PlatformCoreDataKeys.SLOW_DATA_PROVIDERS");
}
try {
for (Validator<Object> validator : validators) {
if (!validator.checkValid(data, dataId, source)) return false;
Expand Down

0 comments on commit e99062b

Please sign in to comment.