mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
don't suggest to replace annotated type elements with diamond (IDEA-207586)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2017 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.
|
||||
// Copyright 2000-2019 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.codeInspection;
|
||||
|
||||
import com.intellij.codeInsight.daemon.GroupNames;
|
||||
@@ -52,6 +52,11 @@ public class ExplicitTypeCanBeDiamondInspection extends AbstractBaseJavaLocalIns
|
||||
LOG.assertTrue(classReference != null);
|
||||
final PsiReferenceParameterList parameterList = classReference.getParameterList();
|
||||
LOG.assertTrue(parameterList != null);
|
||||
for (PsiTypeElement typeElement : parameterList.getTypeParameterElements()) {
|
||||
if (typeElement.getAnnotations().length > 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
final PsiElement firstChild = parameterList.getFirstChild();
|
||||
final PsiElement lastChild = parameterList.getLastChild();
|
||||
final TextRange range = new TextRange(firstChild != null && firstChild.getNode().getElementType() == JavaTokenType.LT ? 1 : 0,
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
// "Replace with <>" "false"
|
||||
class XYZ {
|
||||
@Target({ElementType.TYPE_USE, ElementType.METHOD})
|
||||
public @interface Nullable {}
|
||||
|
||||
public final static class Wrapper<T> {
|
||||
private final T value;
|
||||
|
||||
public Wrapper(T value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@Nullable
|
||||
public static String getString() {
|
||||
return ThreadLocalRandom.current().nextBoolean() ? "hello" : null;
|
||||
}
|
||||
|
||||
public static <T> void genericConsumer(T item) {}
|
||||
|
||||
public static void main(String[] args) {
|
||||
genericConsumer(new Wrapper<@Nullable<caret>s String>(getString()));
|
||||
// below one works great
|
||||
Wrapper<@Nullable String> wrapper = new Wrapper<>(getString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user