com.intellij.psi.codeStyle.ChangedRangesInfo Java Examples

The following examples show how to use com.intellij.psi.codeStyle.ChangedRangesInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChangedRangesUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
static List<TextRange> processChangedRanges(@Nonnull PsiFile file, @Nonnull ChangedRangesInfo changedRangesInfo) {
  Document document = file.getViewProvider().getDocument();
  List<TextRange> result = new ArrayList<>();
  if (document != null) {
    FormattingRangesExtender extender = new FormattingRangesExtender(document, file);
    for (TextRange range : changedRangesInfo.allChangedRanges) {
      List<TextRange> extended = extender.getExtendedRanges(Collections.singletonList(range));
      result.addAll(extended);
    }
  }
  else {
    result.addAll(changedRangesInfo.allChangedRanges);
  }
  return optimizedChangedRanges(result);
}
 
Example #2
Source File: ExternalFormatterCodeStyleManager.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public void reformatTextWithContext(PsiFile file, ChangedRangesInfo info) {
  if (overrideFormatterForFile(file)) {
    formatInternal(file, info);
  } else {
    super.reformatTextWithContext(file, info);
  }
}
 
Example #3
Source File: ExternalFormatterCodeStyleManager.java    From intellij with Apache License 2.0 5 votes vote down vote up
private void formatInternal(PsiFile file, ChangedRangesInfo info) {
  List<TextRange> ranges = new ArrayList<>();
  if (info.insertedRanges != null) {
    ranges.addAll(info.insertedRanges);
  }
  ranges.addAll(info.allChangedRanges);
  formatInternal(file, ranges);
}
 
Example #4
Source File: FormatTextRanges.java    From consulo with Apache License 2.0 5 votes vote down vote up
public FormatTextRanges(@Nonnull ChangedRangesInfo changedRangesInfo, @Nonnull List<TextRange> contextRanges) {
  myInsertedRanges = changedRangesInfo.insertedRanges;
  boolean processHeadingWhitespace = false;
  for (TextRange range : contextRanges) {
    add(range, processHeadingWhitespace);
    processHeadingWhitespace = true;
  }
}
 
Example #5
Source File: DelegatingCodeStyleManager.java    From spring-javaformat with Apache License 2.0 4 votes vote down vote up
@Override
public void reformatTextWithContext(PsiFile file, ChangedRangesInfo info) throws IncorrectOperationException {
	this.delegate.reformatTextWithContext(file, info);
}
 
Example #6
Source File: DelegatingCodeStyleManager.java    From intellij with Apache License 2.0 4 votes vote down vote up
@Override
public void reformatTextWithContext(PsiFile file, ChangedRangesInfo info)
    throws IncorrectOperationException {
  delegate.reformatTextWithContext(file, info);
}
 
Example #7
Source File: CodeStyleManagerDecorator.java    From google-java-format with Apache License 2.0 4 votes vote down vote up
@Override
public void reformatTextWithContext(PsiFile psiFile, ChangedRangesInfo changedRangesInfo)
    throws IncorrectOperationException {
  delegate.reformatTextWithContext(psiFile, changedRangesInfo);
}
 
Example #8
Source File: DelegatingCodeStyleManager.java    From EclipseCodeFormatter with Apache License 2.0 4 votes vote down vote up
@Override
public void reformatTextWithContext(@NotNull PsiFile psiFile, @NotNull ChangedRangesInfo changedRangesInfo) throws IncorrectOperationException {
	original.reformatTextWithContext(psiFile, changedRangesInfo);
}