• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FormattingModel类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.formatting.FormattingModel的典型用法代码示例。如果您正苦于以下问题:Java FormattingModel类的具体用法?Java FormattingModel怎么用?Java FormattingModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



FormattingModel类属于com.intellij.formatting包,在下文中一共展示了FormattingModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {

    final Block impexBlock = new ImpexBlock(
        element.getNode(),
        null,
        Alignment.createAlignment(),
        createSpaceBuilder(settings)
    );

    return FormattingModelProvider.createFormattingModelForPsiFile(
        element.getContainingFile(),
        impexBlock,
        settings
    );
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:18,代码来源:ImpexFormattingModelBuilder.java


示例2: createModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
    ASTNode root = CsvFormatHelper.getRoot(element.getNode());
    CsvFormattingInfo formattingInfo = new CsvFormattingInfo(
            settings,
            CsvFormatHelper.createSpaceBuilder(settings),
            CsvFormatHelper.createColumnInfoMap(root, settings)
    );

    return FormattingModelProvider.createFormattingModelForPsiFile(
            element.getContainingFile(),
            new CsvBlock(root, formattingInfo),
            settings
    );
}
 
开发者ID:SeeSharpSoft,项目名称:intellij-csv-validator,代码行数:17,代码来源:CsvFormattingModelBuilder.java


