mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
java PIEAE diagnostics, blame plugins where possible (EA-135158, EA-135126, EA-135093, EA-134991)
This commit is contained in:
+9
-1
@@ -6,6 +6,7 @@ import com.intellij.codeInsight.JavaTargetElementEvaluator;
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
import com.intellij.codeInsight.daemon.impl.analysis.JavaHighlightUtil;
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.find.FindManager;
|
||||
import com.intellij.find.findUsages.FindUsagesHandler;
|
||||
import com.intellij.find.findUsages.FindUsagesManager;
|
||||
@@ -316,7 +317,14 @@ public class ChangeMethodSignatureFromUsageFix implements IntentionAction/*, Hig
|
||||
PsiExpression expression = expressions[i];
|
||||
PsiType bareParamType = parameter.getType();
|
||||
if (!bareParamType.isValid()) {
|
||||
PsiUtil.ensureValidType(bareParamType, parameter.getClass() + "; valid=" + parameter.isValid() + "; method.valid=" + targetMethod.isValid());
|
||||
try {
|
||||
PsiUtil.ensureValidType(bareParamType);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
throw PluginException.createByClass(
|
||||
parameter.getClass() + "; valid=" + parameter.isValid() + "; method.valid=" + targetMethod.isValid(),
|
||||
e, parameter.getClass());
|
||||
}
|
||||
}
|
||||
PsiType paramType = substitutor.substitute(bareParamType);
|
||||
PsiUtil.ensureValidType(paramType);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.psi.augment;
|
||||
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.extensions.ExtensionPointName;
|
||||
import com.intellij.openapi.progress.ProcessCanceledException;
|
||||
@@ -12,6 +13,7 @@ import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiModifierList;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.PsiTypeElement;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.util.Processor;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -82,6 +84,12 @@ public abstract class PsiAugmentProvider {
|
||||
forEach(typeElement.getProject(), provider -> {
|
||||
PsiType type = provider.inferType(typeElement);
|
||||
if (type != null) {
|
||||
try {
|
||||
PsiUtil.ensureValidType(type);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
throw PluginException.createByClass(e.getMessage(), e, provider.getClass());
|
||||
}
|
||||
result.set(type);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi.util;
|
||||
|
||||
import com.intellij.diagnostic.PluginException;
|
||||
import com.intellij.psi.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -76,8 +77,13 @@ public class MethodSignatureBackedByPsiMethod extends MethodSignatureBase {
|
||||
substitutor = JavaPsiFacade.getElementFactory(method.getProject()).createRawSubstitutor(substitutor, methodTypeParameters);
|
||||
methodTypeParameters = PsiTypeParameter.EMPTY_ARRAY;
|
||||
}
|
||||
|
||||
assert substitutor.isValid();
|
||||
|
||||
try {
|
||||
substitutor.ensureValid();
|
||||
}
|
||||
catch (Throwable e) {
|
||||
throw PluginException.createByClass(e.getMessage(), e, method.getClass());
|
||||
}
|
||||
|
||||
final PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||
PsiType[] parameterTypes = PsiType.createArray(parameters.length);
|
||||
|
||||
@@ -19,10 +19,10 @@ import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.augment.PsiAugmentProvider;
|
||||
import com.intellij.psi.impl.light.LightClassReference;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.SmartList;
|
||||
@@ -189,7 +189,9 @@ public class PsiClassReferenceType extends PsiClassType.Stub {
|
||||
@NotNull
|
||||
public ClassResolveResult resolveGenerics() {
|
||||
PsiJavaCodeReferenceElement reference = getReference();
|
||||
PsiUtilCore.ensureValid(reference);
|
||||
if (!reference.isValid()) {
|
||||
throw new PsiInvalidElementAccessException(reference, myReference.toString() + "; augmenters=" + PsiAugmentProvider.EP_NAME.getExtensionList());
|
||||
}
|
||||
final JavaResolveResult result = reference.advancedResolve(false);
|
||||
return result.getElement() == null ? ClassResolveResult.EMPTY : new DelegatingClassResolveResult(result);
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Computable<PsiJavaCodeReferenceElement> computeFromTypeOwner(final PsiElement parent, @NotNull WeakReference<PsiJavaCodeReferenceElement> ref) {
|
||||
private static Computable<PsiJavaCodeReferenceElement> computeFromTypeOwner(PsiElement parent, @NotNull WeakReference<PsiJavaCodeReferenceElement> ref) {
|
||||
return new Computable<PsiJavaCodeReferenceElement>() {
|
||||
volatile WeakReference<PsiJavaCodeReferenceElement> myCache = ref;
|
||||
|
||||
@@ -247,6 +247,12 @@ public class PsiTypeElementImpl extends CompositePsiElement implements PsiTypeEl
|
||||
: ((PsiVariable)parent).getTypeElement();
|
||||
return (PsiTypeElementImpl)ObjectUtils.assertNotNull(typeElement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
String msg = "Type element reference of " + parent.getClass() + " #" + parent.getClass().getSimpleName();
|
||||
return parent.isValid() ? msg + " #" + parent.getLanguage() : msg + ", invalid";
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,11 @@ public interface Computable <T> {
|
||||
public T compute() {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "PredefinedValueComputable{" + myValue + "}";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user