Java inspection: Added a fix for single-value annotations where the annotation doesn't have a 'value()' method and therefore "Expand Annotation to Normal Form" fix couldn't be applied (IDEA-158456, IDEA-157727)

This commit is contained in:
Pavel Dolgov
2016-07-20 13:33:13 +03:00
parent e261b412a4
commit 3773948686
16 changed files with 309 additions and 2 deletions
@@ -0,0 +1,10 @@
// "Add 'type='" "true"
class T {
@interface A {
String[] type();
}
@A(type = "t")
void foo() {
}
}
@@ -0,0 +1,11 @@
// "Add 'name='" "true"
class T {
@interface A {
int size();
String name();
}
@A(name = "a")
void foo() {
}
}
@@ -0,0 +1,11 @@
// "Add 'type='" "true"
class T {
@interface A {
String name();
String type();
}
@A(type = "a", name = "b")
void foo() {
}
}
@@ -0,0 +1,10 @@
// "Add 'type='" "true"
class T {
@interface A {
String[] type();
}
@A(<caret>"t")
void foo() {
}
}
@@ -0,0 +1,11 @@
// "Add 'name='" "true"
class T {
@interface A {
int size();
String name();
}
@A(<caret>"a")
void foo() {
}
}
@@ -0,0 +1,11 @@
// "Add 'type='" "true"
class T {
@interface A {
String name();
String type();
}
@A(<caret>"a", name = "b")
void foo() {
}
}
@@ -0,0 +1,11 @@
// "Add 'name='" "false"
class T {
@interface A {
String name();
String type();
}
@A(<caret>"a", name = "b")
void foo() {
}
}
@@ -0,0 +1,10 @@
// "Add 'type='" "false"
class T {
@interface A {
String[] type();
}
@A(<caret>42)
void foo() {
}
}
@@ -0,0 +1,10 @@
// "Add 'size='" "false"
class T {
@interface A {
int size();
}
@A(<caret>"a")
void foo() {
}
}
@@ -0,0 +1,38 @@
/*
* 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.
* 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.
*/
package com.intellij.codeInsight.daemon.quickFix;
import com.intellij.openapi.projectRoots.Sdk;
import com.intellij.testFramework.IdeaTestUtil;
/**
* @author Pavel.Dolgov
*/
public class AddAnnotationAttributeNameTest extends LightQuickFixParameterizedTestCase {
public void test() throws Exception {
doAllTests();
}
@Override
protected String getBasePath() {
return "/codeInsight/daemonCodeAnalyzer/quickFix/addAnnotationAttributeName";
}
@Override
protected Sdk getProjectJDK() {
return IdeaTestUtil.getMockJdk18();
}
}