本文整理汇总了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
);
}
示例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);
}
}
示例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));
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
}
示例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);
}
示例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();
}
示例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);
}