public boolean parse()

in agent/src/jetbrains/buildServer/xmlReportPlugin/parsers/findBugs/FindBugsReportParser.java [115:181]


  public boolean parse(@NotNull final File file, @Nullable final ParsingResult prevResult) throws ParsingException {
    if (!ParserUtils.isReportComplete(file, "BugCollection")) {
      return false;
    }

    if (myFindBugsHome != null) {
      new FindBugsPluginVisitor(new FindBugsPluginVisitor.Callback() {
        @Override
        public void pluginFound(@NotNull File messages) {
          try {
            myPatternXmlParser.parse(messages);
            myCategoryXmlParser.parse(messages);
          } catch (IOException e) {
            myInspectionReporter.error("Error occurred while loading bug patterns from " + myFindBugsHome);
          }
        }
      }).visit(myFindBugsHome);
    }

    try {
      myPatternXmlParser.parse(file);
      myCategoryXmlParser.parse(file);

      new FindBugsReportXmlParser(new FindBugsReportXmlParser.Callback() {
        public void jarFound(@NotNull final String jar) {
          myFileFinder.addJar(FileUtil.resolvePath(myBaseFolder, jar).getAbsolutePath());
        }

        public void bugInstanceFound(@Nullable final String file,
                                     @Nullable final String clazz,
                                     final int line,
                                     @Nullable final String type,
                                     @Nullable final String category,
                                     @Nullable final String message,
                                     @Nullable final String details,
                                     final int priority) {
          switch (priority) {
            case 1:
              ++myErrors;
              break;
            case 2:
              ++myWarnings;
              break;
            default:
              ++myInfos;
          }
          final String cName = myCategories.containsKey(category) ? myCategories.get(category).getName() : category;
          final String descr = myCategories.containsKey(category) ? myCategories.get(category).getDescription() : null;
          final String mess = getFullMessage(message, myPatterns.containsKey(type) ? myPatterns.get(type).getDescription() : null, details);
          final String pName = myPatterns.containsKey(type) ? myPatterns.get(type).getName() : type;

          myInspectionReporter.reportInspectionType(new InspectionTypeResult(type, pName, descr, cName));
          myInspectionReporter.reportInspection(new InspectionResult(findFile(file, clazz), type, mess, line, priority));
        }

        @Override
        public void error(@NotNull final String message) {
          myInspectionReporter.error(message);
        }
      }).parse(file);
    } catch (IOException e) {
      throw new ParsingException(e);
    } finally {
      myFileFinder.close();
    }
    return true;
  }