本文整理匯總了Java中com.intellij.lang.ASTNode.findChildByType方法的典型用法代碼示例。如果您正苦於以下問題:Java ASTNode.findChildByType方法的具體用法?Java ASTNode.findChildByType怎麽用?Java ASTNode.findChildByType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.lang.ASTNode
的用法示例。
在下文中一共展示了ASTNode.findChildByType方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getName
import com.intellij.lang.ASTNode; //導入方法依賴的package包/類
public static String getName(TSObjectExpr obj) {
//Should be the first element after the open paren
ASTNode node = obj.getNode();
if (node == null) {
return null;
}
ASTNode openParen = node.findChildByType(TSTypes.PAREN_OPEN);
if (openParen == null) {
return null;
}
PsiElement nameNode = openParen.getPsi().getNextSibling();
if (nameNode == null) {
return null;
}
if (nameNode instanceof TSLiteralExpr) {
return ((TSLiteralExpr) nameNode).getName();
}
if (nameNode.getNode().getElementType().equals(TSTypes.ID)) {
return nameNode.getText();
}
return null;
}
示例2: annotate
import com.intellij.lang.ASTNode; //導入方法依賴的package包/類
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
PsiElement classElement = null;
if (element instanceof TSDatablockDecl) {
TSDatablockDecl db = (TSDatablockDecl) element;
//Find the first id node, this is kinda wonky since we have to account for whitespace nodes
//datablock ClassName(...)
ASTNode node = db.getNode();
if (node == null) {
return;
}
node = node.findChildByType(TSTypes.ID);
if (node == null) {
return;
}
classElement = node.getPsi();
} else if (element instanceof TSObjectExpr) {
TSObjectExpr obj = (TSObjectExpr) element;
//Class name should be the second thing in the element:
// new ClassName(...)
classElement = PsiTreeUtil.getChildOfType(obj, TSClassNameExpr.class);
if (classElement == null) {
return;
}
classElement = classElement.getFirstChild();
}
if (classElement == null) {
return;
}
//Only annotate if it's an id, can't really tell if it's an expr
if (classElement.getNode().getElementType().equals(TSTypes.ID)) {
createSuccessAnnotation(classElement, holder, TSSyntaxHighlighter.CLASSNAME);
}
}
示例3: useStandardAdditions
import com.intellij.lang.ASTNode; //導入方法依賴的package包/類
public static boolean useStandardAdditions(AppleScriptUseStatement useStatement) {
ASTNode node = useStatement.getNode();
return node.findChildByType(AppleScriptTypes.SCRIPTING_ADDITIONS) != null;
}
示例4: withImportingStdLibrary
import com.intellij.lang.ASTNode; //導入方法依賴的package包/類
public static boolean withImportingStdLibrary(AppleScriptUsingTermsFromStatement usingTermsStatement) {
ASTNode node = usingTermsStatement.getNode();
return node.findChildByType(AppleScriptTypes.SCRIPTING_ADDITIONS) != null;
}