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


Java PsiTreeUtil.getChildOfType方法代码示例

本文整理汇总了Java中com.intellij.psi.util.PsiTreeUtil.getChildOfType方法的典型用法代码示例。如果您正苦于以下问题:Java PsiTreeUtil.getChildOfType方法的具体用法?Java PsiTreeUtil.getChildOfType怎么用?Java PsiTreeUtil.getChildOfType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.util.PsiTreeUtil的用法示例。


在下文中一共展示了PsiTreeUtil.getChildOfType方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createHandlerParameterLabel

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public static AppleScriptHandlerParameterLabel createHandlerParameterLabel(Project project, String labelName) {
    StringBuilder builder = new StringBuilder();
    String newLabelName = labelName != null && !labelName.isEmpty() ? labelName : "to";
    builder.append("dummyHandlerName ").append(newLabelName).append(" \"some sting val\"");
    AppleScriptFile file = createFile(project, builder.toString());
    file.findChildByClass(AppleScriptHandlerLabeledParametersCallExpression.class);
//    file.getFirstChild().findChildByClass(AppleScriptHandlerLabeledParametersCallExpression.class);
    AppleScriptHandlerLabeledParametersCallExpression handlerCall =
            (AppleScriptHandlerLabeledParametersCallExpression) file
                    .getFirstChild();

    AppleScriptHandlerParameterLabel psiLabelNode = PsiTreeUtil.getChildOfType(file, AppleScriptHandlerParameterLabel
            .class);

    PsiElement[] childElements = handlerCall.getChildren();
    for (PsiElement childElement : childElements) {
      if (childElement.getNode().getElementType() == HANDLER_PARAMETER_LABEL) {
        return (AppleScriptHandlerParameterLabel) childElement;
      }
    }
    return null;
  }
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:23,代码来源:AppleScriptPsiElementFactory.java

示例2: getClassName

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public static String getClassName(@NotNull PsiElement element) {
    ParameterList parameterList = PsiTreeUtil.getParentOfType(element, ParameterList.class);
    if (parameterList == null) {
        return null;
    }

    MethodReference methodReference = PsiTreeUtil.getParentOfType(element, MethodReference.class);
    if (methodReference == null) {
        return null;
    }

    Variable variableBeingCalledOn = PsiTreeUtil.findChildOfType(methodReference, Variable.class);
    if (variableBeingCalledOn != null && variableBeingCalledOn.getInferredType() != null) {
        PhpType inferredType = variableBeingCalledOn.getInferredType();
        return inferredType.toString();
    }

    ClassReference classReference = PsiTreeUtil.getChildOfType(methodReference, ClassReference.class);

    return extractFqnFromClassReference(methodReference, classReference);
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:22,代码来源:PhpLangUtil.java

示例3: annotate

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的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);
    }
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:39,代码来源:TSClassNameAnnotator.java

