dataflow to/from containers support

This commit is contained in:
Alexey Kudravtsev
2013-10-22 12:33:55 +04:00
parent 999a2e8e52
commit 6bcad287da
50 changed files with 1303 additions and 301 deletions
@@ -0,0 +1,23 @@
class AnonArray {
void x() {
final int[] params = <flown11>{<flown111>-1};
calcIt(new Runnable() {
public void run() {
params[0] = <flown12>z(<flown12111>2);
}
});
y(<flown1>params[0]);
}
void y(int <caret>arg) {
}
void calcIt(Runnable r) {
r.run();
}
int z(int <flown1211>arg) {
return <flown121>arg;
}
}
@@ -1,16 +1,16 @@
class Test {
public static void main(String[] args) {
final String a = <flown11>args[0];
public static void main(String[] <flown1111>args) {
final String a = <flown111>args[0];
final String b = args[1];
new Runnable() {
public void run() {
System.out.println(f(<flown1>a, b));
System.out.println(f(<flown11>a, b));
}
}.run();
}
private static String f(String a, String b) {
private static String f(String <flown1>a, String b) {
return <caret>a + b;
}
@@ -0,0 +1,9 @@
class ArrayCopy {
void f(String s) {
String[] l = new String[]{"x"};
String[] y = new String[1];
System.arraycopy(l, 0, y, 0, l.length);
String <caret>c = y[0];
}
}
@@ -0,0 +1,16 @@
class Test {
private void x(int[] <flown1111>params) {
if (params == null) {
params = <flown1112>new int[]{<flown11121>-1};
}
params[3] = <flown1113>44;
for (int <flown11>param : <flown111>params) y(<flown1>param);
}
private void y(int <caret>arg) {
}
private void z() {
x(<flown11111>new int[]{<flown111111>1,<flown111112>8});
}
}
@@ -0,0 +1,37 @@
package x;
import java.util.*;
import org.intellij.lang.annotations.Flow;
public class ListTack {
void f(String <caret>s) {
}
void g(List<String> l) {
l.add(1, "uuu");
f(l.get(0));
}
void h() {
ArrayList<String> strings = new ArrayList<String>();
strings.add("x");
X<String> s2 = new X<String>(strings);
s2.add("y");
List<String> s3 = new ArrayList<String>();
s3.addAll(s2.toCollection());
Collection<String> s4 = new ArrayList<String>(s3.subList(0,1));
g(new ArrayList<String>(s4));
}
class X<T> {
X (@Flow(sourceIsContainer = true, targetIsContainer = true) Collection<T> input) {}
@Flow(sourceIsContainer = true)
T get() { return null;}
void add(@Flow(targetIsContainer = true) T item) {}
@Flow(sourceIsContainer=true, targetIsContainer = true)
Collection<T> toCollection() { return null; }
}
}
@@ -1,9 +1,9 @@
class Pair<A, B> {
public final A first;
public final A <flown111>first;
public final B second;
public Pair(A first, B second) {
this.first = <flown111>first;
public Pair(A <flown11111>first, B second) {
this.first = <flown1111>first;
this.second = second;
}
@@ -15,8 +15,8 @@ class Pair<A, B> {
return second;
}
public static <A, B> Pair<A, B> create(A first, B second) {
return new Pair<A,B>(<flown1111>first, second);
public static <A, B> Pair<A, B> create(A <flown1111111>first, B second) {
return new Pair<A,B>(<flown111111>first, second);
}
public final boolean equals(Object o){
@@ -1,13 +1,13 @@
class s {
{
x(<flown11211>"xxx");
x(<flown1121111>"xxx");
}
String x(String g) {
String d = <flown1>foo(<flown1121>g);
String x(String <flown112111>g) {
String d = <flown1>foo(<flown11211>g);
return <caret>d;
}
private String foo(String i) {
private String foo(String <flown1121>i) {
return <flown11>i==null ? <flown111>null : <flown112>i;
}
}
@@ -1,16 +1,16 @@
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;
public static void main(String[] <flown111211><flown11111>args) {
final String a = <flown11121>args[0];
final String b = <flown111>Test.class == null ? <flown1111>args[1] : <flown1112>a;
new Runnable() {
public void run() {
System.out.println(f(a, <flown1>b));
System.out.println(f(a, <flown11>b));
}
}.run();
}
private static String f(String a, String b) {
private static String f(String a, String <flown1>b) {
return a + <caret>b;
}
@@ -1,16 +1,17 @@
import java.util.Map;
class M<X, Y> {
interface Map<X,Y> {
Y get(X x);
}
Map<X, Y> m;
Y y;
Y <flown11111>y;
public M(Map<X, Y> m, Y y) {
public M(Map<X, Y> m, Y <flown1111111>y) {
this.m = m;
this.y = <flown11111>y;
this.y = <flown111111>y;
}
public static <MX, MY> M<MX, MY> makeM(MY y) {
return new M<MX, MY>(null, <flown111111>y);
public static <MX, MY> M<MX, MY> makeM(MY <flown111111111>y) {
return new M<MX, MY>(null, <flown11111111>y);
}
Y get(X x) {
@@ -19,7 +20,7 @@ class M<X, Y> {
}
public static void g() {
String <caret>a = <flown1>f(M.<String, String>makeM(<flown1111111>"a"), "k");
String <caret>a = <flown1>f(M.<String, String>makeM(<flown1111111111>"a"), "k");
}
public static <A> A f(M<A, A> a, A ka) {
@@ -0,0 +1,23 @@
import java.util.ArrayList;
import java.util.List;
public class ListTack {
void f(String s) {
String <caret>p = s;
}
void g(List<String> list) {
list.add(1, "uuu");
f(list.get(0));
f(list.remove(0));
}
void h() {
List<String> g = new ArrayList<String>();
g.add("zzz");
List<String> list = new ArrayList<String>();
list.add("xxx");
g(list);
}
}
@@ -1,24 +1,24 @@
public class WW {
void f(String ddd) {
void f(String <flown11111>ddd) {
if (hashCode() == 0)
ddd = <flown1111>"dd";
foo(<flown111>ddd);
ddd = <flown11112>"dd";
foo(<flown1111>ddd);
}
{
f(<flown1112>"xxx");
f(<flown111111>"xxx");
}
{
x(<flown1121>"zzz");
x(<flown111211>"zzz");
}
String x(String g) {
String d = <flown1>foo(<flown112>g);
String x(String <flown11121>g) {
String d = <flown1>foo(<flown1112>g);
return <caret>d;
}
private String foo(String i) {
private String foo(String <flown111>i) {
return <flown11>i;
}
}
@@ -0,0 +1,31 @@
package x;
import java.util.ArrayList;
import java.util.List;
public class ListTack {
void f(String <caret>s) {
}
void g(List<String> <flown111>l) {
l.add(1, <flown112>"uuu");
// f(l.get(0));
// f(l.remove(0));
Object[] array = <flown11>l.toArray();
f((String)<flown1>array[0]);
}
void h() {
List<String> g = <flown111131>new ArrayList<String>();
g.add(<flown111132>"zzz");
List<String> list = <flown11111>new ArrayList<String>();
list.add(<flown11112>"xxx");
list.addAll(<flown11113>g);
g(<flown1111>list);
}
}
@@ -1,5 +1,5 @@
class S {
String x(String g) {
String x(String <flown11>g) {
String d = (String)(<flown1>g);
return <caret>d;
}
@@ -0,0 +1,10 @@
import java.util.*;
class Map5 {
void f(String s, Map<String, String> m) {
m.put("x", s);
Set<String> keys = m.keySet();
String[] keyArray = keys.toArray(new String[0]);
String <caret>v = keyArray[0];
}
}
@@ -0,0 +1,8 @@
import java.util.Map;
class Map4 {
void f(String s, Map<String, String> m) {
m.put(s, "y");
String <caret>v = m.get(s);
}
}
@@ -1,14 +1,13 @@
class s {
{
x(<flown1211>"xxx");
x(<flown121111>"xxx");
}
String x(String g) {
String d = <flown1>foo(<flown121>g);
String x(String <flown12111>g) {
String d = <flown1>foo(<flown1211>g);
return <caret>d;
}
private String foo(String i) {
private String foo(String <flown121>i) {
if (i==null) {
new Callable<String>(){
public String call() throws Exception {
@@ -3,7 +3,7 @@ public class OverrideSlice {
int f(int i);
}
class O implements I {
public int f(int i) {
public int f(int <flown111>i) {
return <flown11>i;
}
}
@@ -14,9 +14,9 @@ public class OverrideSlice {
}
{
f(<flown1111>1, new O());
f(<flown111111>1, new O());
}
void f(int c, I i) {
int <caret>x = <flown1>i.f(<flown111>c);
void f(int <flown11111>c, I i) {
int <caret>x = <flown1>i.f(<flown1111>c);
}
}
@@ -1,10 +1,11 @@
class WW {
{ String ddd;
ddd = foo(<flown1>1);
{
String ddd;
ddd = foo(<flown11>1);
}
private String foo(int i) {
return <caret>i+"";
}
private String foo(int <flown1>i) {
return <caret>i+"";
}
}
@@ -1,14 +1,14 @@
class A {
private static class Tuple<X,Y> {
public final X x;
public final X <flown11>x;
public final Y y;
public Tuple(X x,Y y) {this.x=<flown11>x; this.y=y;}
public Tuple(X <flown1111>x,Y y) {this.x=<flown111>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<String,String> t2 = new Tuple<String,String>(<flown11111>"a","b");
Tuple<Foo,Foo> t2w = new Tuple<Foo,Foo>(null,null);
String <caret>x = t2.<flown1>x;
@@ -2,13 +2,13 @@ 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;}
public Tuple(X <flown11>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");
Tuple<Integer,Integer> t1 = new Tuple<Integer,Integer>(<flown111>1,2);
Tuple<String,String> t2 = new Tuple<String,String>(<flown112>"a","b");
String x = t2.x;
}
}
@@ -1,8 +1,8 @@
class A {
private static class Tuple<X,Y> {
public final X x;
public final X <flown11>x;
public final Y y;
public Tuple(X x,Y y) {this.x=<flown11>x; this.y=y;}
public Tuple(X <flown1111>x,Y y) {this.x=<flown111>x; this.y=y;}
}
private static class Foo {
@@ -0,0 +1,10 @@
public class VarArgs {
private void g() {
f<flown111>(<flown1111>1);
f<flown112>(<flown1121>2, <flown1122>3, <flown1123>4);
}
private void f(int... <flown11>ints) {
int <caret>p = <flown1>ints[0];
}
}
@@ -1,16 +1,16 @@
class A {
private static class Tuple<X,Y> {
public final X x;
public final X <flown11>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);
public Tuple(X <flown1111>x,Y y) {this.x=<flown111>x; this.y=y;}
public static <X1,Y1> Tuple<X1,Y1> create(X1 <flown111111>x, Y1 y) {
return new Tuple<X1,Y1>(<flown11111>x, y);
}
}
private static class Foo {
void f() {
Tuple<String,String> t = Tuple.create(<flown1111>"","");
Tuple<String,String> t = Tuple.create(<flown1111111>"","");
Tuple<Object,Object> t2 = Tuple.create((Object) "",(Object) "");
String <caret>x = t.<flown1>x;
@@ -1,29 +1,29 @@
class Foo {
private static MyEnum staticMyEnum = MyEnum.<flown11>BAR;
private static MyEnum staticMyEnum = MyEnum.<flown111>BAR;
public static void main(String[] args) {
produce();
}
static void produce() {
produce(<flown1>staticMyEnum);
produce(<flown11>staticMyEnum);
}
static void produce(MyEnum myEnum) {
static void produce(MyEnum <flown1>myEnum) {
System.out.println("myEnum: " + myEnum<caret>);
}
static void f() {
staticMyEnum = MyEnum.<flown12>BAZ;
staticMyEnum = MyEnum.<flown112>BAZ;
}
static void g() {
staticMyEnum = MyEnum.<flown13>FOO;
staticMyEnum = MyEnum.<flown113>FOO;
}
enum MyEnum {
FOO,
BAR,
BAZ
<flown1131>FOO,
<flown1111>BAR,
<flown1121>BAZ
}
}