Add default implementation to getRangeAffectingIndent()

and remove dummy implementations returning null.
This commit is contained in:
Rustam Vishnyakov
2018-06-01 14:53:13 +03:00
parent 4958b4da81
commit 7f46a79dbd
11 changed files with 5 additions and 50 deletions
@@ -24,12 +24,6 @@ public class JsonFormattingBuilderModel implements FormattingModelBuilder {
return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), block, settings);
}
@Nullable
@Override
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
return null;
}
static SpacingBuilder createSpacingBuilder(CodeStyleSettings settings) {
final JsonCodeStyleSettings jsonSettings = settings.getCustomSettings(JsonCodeStyleSettings.class);
final CommonCodeStyleSettings commonSettings = settings.getCommonSettings(JsonLanguage.INSTANCE);
@@ -32,7 +32,7 @@ import org.jetbrains.annotations.Nullable;
* as the language's whitespace tokens. See {@link com.intellij.lang.ParserDefinition}
*
* @see com.intellij.lang.LanguageFormatting
* @see FormattingModelProvider#createFormattingModelForPsiFile(com.intellij.psi.PsiFile, Block, com.intellij.psi.codeStyle.CodeStyleSettings)
* @see FormattingModelProvider#createFormattingModelForPsiFile(PsiFile, Block, CodeStyleSettings)
*/
public interface FormattingModelBuilder {
@@ -58,5 +58,7 @@ public interface FormattingModelBuilder {
* @return the range to reformat, or null if the default range should be used
*/
@Nullable
TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset);
default TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
return null;
}
}
@@ -91,11 +91,6 @@ public abstract class TemplateLanguageFormattingModelBuilder implements Delegati
};
}
@Override
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
return null;
}
@Override
public boolean dontFormatMyModel() {
return true;
@@ -68,8 +68,4 @@ public class SimpleTemplateLanguageFormattingModelBuilder implements FormattingM
}, element.getProject(), settings, file.getFileType(), file);
}
@Override
public TextRange getRangeAffectingIndent(final PsiFile file, final int offset, final ASTNode elementAtOffset) {
return null;
}
}
@@ -68,12 +68,6 @@ public class GroovyFormattingModelBuilder implements FormattingModelBuilder {
}
}
@Override
@Nullable
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
return null;
}
/**
* Standard {@link PsiBasedFormattingModel} extension that handles the fact that groovy uses not single white space token type
* ({@link TokenType#WHITE_SPACE}) but one additional token type as well: {@link GroovyTokenTypes#mNLS}. So, it allows to adjust
@@ -41,9 +41,4 @@ public class PropertiesFormattingModelBuilder implements FormattingModelBuilder
return new PsiBasedFormattingModel(element.getContainingFile(), new PropertiesRootBlock(root, settings), documentModel);
}
@Nullable
@Override
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
return null;
}
}
@@ -167,11 +167,6 @@ public class PythonFormattingModelBuilder implements FormattingModelBuilderEx, C
return TokenSet.create(IElementType.enumerate(type -> type != LAMBDA_KEYWORD && type.getLanguage().isKindOf(pythonLanguage)));
}
@Override
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
return null;
}
private static void printAST(ASTNode node, int indent) {
while (node != null) {
for (int i = 0; i < indent; i++) {
@@ -45,8 +45,4 @@ public class HtmlFormattingModelBuilder implements FormattingModelBuilder {
documentModel);
}
@Override
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
return null;
}
}
@@ -46,8 +46,4 @@ public class XhtmlFormattingModelBuilder implements FormattingModelBuilder {
documentModel);
}
@Override
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
return null;
}
}
@@ -48,8 +48,5 @@ public class XmlFormattingModelBuilder implements FormattingModelBuilder {
return new XmlBlock(root, null, null, new XmlPolicy(settings, documentModel), null, null, false);
}
@Override
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
return null;
}
}
@@ -33,9 +33,4 @@ public class RncFormattingModelBuilder implements FormattingModelBuilder {
return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), new RncBlock(element.getNode()), settings);
}
@Override
public TextRange getRangeAffectingIndent(PsiFile file, int offset, ASTNode elementAtOffset) {
// TODO
return null;
}
}