Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more flexibility to the way we find the ICompositeNode for an object #2927

Merged
merged 1 commit into from
Feb 4, 2024

Conversation

szarnekow
Copy link
Contributor

No description provided.

@szarnekow szarnekow added this to the Release_2.34 milestone Feb 3, 2024
@szarnekow szarnekow self-assigned this Feb 3, 2024
Copy link
Contributor

@LorenzoBettini LorenzoBettini left a comment

Choose a reason for hiding this comment

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

I only left 2 small comments.

*
* @since 2.34
* Alternatively, the {@link EObject} might contain an adapter that is for the {@link ICompositeNode ICompositeNode.class}
Copy link
Contributor

Choose a reason for hiding this comment

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

nip: maybe "that is" is redundant?

}
if (adapter instanceof INodeReference) {
return ((INodeReference) adapter).getNode();
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe I don't understand the details, but wouldn't this be equivalent to

Adapter adapter = EcoreUtil.getExistingAdapter(object, ICompositeNode.class);
if (adapter instanceof INodeReference) {
	return ((INodeReference) adapter).getNode();
}
return (ICompositeNode) adapter;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I wanted to have the instanceof check for the ICompositeNode first since it's far more likely to be true. Doesn't matter in practice so I'll apply your suggestion.

Signed-off-by: Sebastian Zarnekow <sebastian.zarnekow@gmail.com>
@szarnekow szarnekow merged commit 59784bc into main Feb 4, 2024
9 checks passed
@szarnekow szarnekow deleted the sz_nodemodel branch February 4, 2024 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants