@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;
  }
 void validateExternal(int scriptIndex, HtmlScriptElement script) {
   if (!(script instanceof ExternalHtmlScriptElementImpl)) {
     fail(
         "Expected script "
             + scriptIndex
             + " to be external with src="
             + expectedExternalScriptName
             + " but found "
             + (script != null ? script.getClass() : "null"));
   }
   ExternalHtmlScriptElementImpl externalScript = (ExternalHtmlScriptElementImpl) script;
   Source scriptSource = externalScript.getScriptSource();
   if (expectedExternalScriptName == null) {
     assertNull("script " + scriptIndex, scriptSource);
   } else {
     assertNotNull("script " + scriptIndex, scriptSource);
     String actualExternalScriptName = scriptSource.getShortName();
     assertEquals("script " + scriptIndex, expectedExternalScriptName, actualExternalScriptName);
   }
 }