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


Java PhpType类代码示例

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


PhpType类属于com.jetbrains.php.lang.psi.resolve.types包,在下文中一共展示了PhpType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getType

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入依赖的package包/类
@Nullable
@Override
public PhpType getType(PsiElement psiElement) {
    if (MethodUtils.isYiiCreateObjectMethod(psiElement)) {
                PhpPsiElement firstParam = (PhpPsiElement)MethodUtils.getParameter((MethodReference)psiElement, 0);
                //  Case: Yii::createObject($obj->array_var)
                if (firstParam instanceof FieldReference ) {
                    String signature = ((MethodReference)psiElement).getSignature();
                    return new PhpType().add("#" + this.getKey() + signature + TRIM_KEY + ((FieldReference) firstParam).getSignature());
                }
                // Case: Yii::createObject($array_var)
                if (firstParam instanceof Variable  && ((VariableImpl) firstParam).getDeclaredType().getTypes().contains("\\array") ) {
                    firstParam = getArrayCreationByVariableRef(firstParam);
                }
                if (firstParam instanceof ArrayCreationExpression) {
                    PhpType elem = getClassByArrayCreationOptimized((ArrayCreationExpression) firstParam);
                    if (elem != null) return elem;
                }
                else {
                    return getClass(firstParam);
                }
    }
    return null;
}
 
开发者ID:nvlad,项目名称:yii2support,代码行数:25,代码来源:YiiTypeProvider.java

示例3: getType

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入依赖的package包/类
@Nullable
@Override
public PhpType getType(PsiElement psiElement) {
    if (DumbService.getInstance(psiElement.getProject()).isDumb()) {
        return null;
    }

    if (!(psiElement instanceof MethodReference) || !PhpElementsUtil.isMethodWithFirstStringOrFieldReference(psiElement, "get")) {
        return null;
    }

    MethodReference methodReference = (MethodReference) psiElement;
    if (methodReference.getParameters().length == 0) {
        return null;
    }

    PsiElement firstParam = methodReference.getParameters()[0];
    if (firstParam instanceof PhpReference) {
        PhpReference ref = (PhpReference) firstParam;
        if (ref.getText().toLowerCase().contains("::class")) {
            return new PhpType().add("#" + this.getKey() + ref.getSignature());
        }
    }

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

示例4: 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

示例5: hasOnlyTypes

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入依赖的package包/类
private static boolean hasOnlyTypes(
    @NotNull final PsiElement fileSample,
    @NotNull final String functionName,
    @NotNull final PhpType... expectedTypesList
) {
    final Collection<String> returnTypes = new ArrayList<>(valueOf(PhpFunctionUtil.getReturnType(getFunction(fileSample, functionName))).getTypes());

    for (final PhpType expectedTypes : expectedTypesList) {
        for (final String expectedType : expectedTypes.getTypes()) {
            if (!returnTypes.contains(expectedType)) {
                return false;
            }

            returnTypes.remove(expectedType);
        }
    }

    return returnTypes.isEmpty();
}
 
开发者ID:rentalhost,项目名称:laravel-insight,代码行数:20,代码来源:PhpFunctionUtilTest.java

示例6: getType

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入依赖的package包/类
@Nullable
@Override
public PhpType getType(PsiElement psiElement) {
    if (!(psiElement instanceof FieldReference)) {
        return null;
    }
    FieldReference fieldReference = (FieldReference)psiElement;
    PhpExpression classReference = fieldReference.getClassReference();
    if (classReference == null) {
        return null;
    }
    PhpType referenceType = classReference.getType();
    String fieldReferenceName = fieldReference.getName();
    if (!StringUtil.startsWithUppercaseCharacter(fieldReferenceName)) {
        return null;
    }
    for (String type : referenceType.getTypes()) {
        if (type.contains("Controller")) {
            return new PhpType().add("\\" + fieldReferenceName)
                    .add("\\" + fieldReferenceName + "Component");
        }
    }
    return null;
}
 
开发者ID:dmeybohm,项目名称:chocolate-cakephp,代码行数:25,代码来源:ControllerFieldTypeProvider.java

示例7: getType

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入依赖的package包/类
@Nullable
@Override
public PhpType getType(PsiElement psiElement) {
    if (!(psiElement instanceof FieldReference)) {
        return null;
    }
    FieldReference fieldReference = (FieldReference)psiElement;
    PhpExpression classReference = fieldReference.getClassReference();
    if (classReference == null) {
        return null;
    }
    PhpType types = classReference.getType();
    String fieldReferenceName = fieldReference.getName();
    if (!StringUtil.startsWithUppercaseCharacter(fieldReferenceName)) {
        return null;
    }
    for (String type : types.getTypes()) {
        if (type.contains("#Vthis")) {
            return new PhpType().add("\\" + fieldReferenceName + "Helper");
        }
    }
    return null;
}
 
开发者ID:dmeybohm,项目名称:chocolate-cakephp,代码行数:24,代码来源:ViewHelperTypeProvider.java

示例8: buildVisitor

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入依赖的package包/类
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
    return new PhpElementVisitor() {
        @Override
        public void visitPhpClass(PhpClass phpClass) {
            if (TesterUtil.isTestClass(phpClass)) {
                runMap.put(phpClass.getType(), Boolean.FALSE);
            }
        }

        @Override
        public void visitPhpMethodReference(MethodReference reference) {
            if (reference.getClassReference() == null) {
                return;
            }

            PhpType classType = reference.getClassReference().getType();
            if (runMap.containsKey(classType)) {
                runMap.put(classType, Boolean.TRUE);
            }
        }
    };
}
 
