Guest User

FormatModelBuilder

a guest
Jun 1st, 2016
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. package com.gameforge.idea.Corona.lang.formatter;
  2.  
  3. import com.intellij.formatting.*;
  4. import com.intellij.lang.ASTNode;
  5. import com.intellij.openapi.util.TextRange;
  6. import com.intellij.psi.PsiElement;
  7. import com.intellij.psi.PsiFile;
  8. import com.intellij.psi.codeStyle.CodeStyleSettings;
  9. import org.jetbrains.annotations.NotNull;
  10. import org.jetbrains.annotations.Nullable;
  11.  
  12. /**
  13.  * Created by felix.doerschner on 17.05.2016.
  14.  */
  15. public class CoronaFormatModelBuilder implements FormattingModelBuilder {
  16.     @NotNull
  17.     @Override
  18.     public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
  19.         PsiFile file = element.getContainingFile();
  20.         ASTNode node = element.getNode();
  21.         Block block = new CoronaFormatBlock(node, Wrap.createWrap(WrapType.NONE, true), Alignment.createAlignment(), Indent.getNoneIndent());
  22.  
  23.         FormattingModel model = FormattingModelProvider.createFormattingModelForPsiFile(file, block, settings);
  24.  
  25.         return model;
  26.     }
  27.  
  28.     @Nullable
  29.     @Override
  30.     public TextRange getRangeAffectingIndent(PsiFile psiFile, int i, ASTNode astNode) {
  31.         return null;
  32.     }
  33. }
Add Comment
Please, Sign In to add comment