本文整理匯總了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);
}