mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 04:51:24 +07:00
[java-incomplete-model] Support declared but unresolved exceptions
GitOrigin-RevId: 2e493f1820ce2e676708e191c0ff0b72b4ecaa59
This commit is contained in:
committed by
intellij-monorepo-bot
parent
f570494f4a
commit
15bb3eb9f4
@@ -927,15 +927,12 @@ public final class HighlightUtil {
|
||||
static HighlightInfo.Builder checkUnhandledExceptions(@NotNull PsiElement element) {
|
||||
List<PsiClassType> unhandled = ExceptionUtil.getOwnUnhandledExceptions(element);
|
||||
if (unhandled.isEmpty()) return null;
|
||||
unhandled = ContainerUtil.filter(unhandled, type -> type.resolve() != null);
|
||||
if (unhandled.isEmpty()) return null;
|
||||
|
||||
HighlightInfoType highlightType = getUnhandledExceptionHighlightType(element);
|
||||
if (highlightType == null) return null;
|
||||
|
||||
if (IncompleteModelUtil.isIncompleteModel(element)) {
|
||||
unhandled = ContainerUtil.filter(unhandled, type -> !IncompleteModelUtil.isUnresolvedClassType(type));
|
||||
if (unhandled.isEmpty()) return null;
|
||||
}
|
||||
|
||||
TextRange textRange = computeRange(element);
|
||||
String description = getUnhandledExceptionsDescriptor(unhandled);
|
||||
HighlightInfo.Builder info = HighlightInfo.newHighlightInfo(highlightType).range(textRange).descriptionAndTooltip(description);
|
||||
|
||||
@@ -628,9 +628,8 @@ public final class ExceptionUtil {
|
||||
if (!(type instanceof PsiClassType)) continue;
|
||||
PsiClassType classType = (PsiClassType)type;
|
||||
PsiClass exceptionClass = ((PsiClassType)type).resolve();
|
||||
if (exceptionClass == null) continue;
|
||||
if (exceptionClass != null && isUncheckedException(classType)) continue;
|
||||
|
||||
if (isUncheckedException(classType)) continue;
|
||||
if (getHandlePlace(element, classType, topElement) != HandlePlace.UNHANDLED) continue;
|
||||
|
||||
result.add((PsiClassType)type);
|
||||
|
||||
@@ -142,6 +142,21 @@ public class Simple {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void testThrow2() {
|
||||
try {
|
||||
declaredUnknownException();
|
||||
}
|
||||
catch (<info descr="Not resolved until the project is fully loaded">Cls</info> x) {}
|
||||
}
|
||||
|
||||
void testThrow3() {
|
||||
// We don't know whether Cls is checked or not
|
||||
declaredUnknownException();
|
||||
}
|
||||
|
||||
void declaredUnknownException() throws <info descr="Not resolved until the project is fully loaded">Cls</info> {}
|
||||
|
||||
void testConcat(<info descr="Not resolved until the project is fully loaded">Cls</info> cls) {
|
||||
System.out.println("hello " + cls.<info descr="Not resolved until the project is fully loaded">getSomething</info>() + "!!!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user