File tree Expand file tree Collapse file tree 3 files changed +25
-0
lines changed
Expand file tree Collapse file tree 3 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 6969# name. It's commented out because its output differs so greatly
7070# from its input, and because it's really not very useful.
7171classPostWalkHandlers = [
72+ basic .moveStaticExpressions ,
7273 ## basic.classContentSort,
7374]
7475
Original file line number Diff line number Diff line change @@ -225,3 +225,15 @@ def zopeImplementsClassHead(obj):
225225 if implAny (obj ):
226226 for cls in obj .bases :
227227 yield 'zope.interface.implements({})' .format (cls )
228+
229+
230+ def moveStaticExpressions (cls ):
231+ name = '{}.' .format (cls .name ) # notice the dot
232+ exprs = [child for child in cls .children if child .isExpression and name in str (child )]
233+ module = cls .parents (lambda x :x .isModule ).next ()
234+ for expr in exprs :
235+ cls .children .remove (expr )
236+ newExpr = module .factory .expr (fs = name + '{right}' , right = expr )
237+ module .adopt (newExpr , index = len (module .children ))
238+
239+
Original file line number Diff line number Diff line change 1+ public class Class13 {
2+
3+ static int x = 0 ;
4+ static int y = Class13 .x ;
5+
6+ Class klass = Class13 .class ;
7+
8+ public static void main (String [] args ) {
9+ System .out .println (Class13 .x == Class13 .y ? 1 : 0 );
10+ }
11+
12+ }
You can’t perform that action at this time.
0 commit comments