refactor: simplify link method by extracting parsing/linking logic

This commit is contained in:
OMGeeky
2025-06-16 08:23:43 +02:00
parent 5809d33bb4
commit 0a1fef4198
10 changed files with 47 additions and 78 deletions

View File

@@ -206,17 +206,10 @@ public class Item extends JSONElement {
@Override
public void link() {
if (this.state == State.created || this.state == State.modified || this.state == State.saved) {
//This type of state is unrelated to parsing/linking.
return;
}
if (this.state == State.init) {
//Not parsed yet.
this.parse();
} else if (this.state == State.linked) {
//Already linked.
if (shouldSkipParseOrLink()) {
return;
}
ensureParseIfNeeded();
Project proj = getProject();
if (proj == null) {
Notification.addError("Error linking item "+id+". No parent project found.");