Пример #1
0
 @NotNull
 private static List<DiagnosticDescriptor> getSortedDiagnosticDescriptors(
     @NotNull Collection<Diagnostic> diagnostics) {
   LinkedListMultimap<TextRange, Diagnostic> diagnosticsGroupedByRanges =
       LinkedListMultimap.create();
   for (Diagnostic diagnostic : diagnostics) {
     if (!diagnostic.isValid()) continue;
     for (TextRange textRange : diagnostic.getTextRanges()) {
       diagnosticsGroupedByRanges.put(textRange, diagnostic);
     }
   }
   List<DiagnosticDescriptor> diagnosticDescriptors = Lists.newArrayList();
   for (TextRange range : diagnosticsGroupedByRanges.keySet()) {
     diagnosticDescriptors.add(
         new DiagnosticDescriptor(
             range.getStartOffset(), range.getEndOffset(), diagnosticsGroupedByRanges.get(range)));
   }
   Collections.sort(
       diagnosticDescriptors,
       new Comparator<DiagnosticDescriptor>() {
         @Override
         public int compare(@NotNull DiagnosticDescriptor d1, @NotNull DiagnosticDescriptor d2) {
           // Start early -- go first; start at the same offset, the one who end later is the
           // outer, i.e. goes first
           return (d1.start != d2.start) ? d1.start - d2.start : d2.end - d1.end;
         }
       });
   return diagnosticDescriptors;
 }
Пример #2
0
 public Service add(Dependency dep) {
   dependencies.put(dep.initiator, dep);
   return this;
 }