mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[workspace model] fix mapping between facets and sub-facets (IDEA-271303)
There may be several facets with the same underlying facet, so many-to-one connection should be used. GitOrigin-RevId: ca1c8fda14381e108c62219e78e5dd8bd600452d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
53d4023e86
commit
cedb4f294b
@@ -40,7 +40,7 @@ public class AddFacetActionTest extends FacetTestCase {
|
||||
myEditorFacade.getModel().addFacetInfo(subInfo);
|
||||
|
||||
assertTrue(isVisible(MockFacetType.getInstance()));
|
||||
assertFalse(isVisible(MockSubFacetType.getInstance()));
|
||||
assertTrue(isVisible(MockSubFacetType.getInstance()));
|
||||
}
|
||||
|
||||
private boolean isVisible(FacetType type) {
|
||||
|
||||
@@ -98,6 +98,26 @@ public class FacetManagerTest extends FacetTestCase {
|
||||
assertNull(getFacetManager().getFacetByType(MockFacetType.ID));
|
||||
}
|
||||
|
||||
public void testTwoSubFacets() {
|
||||
MockFacet mockFacet = addFacet();
|
||||
Facet<?> subFacet1 = addSubFacet(mockFacet, "sub1");
|
||||
Facet<?> subFacet2 = addSubFacet(mockFacet, "sub2");
|
||||
assertSameElements(getFacetManager().getFacetsByType(mockFacet, MockSubFacetType.ID), subFacet1, subFacet2);
|
||||
|
||||
ModifiableFacetModel model = getFacetManager().createModifiableModel();
|
||||
model.removeFacet(subFacet1);
|
||||
commit(model);
|
||||
|
||||
assertSameElements(getFacetManager().getFacetsByType(mockFacet, MockSubFacetType.ID), subFacet2);
|
||||
assertSameElements(getFacetManager().getFacetsByType(MockSubFacetType.ID), subFacet2);
|
||||
|
||||
model = getFacetManager().createModifiableModel();
|
||||
model.removeFacet(mockFacet);
|
||||
commit(model);
|
||||
assertNull(getFacetManager().getFacetByType(MockFacetType.ID));
|
||||
assertNull(getFacetManager().getFacetByType(MockSubFacetType.ID));
|
||||
}
|
||||
|
||||
public void testChangeFacetConfiguration() {
|
||||
String configData = "data";
|
||||
ModifiableFacetModel model = getFacetManager().createModifiableModel();
|
||||
|
||||
@@ -32,6 +32,11 @@ public class MockSubFacetType extends FacetType<Facet, MockFacetConfiguration> {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnlyOneFacetAllowed() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static MockSubFacetType getInstance() {
|
||||
return findInstance(MockSubFacetType.class);
|
||||
}
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ class ImlSerializationTest {
|
||||
checkSerializationSize(bytes, expectedSize, 2_000)
|
||||
|
||||
assertTrue("This assertion is a reminder. Have you updated the serializer? Update the serializer version!",
|
||||
26_000 == expectedSize && "v20" == EntityStorageSerializerImpl.SERIALIZER_VERSION)
|
||||
26_000 == expectedSize && "v21" == EntityStorageSerializerImpl.SERIALIZER_VERSION)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+1
-1
@@ -761,7 +761,7 @@ class FacetEntity(
|
||||
|
||||
companion object {
|
||||
val moduleDelegate = ManyToOne.NotNull<ModuleEntity, FacetEntity>(ModuleEntity::class.java)
|
||||
val facetDelegate = OneToOneChild.Nullable<FacetEntity, FacetEntity>(FacetEntity::class.java, true)
|
||||
val facetDelegate = ManyToOne.Nullable<FacetEntity, FacetEntity>(FacetEntity::class.java)
|
||||
}
|
||||
|
||||
override fun persistentId(): FacetId = FacetId(name, facetType, moduleId)
|
||||
|
||||
+1
-1
@@ -256,7 +256,7 @@ class ModifiableFacetEntity : ModifiableWorkspaceEntityBase<FacetEntity>() {
|
||||
var moduleId: ModuleId by EntityDataDelegation()
|
||||
|
||||
var module: ModuleEntity by MutableManyToOne.NotNull(FacetEntity::class.java, ModuleEntity::class.java)
|
||||
var underlyingFacet: FacetEntity? by MutableOneToOneChild.Nullable(FacetEntity::class.java, FacetEntity::class.java, true)
|
||||
var underlyingFacet: FacetEntity? by MutableManyToOne.Nullable(FacetEntity::class.java, FacetEntity::class.java)
|
||||
}
|
||||
|
||||
fun WorkspaceEntityStorageDiffBuilder.addFacetEntity(name: String, facetType: String, configurationXmlTag: String?, module: ModuleEntity,
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ class EntityStorageSerializerImpl(
|
||||
private val versionsContributor: () -> Map<String, String> = { emptyMap() },
|
||||
) : EntityStorageSerializer {
|
||||
companion object {
|
||||
const val SERIALIZER_VERSION = "v20"
|
||||
const val SERIALIZER_VERSION = "v21"
|
||||
}
|
||||
|
||||
private val KRYO_BUFFER_SIZE = 64 * 1024
|
||||
|
||||
Reference in New Issue
Block a user