本文整理汇总了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();
}
示例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);
}
示例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;
}
示例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