mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-30 02:09:59 +07:00
unhandled exception: shrink the highlighted range (IDEA-177234)
This commit is contained in:
@@ -381,17 +381,17 @@ public class HighlightMethodUtil {
|
||||
|
||||
final PsiSubstitutor substitutor = resolveResult.getSubstitutor();
|
||||
if (resolved instanceof PsiMethod && resolveResult.isValidResult()) {
|
||||
PsiElement nameElement = referenceToMethod.getReferenceNameElement();
|
||||
TextRange fixRange = getFixRange(methodCall);
|
||||
highlightInfo = HighlightUtil.checkUnhandledExceptions(methodCall, fixRange);
|
||||
highlightInfo = HighlightUtil.checkUnhandledExceptions(methodCall, nameElement != null ? new TextRange(nameElement.getTextOffset(), fixRange.getEndOffset()) : fixRange);
|
||||
|
||||
if (highlightInfo == null && ((PsiMethod)resolved).hasModifierProperty(PsiModifier.STATIC)) {
|
||||
PsiClass containingClass = ((PsiMethod)resolved).getContainingClass();
|
||||
if (containingClass != null && containingClass.isInterface()) {
|
||||
PsiReferenceExpression methodRef = methodCall.getMethodExpression();
|
||||
PsiElement element = ObjectUtils.notNull(methodRef.getReferenceNameElement(), methodRef);
|
||||
PsiElement element = ObjectUtils.notNull(referenceToMethod.getReferenceNameElement(), referenceToMethod);
|
||||
highlightInfo = HighlightUtil.checkFeature(element, HighlightUtil.Feature.STATIC_INTERFACE_CALLS, languageLevel, file);
|
||||
if (highlightInfo == null) {
|
||||
String message = checkStaticInterfaceMethodCallQualifier(methodRef, resolveResult.getCurrentFileResolveScope(), containingClass);
|
||||
String message = checkStaticInterfaceMethodCallQualifier(referenceToMethod, resolveResult.getCurrentFileResolveScope(), containingClass);
|
||||
if (message != null) {
|
||||
highlightInfo = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).descriptionAndTooltip(message).range(fixRange).create();
|
||||
}
|
||||
@@ -460,14 +460,13 @@ public class HighlightMethodUtil {
|
||||
}
|
||||
}
|
||||
else {
|
||||
PsiReferenceExpression methodExpression = methodCall.getMethodExpression();
|
||||
PsiReferenceParameterList typeArgumentList = methodCall.getTypeArgumentList();
|
||||
PsiSubstitutor applicabilitySubstitutor = candidateInfo.getSubstitutor(false);
|
||||
if (typeArgumentList.getTypeArguments().length == 0 && resolvedMethod.hasTypeParameters()) {
|
||||
highlightInfo = GenericsHighlightUtil.checkInferredTypeArguments(resolvedMethod, methodCall, applicabilitySubstitutor);
|
||||
}
|
||||
else {
|
||||
highlightInfo = GenericsHighlightUtil.checkParameterizedReferenceTypeArguments(resolved, methodExpression, applicabilitySubstitutor, javaSdkVersion);
|
||||
highlightInfo = GenericsHighlightUtil.checkParameterizedReferenceTypeArguments(resolved, referenceToMethod, applicabilitySubstitutor, javaSdkVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,10 @@ interface I<T extends Exception> {
|
||||
|
||||
class C {
|
||||
void x(I<?> i) {
|
||||
<error descr="Unhandled exception: java.lang.Exception">i.m();</error>
|
||||
i.<error descr="Unhandled exception: java.lang.Exception">m();</error>
|
||||
}
|
||||
|
||||
void y(I<? extends Exception> i) {
|
||||
<error descr="Unhandled exception: java.lang.Exception">i.m();</error>
|
||||
i.<error descr="Unhandled exception: java.lang.Exception">m();</error>
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ public class ExTest {
|
||||
}
|
||||
|
||||
{
|
||||
Block<String> b = (t) -> <error descr="Unhandled exception: ExTest.Ex">ExTest.maybeThrow(t)</error>;
|
||||
Block<String> b = (t) -> ExTest.<error descr="Unhandled exception: ExTest.Ex">maybeThrow(t)</error>;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,6 @@ class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Iterable<Consumer<Reader>> i = Arrays.asList(<error descr="Unhandled exception: IOException">(r) -> r.read()</error>);
|
||||
Iterable<Consumer<Reader>> i1 = Arrays.<Consumer<Reader>>asList((r) -> <error descr="Unhandled exception: java.io.IOException">r.read()</error>);
|
||||
Iterable<Consumer<Reader>> i1 = Arrays.<Consumer<Reader>>asList((r) -> r.<error descr="Unhandled exception: java.io.IOException">read()</error>);
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ public class c1 {
|
||||
try {
|
||||
fis = new FileInputStream("");
|
||||
DataInputStream dis = new DataInputStream(fis);
|
||||
<caret>dis.readInt();
|
||||
dis.<caret>readInt();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public class c1 {
|
||||
try {
|
||||
fis = new FileInputStream("");
|
||||
DataInputStream dis = new DataInputStream(fis);
|
||||
<caret>dis.readInt();
|
||||
dis.<caret>readInt();
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ void caught() {
|
||||
}
|
||||
|
||||
void uncaught() {
|
||||
<error descr="Unhandled exception: java.lang.IllegalArgumentException">foo.Foo.libraryMethod();</error>
|
||||
foo.Foo.<error descr="Unhandled exception: java.lang.IllegalArgumentException">libraryMethod();</error>
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user