mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-08-28 04:37:32 +07:00
added assertion on attempt to remove ContentEntry obtained from another instance of ModuleRootModel
This commit is contained in:
@@ -753,7 +753,7 @@ public class DirectoryIndexTest extends IdeaTestCase {
|
||||
assertIteratedContent(fileIndex, Arrays.asList(fileRoot, fileSourceRoot, fileTestSourceRoot), null);
|
||||
|
||||
// removing file content root
|
||||
PsiTestUtil.removeContentEntry(myModule, contentEntry);
|
||||
PsiTestUtil.removeContentEntry(myModule, contentEntry.getFile());
|
||||
assertNotInProject(fileRoot);
|
||||
assertFalse(fileIndex.isInContent(fileRoot));
|
||||
assertFalse(fileIndex.isInSource(fileRoot));
|
||||
|
||||
+1
-1
@@ -245,7 +245,7 @@ public class NonProjectFileAccessTest extends HeavyFileEditorManagerTestCase {
|
||||
assertNotNull(NonProjectFileWritingAccessProvider.getAccessStatus(getProject(), nonProjectFile1));
|
||||
assertNull(NonProjectFileWritingAccessProvider.getAccessStatus(getProject(), nonProjectFile2));
|
||||
|
||||
PsiTestUtil.removeContentEntry(myModule, contextRoot);
|
||||
PsiTestUtil.removeContentEntry(myModule, contextRoot.getFile());
|
||||
|
||||
// do not add notification panel until access is requested
|
||||
assertNotNull(NonProjectFileWritingAccessProvider.getAccessStatus(getProject(), nonProjectFile1));
|
||||
|
||||
@@ -213,6 +213,8 @@ public class RootModelImpl extends RootModelBase implements ModifiableRootModel
|
||||
LOG.assertTrue(myContent.contains(entry));
|
||||
if (entry instanceof RootModelComponentBase) {
|
||||
Disposer.dispose((RootModelComponentBase)entry);
|
||||
RootModelImpl entryModel = ((RootModelComponentBase)entry).getRootModel();
|
||||
LOG.assertTrue(entryModel == this, "Removing from " + this + " content entry obtained from " + entryModel);
|
||||
}
|
||||
myContent.remove(entry);
|
||||
}
|
||||
@@ -731,6 +733,15 @@ public class RootModelImpl extends RootModelBase implements ModifiableRootModel
|
||||
return myModuleRootManager.getRootModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RootModelImpl{" +
|
||||
"module=" + getModule().getName() +
|
||||
", writable=" + myWritable +
|
||||
", disposed=" + myDisposed +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public <T> T getModuleExtension(@NotNull final Class<T> klass) {
|
||||
|
||||
@@ -220,11 +220,11 @@ public class PsiTestUtil {
|
||||
return entry;
|
||||
}
|
||||
|
||||
public static void removeContentEntry(Module module, final ContentEntry e) {
|
||||
public static void removeContentEntry(Module module, final VirtualFile contentRoot) {
|
||||
ModuleRootModificationUtil.updateModel(module, new Consumer<ModifiableRootModel>() {
|
||||
@Override
|
||||
public void consume(ModifiableRootModel model) {
|
||||
model.removeContentEntry(e);
|
||||
model.removeContentEntry(findContentEntryWithAssertion(model, contentRoot));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user