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


Java TreeUtil.getFileElement方法代码示例

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PomModelImpl.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:20,代码来源:PomModelImpl.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:JavaFormattingModelBuilder.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:XmlFormattingModelBuilder.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:AbstractXmlBlock.java

示例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);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:11,代码来源:JavaFormattingModelBuilder.java

示例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);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:9,代码来源:XmlFormattingModelBuilder.java

示例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);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:14,代码来源:JavaFormattingModelBuilder.java


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