private static void checkSelectorPresence(@NonNull MergingReport.Builder mergingReport, @NonNull XmlElement element) { Attr selectorAttribute = element.getXml().getAttributeNodeNS(SdkConstants.TOOLS_URI, Selector.SELECTOR_LOCAL_NAME); if (selectorAttribute!=null && !element.supportsSelector()) { String message = String.format( "Unsupported tools:selector=\"%1$s\" found on node %2$s at %3$s", selectorAttribute.getValue(), element.getId(), element.printPosition()); element.addMessage(mergingReport, ERROR, message); } }
/** * 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; }