Skip to content

Commit 34e6679

Browse files
committed
Java: Add upgrade script.
1 parent f8805eb commit 34e6679

File tree

10 files changed

+2062
-0
lines changed

10 files changed

+2062
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
class Annotation extends @annotation {
2+
string toString() { result = "annotation" }
3+
}
4+
5+
class Method extends @method {
6+
string toString() { result = "method" }
7+
}
8+
9+
class Expr extends @expr {
10+
string toString() { result = "expr" }
11+
}
12+
13+
class ParExpr extends Expr, @parexpr {
14+
override string toString() { result = "(...)" }
15+
}
16+
17+
predicate parExprGetExpr(ParExpr pe, Expr e) { exprs(e, _, _, pe, _) }
18+
19+
from Annotation parentid, Method id2, Expr oldvalue, Expr value
20+
where
21+
annotValue(parentid, id2, oldvalue) and
22+
if oldvalue instanceof ParExpr
23+
then
24+
parExprGetExpr+(oldvalue, value) and
25+
not value instanceof ParExpr
26+
else value = oldvalue
27+
select parentid, id2, value
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Expr extends @expr {
2+
string toString() { result = "expr" }
3+
}
4+
5+
class ParExpr extends Expr, @parexpr {
6+
override string toString() { result = "(...)" }
7+
}
8+
9+
class Callable extends @callable {
10+
string toString() { result = "callable" }
11+
}
12+
13+
from Expr id, Callable c
14+
where
15+
callableEnclosingExpr(id, c) and
16+
not id instanceof ParExpr
17+
select id, c
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
class ExprParent extends @exprparent {
2+
string toString() { result = "exprparent" }
3+
}
4+
5+
class Expr extends ExprParent, @expr {
6+
override string toString() { result = "expr" }
7+
}
8+
9+
class ParExpr extends Expr, @parexpr {
10+
override string toString() { result = "(...)" }
11+
}
12+
13+
class Type extends @type {
14+
string toString() { result = "type" }
15+
}
16+
17+
predicate astlink(ExprParent parent, Expr e, int idx, int parens) {
18+
exprs(e, _, _, parent, idx) and
19+
parens = 0 and
20+
not parent instanceof ParExpr and
21+
e instanceof ParExpr
22+
or
23+
exists(ParExpr pe |
24+
exprs(e, _, _, pe, _) and
25+
astlink(parent, pe, idx, parens - 1)
26+
)
27+
}
28+
29+
from Expr id, int kind, Type typeid, ExprParent oldparent, ExprParent parent, int oldidx, int idx
30+
where
31+
exprs(id, kind, typeid, oldparent, oldidx) and
32+
not id instanceof ParExpr and
33+
if oldparent instanceof ParExpr
34+
then astlink(parent, id, idx, _)
35+
else (
36+
parent = oldparent and idx = oldidx
37+
)
38+
select id, kind, typeid, parent, idx
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Locatable extends @locatable {
2+
string toString() { result = "locatable" }
3+
}
4+
5+
class Location extends @location {
6+
string toString() { result = "location" }
7+
}
8+
9+
class ParExpr extends Locatable, @parexpr {
10+
override string toString() { result = "(...)" }
11+
}
12+
13+
from Locatable locatable, Location location
14+
where
15+
hasLocation(locatable, location) and
16+
not locatable instanceof ParExpr
17+
select locatable, location
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class ExprParent extends @exprparent {
2+
string toString() { result = "exprparent" }
3+
}
4+
5+
class Expr extends ExprParent, @expr {
6+
override string toString() { result = "expr" }
7+
}
8+
9+
class ParExpr extends Expr, @parexpr {
10+
override string toString() { result = "(...)" }
11+
}
12+
13+
predicate astlink(ExprParent parent, Expr e, int idx, int parens) {
14+
exprs(e, _, _, parent, idx) and
15+
parens = 0 and
16+
not parent instanceof ParExpr and
17+
e instanceof ParExpr
18+
or
19+
exists(ParExpr pe |
20+
exprs(e, _, _, pe, _) and
21+
astlink(parent, pe, idx, parens - 1)
22+
)
23+
}
24+
25+
from Expr e, int parentheses
26+
where
27+
astlink(_, e, _, parentheses) and
28+
not e instanceof ParExpr
29+
select e, parentheses
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class Sourceline extends @sourceline {
2+
string toString() { result = "sourceline" }
3+
}
4+
5+
class ParExpr extends Sourceline, @parexpr {
6+
override string toString() { result = "(...)" }
7+
}
8+
9+
from Sourceline id, int l, int code, int comm
10+
where
11+
numlines(id, l, code, comm) and
12+
not id instanceof ParExpr
13+
select id, l, code, comm

0 commit comments

Comments
 (0)