mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
notnull
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package com.intellij.psi;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* JavaResolveResult holds additional information that is obtained
|
||||
* when Java references are being resolved.
|
||||
@@ -28,6 +30,7 @@ public interface JavaResolveResult extends ResolveResult {
|
||||
/**
|
||||
* Substitutor providing values of type parameters occurring in {@link #getElement()}.
|
||||
*/
|
||||
@NotNull
|
||||
PsiSubstitutor getSubstitutor();
|
||||
|
||||
boolean isPackagePrefixPackageReference();
|
||||
@@ -47,6 +50,7 @@ public interface JavaResolveResult extends ResolveResult {
|
||||
|
||||
JavaResolveResult EMPTY = new JavaResolveResult() {
|
||||
@Override public PsiElement getElement() { return null; }
|
||||
@NotNull
|
||||
@Override public PsiSubstitutor getSubstitutor() { return PsiSubstitutor.EMPTY; }
|
||||
@Override public boolean isValidResult() { return false; }
|
||||
@Override public boolean isAccessible() { return false; }
|
||||
|
||||
@@ -22,8 +22,6 @@ import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.infos.CandidateInfo;
|
||||
import com.intellij.psi.infos.ClassCandidateInfo;
|
||||
import com.intellij.psi.infos.MethodCandidateInfo;
|
||||
import com.intellij.psi.util.*;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
@@ -579,10 +577,11 @@ public class LambdaUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PsiSubstitutor inferFromReturnType(final PsiTypeParameter[] typeParameters,
|
||||
@NotNull
|
||||
public static PsiSubstitutor inferFromReturnType(@NotNull PsiTypeParameter[] typeParameters,
|
||||
final PsiType returnType,
|
||||
@Nullable final PsiType interfaceMethodReturnType,
|
||||
PsiSubstitutor psiSubstitutor,
|
||||
@NotNull PsiSubstitutor psiSubstitutor,
|
||||
final LanguageLevel languageLevel,
|
||||
final Project project) {
|
||||
if (interfaceMethodReturnType == null) return psiSubstitutor;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -47,16 +47,19 @@ public class PsiCapturedWildcardType extends PsiType {
|
||||
return new PsiCapturedWildcardType(existential, context);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return myExistential.getPresentableText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getCanonicalText() {
|
||||
return myExistential.getCanonicalText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
//noinspection HardCodedStringLiteral
|
||||
@@ -69,7 +72,7 @@ public class PsiCapturedWildcardType extends PsiType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsToText(String text) {
|
||||
public boolean equalsToText(@NotNull String text) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -81,6 +81,7 @@ public class PsiDisjunctionType extends PsiType {
|
||||
return new PsiDisjunctionType(types, myManager);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return StringUtil.join(myTypes, new Function<PsiType, String>() {
|
||||
@@ -88,6 +89,7 @@ public class PsiDisjunctionType extends PsiType {
|
||||
}, " | ");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getCanonicalText() {
|
||||
return StringUtil.join(myTypes, new Function<PsiType, String>() {
|
||||
@@ -95,6 +97,7 @@ public class PsiDisjunctionType extends PsiType {
|
||||
}, " | ");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return StringUtil.join(myTypes, new Function<PsiType, String>() {
|
||||
@@ -111,7 +114,7 @@ public class PsiDisjunctionType extends PsiType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsToText(@NonNls final String text) {
|
||||
public boolean equalsToText(@NotNull @NonNls final String text) {
|
||||
return Comparing.equal(text, getCanonicalText());
|
||||
}
|
||||
|
||||
|
||||
@@ -42,23 +42,26 @@ public class PsiEllipsisType extends PsiArrayType {
|
||||
return new PsiEllipsisType(componentType, annotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return StringUtil.joinOrNull(getComponentType().getPresentableText(), getAnnotationsTextPrefix(false, true, true), "...");
|
||||
return StringUtil.join(getComponentType().getPresentableText(), getAnnotationsTextPrefix(false, true, true), "...");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getCanonicalText() {
|
||||
return StringUtil.joinOrNull(getComponentType().getCanonicalText(), "...");
|
||||
return StringUtil.join(getComponentType().getCanonicalText(), "...");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return StringUtil.joinOrNull(getComponentType().getInternalCanonicalText(), getAnnotationsTextPrefix(true, true, true), "...");
|
||||
return StringUtil.join(getComponentType().getInternalCanonicalText(), getAnnotationsTextPrefix(true, true, true), "...");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsToText(String text) {
|
||||
public boolean equalsToText(@NotNull String text) {
|
||||
return text.endsWith("...") && getComponentType().equalsToText(text.substring(0, text.length() - 3)) ||
|
||||
super.equalsToText(text);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,16 +30,19 @@ public class PsiLambdaExpressionType extends PsiType {
|
||||
myExpression = expression;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return "<lambda expression>";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getCanonicalText() {
|
||||
return getPresentableText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return getCanonicalText();
|
||||
@@ -51,7 +54,7 @@ public class PsiLambdaExpressionType extends PsiType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsToText(@NonNls final String text) {
|
||||
public boolean equalsToText(@NotNull @NonNls final String text) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,16 +30,19 @@ public class PsiLambdaParameterType extends PsiType {
|
||||
myParameter = parameter;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return "<lambda parameter>";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getCanonicalText() {
|
||||
return getPresentableText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return getCanonicalText();
|
||||
@@ -51,7 +54,7 @@ public class PsiLambdaParameterType extends PsiType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsToText(@NonNls final String text) {
|
||||
public boolean equalsToText(@NotNull @NonNls final String text) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -30,16 +30,19 @@ public class PsiMethodReferenceType extends PsiType {
|
||||
myReference = reference;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return "<method reference>";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getCanonicalText() {
|
||||
return getPresentableText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return getPresentableText();
|
||||
@@ -51,7 +54,7 @@ public class PsiMethodReferenceType extends PsiType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsToText(@NonNls final String text) {
|
||||
public boolean equalsToText(@NotNull @NonNls final String text) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ public class PsiWildcardType extends PsiType {
|
||||
@NonNls private static final String EXTENDS_PREFIX = "? extends ";
|
||||
@NonNls private static final String SUPER_PREFIX = "? super ";
|
||||
|
||||
@NotNull
|
||||
private final PsiManager myManager;
|
||||
private final boolean myIsExtending;
|
||||
private final PsiType myBound;
|
||||
@@ -79,6 +80,7 @@ public class PsiWildcardType extends PsiType {
|
||||
return annotations.length == 0 ? this : new PsiWildcardType(this, annotations);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return getAnnotationsTextPrefix(false, false, true) +
|
||||
@@ -86,10 +88,12 @@ public class PsiWildcardType extends PsiType {
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getCanonicalText() {
|
||||
return (myBound == null ? "?" : (myIsExtending ? EXTENDS_PREFIX : SUPER_PREFIX) + myBound.getCanonicalText());
|
||||
return myBound == null ? "?" : (myIsExtending ? EXTENDS_PREFIX : SUPER_PREFIX) + myBound.getCanonicalText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return getAnnotationsTextPrefix(true, false, true) +
|
||||
@@ -115,7 +119,7 @@ public class PsiWildcardType extends PsiType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsToText(String text) {
|
||||
public boolean equalsToText(@NotNull String text) {
|
||||
if (myBound == null) return "?".equals(text);
|
||||
if (myIsExtending) {
|
||||
return text.startsWith(EXTENDS_PREFIX) && myBound.equalsToText(text.substring(EXTENDS_PREFIX.length()));
|
||||
@@ -124,7 +128,7 @@ public class PsiWildcardType extends PsiType {
|
||||
return text.startsWith(SUPER_PREFIX) && myBound.equalsToText(text.substring(SUPER_PREFIX.length()));
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiManager getManager() {
|
||||
return myManager;
|
||||
}
|
||||
@@ -204,6 +208,7 @@ public class PsiWildcardType extends PsiType {
|
||||
*
|
||||
* @return <code>PsiType</code> representing a lower bound. Never returns <code>null</code>.
|
||||
*/
|
||||
@NotNull
|
||||
public PsiType getExtendsBound() {
|
||||
if (myBound == null || !myIsExtending) {
|
||||
return getJavaLangObject(myManager, getResolveScope());
|
||||
@@ -222,6 +227,7 @@ public class PsiWildcardType extends PsiType {
|
||||
*
|
||||
* @return <code>PsiType</code> representing an upper bound. Never returns <code>null</code>.
|
||||
*/
|
||||
@NotNull
|
||||
public PsiType getSuperBound() {
|
||||
return myBound == null || myIsExtending ? NULL : myBound;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -95,6 +95,7 @@ public class CandidateInfo implements JavaResolveResult {
|
||||
return myCandidate;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiSubstitutor getSubstitutor(){
|
||||
return mySubstitutor;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -44,7 +44,7 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
private final PsiElement myArgumentList;
|
||||
private final PsiType[] myArgumentTypes;
|
||||
private final PsiType[] myTypeArguments;
|
||||
private PsiSubstitutor myCalcedSubstitutor = null;
|
||||
private PsiSubstitutor myCalcedSubstitutor; // benign race
|
||||
private final LanguageLevel myLanguageLevel;
|
||||
|
||||
public MethodCandidateInfo(PsiElement candidate,
|
||||
@@ -135,13 +135,16 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
return super.getSubstitutor();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiSubstitutor getSubstitutor() {
|
||||
return getSubstitutor(true);
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public PsiSubstitutor getSubstitutor(boolean includeReturnConstraint) {
|
||||
if (myCalcedSubstitutor == null || !includeReturnConstraint) {
|
||||
PsiSubstitutor substitutor = myCalcedSubstitutor;
|
||||
if (substitutor == null || !includeReturnConstraint) {
|
||||
PsiSubstitutor incompleteSubstitutor = super.getSubstitutor();
|
||||
PsiMethod method = getElement();
|
||||
if (myTypeArguments == null) {
|
||||
@@ -153,18 +156,18 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
return inferredSubstitutor;
|
||||
}
|
||||
|
||||
myCalcedSubstitutor = inferredSubstitutor;
|
||||
myCalcedSubstitutor = substitutor = inferredSubstitutor;
|
||||
}
|
||||
else {
|
||||
PsiTypeParameter[] typeParams = method.getTypeParameters();
|
||||
for (int i = 0; i < myTypeArguments.length && i < typeParams.length; i++) {
|
||||
incompleteSubstitutor = incompleteSubstitutor.put(typeParams[i], myTypeArguments[i]);
|
||||
}
|
||||
myCalcedSubstitutor = incompleteSubstitutor;
|
||||
myCalcedSubstitutor = substitutor = incompleteSubstitutor;
|
||||
}
|
||||
}
|
||||
|
||||
return myCalcedSubstitutor;
|
||||
return substitutor;
|
||||
}
|
||||
|
||||
|
||||
@@ -192,6 +195,7 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
return (PsiMethod)super.getElement();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiSubstitutor inferTypeArguments(@NotNull ParameterTypeInferencePolicy policy, boolean includeReturnConstraint) {
|
||||
return inferTypeArguments(policy, myArgumentList instanceof PsiExpressionList
|
||||
? ((PsiExpressionList)myArgumentList).getExpressions()
|
||||
@@ -215,6 +219,7 @@ public class MethodCandidateInfo extends CandidateInfo{
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public PsiSubstitutor inferTypeArguments(@NotNull ParameterTypeInferencePolicy policy,
|
||||
@NotNull PsiExpression[] arguments,
|
||||
boolean includeReturnConstraint) {
|
||||
|
||||
@@ -71,6 +71,7 @@ public class TypeConversionUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
@NonNls
|
||||
public String getPresentableText() {
|
||||
@@ -1023,7 +1024,7 @@ public class TypeConversionUtil {
|
||||
* <code>InheritanceUtil.isInheritor(derivedClass, superClass, true)</code>
|
||||
*
|
||||
* @return substitutor (never returns <code>null</code>)
|
||||
* @see PsiClass#isInheritor(PsiClass, PsiClass, boolean)
|
||||
* @see PsiClass#isInheritor(PsiClass, boolean)
|
||||
*/
|
||||
@NotNull
|
||||
public static PsiSubstitutor getSuperClassSubstitutor(@NotNull PsiClass superClass,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -28,16 +28,19 @@ public class Bottom extends PsiType {
|
||||
super(PsiAnnotation.EMPTY_ARRAY);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return "_";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getCanonicalText() {
|
||||
return "_";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return getCanonicalText();
|
||||
@@ -49,7 +52,7 @@ public class Bottom extends PsiType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsToText(String text) {
|
||||
public boolean equalsToText(@NotNull String text) {
|
||||
return text.equals("_");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,16 +52,19 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
|
||||
myTypeElement = psiTypeElement;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getCanonicalText() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return "Diamond Type";
|
||||
@@ -73,7 +76,7 @@ public class PsiDiamondTypeImpl extends PsiDiamondType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsToText(@NonNls String text) {
|
||||
public boolean equalsToText(@NotNull @NonNls String text) {
|
||||
return text != null && text.isEmpty();
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ public class PsiClassReferenceType extends PsiClassType {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsToText(String text) {
|
||||
public boolean equalsToText(@NotNull String text) {
|
||||
return Comparing.equal(text, getCanonicalText());
|
||||
}
|
||||
|
||||
@@ -92,10 +92,11 @@ public class PsiClassReferenceType extends PsiClassType {
|
||||
private static class DelegatingClassResolveResult implements ClassResolveResult {
|
||||
private final JavaResolveResult myDelegate;
|
||||
|
||||
private DelegatingClassResolveResult(JavaResolveResult delegate) {
|
||||
private DelegatingClassResolveResult(@NotNull JavaResolveResult delegate) {
|
||||
myDelegate = delegate;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiSubstitutor getSubstitutor() {
|
||||
return myDelegate.getSubstitutor();
|
||||
@@ -178,16 +179,19 @@ public class PsiClassReferenceType extends PsiClassType {
|
||||
return element == null ? this : new PsiImmediateClassType(element, resolveResult.getSubstitutor());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return getAnnotationsTextPrefix(false, false, true) + PsiNameHelper.getPresentableText(myReference);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getCanonicalText() {
|
||||
return myReference.getCanonicalText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return getAnnotationsTextPrefix(true, false, true) + getCanonicalText();
|
||||
|
||||
+4
-2
@@ -23,7 +23,6 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiManagerEx;
|
||||
import com.intellij.psi.impl.light.LightMethod;
|
||||
import com.intellij.psi.impl.source.resolve.ParameterTypeInferencePolicy;
|
||||
import com.intellij.psi.impl.source.resolve.ResolveCache;
|
||||
import com.intellij.psi.impl.source.tree.ChildRole;
|
||||
@@ -396,6 +395,7 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
return new MethodCandidateInfo(method, substitutor, !accessible, staticProblem, argumentList, myCurrentFileContext,
|
||||
argumentList != null ? argumentList.getExpressionTypes() : null, typeParameters.length > 0 ? typeParameters : null,
|
||||
getLanguageLevel()) {
|
||||
@NotNull
|
||||
@Override
|
||||
public PsiSubstitutor inferTypeArguments(@NotNull ParameterTypeInferencePolicy policy, boolean includeReturnConstraint) {
|
||||
return inferTypeArgumentsFromInterfaceMethod(signature, interfaceMethodReturnType, method, substitutor, languageLevel);
|
||||
@@ -423,6 +423,7 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
return JavaResolveResult.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private PsiSubstitutor inferTypeArgumentsFromInterfaceMethod(@Nullable MethodSignature signature,
|
||||
@Nullable PsiType interfaceMethodReturnType,
|
||||
PsiMethod method,
|
||||
@@ -467,7 +468,8 @@ public class PsiMethodReferenceExpressionImpl extends PsiReferenceExpressionBase
|
||||
languageLevel, getProject());
|
||||
}
|
||||
|
||||
private PsiSubstitutor getSubstitutor(PsiType type) {
|
||||
@NotNull
|
||||
private PsiSubstitutor getSubstitutor(@NotNull PsiType type) {
|
||||
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(GenericsUtil.eliminateWildcards(type));
|
||||
PsiSubstitutor psiSubstitutor = resolveResult.getSubstitutor();
|
||||
if (type instanceof PsiClassType) {
|
||||
|
||||
+1
@@ -74,6 +74,7 @@ public class GrAnonymousClassType extends GrLiteralClassType {
|
||||
return new GrAnonymousClassType(languageLevel, myScope, myFacade, myAnonymous);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return getCanonicalText();
|
||||
|
||||
+24
-1
@@ -40,6 +40,7 @@ public class GrClassReferenceType extends PsiClassType {
|
||||
myReferenceElement = referenceElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiClass resolve() {
|
||||
ResolveResult[] results = multiResolve();
|
||||
@@ -56,6 +57,7 @@ public class GrClassReferenceType extends PsiClassType {
|
||||
return myReferenceElement.multiResolve(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getClassName() {
|
||||
final PsiClass resolved = resolve();
|
||||
@@ -63,47 +65,58 @@ public class GrClassReferenceType extends PsiClassType {
|
||||
return myReferenceElement.getReferenceName();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiType[] getParameters() {
|
||||
return myReferenceElement.getTypeArguments();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public ClassResolveResult resolveGenerics() {
|
||||
final GroovyResolveResult resolveResult = myReferenceElement.advancedResolve();
|
||||
return new ClassResolveResult() {
|
||||
@Override
|
||||
public PsiClass getElement() {
|
||||
final PsiElement resolved = resolveResult.getElement();
|
||||
return resolved instanceof PsiClass ? (PsiClass)resolved : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiSubstitutor getSubstitutor() {
|
||||
return resolveResult.getSubstitutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPackagePrefixPackageReference() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAccessible() {
|
||||
return resolveResult.isAccessible();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStaticsScopeCorrect() {
|
||||
return resolveResult.isStaticsOK();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiElement getCurrentFileResolveScope() {
|
||||
return resolveResult.getCurrentFileResolveContext();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValidResult() {
|
||||
return isStaticsScopeCorrect() && isAccessible();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiClassType rawType() {
|
||||
final PsiClass clazz = resolve();
|
||||
@@ -115,38 +128,48 @@ public class GrClassReferenceType extends PsiClassType {
|
||||
return this;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return PsiNameHelper.getPresentableText(myReferenceElement.getReferenceName(), PsiAnnotation.EMPTY_ARRAY, myReferenceElement.getTypeArguments());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getCanonicalText() {
|
||||
return myReferenceElement.getCanonicalText();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return getCanonicalText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return myReferenceElement.isValid();
|
||||
}
|
||||
|
||||
public boolean equalsToText(@NonNls String text) {
|
||||
@Override
|
||||
public boolean equalsToText(@NotNull @NonNls String text) {
|
||||
return text.endsWith(getPresentableText()) && //optimization
|
||||
text.equals(getCanonicalText());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public GlobalSearchScope getResolveScope() {
|
||||
return myReferenceElement.getResolveScope();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public LanguageLevel getLanguageLevel() {
|
||||
return myLanguageLevel;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiClassType setLanguageLevel(@NotNull final LanguageLevel languageLevel) {
|
||||
return new GrClassReferenceType(myReferenceElement,languageLevel);
|
||||
|
||||
@@ -63,11 +63,13 @@ public class GrClosureType extends GrLiteralClassType {
|
||||
myTypeArgs = typeArgs;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getClassName() {
|
||||
return "Closure";
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiType[] getParameters() {
|
||||
if (myTypeArgs == null) {
|
||||
@@ -98,6 +100,7 @@ public class GrClosureType extends GrLiteralClassType {
|
||||
return GroovyCommonClassNames.GROOVY_LANG_CLOSURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiClassType rawType() {
|
||||
if (myTypeArgs != null && myTypeArgs.length == 0) {
|
||||
@@ -107,11 +110,13 @@ public class GrClosureType extends GrLiteralClassType {
|
||||
return new GrClosureType(getLanguageLevel(), getResolveScope(), myFacade, mySignature, false);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@NotNull
|
||||
public String getInternalCanonicalText() {
|
||||
return getCanonicalText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return mySignature.isValid();
|
||||
}
|
||||
@@ -124,10 +129,12 @@ public class GrClosureType extends GrLiteralClassType {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
public boolean equalsToText(@NonNls String text) {
|
||||
@Override
|
||||
public boolean equalsToText(@NotNull @NonNls String text) {
|
||||
return text != null && text.equals(GroovyCommonClassNames.GROOVY_LANG_CLOSURE);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiClassType setLanguageLevel(@NotNull final LanguageLevel languageLevel) {
|
||||
return new GrClosureType(languageLevel, myScope, myFacade, mySignature, myTypeArgs);
|
||||
|
||||
@@ -34,8 +34,8 @@ import static org.jetbrains.plugins.groovy.lang.psi.impl.statements.expressions.
|
||||
* @author Maxim.Medvedev
|
||||
*/
|
||||
public class GrRangeType extends GrLiteralClassType {
|
||||
private final @Nullable PsiType myLeft;
|
||||
private final @Nullable PsiType myRight;
|
||||
@Nullable private final PsiType myLeft;
|
||||
@Nullable private final PsiType myRight;
|
||||
private final PsiType myIterationType;
|
||||
private final String myQualifiedName;
|
||||
|
||||
@@ -97,6 +97,7 @@ public class GrRangeType extends GrLiteralClassType {
|
||||
return new GrRangeType(languageLevel, myScope, myFacade, myLeft, myRight);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return "[" +
|
||||
|
||||
@@ -50,11 +50,13 @@ public class GrTupleType extends GrLiteralClassType {
|
||||
return CommonClassNames.JAVA_UTIL_ARRAY_LIST;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getClassName() {
|
||||
return StringUtil.getShortName(getJavaClassName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiType[] getParameters() {
|
||||
return myParameters;
|
||||
@@ -67,6 +69,8 @@ public class GrTupleType extends GrLiteralClassType {
|
||||
return new PsiType[]{leastUpperBound};
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public String getInternalCanonicalText() {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
builder.append("[");
|
||||
@@ -83,6 +87,7 @@ public class GrTupleType extends GrLiteralClassType {
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
for (PsiType initializer : myComponentTypes) {
|
||||
if (initializer != null && !initializer.isValid()) return false;
|
||||
@@ -90,6 +95,7 @@ public class GrTupleType extends GrLiteralClassType {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public PsiClassType setLanguageLevel(@NotNull final LanguageLevel languageLevel) {
|
||||
return new GrTupleType(myComponentTypes, myFacade, myScope,languageLevel);
|
||||
@@ -106,6 +112,7 @@ public class GrTupleType extends GrLiteralClassType {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAssignableFrom(@NotNull PsiType type) {
|
||||
if (type instanceof GrTupleType) {
|
||||
PsiType[] otherComponents = ((GrTupleType) type).myComponentTypes;
|
||||
|
||||
+10
-4
@@ -78,11 +78,13 @@ public class GroovyPsiManager {
|
||||
myProject = project;
|
||||
|
||||
((PsiManagerEx)PsiManager.getInstance(myProject)).registerRunnableToRunOnAnyChange(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
dropTypesCache();
|
||||
}
|
||||
});
|
||||
((PsiManagerEx)PsiManager.getInstance(myProject)).registerRunnableToRunOnChange(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
myClassCache.clear();
|
||||
}
|
||||
@@ -90,6 +92,7 @@ public class GroovyPsiManager {
|
||||
|
||||
final MessageBusConnection connection = myProject.getMessageBus().connect();
|
||||
connection.subscribe(ProjectTopics.PROJECT_ROOTS, new ModuleRootAdapter() {
|
||||
@Override
|
||||
public void rootsChanged(ModuleRootEvent event) {
|
||||
dropTypesCache();
|
||||
myClassCache.clear();
|
||||
@@ -188,19 +191,22 @@ public class GroovyPsiManager {
|
||||
|
||||
|
||||
private static final PsiType UNKNOWN_TYPE = new PsiType(PsiAnnotation.EMPTY_ARRAY) {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return null;
|
||||
return "?";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getCanonicalText() {
|
||||
return null;
|
||||
return "?";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return null;
|
||||
return "?";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -209,7 +215,7 @@ public class GroovyPsiManager {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsToText(@NonNls String text) {
|
||||
public boolean equalsToText(@NotNull @NonNls String text) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
+7
-4
@@ -28,19 +28,22 @@ import org.jetbrains.annotations.Nullable;
|
||||
public class GrMethodWrapper extends GrLightMethodBuilder {
|
||||
|
||||
private static final PsiType TYPE_MARKER = new PsiType(PsiAnnotation.EMPTY_ARRAY) {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
return null;
|
||||
return "?";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getCanonicalText() {
|
||||
return null;
|
||||
return "?";
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getInternalCanonicalText() {
|
||||
return null;
|
||||
return "?";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -49,7 +52,7 @@ public class GrMethodWrapper extends GrLightMethodBuilder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equalsToText(@NonNls String text) {
|
||||
public boolean equalsToText(@NotNull @NonNls String text) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user