本文整理汇总了Java中com.intellij.psi.impl.source.tree.TreeUtil.ensureParsed方法的典型用法代码示例。如果您正苦于以下问题:Java TreeUtil.ensureParsed方法的具体用法?Java TreeUtil.ensureParsed怎么用?Java TreeUtil.ensureParsed使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.impl.source.tree.TreeUtil
的用法示例。
在下文中一共展示了TreeUtil.ensureParsed方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: suggestKeywords
import com.intellij.psi.impl.source.tree.TreeUtil; //导入方法依赖的package包/类
private static Collection<String> suggestKeywords(PsiElement position) {
TextRange posRange = position.getTextRange();
CupFile posFile = (CupFile) position.getContainingFile();
TextRange range = new TextRange(0, posRange.getStartOffset());
String text = range.isEmpty() ? CompletionInitializationContext.DUMMY_IDENTIFIER : range.substring(posFile.getText());
int completionOffset = posRange.getStartOffset() - range.getStartOffset(); // = posRange.getStartOffset() ...
PsiFile file = PsiFileFactory.getInstance(posFile.getProject()).createFileFromText("a.cup", CupLanguage.INSTANCE, text, true, false);
GeneratedParserUtilBase.CompletionState state = new GeneratedParserUtilBase.CompletionState(completionOffset) {
@Nullable
@Override
public String convertItem(Object o) {
if (o == CupTypes.IDENTIFIER) {
return null;
}
return o.toString();
}
};
file.putUserData(GeneratedParserUtilBase.COMPLETION_STATE_KEY, state);
TreeUtil.ensureParsed(file.getNode());
return state.items;
}
示例2: suggestKeywords
import com.intellij.psi.impl.source.tree.TreeUtil; //导入方法依赖的package包/类
private Collection<String> suggestKeywords(@NotNull PsiElement position)
{
PsiFile psiFile = position.getContainingFile();
PsiElement topLevelElement = position;
while(!(topLevelElement.getParent() instanceof PsiFile))
{
topLevelElement = topLevelElement.getParent();
}
PsiFile file = PsiFileFactory.getInstance(psiFile.getProject()).createFileFromText("a.thrift", ThriftLanguage.INSTANCE, topLevelElement.getText(), true, false);
GeneratedParserUtilBase.CompletionState state = new GeneratedParserUtilBase.CompletionState(position.getTextOffset() - topLevelElement.getTextOffset());
file.putUserData(GeneratedParserUtilBase.COMPLETION_STATE_KEY, state);
TreeUtil.ensureParsed(file.getNode());
return state.items;
}
示例3: suggestKeywords
import com.intellij.psi.impl.source.tree.TreeUtil; //导入方法依赖的package包/类
private Collection<String> suggestKeywords(@NotNull PsiElement position) {
PsiFile psiFile = position.getContainingFile();
PsiElement topLevelElement = position;
while (!(topLevelElement.getParent() instanceof PsiFile)) {
topLevelElement = topLevelElement.getParent();
}
PsiFile file = PsiFileFactory.getInstance(psiFile.getProject())
.createFileFromText("a.thrift", ThriftLanguage.INSTANCE, topLevelElement.getText(), true, false);
GeneratedParserUtilBase.CompletionState state =
new GeneratedParserUtilBase.CompletionState(position.getTextOffset() - topLevelElement.getTextOffset());
file.putUserData(GeneratedParserUtilBase.COMPLETION_STATE_KEY, state);
TreeUtil.ensureParsed(file.getNode());
return state.items;
}
示例4: ReplaceElementWithEvents
import com.intellij.psi.impl.source.tree.TreeUtil; //导入方法依赖的package包/类
private ReplaceElementWithEvents(@Nonnull CompositeElement oldRoot, @Nonnull CompositeElement newRoot) {
myOldRoot = oldRoot;
myNewRoot = newRoot;
// parse in background to reduce time spent in EDT and to ensure the newRoot light containing file is still valid
TreeUtil.ensureParsed(myOldRoot.getFirstChildNode());
TreeUtil.ensureParsed(myNewRoot.getFirstChildNode());
}
示例5: triggerParsingInFile
import com.intellij.psi.impl.source.tree.TreeUtil; //导入方法依赖的package包/类
private void triggerParsingInFile(PsiFile file) {
TreeUtil.ensureParsed(file.getNode());
}