@Override
    protected void scanFile() {
      logger.debug("updating " + getFile().getVirtualFile());


      XmlDoctype doctype = null;
      PsiElement root = null;

      XmlDocument doc = ((XmlFile)getFile()).getDocument();
      PsiElement elem = doc.getFirstChild();
      while (elem != null) {
        if (elem instanceof XmlProlog) {
          PsiElement prolog = elem.getFirstChild();
          while (prolog != null) {
            if (prolog instanceof XmlDoctype) {
              doctype = (XmlDoctype)prolog;
            }

            prolog = prolog.getNextSibling();
          }
        }
        else if (elem instanceof XmlTag || elem instanceof XmlElementDecl || elem instanceof XmlAttributeDecl) {
          root = elem;
          break;
        }

        elem = elem.getNextSibling();
      }

      PsiElement first = doc.getFirstChild();
      if (root == null) {
        root = doc.getLastChild();
      }

      int location = getLanguageOptions().getFileLocation();
      if (doctype != null) {
        checkComments(first, doctype, location == XmlOptions.LOCATION_BEFORE_DOCTYPE);
        first = doctype;
      }
      else if (location == XmlOptions.LOCATION_BEFORE_DOCTYPE) {
        location = XmlOptions.LOCATION_BEFORE_ROOTTAG;
      }

      if (root != null) {
        checkComments(first, root, location == XmlOptions.LOCATION_BEFORE_ROOTTAG);
      }
      else if (location == XmlOptions.LOCATION_BEFORE_ROOTTAG) {
        // If we get here we have an empty file
        checkComments(first, first, true);
      }
    }
@Override
    protected void scanFile()