mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
type migration: do not add roots outside source content IDEA-163223
This commit is contained in:
+10
-7
@@ -21,6 +21,7 @@ import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ProjectRootManager;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
@@ -575,18 +576,12 @@ public class TypeMigrationLabeler {
|
||||
if (type.equals(PsiType.NULL)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final PsiElement resolved = Util.normalizeElement(element);
|
||||
|
||||
final SearchScope searchScope = myRules.getSearchScope();
|
||||
if (!resolved.isPhysical() || !PsiSearchScopeUtil.isInScope(searchScope, resolved)) {
|
||||
if (!canBeRoot(resolved, myRules.getSearchScope())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final PsiType originalType = getElementType(resolved);
|
||||
|
||||
LOG.assertTrue(originalType != null);
|
||||
|
||||
type = userDefinedType ? type : TypeEvaluator.substituteType(type, originalType, isContraVariantPosition);
|
||||
|
||||
if (!userDefinedType) {
|
||||
@@ -1123,6 +1118,14 @@ public class TypeMigrationLabeler {
|
||||
return refs;
|
||||
}
|
||||
|
||||
private boolean canBeRoot(@Nullable PsiElement element, @NotNull SearchScope migrationScope) {
|
||||
if (element == null) return false;
|
||||
return element.isValid() &&
|
||||
element.isPhysical() &&
|
||||
PsiSearchScopeUtil.isInScope(migrationScope, element) &&
|
||||
ProjectRootManager.getInstance(element.getProject()).getFileIndex().isInSourceContent(element.getContainingFile().getVirtualFile());
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public String getMigrationReport() {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user