astNodeFor abstract method

Future<AstNode?> astNodeFor(
  1. Element element, {
  2. bool resolve = false,
})

Returns the parsed AstNode for Element.

This should always be preferred over using the AnalysisSession directly, because it avoids InconsistentAnalysisException issues.

If resolve is true then you will get a resolved ast node, otherwise it will only be a parsed ast node.

Returns null if the ast node can not be found. This can happen if an element is coming from a summary, or is unavailable for some other reason.

Implementation

Future<AstNode?> astNodeFor(Element element, {bool resolve = false});