private int[] getSpacesToAdd(List<? extends RangeMarker> markers) {
      int size = markers.size();
      int[] spacesToAdd = new int[size];
      Arrays.fill(spacesToAdd, -1);
      CharSequence text = myDoc.getCharsSequence();
      FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forContext(myFile);
      CodeStyleSettings settings = CodeStyle.getSettings(myFile);
      FormattingModel model = builder == null ? null : builder.createModel(FormattingContext.create(myFile, settings));
      FormatterEx formatter = FormatterEx.getInstance();
      for (int i = 0; i < size; i++) {
        myIndicator.checkCanceled();
        myIndicator.setFraction(0.7 + 0.25 * i / size);
        RangeMarker marker = markers.get(i);
        if (!marker.isValid()) continue;
        int end = StringUtil.skipWhitespaceForward(text, marker.getStartOffset());
        int spacesToCreate = end >= text.length() || text.charAt(end) == '\n' ? 0 :
                             model == null ? 1 : formatter.getSpacingForBlockAtOffset(model, end);
        spacesToAdd[i] = spacesToCreate < 0 ? 1 : spacesToCreate;
      }
      return spacesToAdd;
    }
private int[] getSpacesToAdd(List<? extends RangeMarker> markers)