This commit is contained in:
Rustam Vishnyakov
2016-12-27 13:36:40 +03:00
parent 8f533a3edc
commit cd6b01ec50
2 changed files with 22 additions and 1 deletions
@@ -267,7 +267,14 @@ public abstract class CodeStyleManager {
public abstract <T extends Throwable> void performActionWithFormatterDisabled(ThrowableRunnable<T> r) throws T;
public abstract <T> T performActionWithFormatterDisabled(Computable<T> r);
/**
* Retrieves the current formatting mode.
*
* @param project The current project used to obtain {@code CodeStyleManager} instance.
* @return The current formatting mode.
* @see FormattingMode
*/
public static FormattingMode getCurrentFormattingMode(@NotNull Project project) {
if (!project.isDisposed()) {
CodeStyleManager instance = getInstance(project);
@@ -19,8 +19,22 @@ import com.intellij.formatting.FormattingMode;
import com.intellij.openapi.editor.Document;
import org.jetbrains.annotations.NotNull;
/**
* Used to differentiate between line indent adjustment on a new line after Enter and explicit indent adjustment action.
*
* @see FormattingMode
* @see CodeStyleManager
*/
public interface FormattingModeAwareIndentAdjuster {
/**
* Adjust line indent at document offset using {@code mode}.
*
* @param document The document to adjust line indent in.
* @param offset The offset in the document.
* @param mode The mode: {@link FormattingMode#ADJUST_INDENT} or {@link FormattingMode#ADJUST_INDENT_ON_ENTER}
* @return Adjusted offset.
*/
int adjustLineIndent(@NotNull final Document document, final int offset, FormattingMode mode);
FormattingMode getCurrentFormattingMode();