test: extract method annotations

GitOrigin-RevId: 5ee84ec5206ded06637d9b08026e8dc7bdfff1f0
This commit is contained in:
Alexandr Suhinin
2020-04-14 16:02:49 +00:00
committed by intellij-monorepo-bot
parent 0e253bc715
commit cb6aaaed97
11 changed files with 139 additions and 2 deletions
@@ -0,0 +1,15 @@
import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.Nls;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@Target({ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.PARAMETER})
@interface Anno {}
class Test {
String test(@Anno @Language("HTML") @Nls String sample){
sample = "<html>EOF</html>";
<selection>return sample;</selection>
}
}
@@ -0,0 +1,21 @@
import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.Nls;
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@Target({ElementType.FIELD, ElementType.LOCAL_VARIABLE, ElementType.PARAMETER})
@interface Anno {}
class Test {
String test(@Anno @Language("HTML") @Nls String sample){
sample = "<html>EOF</html>";
return newMethod(sample);
}
@Language("HTML")
@Nls
private String newMethod(@Language("HTML") @Nls String sample) {
return sample;
}
}
@@ -0,0 +1,13 @@
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@Target({ElementType.LOCAL_VARIABLE})
@interface Anno {}
class Test {
void test() {
<selection>@Anno String s;
s = "";</selection>
s = "external assign";
}
}
@@ -0,0 +1,18 @@
import java.lang.annotation.ElementType;
import java.lang.annotation.Target;
@Target({ElementType.LOCAL_VARIABLE})
@interface Anno {}
class Test {
void test() {
newMethod();
@Anno String s;
s = "external assign";
}
private void newMethod() {
@Anno String s;
s = "";
}
}
@@ -0,0 +1,9 @@
import org.jetbrains.annotations.Nullable;
class Test {
void test(){
@Nullable String s = null;
if (s == null) return;
<selection>System.out.println(s);</selection>
}
}
@@ -0,0 +1,14 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class Test {
void test(){
@Nullable String s = null;
if (s == null) return;
newMethod(s);
}
private void newMethod(@NotNull String s) {
System.out.println(s);
}
}
@@ -0,0 +1,13 @@
import org.jetbrains.annotations.Nullable;
class Test {
static class A {
static class B {}
}
void test(){
@Nullable A.B x = new A.B();
if (x == null) return;
<selection>System.out.println(x);</selection>
}
}
@@ -0,0 +1,18 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
class Test {
static class A {
static class B {}
}
void test(){
@Nullable A.B x = new A.B();
if (x == null) return;
newMethod(x);
}
private void newMethod(A.@NotNull B x) {
System.out.println(x);
}
}
@@ -17,7 +17,7 @@ class Test {
newMethod(s);
}
private void newMethod(@Anno String s) {
private void newMethod(String s) {
if (s == null) {}
}
}
@@ -1208,7 +1208,23 @@ public class ExtractMethodNewTest extends LightJavaCodeInsightTestCase {
doTest();
}
public void testTypeUseAnnotationsOnParameter() throws Exception {
public void testSkipCustomAnnotations() throws Exception {
doTest();
}
public void testNullabilityIsTypeAnnotation() throws Exception {
doTest();
}
public void testKeepDeclarationWithAnnotations() throws Exception {
doTest();
}
public void testFilterAnnotations() throws Exception {
doTest();
}
public void testNullabilityAnnotationOverridden() throws Exception {
doTest();
}