Java 类com.intellij.psi.formatter.FormattingDocumentModelImpl 实例源码

项目:bamboo-soy    文件:SoyFormattingModelBuilder.java   
@Override
public TemplateLanguageBlock createTemplateLanguageBlock(
    @NotNull ASTNode node,
    @Nullable Wrap wrap,
    @Nullable Alignment alignment,
    @Nullable List<DataLanguageBlockWrapper> foreignChildren,
    @NotNull CodeStyleSettings codeStyleSettings) {
  final FormattingDocumentModelImpl documentModel =
      FormattingDocumentModelImpl.createOn(node.getPsi().getContainingFile());
  if (node.getPsi() instanceof TagElement) {
    return new SoyTagBlock(
        this,
        codeStyleSettings,
        node,
        foreignChildren,
        new HtmlPolicy(codeStyleSettings, documentModel));
  } else if(node.getPsi() instanceof TagBlockElement) {
    return new SoyTagBlockBlock(
        this,
        codeStyleSettings,
        node,
        foreignChildren,
        new HtmlPolicy(codeStyleSettings, documentModel));
  } else if (node.getPsi() instanceof SoyStatementList) {
    return new SoyStatementListBlock(
        this,
        codeStyleSettings,
        node,
        foreignChildren,
        new HtmlPolicy(codeStyleSettings, documentModel));
  } else {
    return new SoyBlock(
      this,
      codeStyleSettings,
      node,
      foreignChildren,
      new HtmlPolicy(codeStyleSettings, documentModel));
  }
}
项目:intellij-ce-playground    文件:JavaFormattingModelBuilder.java   
@Override
@NotNull
  public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
  final FileElement fileElement = TreeUtil.getFileElement((TreeElement)SourceTreeToPsiMap.psiElementToTree(element));
  LOG.assertTrue(fileElement != null, "File element should not be null for " + element);
  CommonCodeStyleSettings commonSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
  JavaCodeStyleSettings customJavaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class);
  Block block = AbstractJavaBlock.newJavaBlock(fileElement, commonSettings, customJavaSettings);
  FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile());
  return new PsiBasedFormatterModelWithShiftIndentInside (element.getContainingFile(), block, model);
}
项目:intellij-ce-playground    文件:XhtmlFormattingModelBuilder.java   
@Override
@NotNull
  public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
  final PsiFile psiFile = element.getContainingFile();
  final FormattingDocumentModelImpl documentModel = FormattingDocumentModelImpl.createOn(psiFile);
  return new XmlFormattingModel(psiFile,
                                                          new XmlBlock(SourceTreeToPsiMap.psiElementToTree(psiFile),
                                                                       null, null,
                                                                       new HtmlPolicy(settings, documentModel), null, null, false),
                                                          documentModel);
}
项目:intellij-ce-playground    文件:XmlFormattingModelBuilder.java   
@Override
@NotNull
public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
  final ASTNode root = TreeUtil.getFileElement((TreeElement)SourceTreeToPsiMap.psiElementToTree(element));
  final FormattingDocumentModelImpl documentModel = FormattingDocumentModelImpl.createOn(element.getContainingFile());
  return new XmlFormattingModel(element.getContainingFile(), createBlock(settings, root, documentModel), documentModel);
}
项目:intellij-ce-playground    文件:HtmlFormattingModelBuilder.java   
@Override
@NotNull
  public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
  final PsiFile psiFile = element.getContainingFile();
  final FormattingDocumentModelImpl documentModel = FormattingDocumentModelImpl.createOn(psiFile);
  return new XmlFormattingModel(psiFile,
                                                         new XmlBlock(SourceTreeToPsiMap.psiElementToTree(psiFile),
                                                                      null, null, new HtmlPolicy(settings, documentModel), null, null, false),
                                                         documentModel);
}
项目:tools-idea    文件:JavaFormattingModelBuilder.java   
@Override
@NotNull
  public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
  final FileElement fileElement = TreeUtil.getFileElement((TreeElement)SourceTreeToPsiMap.psiElementToTree(element));
  LOG.assertTrue(fileElement != null, "File element should not be null for " + element);
  CommonCodeStyleSettings javaSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
  Block block = AbstractJavaBlock.createJavaBlock(fileElement, javaSettings);
  FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile());
  return new PsiBasedFormatterModelWithShiftIndentInside (element.getContainingFile(), block, model);
}
项目:tools-idea    文件:InitialInfoBuilder.java   
public static void assertInvalidRanges(final int startOffset, final int newEndOffset, FormattingDocumentModel model, String message) {
  @NonNls final StringBuilder buffer = new StringBuilder();
  buffer.append("Invalid formatting blocks:").append(message).append("\n");
  buffer.append("Start offset:");
  buffer.append(startOffset);
  buffer.append(" end offset:");
  buffer.append(newEndOffset);
  buffer.append("\n");

  int minOffset = Math.max(Math.min(startOffset, newEndOffset) - 20, 0);
  int maxOffset = Math.min(Math.max(startOffset, newEndOffset) + 20, model.getTextLength());

  buffer.append("Affected text fragment:[").append(minOffset).append(",").append(maxOffset).append("] - '")
    .append(model.getText(new TextRange(minOffset, maxOffset))).append("'\n");

  final StringBuilder messageBuffer =  new StringBuilder();
  messageBuffer.append("Invalid ranges during formatting");
  if (model instanceof FormattingDocumentModelImpl) {
    messageBuffer.append(" in ").append(((FormattingDocumentModelImpl)model).getFile().getLanguage());
  }

  buffer.append("File text:(").append(model.getTextLength()).append(")\n'");
  buffer.append(model.getText(new TextRange(0, model.getTextLength())).toString());
  buffer.append("'\n");
  buffer.append("model (").append(model.getClass()).append("): ").append(model);

  if (model instanceof FormattingDocumentModelImpl) {
    final FormattingDocumentModelImpl modelImpl = (FormattingDocumentModelImpl)model;
    buffer.append("Psi Tree:\n");
    final PsiFile file = modelImpl.getFile();
    final List<PsiFile> roots = file.getViewProvider().getAllFiles();
    for (PsiFile root : roots) {
      buffer.append("Root ");
      DebugUtil.treeToBuffer(buffer, root.getNode(), 0, false, true, true, true);
    }
    buffer.append('\n');
  }

  LogMessageEx.error(LOG, messageBuffer.toString(), buffer.toString());
}
项目:tools-idea    文件:XhtmlFormattingModelBuilder.java   
@NotNull
  public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
  final PsiFile psiFile = element.getContainingFile();
  final FormattingDocumentModelImpl documentModel = FormattingDocumentModelImpl.createOn(psiFile);
  return new XmlFormattingModel(psiFile,
                                                          new XmlBlock(SourceTreeToPsiMap.psiElementToTree(psiFile),
                                                                       null, null,
                                                                       new HtmlPolicy(settings, documentModel), null, null, false),
                                                          documentModel);
}
项目:tools-idea    文件:XmlFormattingModelBuilder.java   
@NotNull
public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
  final ASTNode root = TreeUtil.getFileElement((TreeElement)SourceTreeToPsiMap.psiElementToTree(element));
  final FormattingDocumentModelImpl documentModel = FormattingDocumentModelImpl.createOn(element.getContainingFile());
  return new XmlFormattingModel(element.getContainingFile(),
                                                         new XmlBlock(root, null, null, new XmlPolicy(settings, documentModel), null, null, false),
                                                         documentModel);
}
项目:tools-idea    文件:HtmlFormattingModelBuilder.java   
@NotNull
  public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
  final PsiFile psiFile = element.getContainingFile();
  final FormattingDocumentModelImpl documentModel = FormattingDocumentModelImpl.createOn(psiFile);
  return new XmlFormattingModel(psiFile,
                                                         new XmlBlock(SourceTreeToPsiMap.psiElementToTree(psiFile),
                                                                      null, null, new HtmlPolicy(settings, documentModel), null, null, false),
                                                         documentModel);
}
项目:consulo-csharp    文件:CSharpFormattingModelBuilder.java   
@NotNull
@Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings)
{
    final PsiFile file = element.getContainingFile();
    FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile());
    Block rootBlock = new CSharpFormattingBlock(file.getNode(), null, null, settings);
    return new PsiBasedFormattingModel(file, rootBlock, model);
}
项目:consulo-css    文件:CssFormattingModelBuilder.java   
@NotNull
@Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings codeStyleSettings)
{
    final PsiFile file = element.getContainingFile();
    FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile());
    Block rootBlock = new CssFormattingBlock(element.getNode(), null, null);
    return new PsiBasedFormattingModel(file, rootBlock, model);
}
项目:consulo-xml    文件:XhtmlFormattingModelBuilder.java   
@NotNull
  public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
  final PsiFile psiFile = element.getContainingFile();
  final FormattingDocumentModelImpl documentModel = FormattingDocumentModelImpl.createOn(psiFile);
  return new XmlFormattingModel(psiFile,
                                                          new XmlBlock(SourceTreeToPsiMap.psiElementToTree(psiFile),
                                                                       null, null,
                                                                       new HtmlPolicy(settings, documentModel), null, null, false),
                                                          documentModel);
}
项目:consulo-xml    文件:XmlFormattingModelBuilder.java   
@NotNull
public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
  final ASTNode root = TreeUtil.getFileElement((TreeElement)SourceTreeToPsiMap.psiElementToTree(element));
  final FormattingDocumentModelImpl documentModel = FormattingDocumentModelImpl.createOn(element.getContainingFile());
  return new XmlFormattingModel(element.getContainingFile(),
                                                         new XmlBlock(root, null, null, new XmlPolicy(settings, documentModel), null, null, false),
                                                         documentModel);
}
项目:consulo-xml    文件:HtmlFormattingModelBuilder.java   
@NotNull
  public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
  final PsiFile psiFile = element.getContainingFile();
  final FormattingDocumentModelImpl documentModel = FormattingDocumentModelImpl.createOn(psiFile);
  return new XmlFormattingModel(psiFile,
                                                         new XmlBlock(SourceTreeToPsiMap.psiElementToTree(psiFile),
                                                                      null, null, new HtmlPolicy(settings, documentModel), null, null, false),
                                                         documentModel);
}
项目:consulo-java    文件:JavaFormattingModelBuilder.java   
@Override
@NotNull
@RequiredReadAction
public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings)
{
    final FileElement fileElement = TreeUtil.getFileElement((TreeElement) SourceTreeToPsiMap.psiElementToTree(element));
    LOG.assertTrue(fileElement != null, "File element should not be null for " + element);
    CommonCodeStyleSettings commonSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
    JavaCodeStyleSettings customJavaSettings = settings.getCustomSettings(JavaCodeStyleSettings.class);
    Block block = AbstractJavaBlock.newJavaBlock(fileElement, commonSettings, customJavaSettings);
    FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile());
    return new PsiBasedFormatterModelWithShiftIndentInside(element.getContainingFile(), block, model);
}
项目:consulo-java    文件:PsiBasedFormatterModelWithShiftIndentInside.java   
public PsiBasedFormatterModelWithShiftIndentInside(final PsiFile file,
        @NotNull final Block rootBlock,
        final FormattingDocumentModelImpl documentModel)
{
    super(file, rootBlock, documentModel);
    myProject = file.getProject();
}
项目:AppleScript-IDEA    文件:AppleScriptFormattingModelBuilder.java   
AppleScriptFormattingModel(PsiFile file, @NotNull Block rootBlock, FormattingDocumentModelImpl documentModel) {
  super(file, rootBlock, documentModel);
}
项目:intellij-ce-playground    文件:ImportsFormatter.java   
public ImportsFormatter(@NotNull CodeStyleSettings settings, @NotNull PsiFile file) {
  myPostProcessor = new PostFormatProcessorHelper(settings);
  myDocumentModel = FormattingDocumentModelImpl.createOn(file);
  myIndentOptions = settings.getIndentOptionsByFile(file);
}
项目:intellij-ce-playground    文件:PsiBasedFormatterModelWithShiftIndentInside.java   
public PsiBasedFormatterModelWithShiftIndentInside(final PsiFile file,
                                                   @NotNull final Block rootBlock,
                                                   final FormattingDocumentModelImpl documentModel) {
  super(file, rootBlock, documentModel);
  myProject = file.getProject();
}
项目:intellij-ce-playground    文件:FormatterImpl.java   
@Override
public FormattingModel createFormattingModelForPsiFile(final PsiFile file,
                                                       @NotNull final Block rootBlock,
                                                       final CodeStyleSettings settings) {
  return new PsiBasedFormattingModel(file, rootBlock, FormattingDocumentModelImpl.createOn(file));
}
项目:intellij-ce-playground    文件:InitialInfoBuilder.java   
public static void assertInvalidRanges(final int startOffset, final int newEndOffset, FormattingDocumentModel model, String message) {
  @NonNls final StringBuilder buffer = new StringBuilder();
  buffer.append("Invalid formatting blocks:").append(message).append("\n");
  buffer.append("Start offset:");
  buffer.append(startOffset);
  buffer.append(" end offset:");
  buffer.append(newEndOffset);
  buffer.append("\n");

  int minOffset = Math.max(Math.min(startOffset, newEndOffset) - 20, 0);
  int maxOffset = Math.min(Math.max(startOffset, newEndOffset) + 20, model.getTextLength());

  buffer.append("Affected text fragment:[").append(minOffset).append(",").append(maxOffset).append("] - '")
    .append(model.getText(new TextRange(minOffset, maxOffset))).append("'\n");

  final StringBuilder messageBuffer =  new StringBuilder();
  messageBuffer.append("Invalid ranges during formatting");
  if (model instanceof FormattingDocumentModelImpl) {
    messageBuffer.append(" in ").append(((FormattingDocumentModelImpl)model).getFile().getLanguage());
  }

  buffer.append("File text:(").append(model.getTextLength()).append(")\n'");
  buffer.append(model.getText(new TextRange(0, model.getTextLength())).toString());
  buffer.append("'\n");
  buffer.append("model (").append(model.getClass()).append("): ").append(model);

  Throwable currentThrowable = new Throwable();
  if (model instanceof FormattingDocumentModelImpl) {
    final FormattingDocumentModelImpl modelImpl = (FormattingDocumentModelImpl)model;
    buffer.append("Psi Tree:\n");
    final PsiFile file = modelImpl.getFile();
    final List<PsiFile> roots = file.getViewProvider().getAllFiles();
    for (PsiFile root : roots) {
      buffer.append("Root ");
      DebugUtil.treeToBuffer(buffer, root.getNode(), 0, false, true, true, true);
    }
    buffer.append('\n');
    currentThrowable = makeLanguageStackTrace(currentThrowable, file);
  }

  LogMessageEx.error(LOG, messageBuffer.toString(), currentThrowable, buffer.toString());
}
项目:intellij-ce-playground    文件:XmlFormattingModelBuilder.java   
protected XmlBlock createBlock(CodeStyleSettings settings, ASTNode root, FormattingDocumentModelImpl documentModel) {
  return new XmlBlock(root, null, null, new XmlPolicy(settings, documentModel), null, null, false);
}
项目:intellij-ce-playground    文件:XmlFormattingModel.java   
public XmlFormattingModel(final PsiFile file,
                                                   final Block rootBlock,
                                                   final FormattingDocumentModelImpl documentModel) {
  super(file, rootBlock, documentModel);
  myProject = file.getProject();
}
项目:intellij-ce-playground    文件:GroovyFormattingModelBuilder.java   
GroovyFormattingModel(PsiFile file, @NotNull Block rootBlock, FormattingDocumentModelImpl documentModel) {
  super(file, rootBlock, documentModel);
}
项目:tools-idea    文件:ImportsFormatter.java   
public ImportsFormatter(@NotNull CodeStyleSettings settings, @NotNull PsiFile file) {
  myPostProcessor = new PostFormatProcessorHelper(settings);
  myDocumentModel = FormattingDocumentModelImpl.createOn(file);
  myIndentOptions = settings.getIndentOptions(file.getFileType());
}
项目:tools-idea    文件:PsiBasedFormatterModelWithShiftIndentInside.java   
public PsiBasedFormatterModelWithShiftIndentInside(final PsiFile file,
                                                   @NotNull final Block rootBlock,
                                                   final FormattingDocumentModelImpl documentModel) {
  super(file, rootBlock, documentModel);
  myProject = file.getProject();
}
项目:tools-idea    文件:FormatterImpl.java   
@Override
public FormattingModel createFormattingModelForPsiFile(final PsiFile file,
                                                       @NotNull final Block rootBlock,
                                                       final CodeStyleSettings settings) {
  return new PsiBasedFormattingModel(file, rootBlock, FormattingDocumentModelImpl.createOn(file));
}
项目:tools-idea    文件:XmlFormattingModel.java   
public XmlFormattingModel(final PsiFile file,
                                                   final Block rootBlock,
                                                   final FormattingDocumentModelImpl documentModel) {
  super(file, rootBlock, documentModel);
  myProject = file.getProject();
}
项目:tools-idea    文件:GroovyFormattingModelBuilder.java   
GroovyFormattingModel(PsiFile file, @NotNull Block rootBlock, FormattingDocumentModelImpl documentModel) {
  super(file, rootBlock, documentModel);
}
项目:consulo    文件:FormatterImpl.java   
@Override
public FormattingModel createFormattingModelForPsiFile(final PsiFile file,
                                                       @Nonnull final Block rootBlock,
                                                       final CodeStyleSettings settings) {
  return new PsiBasedFormattingModel(file, rootBlock, FormattingDocumentModelImpl.createOn(file));
}
项目:consulo    文件:RangesAssert.java   
public void assertInvalidRanges(final int startOffset, final int newEndOffset, FormattingDocumentModel model, String message) {
  final StringBuilder buffer = new StringBuilder();
  buffer.append("Invalid formatting blocks:").append(message).append("\n");
  buffer.append("Start offset:");
  buffer.append(startOffset);
  buffer.append(" end offset:");
  buffer.append(newEndOffset);
  buffer.append("\n");

  int minOffset = Math.max(Math.min(startOffset, newEndOffset) - 20, 0);
  int maxOffset = Math.min(Math.max(startOffset, newEndOffset) + 20, model.getTextLength());

  buffer.append("Affected text fragment:[").append(minOffset).append(",").append(maxOffset).append("] - '")
          .append(model.getText(new TextRange(minOffset, maxOffset))).append("'\n");

  final StringBuilder messageBuffer =  new StringBuilder();
  messageBuffer.append("Invalid ranges during formatting");
  if (model instanceof FormattingDocumentModelImpl) {
    messageBuffer.append(" in ").append(((FormattingDocumentModelImpl)model).getFile().getLanguage());
  }

  buffer.append("File text:(").append(model.getTextLength()).append(")\n'");
  buffer.append(model.getText(new TextRange(0, model.getTextLength())).toString());
  buffer.append("'\n");
  buffer.append("model (").append(model.getClass()).append("): ").append(model);

  Throwable currentThrowable = new Throwable();
  if (model instanceof FormattingDocumentModelImpl) {
    final FormattingDocumentModelImpl modelImpl = (FormattingDocumentModelImpl)model;
    buffer.append("Psi Tree:\n");
    final PsiFile file = modelImpl.getFile();
    final List<PsiFile> roots = file.getViewProvider().getAllFiles();
    for (PsiFile root : roots) {
      buffer.append("Root ");
      DebugUtil.treeToBuffer(buffer, root.getNode(), 0, false, true, true, true);
    }
    buffer.append('\n');
    currentThrowable = makeLanguageStackTrace(currentThrowable, file);
  }

  LogMessageEx.error(LOG, messageBuffer.toString(), currentThrowable, buffer.toString());
}
项目:consulo-xml    文件:XmlFormattingModel.java   
public XmlFormattingModel(final PsiFile file,
                                                   final Block rootBlock,
                                                   final FormattingDocumentModelImpl documentModel) {
  super(file, rootBlock, documentModel);
  myProject = file.getProject();
}
项目:consulo-java    文件:ImportsFormatter.java   
public ImportsFormatter(@NotNull CodeStyleSettings settings, @NotNull PsiFile file) {
  myPostProcessor = new PostFormatProcessorHelper(settings);
  myDocumentModel = FormattingDocumentModelImpl.createOn(file);
  myIndentOptions = settings.getIndentOptions(file.getFileType());
}
项目:intellij-ce-playground    文件:WhiteSpace.java   
/**
 * Allows to check if <code>'myInitial'</code> property value stands for continuous white space text.
 * <p/>
 * The text is considered to be continuous <code>'white space'</code> at following cases:
 * <ul>
 *   <li><code>'myInitial'</code> is empty string or string that contains white spaces only;</li>
 *   <li><code>'myInitial'</code> is a <code>CDATA</code> string which content is empty or consists from white spaces only;</li>
 *   <li><code>'myInitial'</code> string belongs to the same {@link PsiWhiteSpace} element;</li>
 * </ul>
 *
 * @param model     formatting model that is used to provide access to the <code>PSI API</code> if necessary
 * @return          <code>true</code> if <code>'myInitial'</code> property value stands for white space;
 *                  <code>false</code> otherwise
 */
