@Override public void visitElement(Context context, Element element) { NodeList childNodes = element.getChildNodes(); for (int i = 0, n = childNodes.getLength(); i < n; i++) { Node child = childNodes.item(i); if (child.getNodeType() == Node.TEXT_NODE) { String text = child.getNodeValue(); checkText(context, element, text); } else if (child.getNodeType() == Node.ELEMENT_NODE && child.getParentNode().getNodeName().equals(TAG_STRING_ARRAY)) { // String array item children NodeList items = child.getChildNodes(); for (int j = 0, m = items.getLength(); j < m; j++) { Node item = items.item(j); if (item.getNodeType() == Node.TEXT_NODE) { String text = item.getNodeValue(); checkText(context, child, text); } } } } }
/** * Returns a list of edits to be applied to fix the suggestion made by the * given warning. The specific issue id and message should be the message * provided by this detector in an earlier run. * <p> * This is intended to help tools implement automatic fixes of these * warnings. The reason only the message and issue id can be provided * instead of actual state passed in the data field to a reporter is that * fix operation can be run much later than the lint is processed (for * example, in a subsequent run of the IDE when only the warnings have been * persisted), * * @param issueId the issue id, which should be the id for one of the * typography issues * @param message the actual error message, which should be a message * provided by this detector * @param textNode a text node which corresponds to the text node the * warning operated on * @return a list of edits, which is never null but could be empty. The * offsets in the edit objects are relative to the text node. */ public static List<ReplaceEdit> getEdits(String issueId, String message, Node textNode) { return getEdits(issueId, message, textNode.getNodeValue()); }
Character.isWhitespace(matcher.group(1).charAt( matcher.group(1).length() - 1)); if (!isNegativeNumber && !isAnalyticsTrackingId((Element) element)) { context.report(DASHES, element, context.getLocation(textNode), EN_DASH_MESSAGE);
Character.isWhitespace(matcher.group(1).charAt( matcher.group(1).length() - 1)); if (!isNegativeNumber && !isAnalyticsTrackingId((Element) element)) { context.report(DASHES, element, context.getLocation(textNode), EN_DASH_MESSAGE);
@Override public void visitElement(@NonNull XmlContext context, @NonNull Element element) { NodeList childNodes = element.getChildNodes(); for (int i = 0, n = childNodes.getLength(); i < n; i++) { Node child = childNodes.item(i); if (child.getNodeType() == Node.TEXT_NODE) { String text = child.getNodeValue(); checkText(context, element, child, text); } else if (child.getNodeType() == Node.ELEMENT_NODE && (child.getParentNode().getNodeName().equals(TAG_STRING_ARRAY) || child.getParentNode().getNodeName().equals(TAG_PLURALS))) { // String array or plural item children NodeList items = child.getChildNodes(); for (int j = 0, m = items.getLength(); j < m; j++) { Node item = items.item(j); if (item.getNodeType() == Node.TEXT_NODE) { String text = item.getNodeValue(); checkText(context, child, item, text); } } } } }
/** * Returns a list of edits to be applied to fix the suggestion made by the * given warning. The specific issue id and message should be the message * provided by this detector in an earlier run. * <p> * This is intended to help tools implement automatic fixes of these * warnings. The reason only the message and issue id can be provided * instead of actual state passed in the data field to a reporter is that * fix operation can be run much later than the lint is processed (for * example, in a subsequent run of the IDE when only the warnings have been * persisted), * * @param issueId the issue id, which should be the id for one of the * typography issues * @param message the actual error message, which should be a message * provided by this detector * @param textNode a text node which corresponds to the text node the * warning operated on * @return a list of edits, which is never null but could be empty. The * offsets in the edit objects are relative to the text node. */ public static List<ReplaceEdit> getEdits(String issueId, String message, Node textNode) { return getEdits(issueId, message, textNode.getNodeValue()); }
if (child.getNodeType() == Node.TEXT_NODE) { String text = child.getNodeValue(); checkText(context, element, child, text); } else if (child.getNodeType() == Node.ELEMENT_NODE && (child.getParentNode().getNodeName().equals(TAG_STRING_ARRAY) || if (item.getNodeType() == Node.TEXT_NODE) { String text = item.getNodeValue(); checkText(context, child, item, text);