本文整理汇总了Java中com.intellij.formatting.FormattingModel.getRootBlock方法的典型用法代码示例。如果您正苦于以下问题:Java FormattingModel.getRootBlock方法的具体用法?Java FormattingModel.getRootBlock怎么用?Java FormattingModel.getRootBlock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.formatting.FormattingModel
的用法示例。
在下文中一共展示了FormattingModel.getRootBlock方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: 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;
}
}
示例3: 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);
}
示例4: 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();
}
示例5: buildBlocks
import com.intellij.formatting.FormattingModel; //导入方法依赖的package包/类
@Nullable
private static Block buildBlocks(@Nonnull 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;
}
}
示例6: DocumentBasedFormattingModel
import com.intellij.formatting.FormattingModel; //导入方法依赖的package包/类
public DocumentBasedFormattingModel(@Nonnull final FormattingModel originalModel,
@Nonnull 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);
}
示例7: 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();
}