mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-09 15:41:26 +07:00
more java tests moved to community
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
final String a = <flown11>args[0];
|
||||
final String b = args[1];
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
System.out.println(f(<flown1>a, b));
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
|
||||
private static String f(String a, String b) {
|
||||
return <caret>a + b;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class V {
|
||||
{
|
||||
int i;
|
||||
i<caret>= <flown1>1;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
class Pair<A, B> {
|
||||
public final A first;
|
||||
public final B second;
|
||||
|
||||
public Pair(A first, B second) {
|
||||
this.first = <flown111>first;
|
||||
this.second = second;
|
||||
}
|
||||
|
||||
public final A getFirst() {
|
||||
return <flown11>first;
|
||||
}
|
||||
|
||||
public final B getSecond() {
|
||||
return second;
|
||||
}
|
||||
|
||||
public static <A, B> Pair<A, B> create(A first, B second) {
|
||||
return new Pair<A,B>(<flown1111>first, second);
|
||||
}
|
||||
|
||||
public final boolean equals(Object o){
|
||||
return o instanceof Pair && false;
|
||||
}
|
||||
|
||||
public final int hashCode(){
|
||||
int hashCode = 0;
|
||||
if (first != null){
|
||||
hashCode += hashCode(first);
|
||||
}
|
||||
if (second != null){
|
||||
hashCode += hashCode(second);
|
||||
}
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
private static int hashCode(final Object o) {
|
||||
return o.hashCode();
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return "<" + first + "," + second + ">";
|
||||
}
|
||||
}
|
||||
class Ref<T> {
|
||||
private T myValue;
|
||||
|
||||
public Ref() { }
|
||||
|
||||
public Ref(T value) {
|
||||
myValue = value;
|
||||
}
|
||||
|
||||
public boolean isNull () {
|
||||
return myValue == null;
|
||||
}
|
||||
|
||||
public T get () {
|
||||
return myValue;
|
||||
}
|
||||
|
||||
public void set (T value) {
|
||||
myValue = value;
|
||||
}
|
||||
|
||||
public static <T> Ref<T> create(T value) {
|
||||
return new Ref<T>(value);
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return myValue == null ? null : myValue.toString();
|
||||
}
|
||||
}
|
||||
class PsiVariable {}
|
||||
class PsiField extends PsiVariable {}
|
||||
|
||||
class S {
|
||||
private static Pair<boolean[], Boolean> parseFlags(final String string) {
|
||||
boolean returnFlag = false;
|
||||
final boolean[] result = new boolean[0];
|
||||
return Pair.create(result, returnFlag);
|
||||
}
|
||||
void psiflow() {
|
||||
Ref<Pair<PsiField, Boolean>> anchorRef = new Ref<Pair<PsiField, Boolean>>();
|
||||
Pair<PsiField, Boolean> fieldAnchor = anchorRef.get();
|
||||
|
||||
PsiVariable <caret>psiVariable = <flown1>fieldAnchor.getFirst();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
class s {
|
||||
{
|
||||
x(<flown11211>"xxx");
|
||||
}
|
||||
String x(String g) {
|
||||
String d = <flown1>foo(<flown1121>g);
|
||||
return <caret>d;
|
||||
}
|
||||
|
||||
private String foo(String i) {
|
||||
return <flown11>i==null ? <flown111>null : <flown112>i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
final String a = <flown1121>args[0];
|
||||
final String b = <flown11>Test.class == null ? <flown111>args[1] : <flown112>a;
|
||||
new Runnable() {
|
||||
public void run() {
|
||||
System.out.println(f(a, <flown1>b));
|
||||
}
|
||||
}.run();
|
||||
}
|
||||
|
||||
private static String f(String a, String b) {
|
||||
return a + <caret>b;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
public class X {
|
||||
String <caret>l;
|
||||
{
|
||||
l = null;
|
||||
}
|
||||
{
|
||||
l = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
public class DupSlice {
|
||||
int <caret>field;
|
||||
|
||||
void multiply(int fp) {
|
||||
this.field = fp;
|
||||
multiplay2(1111111111);
|
||||
}
|
||||
|
||||
void multiplay2(int i) {
|
||||
field = i;
|
||||
multiply(i);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
class Test {
|
||||
boolean <caret>fie;
|
||||
int f(T t) {
|
||||
fie = t.t;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void g(T t) {
|
||||
// t.t = false;
|
||||
fie = true;
|
||||
}
|
||||
void h(T t) {
|
||||
boolean t1 = t.t;
|
||||
try {
|
||||
t.t = false;
|
||||
g(t);
|
||||
}
|
||||
finally {
|
||||
t.t = t1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class T {
|
||||
public boolean t = true;
|
||||
|
||||
public boolean isT() {
|
||||
isT();
|
||||
return t;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
public class X {
|
||||
String <caret>l;
|
||||
|
||||
public X() {
|
||||
fs("oo", this);
|
||||
}
|
||||
|
||||
void fs(String t, X x)
|
||||
{
|
||||
x.set(t);
|
||||
}
|
||||
//
|
||||
void set(String d) {
|
||||
l = d;
|
||||
}
|
||||
}
|
||||
|
||||
class XX extends X {
|
||||
void fs(String t, X x) {
|
||||
x.fs(t, x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
enum M {
|
||||
X(<flown1>999);
|
||||
|
||||
M(int <caret>i) {
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
public class Boxi {
|
||||
private interface Foo<T> {
|
||||
T t();
|
||||
}
|
||||
|
||||
{
|
||||
Foo<String> a = new Foo<String>() {
|
||||
public String t() {
|
||||
return "a";
|
||||
}
|
||||
};
|
||||
Foo<Integer> b = new Foo<Integer>() {
|
||||
public Integer t() {
|
||||
return <flown11>42;
|
||||
}
|
||||
};
|
||||
|
||||
int <caret>i = <flown1>b.t();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
public class X {
|
||||
{
|
||||
Proc<String> procs = new Proc<String>() {
|
||||
public void f(String <caret>s) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
};
|
||||
Proc<Integer> proci = new Proc<Integer>() {
|
||||
public void f(Integer s) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
};
|
||||
|
||||
procs.f(<flown1>"");
|
||||
proci.f(0);
|
||||
}
|
||||
}
|
||||
|
||||
interface Proc<T> {
|
||||
void f(T t);
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
public class X {
|
||||
{
|
||||
Proc<String> procs = new Proc<String>() {
|
||||
public void f(String s) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
};
|
||||
Proc<Integer> proci = new Proc<Integer>() {
|
||||
public void f(Integer <caret>s) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
};
|
||||
|
||||
procs.f("");
|
||||
proci.f(<flown1>0);
|
||||
}
|
||||
}
|
||||
|
||||
interface Proc<T> {
|
||||
void f(T t);
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import java.util.Map;
|
||||
|
||||
class M<X, Y> {
|
||||
Map<X, Y> m;
|
||||
Y y;
|
||||
|
||||
public M(Map<X, Y> m, Y y) {
|
||||
this.m = m;
|
||||
this.y = <flown11111>y;
|
||||
}
|
||||
|
||||
public static <MX, MY> M<MX, MY> makeM(MY y) {
|
||||
return new M<MX, MY>(null, <flown111111>y);
|
||||
}
|
||||
|
||||
Y get(X x) {
|
||||
Y res = <flown11121>m.get(x);
|
||||
return <flown111>res == null ? <flown1111>y : <flown1112>res;
|
||||
}
|
||||
|
||||
public static void g() {
|
||||
String <caret>a = <flown1>f(M.<String, String>makeM(<flown1111111>"a"), "k");
|
||||
}
|
||||
|
||||
public static <A> A f(M<A, A> a, A ka) {
|
||||
return <flown11>a.get(ka);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
public class WW {
|
||||
void f(String ddd) {
|
||||
if (hashCode() == 0)
|
||||
ddd = <flown1111>"dd";
|
||||
foo(<flown111>ddd);
|
||||
}
|
||||
|
||||
{
|
||||
f(<flown1112>"xxx");
|
||||
}
|
||||
|
||||
{
|
||||
x(<flown1121>"zzz");
|
||||
}
|
||||
|
||||
String x(String g) {
|
||||
String d = <flown1>foo(<flown112>g);
|
||||
return <caret>d;
|
||||
}
|
||||
|
||||
private String foo(String i) {
|
||||
return <flown11>i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
class S {
|
||||
String x(String g) {
|
||||
String d = (String)(<flown1>g);
|
||||
return <caret>d;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class T2 {
|
||||
void f() {
|
||||
int i = <caret>x();
|
||||
}
|
||||
|
||||
private int x() {
|
||||
return <flown1>0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
|
||||
class s {
|
||||
{
|
||||
x(<flown1211>"xxx");
|
||||
}
|
||||
String x(String g) {
|
||||
String d = <flown1>foo(<flown121>g);
|
||||
return <caret>d;
|
||||
}
|
||||
|
||||
private String foo(String i) {
|
||||
if (i==null) {
|
||||
new Callable<String>(){
|
||||
public String call() throws Exception {
|
||||
return "xxxxxxxxx";
|
||||
}
|
||||
};
|
||||
return <flown11>null;
|
||||
} else {
|
||||
return <flown12>i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
interface Callable<V> {
|
||||
V call() throws Exception;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public class X {
|
||||
private final static String CON = "";
|
||||
String <caret>l;
|
||||
private String d;
|
||||
|
||||
public X(String g) {
|
||||
set("xxx");
|
||||
set(g);
|
||||
fs("oo", this);
|
||||
|
||||
String o = (String)((null));
|
||||
set(o);
|
||||
|
||||
set(new String());
|
||||
set(nn());
|
||||
set(CON);
|
||||
String nn = g == null ? CON : g;
|
||||
set(nn);
|
||||
|
||||
String other = g == "" ? CON : g;
|
||||
set(other);
|
||||
|
||||
g.hashCode(); // g derefernced before use, must be NN
|
||||
set(g);
|
||||
|
||||
set(nu());
|
||||
set(hz());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
String nn() {
|
||||
return "";
|
||||
}
|
||||
@Nullable
|
||||
String nu() {
|
||||
return "";
|
||||
}
|
||||
String hz() {
|
||||
return d;
|
||||
}
|
||||
void fs(@Nullable String t, X x)
|
||||
{
|
||||
x.set(t);
|
||||
|
||||
x.set(t == null ? "null" : t);
|
||||
}
|
||||
|
||||
void set(String d) {
|
||||
l = d;
|
||||
}
|
||||
void setFromNN(@NotNull String d) {
|
||||
l = d;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import java.util.*;
|
||||
|
||||
public class Auto {
|
||||
public Auto(ArrayList w, Runnable <caret>i) {
|
||||
this(w, null,null);
|
||||
}
|
||||
public Auto(ArrayList w, Runnable i,Runnable o) {
|
||||
o.hashCode();
|
||||
}
|
||||
|
||||
{
|
||||
|
||||
new Auto(null,null,null);
|
||||
new Auto(null,<flown1>null);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
public class OverrideSlice {
|
||||
interface I {
|
||||
int f(int i);
|
||||
}
|
||||
class O implements I {
|
||||
public int f(int i) {
|
||||
return <flown11>i;
|
||||
}
|
||||
}
|
||||
class O0 implements I {
|
||||
public int f(int i) {
|
||||
return <flown12>0;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
f(<flown1111>1, new O());
|
||||
}
|
||||
void f(int c, I i) {
|
||||
int <caret>x = <flown1>i.f(<flown111>c);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class IncrDecrIgnore {
|
||||
int <caret>i = <flown1>0;
|
||||
|
||||
int incr() {
|
||||
return <flown2>i++;
|
||||
}
|
||||
int decr() {
|
||||
return <flown3>--i;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
class WW {
|
||||
{ String ddd;
|
||||
ddd = foo(<flown1>1);
|
||||
}
|
||||
|
||||
private String foo(int i) {
|
||||
return <caret>i+"";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class Tuple<X,Y> {
|
||||
public final X x;
|
||||
public final Y y;
|
||||
public Tuple(X x,Y y) {this.x=x; this.y=y;}
|
||||
|
||||
public X getX() {
|
||||
return <caret>x;
|
||||
}
|
||||
|
||||
private static <X,Y> Tuple<X,Y> copy(Tuple<X,Y> t) {
|
||||
return new Tuple<X,Y>(t.x, t.y);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
class A {
|
||||
private static class Tuple<X,Y> {
|
||||
public final X x;
|
||||
public final Y y;
|
||||
public Tuple(X x,Y y) {this.x=<flown11>x; this.y=y;}
|
||||
}
|
||||
|
||||
private static class Foo {
|
||||
void f() {
|
||||
Tuple<Integer,Integer> t1 = new Tuple<Integer,Integer>(1,2);
|
||||
Tuple<String,String> t2 = new Tuple<String,String>(<flown111>"a","b");
|
||||
Tuple<Foo,Foo> t2w = new Tuple<Foo,Foo>(null,null);
|
||||
|
||||
String <caret>x = t2.<flown1>x;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
class A {
|
||||
private static class Tuple<X,Y> {
|
||||
public final X <caret>x;
|
||||
public final Y y;
|
||||
public Tuple(X x,Y y) {this.x=<flown1>x; this.y=y;}
|
||||
}
|
||||
|
||||
private static class Foo {
|
||||
void f() {
|
||||
Tuple<Integer,Integer> t1 = new Tuple<Integer,Integer>(<flown11>1,2);
|
||||
Tuple<String,String> t2 = new Tuple<String,String>(<flown12>"a","b");
|
||||
String x = t2.x;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
class A {
|
||||
private static class Tuple<X,Y> {
|
||||
public final X x;
|
||||
public final Y y;
|
||||
public Tuple(X x,Y y) {this.x=<flown11>x; this.y=y;}
|
||||
}
|
||||
|
||||
private static class Foo {
|
||||
void f2(Tuple<String, String> t2w) {
|
||||
Tuple t2 = new Tuple(1,2);
|
||||
String <caret>x = t2w.<flown1>x;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
class S {
|
||||
private String foo = <flown11>"xxx";
|
||||
|
||||
{
|
||||
String bar = <flown1>foo;
|
||||
if (bar.equals("a")) {
|
||||
} else if (bar.equals("b")) {
|
||||
}
|
||||
|
||||
if (bar.equals("c")) {
|
||||
bar = <flown2>"";
|
||||
}
|
||||
|
||||
System.out.println("bar: " + <caret>bar);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
class A {
|
||||
private static class Tuple<X,Y> {
|
||||
public final X x;
|
||||
public final Y y;
|
||||
public Tuple(X x,Y y) {this.x=<flown11>x; this.y=y;}
|
||||
public static <X1,Y1> Tuple<X1,Y1> create(X1 x, Y1 y) {
|
||||
return new Tuple<X1,Y1>(<flown111>x, y);
|
||||
}
|
||||
}
|
||||
|
||||
private static class Foo {
|
||||
void f() {
|
||||
Tuple<String,String> t = Tuple.create(<flown1111>"","");
|
||||
Tuple<Object,Object> t2 = Tuple.create((Object) "",(Object) "");
|
||||
|
||||
String <caret>x = t.<flown1>x;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
class Foo {
|
||||
private static MyEnum staticMyEnum = MyEnum.<flown11>BAR;
|
||||
|
||||
public static void main(String[] args) {
|
||||
produce();
|
||||
}
|
||||
|
||||
static void produce() {
|
||||
produce(<flown1>staticMyEnum);
|
||||
}
|
||||
|
||||
static void produce(MyEnum myEnum) {
|
||||
System.out.println("myEnum: " + myEnum<caret>);
|
||||
}
|
||||
|
||||
static void f() {
|
||||
staticMyEnum = MyEnum.<flown12>BAZ;
|
||||
}
|
||||
|
||||
static void g() {
|
||||
staticMyEnum = MyEnum.<flown13>FOO;
|
||||
}
|
||||
|
||||
enum MyEnum {
|
||||
FOO,
|
||||
BAR,
|
||||
BAZ
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
public class T2 {
|
||||
int <caret>fff;
|
||||
|
||||
public T2(int i) {
|
||||
fff = i;
|
||||
}
|
||||
|
||||
public int <flown11>getFff() {
|
||||
return <flown1>fff;
|
||||
}
|
||||
|
||||
void f(int i2) {
|
||||
// fff=i2;
|
||||
p(<flown111>getFff());
|
||||
}
|
||||
|
||||
public void p(int <flown1111>i) {
|
||||
new F(<flown11111>i);
|
||||
}
|
||||
|
||||
private class F {
|
||||
private int <flown11111111>xss;
|
||||
|
||||
public F(int <flown111111>i) {
|
||||
xss = <flown1111111>i;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import java.util.*;
|
||||
|
||||
class X {
|
||||
class MyMap implements Map {
|
||||
public int size() {
|
||||
return 0; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public boolean containsKey(Object key) {
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public boolean containsValue(Object value) {
|
||||
return false; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public Object get(Object <flown1111>key) {
|
||||
return key.<flown11111>getClass();
|
||||
}
|
||||
|
||||
public Object put(Object key, Object value) {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public Object remove(Object key) {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public void putAll(Map m) {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
//To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public Set keySet() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public Collection values() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
public Set entrySet() {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
}
|
||||
|
||||
public String getEncoding( int <caret>virtualFile, boolean useParentDefaults) {
|
||||
Map<Integer,String> myMapping = null;
|
||||
int <flown11>parent = <flown1>virtualFile;
|
||||
while (true) {
|
||||
String charset = myMapping.get(<flown111>parent);
|
||||
if (charset != null || !useParentDefaults) return charset;
|
||||
if (parent == 0) break;
|
||||
parent = parent-1;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
public class T2 {
|
||||
int <flown111111>fff;
|
||||
|
||||
{
|
||||
// f(fff);
|
||||
}
|
||||
|
||||
void f(int <caret>i2) {
|
||||
int i = -1;
|
||||
i = 0;
|
||||
try { //
|
||||
i = 1;
|
||||
if (i2 == 0) {
|
||||
p(<flown1>i2);//
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
}
|
||||
finally {
|
||||
i = 9;
|
||||
}
|
||||
}
|
||||
|
||||
public void p(int <flown11>i) {//
|
||||
// fff = i;
|
||||
int <flown1111>ddd = <flown111>i;
|
||||
fff =<flown11111>ddd;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user