Fix Macro APIs to return Structural or Phrase Nodes instead of java.l… #1084
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…ang.Object.
Kind of change
Description
What is the goal of this pull request?
As @melix had to experience painfully this week the macro APIs are not really showing what type of node an extension has to return. Currently both InlineMacroProcessors and BlockMacroProcessors define java.lang.Object as the return type.
Instead of parameterizing the return type of the method I parameterized the parameter for the parent node 🤦
I don't know what I had drunk when looking over that.
This PR tries to update the signatures so that it's clearer for the user what type of nodes they have to return.
How does it achieve that?
It updates the InlineMacroProcessor.process() to return a PhraseNode instead of java.lang.Object and BlockMacroProcessor.process() to return StructuralNode.
@mojavelinux Is it even possible that anything else than a StructuralNode/AbstractBlock is passed as a parent to an Inline- or BlockMacroProcessor?
We currently have the topmost base class ContentNode as the type of the parent parameter.
If not I could remove that type parameter.
Are there any alternative ways to implement this?
I don't think so.
Are there any implications of this pull request? Anything a user must know?
This is a breaking change. The source code of existing extensions must be updated.
Issue
If this PR fixes an open issue, please add a line of the form:
Fixes #Issue
Release notes
Please add a corresponding entry to the file CHANGELOG.adoc