示例4: getFunctionName

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public static String getFunctionName(TSFnDeclStmt element) {
    TSFnNameStmt name = PsiTreeUtil.getChildOfType(element, TSFnNameStmt.class);
    if (name == null) {
        return null;
    }
    return name.getFunctionName();
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:8,代码来源:TSPsiImplUtil.java

示例5: getNamespace

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public static String getNamespace(TSFnDeclStmt element) {
    TSFnNameStmt name = PsiTreeUtil.getChildOfType(element, TSFnNameStmt.class);
    if (name == null) {
        return null;
    }
    return name.getNamespace();
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:8,代码来源:TSPsiImplUtil.java

示例6: getFunctionType

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
public static TSFunctionType getFunctionType(TSFnDeclStmt element) {
    TSFnNameStmt name = PsiTreeUtil.getChildOfType(element, TSFnNameStmt.class);
    if (name == null) {
        return null;
    }
    return name.getFunctionType();
}
 
开发者ID:CouleeApps,项目名称:TS-IJ,代码行数:8,代码来源:TSPsiImplUtil.java

示例7: handleElementRename

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Override
public PsiElement handleElementRename(String newElementName) throws IncorrectOperationException {
  PsiElement element = this;
  final AppleScriptIdentifier identifier = PsiTreeUtil.getChildOfType(element, AppleScriptIdentifier.class);
  final AppleScriptIdentifier identifierNew = AppleScriptPsiElementFactory.createIdentifierFromText(getProject(), newElementName);
  if (identifierNew != null && identifier != null) {
    element.getNode().replaceChild(identifier.getNode(), identifierNew.getNode());
  }
  return this;
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:11,代码来源:AppleScriptReferenceElementImpl.java

示例8: getType

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Nullable
@Override
public PhpType getType(PsiElement psiElement) {
    // $GLOBALS['TYPO3_DB']
    if (!(psiElement instanceof ArrayAccessExpression)) {
        return null;
    }

    VariableImpl variable = PsiTreeUtil.getChildOfType(psiElement, VariableImpl.class);
    if (variable == null || !variable.getName().equals("GLOBALS")) {
        return null;
    }

    ArrayIndex arrayIndex = PsiTreeUtil.getChildOfType(psiElement, ArrayIndex.class);
    if (arrayIndex == null) {
        return null;
    }

    StringLiteralExpression arrayIndexName = PsiTreeUtil.getChildOfType(arrayIndex, StringLiteralExpressionImpl.class);
    if (arrayIndexName == null) {
        return null;
    }

    switch (arrayIndexName.getContents()) {
        case "TYPO3_DB":
            return new PhpType().add("#C\\TYPO3\\CMS\\Core\\Database\\DatabaseConnection");
        case "TSFE":
            return new PhpType().add("#C\\TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController");
        case "BE_USER":
            return new PhpType().add("#C\\TYPO3\\CMS\\Core\\Authentication\\BackendUserAuthentication");
        case "LANG":
            return new PhpType().add("#C\\TYPO3\\CMS\\Lang\\LanguageService");
        default:
            return null;
    }
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:37,代码来源:PhpGlobalsTypeProvider.java

示例9: getParamAtPosition

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Nullable
private static Parameter getParamAtPosition(@NotNull StringLiteralExpression element, @NotNull Integer position) {
    ParameterList parameterList = PsiTreeUtil.getParentOfType(element, ParameterList.class);
    if (parameterList == null) {
        return null;
    }

    MethodReference methodReference = PsiTreeUtil.getParentOfType(element, MethodReference.class);
    if (methodReference == null) {
        return null;
    }

    String methodName = methodReference.getName();
    ClassReference classReference = PsiTreeUtil.getChildOfType(methodReference, ClassReference.class);

    // may be null if the call is chained
    String name = extractFqnFromClassReference(methodReference, classReference);

    if (name == null || methodName == null) {
        return null;
    }

    // there can be multiple classes in one project scope that share the same FQN
    Collection<PhpClass> phpClasses = PhpIndex.getInstance(element.getProject()).getClassesByFQN(name);
    for (PhpClass c : phpClasses) {
        Method method = c.findMethodByName(methodName);

        ParameterList originalMethodParameterList = PsiTreeUtil.getChildOfType(method, ParameterList.class);
        if (originalMethodParameterList != null) {
            List<Parameter> parameters = PsiTreeUtil.getChildrenOfTypeAsList(originalMethodParameterList, Parameter.class);
            if (parameters.size() > 0 && parameters.get(position) != null) {

                return parameters.get(position);
            }
        }
    }

    return null;
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:40,代码来源:PhpLangUtil.java

示例10: getIndexer

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
    return inputData -> {
        Map<String, Void> map = new HashMap<>();
        JsonFile jsonFile = (JsonFile)inputData.getPsiFile();
        if (!Settings.isEnabled(jsonFile.getProject())) {
            return map;
        }

        JsonObject jsonObject = PsiTreeUtil.getChildOfType(jsonFile, JsonObject.class);
        if (jsonObject == null) {
            return map;
        }
        ComposerPackageModel composerObject = new ComposerPackageModelImpl(jsonObject);

        String type = composerObject.getType();
        if (type == null) {
            return map;
        }

        if (!type.startsWith("magento2-")) {
            return map;
        }

        String name = composerObject.getName();

        if (name != null) {
            map.put(name, null);
        }

        return map;
    };
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:35,代码来源:ModulePackageIndex.java

示例11: loadModules

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
private void loadModules() {
    Collection<String> packages = FileBasedIndex.getInstance().getAllKeys(ModulePackageIndex.KEY, this.project);
    PsiManager psiManager = PsiManager.getInstance(this.project);
    for (String packageName: packages) {
        if (components.containsKey(packageName)) {
            continue;
        }

        Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
            .getContainingFiles(ModulePackageIndex.KEY, packageName, GlobalSearchScope.allScope(this.project));

        if (containingFiles.size() > 0) {
            VirtualFile configurationFile = containingFiles.iterator().next();

            PsiFile psiFile = psiManager.findFile(configurationFile);
            if (psiFile != null && psiFile instanceof JsonFile) {
                JsonObject jsonObject = PsiTreeUtil.getChildOfType((JsonFile) psiFile, JsonObject.class);
                if (jsonObject == null) {
                    continue;
                }

                MagentoComponent magentoComponent;
                ComposerPackageModel composerPackageModel = new ComposerPackageModelImpl(jsonObject);
                if ("magento2-module".equals(composerPackageModel.getType())) {
                    magentoComponent = new MagentoModuleImpl(new ComposerPackageModelImpl(jsonObject), psiFile.getContainingDirectory());
                } else {
                    magentoComponent = new MagentoComponentImp(new ComposerPackageModelImpl(jsonObject), psiFile.getContainingDirectory());
                }

                components.put(
                    packageName,
                    magentoComponent
                );
            }
        }
    }
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:38,代码来源:MagentoComponentManager.java

示例12: getDirectParameter

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Nullable
@Override
public PsiElement getDirectParameter() {
  return PsiTreeUtil.getChildOfType(this, AppleScriptDirectParameterVal.class);
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:6,代码来源:AbstractAppleScriptCommandHandlerCall.java

示例13: getApplicationReference

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@Nullable
public static AppleScriptApplicationReference getApplicationReference(
        @NotNull AppleScriptTellCompoundStatement tellCompoundStatement) {
  return PsiTreeUtil.getChildOfType(tellCompoundStatement, AppleScriptApplicationReference.class);
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:6,代码来源:AppleScriptPsiImplUtil.java

示例14: getIdentifier

import com.intellij.psi.util.PsiTreeUtil; //导入方法依赖的package包/类
@NotNull
@Override
public AppleScriptIdentifier getIdentifier() {
  return PsiTreeUtil.getChildOfType(this, AppleScriptIdentifier.class);
}
 
开发者ID:ant-druha,项目名称:AppleScript-IDEA,代码行数:6,代码来源:AppleScriptNamedElementImpl.java


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