示例3: doTestLineToIndentMapping

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
private static void doTestLineToIndentMapping(@NotNull String text, int... spacesForLine) {
  configureFromFileText("x.java", text);
  Document document = PsiDocumentManager.getInstance(getProject()).getDocument(myFile);
  FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forContext(myFile);
  
  Assert.assertNotNull(document);
  Assert.assertNotNull(builder);
  
  FormattingModel model = builder.createModel(myFile, CodeStyleSettingsManager.getSettings(getProject()));
  Block block = model.getRootBlock();
  List<LineIndentInfo> list = new FormatterBasedLineIndentInfoBuilder(document, block).build();
  
  Assert.assertEquals(list.size(), spacesForLine.length);
  for (int i = 0; i < spacesForLine.length; i++) {
    int indentSize = list.get(i).getIndentSize();
    Assert.assertEquals("Mismatch on line " + i, spacesForLine[i], indentSize);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JavaAutoDetectIndentTest.java


示例4: createModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
  PsiFile containingFile = element.getContainingFile().getViewProvider().getPsi(AppleScriptLanguage.INSTANCE);
  assert containingFile != null : element.getContainingFile();
  ASTNode astNode = containingFile.getNode();
  assert astNode != null;
  CommonCodeStyleSettings appleScriptSettings = settings.getCommonSettings(AppleScriptLanguage.INSTANCE);
  final AppleScriptBlock rootBlock = new AppleScriptBlock(astNode, null, null, settings);
  return new AppleScriptFormattingModel(containingFile, rootBlock, FormattingDocumentModelImpl.createOn(containingFile));
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:12,代码来源:AppleScriptFormattingModelBuilder.java


示例5: createModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@NotNull
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
  final PsiFile file = element.getContainingFile();

  if (element.getNode().getElementType() == SoyTypes.OTHER) {
    return new SimpleTemplateLanguageFormattingModelBuilder().createModel(element, settings);
  } else {
    return new DocumentBasedFormattingModel(
        getRootBlock(file, file.getViewProvider(), settings),
        element.getProject(),
        settings,
        file.getFileType(),
        file);
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:16,代码来源:SoyFormattingModelBuilder.java


示例6: createModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(
    final PsiElement element, final CodeStyleSettings settings
) {
    final Block block = new FlexibleSearchBlock(
        element.getNode(),
        null,
        Alignment.createAlignment(),
        createSpaceBuilder(settings)
    );

    return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(), block, settings);
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:15,代码来源:FlexibleSearchFormattingModelBuilder.java


示例7: createModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
    PsiFile containingFile = element.getContainingFile().getViewProvider().getPsi(ProtoLanguage.INSTANCE);
    ASTNode fileNode = containingFile.getNode();
    Wrap wrap = Wrap.createWrap(WrapType.NONE, false);
    Alignment alignment = Alignment.createAlignment();
    ProtoFileBlock block = new ProtoFileBlock(fileNode, wrap, alignment, settings);
    return FormattingModelProvider.createFormattingModelForPsiFile(containingFile, block, settings);
}
 
开发者ID:protostuff,项目名称:protobuf-jetbrains-plugin,代码行数:11,代码来源:FormattingModelBuilder.java


示例8: createModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {

    final com.amazon.ion.plugin.intellij.formatting.IonBlock rootBlock = new com.amazon.ion.plugin.intellij.formatting.IonBlock(element.getNode(),
            Wrap.createWrap(WrapType.NONE, false),
            Alignment.createAlignment(true),
            createSpaceBuilder(settings), settings);

    return FormattingModelProvider.createFormattingModelForPsiFile(
            element.getContainingFile(),
            rootBlock, settings);
}
 
开发者ID:amzn,项目名称:ion-intellij-plugin,代码行数:14,代码来源:IonFormattingModelBuilder.java


示例9: createModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:JavaFormattingModelBuilder.java


示例10: getMaxUsedIndentInfo

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@NotNull
private IndentUsageInfo getMaxUsedIndentInfo() {
  configureByFile(getFileNameWithExtension());
  Document document = getDocument(myFile);

  FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forContext(myFile);
  Assert.assertNotNull(builder);
  
  FormattingModel model = builder.createModel(myFile, CodeStyleSettingsManager.getSettings(getProject()));
  List<LineIndentInfo> lines = new FormatterBasedLineIndentInfoBuilder(document, model.getRootBlock()).build();
  
  IndentUsageStatistics statistics = new IndentUsageStatisticsImpl(lines);
  return statistics.getKMostUsedIndentInfo(0);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:AbstractIndentAutoDetectionTest.java


示例11: getSpacing

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
private static String getSpacing(PsiFile file, int offset) {
  FormattingModelBuilder builder = LanguageFormatting.INSTANCE.forContext(file);
  if (builder == null) {
    return "";
  }
  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(file.getProject());
  FormattingModel model = builder.createModel(file, settings);
  int spacing = FormatterEx.getInstance().getSpacingForBlockAtOffset(model, offset);
  return StringUtil.repeatSymbol(' ', spacing);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:SmartIndentingBackspaceHandler.java


示例12: buildBlocks

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@Nullable
private static Block buildBlocks(@NotNull PsiElement rootElement) {
  FormattingModelBuilder formattingModelBuilder = LanguageFormatting.INSTANCE.forContext(rootElement);
  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(rootElement.getProject());
  if (formattingModelBuilder != null) {
    FormattingModel formattingModel = formattingModelBuilder.createModel(rootElement, settings);
    return formattingModel.getRootBlock();
  }
  else {
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:PsiViewerDialog.java


示例13: DocumentBasedFormattingModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
public DocumentBasedFormattingModel(@NotNull final FormattingModel originalModel,
                                    @NotNull final Document document,
                                    final Project project,
                                    final CodeStyleSettings settings,
                                    final FileType fileType,
                                    final PsiFile file) {
  myOriginalFormattingModel = originalModel;
  myRootBlock = originalModel.getRootBlock();
  myDocument = document;
  myProject = project;
  mySettings = settings;
  myFileType = fileType;
  myFile = file;
  myDocumentModel = new FormattingDocumentModelImpl(document,file);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:DocumentBasedFormattingModel.java


示例14: calcLineIndentInfo

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
private List<LineIndentInfo> calcLineIndentInfo() {
  if (myDocument == null) return null;
  CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(myProject);
  FormattingModelBuilder modelBuilder = LanguageFormatting.INSTANCE.forContext(myFile);
  if (modelBuilder == null) return null;
  
  FormattingModel model = modelBuilder.createModel(myFile, settings);
  Block rootBlock = model.getRootBlock();
  return new FormatterBasedLineIndentInfoBuilder(myDocument, rootBlock).build();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:IndentOptionsDetectorImpl.java


示例15: createModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:XhtmlFormattingModelBuilder.java


示例16: createModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:XmlFormattingModelBuilder.java


示例17: createModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:HtmlFormattingModelBuilder.java


示例18: createModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@Override
@NotNull
public FormattingModel createModel(final PsiElement element, final CodeStyleSettings settings) {
  ASTNode node = element.getNode();
  assert node != null;
  PsiFile containingFile = element.getContainingFile().getViewProvider().getPsi(GroovyLanguage.INSTANCE);
  assert containingFile != null : element.getContainingFile();
  ASTNode astNode = containingFile.getNode();
  assert astNode != null;
  CommonCodeStyleSettings groovySettings = settings.getCommonSettings(GroovyLanguage.INSTANCE);
  GroovyCodeStyleSettings customSettings = settings.getCustomSettings(GroovyCodeStyleSettings.class);

  final AlignmentProvider alignments = new AlignmentProvider();
  if (customSettings.USE_FLYING_GEESE_BRACES) {
    element.accept(new PsiRecursiveElementVisitor() {
      @Override
      public void visitElement(PsiElement element) {
        if (GeeseUtil.isClosureRBrace(element)) {
          GeeseUtil.calculateRBraceAlignment(element, alignments);
        }
        else {
          super.visitElement(element);
        }
      }
    });
  }
  final GroovyBlock block = new GroovyBlock(astNode, Indent.getAbsoluteNoneIndent(), null, new FormattingContext(groovySettings, alignments, customSettings, false));
  return new GroovyFormattingModel(containingFile, block, FormattingDocumentModelImpl.createOn(containingFile));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:GroovyFormattingModelBuilder.java


示例19: createModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(PsiElement element, CodeStyleSettings settings) {
    return FormattingModelProvider.createFormattingModelForPsiFile(element.getContainingFile(),
            new CndBlock(element.getNode(), Wrap.createWrap(WrapType.ALWAYS, false),
                    Alignment.createAlignment(), createSpaceBuilder(settings)), settings);
}
 
开发者ID:Tolc,项目名称:IntelliJ_Jahia_plugin,代码行数:8,代码来源:CndFormattingModelBuilder.java


示例20: createModel

import com.intellij.formatting.FormattingModel; //导入依赖的package包/类
@NotNull
@Override
public FormattingModel createModel(@NotNull final PsiElement element, @NotNull final CodeStyleSettings settings) {
    final PsiFile psiFile = element.getContainingFile();
    final ASTNode rootNode = psiFile instanceof SquirrelFile ? psiFile.getNode() : element.getNode();
    final SquirrelBlock rootBlock = new SquirrelBlock(rootNode, null, null, settings);
    return new DocumentBasedFormattingModel(rootBlock, element.getProject(), settings, psiFile.getFileType(), psiFile);
}
 
开发者ID:shvetsgroup,项目名称:squirrel-lang-idea-plugin,代码行数:9,代码来源:SquirrelFormattingModelBuilder.java



注:本文中的com.intellij.formatting.FormattingModel类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BroadcastTree类代码示例发布时间:2022-05-21
下一篇:
Java Quad类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap