public void copySettingsFrom(AbstractCodeWriter<T> other) {
        // Copy global settings.
        trailingNewline = other.trailingNewline;
        trimBlankLines = other.trimBlankLines;
        enableStackTraceComments = other.enableStackTraceComments;

        // Copy the current state settings of other into the current state.
        currentState.copyStateFrom(other.currentState);

        // Flatten containers into the current state. This is done in reverse order to ensure that more recent
        // state changes supersede earlier changes.
        Iterator<State> reverseOtherStates = other.states.descendingIterator();
        while (reverseOtherStates.hasNext()) {
            State otherState = reverseOtherStates.next();
            currentState.interceptors.addAll(otherState.interceptors);
            currentState.formatters.putAll(otherState.formatters);
            currentState.context.putAll(otherState.context);
        }
    }
Copies settings from the given AbstractCodeWriter into this AbstractCodeWriter.

<p>The settings of the {@code other} AbstractCodeWriter will overwrite both global and state-based settings
of this AbstractCodeWriter.

<p>Stateful settings of the {@code other} AbstractCodeWriter like formatters, interceptors, and context are
flattened and then copied into the <em>current</em> state of this AbstractCodeWriter. Any conflicts between
formatters, interceptors, or context of the current writer are overwritten by the other writer. The stack of
states and the contents written to {@code other} are not copied.

<pre>{@code
SimpleCodeWriter a = new SimpleCodeWriter();
a.setExpressionStart('#');

SimpleCodeWriter b = new SimpleCodeWriter();
b.copySettingsFrom(a);

assert(b.getExpressionStart() == '#');
}</pre>

@param other CodeWriter to copy settings from.
smithy-utils/src/main/java/software/amazon/smithy/utils/AbstractCodeWriter.java