コード例 #1
0
ファイル: HtmlBuildParticipant.java プロジェクト: aam/dartdev
  private void validate(XmlElement node, IFile file) throws CoreException {
    // We need to be very smart about html attribute validation, as lots of html code
    // uses older attributes, or makes up their own custom attributes.
    // We should probably look for typos of the common attributes.
    if (DartCoreDebug.ENABLE_HTML_VALIDATION) {
      if (node.getAttributes().size() > 0) {
        List<String> validAttributes = HtmlKeywords.getAttributes(node.getLabel());

        if (!validAttributes.isEmpty()) {
          for (XmlAttribute attribute : node.getAttributes()) {
            String name = attribute.getName();

            // A common pattern with data-binding frameworks.
            if (name.startsWith("ng-")) {
              continue;
            }

            // A data attribute.
            if (name.startsWith("data-")) {
              continue;
            }

            if (!validAttributes.contains(name)) {
              if (!HtmlKeywords.isValidEventAttribute(name)) {
                int charStart = attribute.getStartToken().getLocation();
                String message =
                    "\""
                        + name
                        + "\" is not a valid attribute for the "
                        + "<"
                        + node.getLabel()
                        + "> element.";

                MarkerUtilities.createWarningMarker(
                    file,
                    message,
                    attribute.getStartToken().getLineNumber(),
                    charStart,
                    charStart + name.length());
              }
            }
          }
        }
      }
    }

    for (XmlNode child : node.getChildren()) {
      if (child instanceof XmlElement) {
        validate((XmlElement) child, file);
      }
    }
  }
コード例 #2
0
ファイル: HtmlBuildParticipant.java プロジェクト: aam/dartdev
  protected void processHtml(IFile file) {
    try {
      MarkerUtilities.deleteMarkers(file);

      XmlDocument document =
          new HtmlParser(Files.toString(file.getLocation().toFile(), Charsets.UTF_8)).parse();

      validate(document, file);
    } catch (CoreException e) {
      DartCore.logError(e);
    } catch (IOException ioe) {

    }

    HtmlAnalyzeHelper.analyze(file);
  }
コード例 #3
0
ファイル: HtmlBuildParticipant.java プロジェクト: aam/dartdev
 @Override
 public void clean(CleanEvent event, IProgressMonitor monitor) throws CoreException {
   MarkerUtilities.deleteMarkers(event.getProject());
 }