@Override
  public Void visitXmlTagNode(XmlTagNode node) {
    if (isScriptNode(node)) {
      Source htmlSource = htmlElement.getSource();
      String scriptSourcePath = getScriptSourcePath(node);
      if (node.getAttributeEnd().getType() == TokenType.GT && scriptSourcePath == null) {
        EmbeddedHtmlScriptElementImpl script = new EmbeddedHtmlScriptElementImpl(node);
        String contents = node.getContent();

        // TODO (danrubel): Move scanning embedded scripts into AnalysisContextImpl
        // so that clients such as builder can scan, parse, and get errors without resolving
        AnalysisErrorListener errorListener =
            new AnalysisErrorListener() {
              @Override
              public void onError(AnalysisError error) {
                // TODO (danrubel): make errors accessible once this is moved into
                // AnalysisContextImpl
              }
            };
        StringScanner scanner = new StringScanner(null, contents, errorListener);
        com.google.dart.engine.scanner.Token firstToken = scanner.tokenize();
        int[] lineStarts = scanner.getLineStarts();

        // TODO (danrubel): Move parsing embedded scripts into AnalysisContextImpl
        // so that clients such as builder can scan, parse, and get errors without resolving
        Parser parser = new Parser(null, errorListener);
        CompilationUnit unit = parser.parseCompilationUnit(firstToken);

        try {
          CompilationUnitBuilder builder = new CompilationUnitBuilder();
          CompilationUnitElementImpl elem = builder.buildCompilationUnit(htmlSource, unit);
          LibraryElementImpl library = new LibraryElementImpl(context, null);
          library.setDefiningCompilationUnit(elem);
          script.setScriptLibrary(library);
        } catch (AnalysisException e) {
          // TODO (danrubel): Handle or forward the exception
          e.printStackTrace();
        }

        scripts.add(script);
      } else {
        ExternalHtmlScriptElementImpl script = new ExternalHtmlScriptElementImpl(node);
        if (scriptSourcePath != null) {
          script.setScriptSource(
              context.getSourceFactory().resolveUri(htmlSource, scriptSourcePath));
        }
        scripts.add(script);
      }
    } else {
      node.visitChildren(this);
    }
    return null;
  }
  public static void main(final String[] args) {
    final AnalyzerOptions options = AnalyzerOptions.createFromArgs(args);

    options.initializeSdkPath();

    if (args.length == 0 || options.showHelp()) {
      showVersion(options, System.out);
      System.out.println();
      showUsage(System.out);
      System.out.println("For more information, see http://www.dartlang.org/tools/analyzer.");
      System.exit(0);
    }

    if (options.getShowVersion()) {
      showVersion(options, System.out);
      System.exit(0);
    }

    if (options.getDartSdkPath() == null) {
      System.out.println(PROGRAM_NAME + ": no Dart SDK found.");
      showUsage(System.out);
      System.exit(1);
    }

    if (!options.getDartSdkPath().exists()) {
      System.out.println(PROGRAM_NAME + ": invalid Dart SDK path: " + options.getDartSdkPath());
      showUsage(System.out);
      System.exit(1);
    }

    try {

      if (options.shouldBatch()) {
        ErrorSeverity result =
            BatchRunner.runAsBatch(
                args,
                new BatchRunnerInvocation() {
                  @Override
                  public ErrorSeverity invoke(String[] lineArgs) throws Throwable {
                    AnalyzerOptions compilerOptions = AnalyzerOptions.createFromArgs(lineArgs);

                    if (compilerOptions.getDartSdkPath() == null) {
                      compilerOptions.setDartSdkPath(options.getDartSdkPath());
                    }

                    if (options.getWarningsAreFatal()) {
                      compilerOptions.setWarningsAreFatal(true);
                    }

                    return runAnalyzer(compilerOptions);
                  }
                });

        if (result != ErrorSeverity.NONE) {
          System.exit(getReturnCode(result));
        }
      } else {
        String sourceFilePath = options.getSourceFile();

        if (sourceFilePath == null) {
          System.out.println(PROGRAM_NAME + ": no source files were specified.");
          showUsage(System.out);
          System.exit(1);
        }

        ErrorSeverity result = runAnalyzer(options);

        if (result != ErrorSeverity.NONE) {
          System.exit(getReturnCode(result));
        }
      }
    } catch (AnalysisException exception) {
      System.err.println("Error: " + exception.getMessage());

      crashAndExit();
    } catch (Throwable t) {
      t.printStackTrace();

      crashAndExit();
    }
  }