use of com.google.template.soy.shared.internal.FindCalleesNotInFileVisitor in project closure-templates by google.
the class GenJsCodeVisitor method addCodeToRequireSoyNamespaces.
/**
* Helper for visitSoyFileNode(SoyFileNode) to add code to require Soy namespaces.
*
* @param soyFile The node we're visiting.
*/
private void addCodeToRequireSoyNamespaces(SoyFileNode soyFile) {
String prevCalleeNamespace = null;
Set<String> calleeNamespaces = new TreeSet<>();
for (CallBasicNode node : new FindCalleesNotInFileVisitor().exec(soyFile)) {
String calleeNotInFile = node.getCalleeName();
int lastDotIndex = calleeNotInFile.lastIndexOf('.');
calleeNamespaces.add(calleeNotInFile.substring(0, lastDotIndex));
}
for (String calleeNamespace : calleeNamespaces) {
if (calleeNamespace.length() > 0 && !calleeNamespace.equals(prevCalleeNamespace)) {
jsCodeBuilder.addGoogRequire(GoogRequire.create(calleeNamespace));
prevCalleeNamespace = calleeNamespace;
}
}
}
Aggregations