private boolean coveredByBlock(final FormattingDocumentModel model) {
  if (myInitial == null) return true;
  if (model.containsWhiteSpaceSymbolsOnly(myStart, myEnd)) return true;

  if (!(model instanceof FormattingDocumentModelImpl)) return false;
  PsiFile psiFile = ((FormattingDocumentModelImpl)model).getFile();
  if (psiFile == null) return false;
  PsiElement start = psiFile.findElementAt(myStart);
  PsiElement end = psiFile.findElementAt(myEnd-1);
  return start == end && start instanceof PsiWhiteSpace; // there maybe non-white text inside CDATA-encoded injected elements
}
项目:tools-idea    文件:WhiteSpace.java   
/**
 * Allows to check if <code>'myInitial'</code> property value stands for continuous white space text.
 * <p/>
 * The text is considered to be continuous <code>'white space'</code> at following cases:
 * <ul>
 *   <li><code>'myInitial'</code> is empty string or string that contains white spaces only;</li>
 *   <li><code>'myInitial'</code> is a <code>CDATA</code> string which content is empty or consists from white spaces only;</li>
 *   <li><code>'myInitial'</code> string belongs to the same {@link PsiWhiteSpace} element;</li>
 * </ul>
 *
 * @param model     formatting model that is used to provide access to the <code>PSI API</code> if necessary
 * @return          <code>true</code> if <code>'myInitial'</code> property value stands for white space;
 *                  <code>false</code> otherwise
 */