开发者ID:jiripudil,项目名称:intellij-nette-tester,代码行数:25,代码来源:TestCaseIsRunInspection.java

示例9: passThruMethodParameterType

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入依赖的package包/类
@Nullable
private String passThruMethodParameterType(MethodReference methodReference, int parameterPosition) {
    String typeList = null;
    PsiElement[] parameters = methodReference.getParameters();
    if (parameters.length > parameterPosition)
    {
        PsiElement parameter = parameters[parameterPosition];
        if (parameter instanceof Variable)
        {
            PhpType type = ((Variable) parameter).getType();
            typeList = StringUtil.join(type.getTypes(), "|");
        }
        else if (parameter instanceof MethodReference)
        {
            typeList = ((MethodReference) parameter).getSignature();
        }
    }
    return typeList;
}
 
开发者ID:mlively,项目名称:idea-php-phake,代码行数:20,代码来源:PhakeMockTypeProvider.java

示例10: 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 methodReference = (MethodReference) element;
	if (!methodReference.getName().equals("persist") && !methodReference.getName().equals("persistAndFlush")) {
		return null;
	}
	String className = ((MethodReference) element).getClassReference().getName().toLowerCase();

	//cannot access index here, so just dummy check
	if (!className.endsWith("model") && !className.endsWith("repository") && !className.endsWith("repositorycontainer")) {
		return null;
	}
	if (methodReference.getParameters().length == 0) {
		return null;
	}
	if (!(methodReference.getParameters()[0] instanceof PhpTypedElement)) {
		return null;
	}
	return ((PhpTypedElement) methodReference.getParameters()[0]).getType();
}
 
开发者ID:nextras,项目名称:orm-intellij,代码行数:26,代码来源:PersistenceMethodsTypeProvider.java

示例11: 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;
}
 
开发者ID:nextras,项目名称:orm-intellij,代码行数:26,代码来源:CollectionTypeProvider.java

示例12: findQueriedEntities

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入依赖的package包/类
public static Collection<PhpClass> findQueriedEntities(MemberReference ref)
{
	PhpExpression classReference = ref.getClassReference();
	if (classReference == null) {
		return Collections.emptyList();
	}
	Collection<PhpClass> entities = new HashSet<>();
	PhpIndex phpIndex = PhpIndex.getInstance(ref.getProject());
	Collection<PhpClass> classes = PhpIndexUtils.getByType(classReference.getType(), phpIndex);
	Collection<PhpClass> repositories = classes.stream()
		.filter(cls -> OrmClass.REPOSITORY.is(cls, phpIndex))
		.collect(Collectors.toList());
	if (repositories.size() > 0) {
		entities.addAll(findRepositoryEntities(repositories));
	}
	for (String type : classReference.getType().getTypes()) {
		if (!type.endsWith("[]")) {
			continue;
		}
		PhpType typeWithoutArray = new PhpType().add(type.substring(0, type.length() - 2));
		Collection<PhpClass> maybeEntities = PhpIndexUtils.getByType(typeWithoutArray, phpIndex);
		entities.addAll(maybeEntities.stream().filter(cls -> OrmClass.ENTITY.is(cls, phpIndex)).collect(Collectors.toList()));
	}

	return entities;
}
 
开发者ID:nextras,项目名称:orm-intellij,代码行数:27,代码来源:OrmUtils.java

示例13: addEntitiesFromField

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入依赖的package包/类
public static void addEntitiesFromField(Collection<PhpClass> entities, PhpDocProperty field)
{
	PhpIndex index = PhpIndex.getInstance(field.getProject());
	for (String type : field.getType().getTypes()) {
		if (type.contains("Nextras\\Orm\\Relationship")) {
			continue;
		}
		if (type.endsWith("[]")) {
			type = type.substring(0, type.length() - 2);
		}
		for (PhpClass entityCls : PhpIndexUtils.getByType(new PhpType().add(type), index)) {
			if (!OrmClass.ENTITY.is(entityCls, index)) {
				continue;
			}
			entities.add(entityCls);
		}
	}
}
 
开发者ID:nextras,项目名称:orm-intellij,代码行数:19,代码来源:OrmUtils.java

示例14: isPhpTypeEqual

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入依赖的package包/类
private static boolean isPhpTypeEqual(@NotNull PhpType phpType, @NotNull PhpClass phpClass) {

        Symfony2InterfacesUtil util = null;

        for (String s : phpType.getTypes()) {
            if(util == null) {
                util = new Symfony2InterfacesUtil();
            }

            if(util.isInstanceOf(phpClass, s)) {
                return true;
            }
        }

        return false;
    }
 
开发者ID:Haehnchen,项目名称:idea-php-laravel-plugin,代码行数:17,代码来源:PhpTypeProviderUtil.java

示例15: getType

import com.jetbrains.php.lang.psi.resolve.types.PhpType; //导入依赖的package包/类
@Nullable
@Override
public PhpType getType(PsiElement e) {
    if (!Settings.getInstance(e.getProject()).pluginEnabled) {
        return null;
    }

    if(!(e instanceof MethodReference) || !PhpElementsUtil.isMethodWithFirstStringOrFieldReference(e, "getRepository")) {
        return null;
    }


    String refSignature = ((MethodReference)e).getSignature();
    if(StringUtil.isEmpty(refSignature)) {
        return null;
    }

    String signature = PhpTypeProviderUtil.getReferenceSignatureByFirstParameter((MethodReference) e, TRIM_KEY);
    return signature == null ? null : new PhpType().add("#" + this.getKey() + signature);
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:21,代码来源:ObjectRepositoryTypeProvider.java


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