mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
(no message)
This commit is contained in:
@@ -13,6 +13,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.*;
|
||||
import com.intellij.util.containers.HashMap;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
@@ -362,22 +363,25 @@ public abstract class GenericsHighlightUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static HighlightInfo checkClassUsedAsTypeParameter(PsiTypeElement typeElement) {
|
||||
public static HighlightInfo checkReferenceTypeUsedAsTypeArgument(PsiTypeElement typeElement) {
|
||||
final PsiType type = typeElement.getType();
|
||||
if (!(type instanceof PsiPrimitiveType)) return null;
|
||||
if (type instanceof PsiPrimitiveType ||
|
||||
(type instanceof PsiWildcardType && ((PsiWildcardType)type).getBound() instanceof PsiPrimitiveType)) {
|
||||
final PsiElement element = new PsiMatcherImpl(typeElement)
|
||||
.parent(PsiMatcherImpl.hasClass(PsiReferenceParameterList.class))
|
||||
.parent(PsiMatcherImpl.hasClass(PsiJavaCodeReferenceElement.class))
|
||||
.getElement();
|
||||
if (element == null) return null;
|
||||
|
||||
final PsiElement element = new PsiMatcherImpl(typeElement)
|
||||
.parent(PsiMatcherImpl.hasClass(PsiReferenceParameterList.class))
|
||||
.parent(PsiMatcherImpl.hasClass(PsiJavaCodeReferenceElement.class))
|
||||
.getElement();
|
||||
if (element == null) return null;
|
||||
String description = MessageFormat.format("Type argument cannot be of primitive type",
|
||||
ArrayUtil.EMPTY_OBJECT_ARRAY);
|
||||
HighlightInfo highlightInfo = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
typeElement,
|
||||
description);
|
||||
return highlightInfo;
|
||||
}
|
||||
|
||||
String description = MessageFormat.format("Type parameter cannot be of primitive type",
|
||||
new Object[]{});
|
||||
HighlightInfo highlightInfo = HighlightInfo.createHighlightInfo(HighlightInfoType.ERROR,
|
||||
typeElement,
|
||||
description);
|
||||
return highlightInfo;
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -841,7 +841,7 @@ public class HighlightVisitorImpl extends PsiElementVisitor implements Highlight
|
||||
|
||||
public void visitTypeElement(PsiTypeElement type) {
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(HighlightUtil.checkIllegalType(type));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkClassUsedAsTypeParameter(type));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkReferenceTypeUsedAsTypeArgument(type));
|
||||
if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkWildcardUsage(type));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user