mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[platform] get rid of usages of DirectoryInfo class in getOrderEntriesForFile calls (IDEA-276394)
GitOrigin-RevId: 0e5f7ea8c30de1cb4027081923c7fe92a19e907a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7ee043d83c
commit
07d81968b1
+1
-1
@@ -16,7 +16,7 @@ import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@HeavyPlatformTestCase.WrapInCommand
|
||||
public class DirectoryIndexRestoreTest extends JavaProjectTestCase {
|
||||
public class ProjectFileIndexRestoreTest extends JavaProjectTestCase {
|
||||
private VirtualFile myTempVFile;
|
||||
private String myTestDirPath;
|
||||
|
||||
+1
-1
@@ -33,7 +33,7 @@ import org.junit.jupiter.api.extension.RegisterExtension
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
class DirectoryIndexForExcludePatternsTest {
|
||||
class ExcludePatternsInProjectFileIndexTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
val projectModel: ProjectModelExtension = ProjectModelExtension()
|
||||
+1
-1
@@ -55,7 +55,7 @@ class LightEditDirectoryIndex extends DirectoryIndex {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<OrderEntry> getOrderEntries(@NotNull DirectoryInfo info) {
|
||||
public List<OrderEntry> getOrderEntries(@NotNull VirtualFile fileOrDir) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ import java.io.File
|
||||
|
||||
@TestApplication
|
||||
@RunInEdt
|
||||
class DirectoryIndexBeneathTest {
|
||||
class IteratingContentUnderExcludedTest {
|
||||
@JvmField
|
||||
@RegisterExtension
|
||||
val projectModel: ProjectModelExtension = ProjectModelExtension()
|
||||
@@ -51,7 +51,7 @@ public abstract class DirectoryIndex {
|
||||
public abstract String getPackageName(@NotNull VirtualFile dir);
|
||||
|
||||
@NotNull
|
||||
public abstract List<OrderEntry> getOrderEntries(@NotNull DirectoryInfo info);
|
||||
public abstract List<OrderEntry> getOrderEntries(@NotNull VirtualFile fileOrDir);
|
||||
|
||||
/**
|
||||
* @return names of unloaded modules which directly or transitively via exported dependencies depend on the specified module
|
||||
|
||||
+19
-11
@@ -1,7 +1,9 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.openapi.roots.impl;
|
||||
|
||||
import com.intellij.injected.editor.VirtualFileWindow;
|
||||
import com.intellij.model.ModelBranch;
|
||||
import com.intellij.notebook.editor.BackedVirtualFile;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
@@ -28,11 +30,12 @@ import com.intellij.util.SlowOperations;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.messages.MessageBusConnection;
|
||||
import com.intellij.workspaceModel.core.fileIndex.WorkspaceFileIndex;
|
||||
import com.intellij.workspaceModel.core.fileIndex.WorkspaceFileSetWithCustomData;
|
||||
import com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileIndexEx;
|
||||
import com.intellij.workspaceModel.core.fileIndex.impl.WorkspaceFileInternalInfo;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
import org.jetbrains.jps.model.module.JpsModuleSourceRootType;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -214,10 +217,23 @@ public final class DirectoryIndexImpl extends DirectoryIndex implements Disposab
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<OrderEntry> getOrderEntries(@NotNull DirectoryInfo info) {
|
||||
public List<OrderEntry> getOrderEntries(@NotNull VirtualFile fileOrDir) {
|
||||
checkAvailability();
|
||||
if (myProject.isDefault()) return Collections.emptyList();
|
||||
return getRootIndex().getOrderEntries(info);
|
||||
if (myWorkspaceFileIndex != null) {
|
||||
WorkspaceFileInternalInfo fileInfo = myWorkspaceFileIndex.getFileInfo(fileOrDir, true, true, true, true);
|
||||
WorkspaceFileSetWithCustomData<?> fileSet = fileInfo.findFileSet(data -> true);
|
||||
if (fileSet == null) return Collections.emptyList();
|
||||
return getRootIndex().getOrderEntries(fileSet.getRoot());
|
||||
}
|
||||
|
||||
if (fileOrDir instanceof VirtualFileWindow) {
|
||||
fileOrDir = ((VirtualFileWindow)fileOrDir).getDelegate();
|
||||
}
|
||||
fileOrDir = BackedVirtualFile.getOriginFileIfBacked(fileOrDir);
|
||||
DirectoryInfo info = getInfoForFile(fileOrDir);
|
||||
if (!(info instanceof DirectoryInfoImpl)) return Collections.emptyList();
|
||||
return getRootIndex().getOrderEntries(((DirectoryInfoImpl)info).getRoot());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -227,14 +243,6 @@ public final class DirectoryIndexImpl extends DirectoryIndex implements Disposab
|
||||
return getRootIndex().getDependentUnloadedModules(module);
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public void assertConsistency(DirectoryInfo info) {
|
||||
List<OrderEntry> entries = getOrderEntries(info);
|
||||
for (int i = 1; i < entries.size(); i++) {
|
||||
assert RootIndex.BY_OWNER_MODULE.compare(entries.get(i - 1), entries.get(i)) <= 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkAvailability() {
|
||||
ApplicationManager.getApplication().assertReadAccessAllowed();
|
||||
if (myDisposed) {
|
||||
|
||||
+2
-2
@@ -99,12 +99,12 @@ public class ModuleFileIndexImpl extends FileIndexBase implements ModuleFileInde
|
||||
@Override
|
||||
@NotNull
|
||||
public List<OrderEntry> getOrderEntriesForFile(@NotNull VirtualFile fileOrDir) {
|
||||
return findAllOrderEntriesWithOwnerModule(myModule, myDirectoryIndex.getOrderEntries(getInfoForFileOrDirectory(fileOrDir)));
|
||||
return findAllOrderEntriesWithOwnerModule(myModule, myDirectoryIndex.getOrderEntries(fileOrDir));
|
||||
}
|
||||
|
||||
@Override
|
||||
public OrderEntry getOrderEntryForFile(@NotNull VirtualFile fileOrDir) {
|
||||
return findOrderEntryWithOwnerModule(myModule, myDirectoryIndex.getOrderEntries(getInfoForFileOrDirectory(fileOrDir)));
|
||||
return findOrderEntryWithOwnerModule(myModule, myDirectoryIndex.getOrderEntries(fileOrDir));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -147,7 +147,7 @@ public class ProjectFileIndexImpl extends FileIndexBase implements ProjectFileIn
|
||||
@Override
|
||||
@NotNull
|
||||
public List<OrderEntry> getOrderEntriesForFile(@NotNull VirtualFile file) {
|
||||
return myDirectoryIndex.getOrderEntries(getInfoForFileOrDirectory(file));
|
||||
return myDirectoryIndex.getOrderEntries(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -28,7 +28,6 @@ import com.intellij.util.containers.Stack;
|
||||
import com.intellij.util.containers.*;
|
||||
import com.intellij.workspaceModel.ide.VirtualFileUrls;
|
||||
import com.intellij.workspaceModel.ide.WorkspaceModel;
|
||||
import com.intellij.workspaceModel.ide.impl.UtilsKt;
|
||||
import com.intellij.workspaceModel.ide.impl.legacyBridge.module.ModuleEntityUtils;
|
||||
import com.intellij.workspaceModel.storage.EntityStorage;
|
||||
import com.intellij.workspaceModel.storage.WorkspaceEntity;
|
||||
@@ -1187,9 +1186,8 @@ class RootIndex {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
List<OrderEntry> getOrderEntries(@NotNull DirectoryInfo info) {
|
||||
if (!(info instanceof DirectoryInfoImpl)) return Collections.emptyList();
|
||||
return getOrderEntryGraph().getOrderEntries(((DirectoryInfoImpl)info).getRoot());
|
||||
List<OrderEntry> getOrderEntries(@NotNull VirtualFile root) {
|
||||
return getOrderEntryGraph().getOrderEntries(root);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user