/** * Returns true if this element supports having a tools:selector decoration, false otherwise. */ public boolean supportsSelector() { return getOperationType().isSelectable(); }
/** * Calculate the effective node operation type for a higher priority node when a lower priority * node is queried for merge. * @param higherPriority the higher priority node which may have a {@link NodeOperationType} * declaration and may also have a {@link Selector} declaration. * @param lowerPriority the lower priority node that is elected for merging with the higher * priority node. * @return the effective {@link NodeOperationType} that should be used to affect higher and * lower priority nodes merging. */ @NonNull private static NodeOperationType calculateNodeOperationType( @NonNull XmlElement higherPriority, @NonNull XmlElement lowerPriority) { @NonNull NodeOperationType operationType = higherPriority.getOperationType(); // if the operation's selector exists and the lower priority node is not selected, // we revert to default operation type which is merge. if (higherPriority.supportsSelector() && higherPriority.mSelector != null && !higherPriority.mSelector.appliesTo(lowerPriority)) { operationType = NodeOperationType.MERGE; } return operationType; }
/** * Record a node that was added due to an implicit presence in earlier SDK release but requires * an explicit declaration in the application targeted SDK. * @param xmlElement the implied element that was added to the resulting xml. * @param reason optional contextual information whey the implied element was added. */ synchronized void recordImpliedNodeAction(@NonNull XmlElement xmlElement, @Nullable String reason) { NodeKey storageKey = xmlElement.getOriginalId(); Actions.DecisionTreeRecord nodeDecisionTree = mRecords.get(storageKey); if (nodeDecisionTree == null) { nodeDecisionTree = new Actions.DecisionTreeRecord(); mRecords.put(storageKey, nodeDecisionTree); } Actions.NodeRecord record = new Actions.NodeRecord(Actions.ActionType.IMPLIED, new SourceFilePosition( xmlElement.getDocument().getSourceFile(), xmlElement.getDocument().getRootNode().getPosition()), xmlElement.getOriginalId(), reason, xmlElement.getOperationType() ); nodeDecisionTree.addNodeRecord(record); }
if (childElement.getOperationType() == NodeOperationType.REMOVE_ALL) { validateRemoveAllOperation(mergingReport, childElement); } else {
default: "Unhandled node operation type %s", higherPriority.getOperationType()); break;
/** * Record a node action taken by the merging tool. * * @param mergedElement the merged xml element * @param actionType the action's type * @param targetElement the action's target when the action is rejected or replaced, it * indicates what is the element being rejected or replaced. */ synchronized void recordNodeAction( @NonNull XmlElement mergedElement, @NonNull Actions.ActionType actionType, @NonNull XmlElement targetElement) { Actions.NodeRecord record = new Actions.NodeRecord(actionType, new SourceFilePosition( targetElement.getDocument().getSourceFile(), targetElement.getPosition()), targetElement.getOriginalId(), null, /* reason */ mergedElement.getOperationType() ); recordNodeAction(mergedElement, record); }
if (usesSdkElement.getOperationType() != NodeOperationType.MERGE) { mergingReport .addMessage(
@NonNull MergingReport.Builder mergingReport) { NodeOperationType operationType = xmlElement.getOperationType(); switch (operationType) { case REPLACE: