Anomaly identified by the detector. Please review whether this anomaly corresponds to a misuse.
Finding:
finding-8
In File:
com/google/javascript/jscomp/ReplaceCssNames.java
In Method:
processStringNode(NodeTraversal, Node)
Code with Finding:
class ReplaceCssNames.Traversal {
/**
* Processes a string argument to goog.getCssName(). The string will be
* renamed based off the symbol map. If there is no map or any part of the
* name can't be renamed, a warning is reported to the compiler and the node
* is left unchanged.
*
* If the type is unexpected then an error is reported to the compiler.
*
* @param t The node traversal.
* @param n The string node to process.
*/
private void processStringNode(NodeTraversal t, Node n) {
if (symbolMap != null || cssNames != null) {
String[] parts = n.getString().split("-");
for (int i = 0; i < parts.length; i++) {
if (cssNames != null) {
Integer count = cssNames.get(parts[i]);
if (count == null) {
count = Integer.valueOf(0);
}
cssNames.put(parts[i], count.intValue() + 1);
}
if (symbolMap != null) {
String replacement = symbolMap.get(parts[i]);
if (replacement == null) {
// If we can't encode all parts, don't encode any of it.
compiler.report(t.makeError(
n, UNKNOWN_SYMBOL_WARNING, parts[i], n.getString()));
return;
}
parts[i] = replacement;
}
}
if (symbolMap != null) {
n.setString(Joiner.on("-").join(parts));
}
}
}
}