Пример #1
0
  @Override
  protected void processFiltered(File aFile, List<String> aLines) {
    // check if already checked and passed the file
    final String fileName = aFile.getPath();
    final long timestamp = aFile.lastModified();
    if (mCache.alreadyChecked(fileName, timestamp)) {
      return;
    }

    try {
      final FileText text = FileText.fromLines(aFile, aLines);
      final FileContents contents = new FileContents(text);
      final DetailAST rootAST = TreeWalker.parse(contents);
      walk(rootAST, contents);
    } catch (final RecognitionException re) {
      Utils.getExceptionLogger().debug("RecognitionException occured.", re);
      getMessageCollector()
          .add(
              new LocalizedMessage(
                  re.getLine(),
                  re.getColumn(),
                  Defn.CHECKSTYLE_BUNDLE,
                  "general.exception",
                  new String[] {re.getMessage()},
                  getId(),
                  this.getClass(),
                  null));
    } catch (final TokenStreamRecognitionException tre) {
      Utils.getExceptionLogger().debug("TokenStreamRecognitionException occured.", tre);
      final RecognitionException re = tre.recog;
      if (re != null) {
        getMessageCollector()
            .add(
                new LocalizedMessage(
                    re.getLine(),
                    re.getColumn(),
                    Defn.CHECKSTYLE_BUNDLE,
                    "general.exception",
                    new String[] {re.getMessage()},
                    getId(),
                    this.getClass(),
                    null));
      } else {
        getMessageCollector()
            .add(
                new LocalizedMessage(
                    0,
                    Defn.CHECKSTYLE_BUNDLE,
                    "general.exception",
                    new String[] {"TokenStreamRecognitionException occured."},
                    getId(),
                    this.getClass(),
                    null));
      }
    } catch (final TokenStreamException te) {
      Utils.getExceptionLogger().debug("TokenStreamException occured.", te);
      getMessageCollector()
          .add(
              new LocalizedMessage(
                  0,
                  Defn.CHECKSTYLE_BUNDLE,
                  "general.exception",
                  new String[] {te.getMessage()},
                  getId(),
                  this.getClass(),
                  null));
    } catch (final Throwable err) {
      Utils.getExceptionLogger().debug("Throwable occured.", err);
      getMessageCollector()
          .add(
              new LocalizedMessage(
                  0,
                  Defn.CHECKSTYLE_BUNDLE,
                  "general.exception",
                  new String[] {"" + err},
                  getId(),
                  this.getClass(),
                  null));
    }

    if (getMessageCollector().size() == 0) {
      mCache.checkedOk(fileName, timestamp);
    }
  }