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


Java PhpType.toString方法代码示例

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


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

示例1: getClassByVariable

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入方法依赖的package包/类
@Nullable
public static PhpClass getClassByVariable(Variable element) {
    if (element == null)
        return null;
    PhpType type = element.getType();
    String typeString = type.toString();
    String[] split = typeString.split("\\|");
    typeString = split[0];
    Pattern pattern = Pattern.compile("\\\\[A-Za-z\\\\]+");
    Matcher matcher = pattern.matcher(typeString);
    if (matcher.find())
        typeString = matcher.group();
    Collection<PhpClass> anyByFQN = PhpIndex.getInstance(element.getProject()).getAnyByFQN(typeString);
    if (anyByFQN.isEmpty())
        return null;
    else
        return anyByFQN.iterator().next();
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:19,代码来源:ClassUtils.java

示例2: getClassName

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入方法依赖的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: getPhpClassByCallChain

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入方法依赖的package包/类
@Nullable
public static PhpClass getPhpClassByCallChain(MethodReference methodRef) {

    while (methodRef != null) {
        PhpExpression expr = methodRef.getClassReference();
        if (expr instanceof ClassReference) {
            return (PhpClass) ((ClassReference) expr).resolve();
        } else if (expr instanceof MethodReference) {
            methodRef = (MethodReference) expr;
        } else if (expr instanceof Variable) {
            PhpType type = expr.getType();
            String strType = type.toString();
            int index1 = strType.indexOf('\\');
            int index2 = strType.indexOf('.');
            if (index2 == -1)
                index2 = strType.length() - index1;

            if (index1 >= 0 && index2 >= 0 && index2 > index1) {
                String className = strType.substring(index1, index2);
                return ClassUtils.getClass(PhpIndex.getInstance(methodRef.getProject()), className);
            } else {
                return null;
            }

            // type.toString()
        } else {
            return null;
        }
    }

    return null;
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:33,代码来源:ClassUtils.java

示例4: buildVisitor

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入方法依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpElement(PhpPsiElement element) {

            if (!PlatformPatterns.psiElement(PhpElementTypes.METHOD_REFERENCE).accepts(element)) {
                return;
            }

            MethodReference methodReference = (MethodReference) element;
            ParameterList parameterList = methodReference.getParameterList();
            PhpExpression classReference = methodReference.getClassReference();
            if (classReference != null) {
                PhpType inferredType = classReference.getInferredType();
                String compiledClassMethodKey = inferredType.toString() + "->" + methodReference.getName();
                if (ExtensionScannerUtil.classMethodHasDroppedArguments(element.getProject(), compiledClassMethodKey)) {
                    Integer maximumNumberOfArguments = ExtensionScannerUtil.getMaximumNumberOfArguments(element.getProject(), compiledClassMethodKey);

                    if (parameterList != null && maximumNumberOfArguments != -1 && parameterList.getParameters().length != maximumNumberOfArguments) {
                        problemsHolder.registerProblem(element, "Number of arguments changed with TYPO3 9, consider refactoring");
                    }
                }
            }
        }
    };
}
 
开发者ID:cedricziel,项目名称:idea-php-typo3-plugin,代码行数:29,代码来源:MethodArgumentDroppedMatcherInspection.java


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