mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-26 19:06:24 +07:00
IDEA-62374 Suggest ternary operation to avoid NPE implemented
This commit is contained in:
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'list != null ?:'" "true"
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class A{
|
||||
void test(@NotNull List l) {
|
||||
final List list = null;
|
||||
test(list != null ? list : <selection>null</selection>);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'integer != null ?:'" "true"
|
||||
|
||||
import java.lang.Integer;
|
||||
|
||||
class A{
|
||||
void test(){
|
||||
Integer integer = null;
|
||||
int i = integer != null ? integer.intValue() : <selection>0</selection>;
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Replace with 'list != null ?:'" "true"
|
||||
|
||||
class A{
|
||||
void test(){
|
||||
List list = null;
|
||||
Object o = list != null ? list.get(0) : <selection>null</selection>;
|
||||
}
|
||||
}
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
// "Replace with 'list != null ?:'" "false"
|
||||
class A{
|
||||
void test(){
|
||||
List list = null;
|
||||
li<caret>st.get(0);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'list != null ?:'" "true"
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
class A{
|
||||
void test(@NotNull List l) {
|
||||
final List list = null;
|
||||
test(li<caret>st);
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// "Replace with 'integer != null ?:'" "true"
|
||||
|
||||
import java.lang.Integer;
|
||||
|
||||
class A{
|
||||
void test(){
|
||||
Integer integer = null;
|
||||
int i = in<caret>teger.intValue();
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Replace with 'list != null ?:'" "true"
|
||||
|
||||
class A{
|
||||
void test(){
|
||||
List list = null;
|
||||
Object o = li<caret>st.get(0);
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2000-2012 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* User: anna
|
||||
* Date: 21-Mar-2008
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.dataFlow.DataFlowInspection;
|
||||
import com.intellij.codeInspection.nullable.NullableStuffInspection;
|
||||
|
||||
public class ReplaceWithTernaryOperatorTest extends LightQuickFixTestCase {
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[]{new DataFlowInspection(), new NullableStuffInspection()};
|
||||
}
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/replaceWithTernaryOperator";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user