Skip to content

Replace common get-or-initialize pattern with utility function#1004

Merged
DavyLandman merged 2 commits intomainfrom
fix/init-and-get-capabilities
Mar 5, 2026
Merged

Replace common get-or-initialize pattern with utility function#1004
DavyLandman merged 2 commits intomainfrom
fix/init-and-get-capabilities

Conversation

@toinehartman
Copy link
Copy Markdown
Member

This PR replaces a common pattern with a utility function.

This is the setting counterpart of #1001.

@toinehartman toinehartman self-assigned this Mar 4, 2026
@toinehartman toinehartman added the bug Something isn't working label Mar 4, 2026
@toinehartman toinehartman force-pushed the fix/init-and-get-capabilities branch from 0baac7b to d9835d9 Compare March 4, 2026 10:41
@toinehartman toinehartman marked this pull request as ready for review March 4, 2026 10:46
@toinehartman toinehartman requested a review from DavyLandman March 4, 2026 10:46
workspace.setFileOperations(fileOps);
}
return fileOps;
var workspace = Nullables.initAndGet(caps, ServerCapabilities::getWorkspace, ServerCapabilities::setWorkspace, WorkspaceServerCapabilities::new);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's a bit strange that the function is called initAndGet and it also does a set?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renamed to ensureNonNullAndGet and explicitly mentioned the set operation in the documentation as well.

@toinehartman toinehartman force-pushed the fix/init-and-get-capabilities branch from ef5b8da to a221501 Compare March 4, 2026 12:54
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Mar 4, 2026

@DavyLandman DavyLandman merged commit 44e6f34 into main Mar 5, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants