Skip to content

Commit d85a9c9

Browse files
committed
feat: allow pinning new resource desc. in ResourceDescriptionDelta
1 parent dd59172 commit d85a9c9

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

com.avaloq.tools.ddk.xtext/src/com/avaloq/tools/ddk/xtext/resource/ResourceDescriptionDelta.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public String apply(final IEObjectDescription from) {
5151
private final URI uri;
5252
private IResourceDescription oldDesc;
5353
private final SoftReference<IResourceDescription> newDesc;
54+
private IResourceDescription pinnedNewDesc;
5455
private final IResourceDescriptions index;
5556

5657
private Boolean hasChanges;
@@ -98,6 +99,9 @@ public IResourceDescription getNew() {
9899
if (newDesc == null) {
99100
return null;
100101
}
102+
if (pinnedNewDesc != null) {
103+
return pinnedNewDesc;
104+
}
101105
IResourceDescription res = newDesc.get();
102106
return res != null ? res : index.getResourceDescription(uri);
103107
}
@@ -127,6 +131,20 @@ public boolean haveEObjectDescriptionsChanged() {
127131
return hasChanges;
128132
}
129133

134+
/**
135+
* Ensure the new resource description is not touched by GC.
136+
*/
137+
public void pinNew() {
138+
pinnedNewDesc = newDesc == null ? null : newDesc.get();
139+
}
140+
141+
/**
142+
* Reverse the effect of {@link pinNew}
143+
*/
144+
public void unpinNew() {
145+
pinnedNewDesc = null;
146+
}
147+
130148
/**
131149
* Discards the old descriptions as it's either equivalent to the new or can be computed from a diff against the new.
132150
*

0 commit comments

Comments
 (0)