asciidoctor / asciidoctorj

:coffee: Java bindings for Asciidoctor. Asciidoctor on the JVM!
http://asciidoctor.org
Apache License 2.0
627 stars 172 forks source link

v2.5.x: Fixes #1096. Make Cell extend StructuralNode instead of ContentNode. #1101

Closed robertpanzer closed 2 years ago

robertpanzer commented 2 years ago

Thank you for opening a pull request and contributing to AsciidoctorJ!

Please take a bit of time giving some details about your pull request:

Kind of change

Description

What is the goal of this pull request?

Similar to #1099 this PR makes org.asciidoctor.ast.Cell extend StructuralNode instead of ContentNode. This matches also the class hierarchy in Asciidoctor Ruby. That way, if Document.findBy() returns a Cell in the result list there will no longer be a ClassCastException.

How does it achieve that?

Are there any alternative ways to implement this?

Probably.

Are there any implications of this pull request? Anything a user must know?

I'd like to argue that this is an almost fully compatible change that doesn't even break binary compatibility: https://docs.oracle.com/javase/specs/jls/se7/html/jls-13.html Someone might have been able to write code that would now break (assert !StructuralNode.class.isInstance(cell)), but that can be said for any bugfix.

Please note that this PR is for the v2.5.x maintenance branch!!!

Issue

If this PR fixes an open issue, please add a line of the form:

Fixes #1096

Release notes

Please add a corresponding entry to the file CHANGELOG.adoc