use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class ExpectedTypesGetter method extractTypes.
@NotNull
public static PsiType[] extractTypes(ExpectedTypeInfo[] infos, boolean defaultTypes) {
Set<PsiType> result = new THashSet<>(infos.length);
for (ExpectedTypeInfo info : infos) {
final PsiType type = info.getType();
final PsiType defaultType = info.getDefaultType();
if (!defaultTypes && !defaultType.equals(type)) {
result.add(type);
}
result.add(defaultType);
}
return result.toArray(PsiType.createArray(result.size()));
}
use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class PsiAugmentProvider method getInferredType.
@Nullable
public static PsiType getInferredType(@NotNull final PsiTypeElement typeElement) {
final Ref<PsiType> result = Ref.create();
forEach(typeElement.getProject(), provider -> {
PsiType type = provider.inferType(typeElement);
if (type != null) {
result.set(type);
return false;
} else {
return true;
}
});
return result.get();
}
use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class GenericsHighlightingTest method testLeastUpperBoundWithRecursiveTypes.
public void testLeastUpperBoundWithRecursiveTypes() throws Exception {
final PsiManager manager = getPsiManager();
final GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
final PsiType leastUpperBound = GenericsUtil.getLeastUpperBound(PsiType.INT.getBoxedType(manager, scope), PsiType.LONG.getBoxedType(manager, scope), manager);
assertNotNull(leastUpperBound);
assertEquals("Number & Comparable<? extends Number & Comparable<?>>", leastUpperBound.getPresentableText());
}
use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class FunctionalInterfaceTest method testIntersectionTypeWithSameBaseInterfaceInConjuncts.
public void testIntersectionTypeWithSameBaseInterfaceInConjuncts() throws Exception {
String filePath = BASE_PATH + "/" + getTestName(false) + ".java";
configureByFile(filePath);
final PsiTypeCastExpression castExpression = PsiTreeUtil.getParentOfType(getFile().findElementAt(getEditor().getCaretModel().getOffset()), PsiTypeCastExpression.class);
assertNotNull(castExpression);
final PsiTypeElement castTypeElement = castExpression.getCastType();
assertNotNull(castTypeElement);
final PsiType type = castTypeElement.getType();
final String errorMessage = LambdaHighlightingUtil.checkInterfaceFunctional(type);
assertEquals(null, errorMessage);
}
use of com.intellij.psi.PsiType in project intellij-community by JetBrains.
the class FilterPattern method methodMatches.
public boolean methodMatches(@NotNull PsiMethod method) {
final String methodName = method.getName();
final Pattern methodNamePattern = getMethodNamePattern();
if ((methodNamePattern != null) && methodNamePattern.matcher(methodName).matches()) {
return true;
}
final PsiType returnType = method.getReturnType();
if (returnType == null) {
return false;
}
final Pattern patternTypePattern = getMethodTypePattern();
final String methodType = returnType.getCanonicalText();
return (patternTypePattern != null) && methodTypePattern.matcher(methodType).matches();
}
Aggregations