private boolean coveredByBlock(final FormattingDocumentModel model) {
  if (myInitial == null) return true;
  if (model.containsWhiteSpaceSymbolsOnly(myStart, myEnd)) return true;

  if (!(model instanceof FormattingDocumentModelImpl)) return false;
  PsiFile psiFile = ((FormattingDocumentModelImpl)model).getFile();
  if (psiFile == null) return false;
  PsiElement start = psiFile.findElementAt(myStart);
  PsiElement end = psiFile.findElementAt(myEnd-1);
  return start == end && start instanceof PsiWhiteSpace; // there maybe non-white text inside CDATA-encoded injected elements
}
项目:consulo    文件:WhiteSpace.java   
/**
 * Allows to check if {@code 'myInitial'} property value stands for continuous white space text.
 * <p/>
 * The text is considered to be continuous {@code 'white space'} at following cases:
 * <ul>
 *   <li>{@code 'myInitial'} is empty string or string that contains white spaces only;</li>
 *   <li>{@code 'myInitial'} is a {@code CDATA} string which content is empty or consists from white spaces only;</li>
 *   <li>{@code 'myInitial'} string belongs to the same {@link PsiWhiteSpace} element;</li>
 * </ul>
 *
 * @param model     formatting model that is used to provide access to the {@code PSI API} if necessary
 * @return          {@code true} if {@code 'myInitial'} property value stands for white space;
 *                  {@code false} otherwise
 */
private boolean coveredByBlock(final FormattingDocumentModel model) {
  if (myInitial == null) return true;
  if (model.containsWhiteSpaceSymbolsOnly(myStart, myEnd)) return true;

  if (!(model instanceof FormattingDocumentModelImpl)) return false;
  PsiFile psiFile = ((FormattingDocumentModelImpl)model).getFile();
  if (psiFile == null) return false;
  PsiElement start = psiFile.findElementAt(myStart);
  PsiElement end = psiFile.findElementAt(myEnd-1);
  return start == end && start instanceof PsiWhiteSpace; // there maybe non-white text inside CDATA-encoded injected elements
}