本文整理汇总了Java中com.intellij.psi.util.PsiTreeUtil.findFirstParent方法的典型用法代码示例。如果您正苦于以下问题:Java PsiTreeUtil.findFirstParent方法的具体用法?Java PsiTreeUtil.findFirstParent怎么用?Java PsiTreeUtil.findFirstParent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.util.PsiTreeUtil
的用法示例。
在下文中一共展示了PsiTreeUtil.findFirstParent方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolve
import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Override
public PsiElement resolve() {
PsiElement element = this.getElement();
CallStatementElement callStatement =
(CallStatementElement) PsiTreeUtil
.findFirstParent(element, elt -> elt instanceof CallStatementElement);
if (callStatement != null) {
PsiElement identifier = callStatement.getBeginCall().getTemplateReferenceIdentifier();
if (identifier == null) {
return null;
}
return ParamUtils.getParametersForInvocation(element, identifier.getText())
.stream()
.filter((var) -> var.name.equals(parameterName))
.findAny()
.map((var) -> var.element)
.orElse(null);
}
return null;
}
示例2: execute
import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public void execute(@NotNull Editor editor, char charTyped, @NotNull DataContext dataContext) {
myOriginalHandler.execute(editor, charTyped, dataContext);
if (isMatchForClosingTag(editor, charTyped)) {
int offset = editor.getCaretModel().getOffset();
PsiFile file = dataContext.getData(LangDataKeys.PSI_FILE);
if (file == null) {
return;
}
PsiElement el = file.findElementAt(offset - 1);
TagBlockElement block = (TagBlockElement) PsiTreeUtil
.findFirstParent(el,
parent -> parent instanceof TagBlockElement && !(parent instanceof SoyChoiceClause));
if (block == null) {
return;
}
String closingTag = block.getOpeningTag().generateClosingTag();
insertClosingTag(editor, offset, closingTag);
if (editor.getProject() != null) {
PsiDocumentManager.getInstance(editor.getProject()).commitDocument(editor.getDocument());
CodeStyleManager.getInstance(editor.getProject()).reformat(block);
}
}
}
示例3: getDocCommentForEnclosingTag
import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Nullable
private static String getDocCommentForEnclosingTag(PsiElement element) {
PsiElement parentTag = PsiTreeUtil.findFirstParent(element, TagElement.class::isInstance);
return PsiTreeUtil.getChildrenOfTypeAsList(parentTag, PsiComment.class)
.stream()
.filter(SoyDocumentationProvider::isDocComment)
.findFirst()
.map(PsiElement::getText)
.orElse(null);
}
示例4: getScope
import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
/** The most concrete scope containing the given [element] or null if none found. */
@Nullable
static Scope getScope(PsiElement element) {
PsiElement scope =
PsiTreeUtil.findFirstParent(element, true, psiElement -> psiElement instanceof Scope);
// If the first scope is not a StatementList or a TemplateBlock, we must be in
// a statement opening tag.
if (!(scope instanceof SoyStatementList) && !(scope instanceof SoyTemplateBlock)) {
scope = PsiTreeUtil.findFirstParent(element, true, psiElement -> psiElement instanceof Scope);
}
return (Scope) scope;
}
示例5: getParentTemplateBlock
import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
private static SoyTemplateBlock getParentTemplateBlock(PsiElement element) {
return (SoyTemplateBlock)
PsiTreeUtil.findFirstParent(element, psiElement -> psiElement instanceof SoyTemplateBlock);
}