mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IG: avoid NPE
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -105,9 +105,15 @@ public abstract class LightInspectionTestCase extends LightCodeInsightFixtureTes
|
||||
if (text.isEmpty()) {
|
||||
newText.append("</warning>");
|
||||
}
|
||||
else if ("!".equals(text)) {
|
||||
newText.append("</error>");
|
||||
}
|
||||
else if ("_".equals(text)) {
|
||||
newText.append("<caret>");
|
||||
}
|
||||
else if (text.startsWith("!")) {
|
||||
newText.append("<error descr=\"").append(text.substring(1)).append("\">");
|
||||
}
|
||||
else {
|
||||
newText.append("<warning descr=\"").append(text).append("\">");
|
||||
}
|
||||
|
||||
+3
@@ -130,6 +130,9 @@ public class AtomicFieldUpdaterIssuesInspection extends BaseInspection {
|
||||
final PsiClassObjectAccessExpression objectAccessExpression = (PsiClassObjectAccessExpression)argument2;
|
||||
final PsiType type = objectAccessExpression.getOperand().getType();
|
||||
final PsiType substFieldType = classType.resolveGenerics().getSubstitutor().substitute(field.getType());
|
||||
if (substFieldType == null) {
|
||||
return;
|
||||
}
|
||||
if (!substFieldType.isAssignableFrom(type)) {
|
||||
registerError(lastArgument, InspectionGadgetsBundle.message("field.incorrect.type.problem.descriptor",
|
||||
fieldName, type.getPresentableText()));
|
||||
|
||||
+9
@@ -124,6 +124,15 @@ public class AtomicFieldUpdaterIssuesInspectionTest extends LightInspectionTestC
|
||||
"}");
|
||||
}
|
||||
|
||||
public void testAvoidNPE() {
|
||||
doTest("import java.util.concurrent.atomic.AtomicReferenceFieldUpdater;\n" +
|
||||
"class Z</*!Cyclic inheritance involving 'T'*//*!*/T extends T> {\n" +
|
||||
" private T value = null;\n" +
|
||||
" private static final AtomicReferenceFieldUpdater updater = \n" +
|
||||
" AtomicReferenceFieldUpdater.newUpdater(Z.class, Object.class, \"value\");\n" +
|
||||
"}");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected InspectionProfileEntry getInspection() {
|
||||
|
||||
Reference in New Issue
Block a user