本文整理汇总了Java中com.jetbrains.php.lang.psi.resolve.types.PhpType.add方法的典型用法代码示例。如果您正苦于以下问题:Java PhpType.add方法的具体用法?Java PhpType.add怎么用?Java PhpType.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.jetbrains.php.lang.psi.resolve.types.PhpType
的用法示例。
在下文中一共展示了PhpType.add方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getType
import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入方法依赖的package包/类
@Nullable
@Override
public PhpType getType(PsiElement element)
{
if (!(element instanceof MethodReference)) {
return null;
}
MethodReference ref = (MethodReference) element;
if (ref.getClassReference() == null) {
return null;
}
if (!pluralMethods.contains(ref.getName()) && !singularMethods.contains(ref.getName())) {
return null;
}
PhpType type = ref.getClassReference().getType();
PhpType resultType = new PhpType();
String arraySuffix = pluralMethods.contains(ref.getName()) ? "[]" : "";
for (String typeStr : type.filterMixed().filterNull().filterPrimitives().getTypes()) {
if (typeStr.startsWith("#V")) {
continue;
}
resultType.add("#" + getKey() + typeStr + "." + ref.getName() + arraySuffix);
}
return resultType;
}
示例2: getTypeDisplayName
import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入方法依赖的package包/类
public static String getTypeDisplayName(Project project, Set<String> types) {
Collection<PhpClass> classFromPhpTypeSet = PhpElementsUtil.getClassFromPhpTypeSet(project, types);
if(classFromPhpTypeSet.size() > 0) {
return classFromPhpTypeSet.iterator().next().getPresentableFQN();
}
PhpType phpType = new PhpType();
for (String type : types) {
phpType.add(type);
}
PhpType phpTypeFormatted = PhpIndex.getInstance(project).completeType(project, phpType, new HashSet<>());
if(phpTypeFormatted.getTypes().size() > 0) {
return StringUtils.join(phpTypeFormatted.getTypes(), "|");
}
if(types.size() > 0) {
return types.iterator().next();
}
return "";
}
示例3: getClassFromPhpTypeSet
import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入方法依赖的package包/类
public static Collection<PhpClass> getClassFromPhpTypeSet(Project project, Set<String> types) {
PhpType phpType = new PhpType();
for (String type : types) {
phpType.add(type);
}
List<PhpClass> phpClasses = new ArrayList<>();
for(String typeName: PhpIndex.getInstance(project).completeType(project, phpType, new HashSet<>()).getTypes()) {
if(typeName.startsWith("\\")) {
PhpClass phpClass = PhpElementsUtil.getClassInterface(project, typeName);
if(phpClass != null) {
phpClasses.add(phpClass);
}
}
}
return phpClasses;
}
示例4: getClassFromPhpTypeSetArrayClean
import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入方法依赖的package包/类
public static Collection<PhpClass> getClassFromPhpTypeSetArrayClean(Project project, Set<String> types) {
PhpType phpType = new PhpType();
for (String type : types) {
phpType.add(type);
}
ArrayList<PhpClass> phpClasses = new ArrayList<>();
for(String typeName: PhpIndex.getInstance(project).completeType(project, phpType, new HashSet<>()).getTypes()) {
if(typeName.startsWith("\\")) {
// we clean array types \Foo[]
if(typeName.endsWith("[]")) {
typeName = typeName.substring(0, typeName.length() - 2);
}
PhpClass phpClass = PhpElementsUtil.getClassInterface(project, typeName);
if(phpClass != null) {
phpClasses.add(phpClass);
}
}
}
return phpClasses;
}