当前位置: 首页>>代码示例>>Java>>正文


Java FormattingModel类代码示例

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


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


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