/** Find the first id attribute with the given value below the given node */ private static Attr findIdAttribute(Node node, String targetValue) { if (node.getNodeType() == Node.ELEMENT_NODE) { Attr attribute = ((Element) node).getAttributeNodeNS(ANDROID_URI, ATTR_ID); if (attribute != null && attribute.getValue().equals(targetValue)) { return attribute; } } NodeList children = node.getChildNodes(); for (int i = 0, n = children.getLength(); i < n; i++) { Node child = children.item(i); Attr result = findIdAttribute(child, targetValue); if (result != null) { return result; } } return null; }
@Override public void afterCheckProject(Context context) { // Look for duplicates if (mIncludes.size() > 0) { // Traverse all the include chains and ensure that there are no duplicates // across. // First perform a topological sort such such checkForIncludeDuplicates(context); } mFileToIds = null; mIncludes = null; }
for (String include : includes) { if (!visiting.contains(include)) { Set<String> otherIds = getMergedIds(context, include, visiting, resourceToLayouts, resourceToIds, mergedIds); for (Map.Entry<File, Set<String>> entry : mFileToIds.entrySet()) { File file = entry.getKey(); String name = getLayoutName(file); if (name.equals(from)) { Set<String> fileIds = entry.getValue(); : mIncludes.entrySet()) { File file = entry.getKey(); String name = getLayoutName(file); if (name.equals(from)) { first = file; List<String> chain = new ArrayList<String>(); chain.add(from); findOrigin(chain, from, id, new HashSet<String>(), resourceToLayouts, resourceToIds); reportError(context, id, first, second, includer, chain); } else { merged.add(id);
String from = getLayoutName(file); String from = getLayoutName(file); Set<String> ids = entry.getValue(); if (ids != null) { for (String from : entryPoints) { visiting.clear(); getMergedIds(context, from, visiting, resourceToLayouts, resourceToIds, mergedIds);
if (findOrigin(chain, include, id, visiting, resourceToLayouts, resourceToIds)) { chain.add(include); return true;
/** Find the first id attribute with the given value below the given node */ private static Attr findIdAttribute(Node node, String targetValue) { if (node.getNodeType() == Node.ELEMENT_NODE) { Attr attribute = ((Element) node).getAttributeNodeNS(ANDROID_URI, ATTR_ID); if (attribute != null && attribute.getValue().equals(targetValue)) { return attribute; } } NodeList children = node.getChildNodes(); for (int i = 0, n = children.getLength(); i < n; i++) { Node child = children.item(i); Attr result = findIdAttribute(child, targetValue); if (result != null) { return result; } } return null; }
Location location = context.getLocation(attribute); Attr first = findIdAttribute(attribute.getOwnerDocument(), id); if (first != null && first != attribute) { Location secondLocation = context.getLocation(first);
Location location = context.getLocation(attribute); Attr first = findIdAttribute(attribute.getOwnerDocument(), id); if (first != null && first != attribute) { Location secondLocation = context.getLocation(first);