/** * Validate an xml declaration with 'tools:node="removeAll" annotation. There should not * be any other attribute declaration on this element. */ private static void validateRemoveAllOperation(@NonNull MergingReport.Builder mergingReport, @NonNull XmlElement element) { NamedNodeMap attributes = element.getXml().getAttributes(); if (attributes.getLength() > 1) { List<String> extraAttributeNames = new ArrayList<String>(); for (int i = 0; i < attributes.getLength(); i++) { Node item = attributes.item(i); if (!(SdkConstants.TOOLS_URI.equals(item.getNamespaceURI()) && NodeOperationType.NODE_LOCAL_NAME.equals(item.getLocalName()))) { extraAttributeNames.add(item.getNodeName()); } } String message = String.format( "Element %1$s at %2$s annotated with 'tools:node=\"removeAll\"' cannot " + "have other attributes : %3$s", element.getId(), element.printPosition(), Joiner.on(',').join(extraAttributeNames) ); element.addMessage(mergingReport, ERROR, message); } }
private static void validateManifestAttribute( @NonNull MergingReport.Builder mergingReport, @NonNull XmlElement manifest, XmlDocument.Type fileType) { Attr attributeNode = manifest.getXml().getAttributeNode(AndroidManifest.ATTRIBUTE_PACKAGE); // it's ok for an overlay to not have a package name, it's not ok for a main manifest // and it's a warning for a library. if (attributeNode == null && fileType != XmlDocument.Type.OVERLAY) { manifest.addMessage(mergingReport, fileType == XmlDocument.Type.MAIN ? ERROR : WARNING, String.format( "Missing 'package' declaration in manifest at %1$s", manifest.printPosition())); } }
xmlElement.addMessage(mergingReport, ERROR, String.format( "tools:remove specified at line:%d for attribute %s, but " + "attribute also declared at line:%d, " xmlElement.addMessage(mergingReport, ERROR, String.format( "tools:replace specified at line:%d for attribute %s, but " + "no new value specified",
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); } }
xmlElement.getId(), xmlElement.printPosition()); xmlElement.addMessage(mergingReport, ERROR, message); return false;
if (!isAttributeOperationPresent( xmlElement, attributeOperation, actions, ActionType.REJECTED)) { xmlElement.addMessage(mergingReport, MergingReport.Record.Severity.WARNING, String.format( "%1$s@%2$s was tagged at %3$s:%4$d to remove other" if (!isAttributeOperationPresent( xmlElement, attributeOperation, actions, ActionType.REJECTED)) { xmlElement.addMessage(mergingReport, MergingReport.Record.Severity.WARNING, String.format( "%1$s@%2$s was tagged at %3$s:%4$d to replace other"
childrenKeys.get(childElement.getId()).printPosition()); if (twin.compareTo(childElement).isPresent()) { childElement.addMessage(mergingReport, ERROR, message); } else { childElement.addMessage(mergingReport, WARNING, message);
PostValidator.validate(finalMergedDocument, mergingReportBuilder); if (mergingReportBuilder.hasErrors()) { finalMergedDocument.getRootNode().addMessage(mergingReportBuilder, MergingReport.Record.Severity.WARNING, "Post merge validation failed");
xmlElement.addMessage(mergingReport, MergingReport.Record.Severity.WARNING, String.format( "%1$s was tagged at %2$s:%3$d to replace another declaration " xmlElement.addMessage(mergingReport, MergingReport.Record.Severity.WARNING, String.format( "%1$s was tagged at %2$s:%3$d to remove other declarations "
if (compareMessage.isPresent()) { addMessage(mergingReport, MergingReport.Record.Severity.ERROR, String.format( "Node %1$s at %2$s is tagged with tools:node=\"strict\", yet " + "%3$s at %4$s is different : %5$s",
switch (thisChild.getType().getMergeType()) { case CONFLICT: addMessage(mergingReport, MergingReport.Record.Severity.ERROR, String.format( "Node %1$s cannot be present in more than one input file and it's " + "present at %2$s and %3$s",