use of com.google.javascript.rhino.Node in project ow by vtst.
the class ClosureCompletionProposal method addFragmentsForFunctionParameters.
/**
* Add the fragments for the parameters of a function.
* @param list The list to which the fragments will be added.
* @param fnNode The function node.
*/
private void addFragmentsForFunctionParameters(List<Fragment> list, Node fnNode) {
if (fnNode == null)
return;
Preconditions.checkState(fnNode.getType() == Token.FUNCTION);
JSType type = fnNode.getJSType();
if (type == null || type.isUnknownType())
return;
FunctionType funType = type.toMaybeFunctionType();
Node paramNode = NodeUtil.getFunctionParameters(fnNode).getFirstChild();
list.add(new Fragment("("));
boolean first = true;
for (@SuppressWarnings("unused") Node parameterTypeNode : funType.getParameters()) {
// Bail out if the paramNode is not there.
if (paramNode == null)
break;
if (first)
first = false;
else
list.add(new Fragment(", "));
list.add(new LinkedFragment(paramNode.getString()));
paramNode = paramNode.getNext();
}
list.add(new Fragment(")"));
}
use of com.google.javascript.rhino.Node in project ow by vtst.
the class CompilerRun method processCustomPassesOnNewScript.
private void processCustomPassesOnNewScript(JsAst ast) {
if (!keepCompilationResultsInMemory)
return;
if (options.customPasses == null)
return;
Node scriptRoot = ast.getAstRoot(compiler);
Node originalRoot = compiler.getRoot();
for (CompilerPass pass : options.customPasses.get(CustomPassExecutionTime.BEFORE_CHECKS)) {
if (pass instanceof HotSwapCompilerPass) {
((HotSwapCompilerPass) pass).hotSwapScript(scriptRoot, originalRoot);
}
}
}
use of com.google.javascript.rhino.Node in project ow by vtst.
the class JSUnit method updateDependencies.
/**
* Update the sets of provided and required names from the current code.
* @param compiler The compiler used to report errors.
* @return true if the dependencies have changed since the last update.
*/
public synchronized boolean updateDependencies(AbstractCompiler compiler) {
if (!timestampKeeperForDependencies.hasChanged())
return false;
long modificationStamp = timestampKeeperForDependencies.getModificationStamp();
// There is no need to make a clone, as this pass does not modify the AST.
Node root = astFactory.getAstRoot(compiler);
Set<String> newProvidedNames = new HashSet<String>();
Set<String> newRequiredNames = new HashSet<String>();
GetDependenciesNodeTraversal.run(compiler, root, newProvidedNames, newRequiredNames);
if (newProvidedNames.equals(providedNames) && newRequiredNames.equals(requiredNames)) {
return false;
}
setDependencies(newProvidedNames, newRequiredNames, modificationStamp);
return true;
}
use of com.google.javascript.rhino.Node in project ow by vtst.
the class DevUtils method printNodeAndAncestors.
public static void printNodeAndAncestors(Node node) {
StringBuffer buffer = new StringBuffer();
Node current = node;
while (current != null) {
System.out.print(buffer.toString());
System.out.println(current);
buffer.append(" ");
current = current.getParent();
}
}
Aggregations