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