+ private void summarizeSubstatementPolicy() {
+ if (noSensitiveSubstatements()) {
+ setAllSubstatementsContextIndependent();
+ }
+ }
+
+ /**
+ * Determine whether any substatements are context-sensitive as determined by {@link StatementSupport#copyPolicy()}.
+ * Only {@link CopyPolicy#CONTEXT_INDEPENDENT} and {@link CopyPolicy#IGNORE} are context-insensitive. Note that
+ * statements which are not {@link StmtContext#isSupportedToBuildEffective()} are all considered
+ * context-insensitive.
+ *
+ * <p>
+ * Implementations are expected to call {@link #noSensitiveSubstatements()} to actually traverse substatement sets.
+ *
+ * @return True if no substatements require context-sensitive handling
+ */
+ abstract boolean noSensitiveSubstatements();
+
+ /**
+ * Determine whether any of the provided substatements are context-sensitive for purposes of implementing
+ * {@link #noSensitiveSubstatements()}.
+ *
+ * @param substatements Substatements to check
+ * @return True if no substatements require context-sensitive handling
+ */
+ static boolean noSensitiveSubstatements(final Collection<? extends ReactorStmtCtx<?, ?, ?>> substatements) {
+ for (ReactorStmtCtx<?, ?, ?> stmt : substatements) {
+ if (stmt.isSupportedToBuildEffective()) {
+ if (!stmt.allSubstatementsContextIndependent()) {
+ // This is a recursive property
+ return false;
+ }
+
+ switch (stmt.definition().support().copyPolicy()) {
+ case CONTEXT_INDEPENDENT:
+ case IGNORE:
+ break;
+ default:
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+