IDEA-54396 (type annotations in "Wrap Return Value")

This commit is contained in:
Roman Shevchenko
2014-03-11 15:07:58 +01:00
parent b360456894
commit 3f3e06483b
6 changed files with 40 additions and 5 deletions
@@ -96,12 +96,12 @@ class ReturnValueBeanBuilder {
}
private void outputField(StringBuilder out) {
final String typeText = myValueType.getCanonicalText();
final String typeText = myValueType.getCanonicalText(false);
out.append('\t' + "private final ").append(typeText).append(' ').append(getFieldName("value")).append(";");
}
private void outputConstructor(StringBuilder out) {
final String typeText = myValueType.getCanonicalText();
final String typeText = myValueType.getCanonicalText(true);
final String name = "value";
final String parameterName = JavaCodeStyleManager.getInstance(myProject).propertyNameToVariableName(name, VariableKind.PARAMETER);
final String fieldName = getFieldName(name);
@@ -119,7 +119,7 @@ class ReturnValueBeanBuilder {
}
private void outputGetter(StringBuilder out) {
final String typeText = myValueType.getCanonicalText();
final String typeText = myValueType.getCanonicalText(true);
final String name = "value";
final String capitalizedName = StringUtil.capitalize(name);
final String fieldName = getFieldName(name);
@@ -762,7 +762,7 @@ public class PsiImplUtil {
private static final Key<Boolean> TYPE_ANNO_MARK = Key.create("type.annotation.mark");
public static void markTypeAnnotations(@NotNull PsiTypeElement typeElement) {
PsiElement left = PsiTreeUtil.skipSiblingsBackward(typeElement, PsiComment.class, PsiWhiteSpace.class, PsiAnnotation.class);
PsiElement left = PsiTreeUtil.skipSiblingsBackward(typeElement, PsiComment.class, PsiWhiteSpace.class, PsiTypeParameterList.class);
if (left instanceof PsiModifierList) {
for (PsiAnnotation annotation : ((PsiModifierList)left).getAnnotations()) {
if (isTypeAnnotation(annotation)) {
@@ -773,7 +773,7 @@ public class PsiImplUtil {
}
public static void deleteTypeAnnotations(@NotNull PsiTypeElement typeElement) {
PsiElement left = PsiTreeUtil.skipSiblingsBackward(typeElement, PsiComment.class, PsiWhiteSpace.class, PsiAnnotation.class);
PsiElement left = PsiTreeUtil.skipSiblingsBackward(typeElement, PsiComment.class, PsiWhiteSpace.class, PsiTypeParameterList.class);
if (left instanceof PsiModifierList) {
for (PsiAnnotation annotation : ((PsiModifierList)left).getAnnotations()) {
if (TYPE_ANNO_MARK.get(annotation) == Boolean.TRUE) {
@@ -0,0 +1,10 @@
import java.lang.annotation.*;
@Target({ElementType.TYPE_USE})
@interface TA { }
class Test {
Wrapper foo() {
return new Wrapper(null);
}
}
@@ -0,0 +1,13 @@
import java.util.List;
public class Wrapper {
private final List<String> value;
public Wrapper(@TA List<@TA String> value) {
this.value = value;
}
public @TA List<@TA String> getValue() {
return value;
}
}
@@ -0,0 +1,11 @@
import java.lang.annotation.*;
import java.util.*;
@Target({ElementType.TYPE_USE})
@interface TA { }
class Test {
@TA List<@TA String> foo() {
return null;
}
}
@@ -54,6 +54,7 @@ public class WrapReturnValueTest extends MultiFileTestCase {
public void testStaticMethodInnerClass() { doTest(false, null, true); }
public void testRawReturnType() { doTest(true, "Existing class does not have appropriate constructor"); }
public void testReturnInsideLambda() { doTest(false, null, true); }
public void testTypeAnnotations() { doTest(false); }
private void doTest(final boolean existing) {
doTest(existing, null);