visit()

in lib/main.ts [560:594]


  visit(node: ts.Node) {
    if (this.nodeSubstitutions.has(node)) {
      node = this.nodeSubstitutions.get(node);
    }
    if (!node) return;
    let comments = ts.getLeadingCommentRanges(this.currentFile.text, node.getFullStart());
    if (comments) {
      comments.forEach((c) => {
        // Warning: the following check means that comments will only be
        // emitted correctly if Dart code is emitted in the same order it
        // appeared in the JavaScript AST.
        if (c.pos <= this.lastCommentIdx) return;
        this.lastCommentIdx = c.pos;
        let text = this.currentFile.text.substring(c.pos, c.end);
        if (c.pos > 1) {
          let prev = this.currentFile.text.substring(c.pos - 2, c.pos);
          if (prev === '\n\n') {
            // If the two previous characters are both \n then add a \n
            // so that we ensure the output has sufficient line breaks to
            // separate comment blocks.
            this.currentOutput.emit('\n');
          }
        }
        this.currentOutput.emitComment(this.translateComment(text));
      });
    }

    for (let i = 0; i < this.transpilers.length; i++) {
      if (this.transpilers[i].visitNode(node)) return;
    }

    this.reportError(
        node,
        'Unsupported node type ' + (<any>ts).SyntaxKind[node.kind] + ': ' + node.getFullText());
  }