本文整理汇总了Java中com.intellij.psi.impl.source.tree.TreeUtil.getFileElement方法的典型用法代码示例。如果您正苦于以下问题:Java TreeUtil.getFileElement方法的具体用法?Java TreeUtil.getFileElement怎么用?Java TreeUtil.getFileElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.impl.source.tree.TreeUtil
的用法示例。
在下文中一共展示了TreeUtil.getFileElement方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getContainingFileByTree
import com.intellij.psi.impl.source.tree.TreeUtil; //导入方法依赖的package包/类
@Nullable
private static PsiFile getContainingFileByTree(@NotNull final PsiElement changeScope) {
// there could be pseudo physical trees (JSPX/JSP/etc.) which must not translate
// any changes to document and not to fire any PSI events
final PsiFile psiFile;
final ASTNode node = changeScope.getNode();
if (node == null) {
psiFile = changeScope.getContainingFile();
}
else {
final FileElement fileElement = TreeUtil.getFileElement((TreeElement)node);
// assert fileElement != null : "Can't find file element for node: " + node;
// Hack. the containing tree can be invalidated if updating supplementary trees like HTML in JSP.
if (fileElement == null) return null;
psiFile = (PsiFile)fileElement.getPsi();
}
return psiFile.getNode() != null ? psiFile : null;
}
示例2: getContainingFileByTree
import com.intellij.psi.impl.source.tree.TreeUtil; //导入方法依赖的package包/类
@Nullable
private static PsiFile getContainingFileByTree(@Nonnull final PsiElement changeScope) {
// there could be pseudo physical trees (JSPX/JSP/etc.) which must not translate
// any changes to document and not to fire any PSI events
final PsiFile psiFile;
final ASTNode node = changeScope.getNode();
if (node == null) {
psiFile = changeScope.getContainingFile();
}
else {
final FileElement fileElement = TreeUtil.getFileElement((TreeElement)node);
// assert fileElement != null : "Can't find file element for node: " + node;
// Hack. the containing tree can be invalidated if updating supplementary trees like HTML in JSP.
if (fileElement == null) return null;
psiFile = (PsiFile)fileElement.getPsi();
}
return psiFile.getNode() != null ? psiFile : null;
}
示例3: createModel
import com.intellij.psi.impl.source.tree.TreeUtil; //导入方法依赖的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);
}
示例4: createModel
import com.intellij.psi.impl.source.tree.TreeUtil; //导入方法依赖的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);
}
示例5: findChildAfter
import com.intellij.psi.impl.source.tree.TreeUtil; //导入方法依赖的package包/类
@Nullable
protected static ASTNode findChildAfter(@NotNull final ASTNode child, final int endOffset) {
TreeElement fileNode = TreeUtil.getFileElement((TreeElement)child);
final LeafElement leaf = fileNode.findLeafElementAt(endOffset);
if (leaf != null && leaf.getStartOffset() == endOffset && endOffset > 0) {
return fileNode.findLeafElementAt(endOffset - 1);
}
return leaf;
}
示例6: createModel
import com.intellij.psi.impl.source.tree.TreeUtil; //导入方法依赖的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 javaSettings = settings.getCommonSettings(JavaLanguage.INSTANCE);
Block block = AbstractJavaBlock.createJavaBlock(fileElement, javaSettings);
FormattingDocumentModelImpl model = FormattingDocumentModelImpl.createOn(element.getContainingFile());
return new PsiBasedFormatterModelWithShiftIndentInside (element.getContainingFile(), block, model);
}
示例7: createModel
import com.intellij.psi.impl.source.tree.TreeUtil; //导入方法依赖的package包/类
@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);
}
示例8: createModel
import com.intellij.psi.impl.source.tree.TreeUtil; //导入方法依赖的package包/类
@Override
@NotNull
@RequiredReadAction
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);
}