类com.intellij.psi.codeStyle.FormattingModeAwareIndentAdjuster源码实例Demo

下面列出了怎么用com.intellij.psi.codeStyle.FormattingModeAwareIndentAdjuster的API类实例代码及写法,或者点击链接到github查看源代码。


@Override
public int adjustLineIndent(Document document, int offset, FormattingMode mode) {
	if (this.delegate instanceof FormattingModeAwareIndentAdjuster) {
		return ((FormattingModeAwareIndentAdjuster) this.delegate).adjustLineIndent(document, offset, mode);
	}
	return offset;
}
 

@Override
public FormattingMode getCurrentFormattingMode() {
	if (this.delegate instanceof FormattingModeAwareIndentAdjuster) {
		return ((FormattingModeAwareIndentAdjuster) this.delegate).getCurrentFormattingMode();
	}
	return FormattingMode.REFORMAT;
}
 

/** Uses same fallback as {@link CodeStyleManager#getCurrentFormattingMode}. */
@Override
public FormattingMode getCurrentFormattingMode() {
  if (delegate instanceof FormattingModeAwareIndentAdjuster) {
    return ((FormattingModeAwareIndentAdjuster) delegate).getCurrentFormattingMode();
  }
  return FormattingMode.REFORMAT;
}
 

@Override
public int adjustLineIndent(final Document document, final int offset, FormattingMode mode)
    throws IncorrectOperationException {
  if (delegate instanceof FormattingModeAwareIndentAdjuster) {
    return ((FormattingModeAwareIndentAdjuster) delegate)
        .adjustLineIndent(document, offset, mode);
  }
  return offset;
}
 

/** Uses same fallback as {@link CodeStyleManager#getCurrentFormattingMode}. */
@Override
public FormattingMode getCurrentFormattingMode() {
  if (delegate instanceof FormattingModeAwareIndentAdjuster) {
    return ((FormattingModeAwareIndentAdjuster) delegate).getCurrentFormattingMode();
  }
  return FormattingMode.REFORMAT;
}
 

@Override
public int adjustLineIndent(final Document document, final int offset, FormattingMode mode)
    throws IncorrectOperationException {
  if (delegate instanceof FormattingModeAwareIndentAdjuster) {
    return ((FormattingModeAwareIndentAdjuster) delegate)
        .adjustLineIndent(document, offset, mode);
  }
  return offset;
}
 

@Override
public int adjustLineIndent(@NotNull Document document, int offset, FormattingMode formattingMode) {
	if (original instanceof FormattingModeAwareIndentAdjuster) {
		return ((FormattingModeAwareIndentAdjuster) original).adjustLineIndent(document, offset, formattingMode);
	} else {
		return offset;
	}
}
 

@Override
public FormattingMode getCurrentFormattingMode() {
	if (original instanceof FormattingModeAwareIndentAdjuster) {
		return ((FormattingModeAwareIndentAdjuster) original).getCurrentFormattingMode();
	} else {
		return FormattingMode.REFORMAT;
	}
}
 

@Override
public void run() {
  int lineStart = myDocument.getLineStartOffset(myLine);
  CommandProcessor.getInstance().runUndoTransparentAction(() -> ApplicationManager.getApplication().runWriteAction(() -> {
    CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(myProject);
    if (codeStyleManager instanceof FormattingModeAwareIndentAdjuster) {
      ((FormattingModeAwareIndentAdjuster)codeStyleManager).adjustLineIndent(myDocument, lineStart, FormattingMode.ADJUST_INDENT_ON_ENTER);
    }
  }));
}
 
 类所在包
 同包方法