mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
test: extract method annotations
GitOrigin-RevId: 5ee84ec5206ded06637d9b08026e8dc7bdfff1f0
This commit is contained in:
committed by
intellij-monorepo-bot
parent
0e253bc715
commit
cb6aaaed97
@@ -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;
|
||||
}
|
||||
}
|
||||
+13
@@ -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";
|
||||
}
|
||||
}
|
||||
+18
@@ -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 = "";
|
||||
}
|
||||
}
|
||||
+9
@@ -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>
|
||||
}
|
||||
}
|
||||
+14
@@ -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);
|
||||
}
|
||||
}
|
||||
+13
@@ -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>
|
||||
}
|
||||
}
|
||||
+18
@@ -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);
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user