private static IProblemLocation[] getHandledProblems(
     IProblemLocation[] locations, ContributedProcessorDescriptor processor) {
   // implementation tries to avoid creating a new array
   boolean allHandled = true;
   List<IProblemLocation> res = null;
   for (int i = 0; i < locations.length; i++) {
     IProblemLocation curr = locations[i];
     if (processor.canHandleMarkerType(curr.getMarkerType())) {
       if (!allHandled) { // first handled problem
         if (res == null) {
           res = Lists.newArrayListWithCapacity(locations.length - i);
         }
         res.add(curr);
       }
     } else if (allHandled) {
       if (i > 0) { // first non handled problem
         res = Lists.newArrayListWithCapacity(locations.length - i);
         for (int k = 0; k < i; k++) {
           res.add(locations[k]);
         }
       }
       allHandled = false;
     }
   }
   if (allHandled) {
     return locations;
   }
   if (res == null) {
     return null;
   }
   return res.toArray(new IProblemLocation[res.size()]);
 }
  private static IMarkerResolution[] internalGetResolutions(IMarker marker) {
    if (!internalHasResolutions(marker)) {
      return NO_RESOLUTIONS;
    }

    CompilationUnit cu = getCompilationUnit(marker);
    if (cu != null) {
      IEditorInput input = EditorUtility.getEditorInput(cu);
      if (input != null) {
        IProblemLocation location = findProblemLocation(input, marker);
        if (location != null) {

          IInvocationContext context =
              new AssistContext(cu, location.getOffset(), location.getLength());

          // TODO(scheglov) do we need this?
          //          if (!hasProblem(context.getASTRoot().getProblems(), location)) {
          //            return NO_RESOLUTIONS;
          //          }

          List<IDartCompletionProposal> proposals = Lists.newArrayList();
          DartCorrectionProcessor_OLD.collectCorrections(
              context, new IProblemLocation[] {location}, proposals);
          Collections.sort(proposals, new CompletionProposalComparator());

          int nProposals = proposals.size();
          IMarkerResolution[] resolutions = new IMarkerResolution[nProposals];
          for (int i = 0; i < nProposals; i++) {
            resolutions[i] =
                new CorrectionMarkerResolution(
                    cu, location.getOffset(), location.getLength(), proposals.get(i));
          }
          return resolutions;
        }
      }
    }
    return NO_RESOLUTIONS;
  }