Clarify behaviour with multiple annotation marks

Issue #84 closed
Chris Fuller created an issue

Discussions related to ADF Change 73 suggest that it is permissible to have multiple annotation marks on a single text node. Currently, the library explicitly rejects anything like this. If a caller attempts to build this construct gracefully through the library, they will get an exception:

com.atlassian.adf.model.ex.mark.MarkException$DuplicateMarkType: duplicate mark type: annotation
  (path: .annotation)
    at com.atlassian.adf.model.node.MarkHolder.lambda$addIfAllowed$4(MarkHolder.java:97)
    at com.atlassian.adf.model.node.MarkHolder.lambda$add$1(MarkHolder.java:77)
    at com.atlassian.adf.model.ex.AdfException.frame(AdfException.java:70)
    at com.atlassian.adf.model.node.MarkHolder.add(MarkHolder.java:75)
    at com.atlassian.adf.model.node.Text.mark(Text.java:223)

During parsing, the duplicate marks are detected and silently discarded.

  1. Establish testing around the current behaviour.
  2. Confirm whether duplicate marks are really acceptable.
  3. If so, figure out what API changes are required to allow for this
    • Is this behaviour peculiar to annotation, or should other duplicate marks also be allowed?
    • How can this be represented in a way that doesn't overly complicate the existing MarkHolder implementation. Maybe an annotation or marker class on the mark to indicate that it permits additional marks of the same type?
    • Idea: Make it work something like Throwable.getSuppressed(). The interface defines suppressedMarks() to access additional marks of the same type. The MarkHolder is aware of this and a) parses redundant marks of that type using addSuppressed(M), and b) serializes the suppressed marks as well, after the mark itself has been rendered.

Comments (3)

  1. Chris Fuller reporter

    I changed my mind on the whole "addSuppressed" approach. It's a big ugly. Instead, I'm changing the internal MarkHolder to have a more flexible key system than just the mark type. While this does create a few temporary warts, I think it's a lot more elegant and manageable than the alternatives.

  2. Log in to comment