Java 类com.intellij.psi.formatter.xml.XmlBlock 实例源码

项目:intellij-ce-playground    文件:AndroidXmlFormattingModelBuilder.java   
private static Block createDelegatingBlock(FormattingModel model,
                                   AndroidXmlCodeStyleSettings.MySettings customSettings,
                                   CodeStyleSettings settings) {
  final Block block = model.getRootBlock();

  if (block instanceof XmlBlock) {
    final XmlBlock b = (XmlBlock)block;
    final XmlPolicy policy = customSettings.createXmlPolicy(settings, model.getDocumentModel());
    return new XmlBlock(b.getNode(), b.getWrap(), b.getAlignment(), policy, b.getIndent(), b.getTextRange()) {
      @Override
      protected XmlTagBlock createTagBlock(ASTNode child, Indent indent, Wrap wrap, Alignment alignment) {
        return new XmlTagBlock(child, wrap, alignment, myXmlFormattingPolicy,
                               indent != null ? indent : Indent.getNoneIndent(),
                               isPreserveSpace());
      }
    };
  }
  else {
    return block;
  }
}
项目: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    文件: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);
}
项目:intellij-ce-playground    文件:XsltFormattingModelBuilder.java   
static Block getDelegatingBlock(final CodeStyleSettings settings, FormattingModel baseModel) {
  final Block block = baseModel.getRootBlock();
  if (block instanceof XmlBlock) {
    final XmlBlock xmlBlock = (XmlBlock)block;

    final XmlPolicy xmlPolicy = new XmlPolicy(settings, baseModel.getDocumentModel()) {
      @Override
      public boolean keepWhiteSpacesInsideTag(XmlTag xmlTag) {
        return super.keepWhiteSpacesInsideTag(xmlTag) || isXslTextTag(xmlTag);
      }

      @Override
      public boolean isTextElement(XmlTag tag) {
        return super.isTextElement(tag) || isXslTextTag(tag) || isXslValueOfTag(tag);
      }
    };

    final ASTNode node = xmlBlock.getNode();
    final Wrap wrap = xmlBlock.getWrap();
    final Alignment alignment = xmlBlock.getAlignment();
    final Indent indent = xmlBlock.getIndent();
    final TextRange textRange = xmlBlock.getTextRange();

    return new XmlBlock(node, wrap, alignment, xmlPolicy, indent, textRange);
  } else {
    return block;
  }
}
项目: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);
}
项目:tools-idea    文件:XslTextFormattingModel.java   
public XslTextFormattingModel(FormattingModel model, CodeStyleSettings settings) {
    myModel = model;

    final Block block = myModel.getRootBlock();
    if (block instanceof XmlBlock) {
        final XmlBlock xmlBlock = (XmlBlock)block;

        final XmlPolicy xmlPolicy = new XmlPolicy(settings, getDocumentModel()) {
            @Override
            public boolean keepWhiteSpacesInsideTag(XmlTag xmlTag) {
                return super.keepWhiteSpacesInsideTag(xmlTag) || isXslTextTag(xmlTag);
            }

            @Override
            public boolean isTextElement(XmlTag tag) {
                return super.isTextElement(tag) || isXslTextTag(tag) || isXslValueOfTag(tag);
            }
        };

        final ASTNode node = xmlBlock.getNode();
        final Wrap wrap = xmlBlock.getWrap();
        final Alignment alignment = xmlBlock.getAlignment();
        final Indent indent = xmlBlock.getIndent();
        final TextRange textRange = xmlBlock.getTextRange();

        myRootBlock = new XmlBlock(node, wrap, alignment, xmlPolicy, indent, textRange);
    } else {
        myRootBlock = block;
    }
}
项目:consulo-xslt    文件:XslTextFormattingModel.java   
public XslTextFormattingModel(FormattingModel model, CodeStyleSettings settings) {
    myModel = model;

    final Block block = myModel.getRootBlock();
    if (block instanceof XmlBlock) {
        final XmlBlock xmlBlock = (XmlBlock)block;

        final XmlPolicy xmlPolicy = new XmlPolicy(settings, getDocumentModel()) {
            @Override
            public boolean keepWhiteSpacesInsideTag(XmlTag xmlTag) {
                return super.keepWhiteSpacesInsideTag(xmlTag) || isXslTextTag(xmlTag);
            }

            @Override
            public boolean isTextElement(XmlTag tag) {
                return super.isTextElement(tag) || isXslTextTag(tag) || isXslValueOfTag(tag);
            }
        };

        final ASTNode node = xmlBlock.getNode();
        final Wrap wrap = xmlBlock.getWrap();
        final Alignment alignment = xmlBlock.getAlignment();
        final Indent indent = xmlBlock.getIndent();
        final TextRange textRange = xmlBlock.getTextRange();

        myRootBlock = new XmlBlock(node, wrap, alignment, xmlPolicy, indent, textRange);
    } else {
        myRootBlock = block;
    }
}
项目: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);
}
项目: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);
}