public OccurrencesSearchQuery(IOccurrencesFinder finder, ITypeRoot element) {
   fFinder = finder;
   fElement = element;
   fJobLabel = fFinder.getJobLabel();
   fResult = new OccurrencesSearchResult(this);
   fSingularLabel = fFinder.getUnformattedSingularLabel();
   fPluralLabel = fFinder.getUnformattedPluralLabel();
   fName = fFinder.getElementName();
   fFinderId = fFinder.getID();
 }
  /*
   * @see org.eclipse.search.ui.ISearchQuery#run(org.eclipse.core.runtime.IProgressMonitor)
   */
  @Override
  public IStatus run(IProgressMonitor monitor) {
    if (fFinder == null) {
      return new StatusInfo(IStatus.ERROR, "Query has already been running"); // $NON-NLS-1$
    }
    if (monitor == null) monitor = new NullProgressMonitor();

    try {
      OccurrenceLocation[] occurrences = fFinder.getOccurrences();
      if (occurrences != null) {
        HashMap<Integer, JavaElementLine> lineMap = new HashMap<>();
        CompilationUnit astRoot = fFinder.getASTRoot();
        ArrayList<OccurrenceMatch> resultingMatches = new ArrayList<>();

        for (int i = 0; i < occurrences.length; i++) {
          OccurrenceLocation loc = occurrences[i];

          JavaElementLine lineKey = getLineElement(astRoot, loc, lineMap);
          if (lineKey != null) {
            OccurrenceMatch match =
                new OccurrenceMatch(lineKey, loc.getOffset(), loc.getLength(), loc.getFlags());
            resultingMatches.add(match);

            lineKey.setFlags(lineKey.getFlags() | loc.getFlags());
          }
        }

        if (!resultingMatches.isEmpty()) {
          fResult.addMatches(resultingMatches.toArray(new Match[resultingMatches.size()]));
        }
      }

    } finally {
      // Don't leak AST:
      fFinder = null;
      monitor.done();
    }
    return Status.OK_STATUS;
  }