Class AstAnalyzer

java.lang.Object
com.google.javascript.jscomp.AstAnalyzer

public class AstAnalyzer extends Object
Logic for answering questions about portions of the AST.

What kind of methods should go here?

Methods that answer questions about some portion of the AST and that may require global information about the compilation, generally taking at least one Node as an argument. For example:

  • Does a node have side effects?
  • Can we statically determine the value of a node?

What kind of logic should not go here?

Really simple logic that requires no global information, like finding the parameter list node of a function, should be in NodeUtil. Logic that creates new Nodes or modifies the AST should go in AstFactory.

  • Method Details

    • mayHaveSideEffects

      public boolean mayHaveSideEffects(Node n)
      Returns true if the node which may have side effects when executed. This version default to the "safe" assumptions when the compiler object is not provided (RegExp have side-effects, etc).