/** * Adds a {@link ContextMutation} to a {@link ModelProcessingPhase}. * * @throws IllegalStateException * when the mutation was registered after phase was completed */ void addMutation(final ModelProcessingPhase phase, final ContextMutation mutation) { ModelProcessingPhase finishedPhase = completedPhase; while (finishedPhase != null) { checkState(!phase.equals(finishedPhase), "Mutation registered after phase was completed at: %s", getStatementSourceReference()); finishedPhase = finishedPhase.getPreviousPhase(); } if (phaseMutation.isEmpty()) { phaseMutation = newMultimap(); } phaseMutation.put(phase, mutation); }
private static StatementDefinition getValidDefinition(final Node node, final StatementWriter writer, final QNameToStatementDefinition stmtDef, final StatementSourceReference ref) { final URI uri = URI_CACHE.getUnchecked(node.getNamespaceURI()); final StatementDefinition def = stmtDef.getByNamespaceAndLocalName(uri, node.getLocalName()); if (def == null) { SourceException.throwIf(writer.getPhase().equals(ModelProcessingPhase.FULL_DECLARATION), ref, "%s is not a YIN statement or use of extension.", node.getLocalName()); } return def; }
void startPhase(final ModelProcessingPhase phase) { final ModelProcessingPhase previousPhase = phase.getPreviousPhase(); verify(Objects.equals(previousPhase, finishedPhase), "Phase sequencing violation: previous phase should be %s, source %s has %s", previousPhase, source, finishedPhase); final Collection<ModifierImpl> previousModifiers = modifiers.get(previousPhase); checkState(previousModifiers.isEmpty(), "Previous phase %s has unresolved modifiers %s in source %s", previousPhase, previousModifiers, source); inProgressPhase = phase; LOG.debug("Source {} started phase {}", source, phase); }
private void startPhase(final ModelProcessingPhase phase) { checkState(Objects.equals(finishedPhase, phase.getPreviousPhase())); startPhaseFor(phase, sources); startPhaseFor(phase, libSources); currentPhase = phase; LOG.debug("Global phase {} started", phase); }
/** * Adds {@link OnPhaseFinished} listener for a {@link ModelProcessingPhase} end. If the base has already completed * the listener is notified immediately. * * @param phase requested completion phase * @param listener listener to invoke * @throws NullPointerException if any of the arguments is null */ void addPhaseCompletedListener(final ModelProcessingPhase phase, final OnPhaseFinished listener) { checkNotNull(phase, "Statement context processing phase cannot be null at: %s", getStatementSourceReference()); checkNotNull(listener, "Statement context phase listener cannot be null at: %s", getStatementSourceReference()); ModelProcessingPhase finishedPhase = completedPhase; while (finishedPhase != null) { if (phase.equals(finishedPhase)) { listener.phaseFinished(this, finishedPhase); return; } finishedPhase = finishedPhase.getPreviousPhase(); } if (phaseListeners.isEmpty()) { phaseListeners = newMultimap(); } phaseListeners.put(phase, listener); }