Debian Codegraph @

test/refactor/extract_variable.py

raw symbols SCIP
1 # -------------------------------------------------- simple-1
2 def test():
3 #? 35 text {'new_name': 'a'}
4 return test(100, (30 + b, c) + 1)
5 # ++++++++++++++++++++++++++++++++++++++++++++++++++
6 def test():
7 #? 35 text {'new_name': 'a'}
8 a = (30 + b, c) + 1
9 return test(100, a)
10 # -------------------------------------------------- simple-2
11 def test():
12 #? 25 text {'new_name': 'a'}
13 return test(100, (30 + b, c) + 1)
14 # ++++++++++++++++++++++++++++++++++++++++++++++++++
15 def test():
16 #? 25 text {'new_name': 'a'}
17 a = 30 + b
18 return test(100, (a, c) + 1)
19 # -------------------------------------------------- simple-3
20 foo = 3.1
21 #? 8 text {'new_name': 'bar'}
22 x = int(foo + 1)
23 # ++++++++++++++++++++++++++++++++++++++++++++++++++
24 foo = 3.1
25 #? 8 text {'new_name': 'bar'}
26 bar = foo + 1
27 x = int(bar)
28 # -------------------------------------------------- simple-4
29 #? 13 text {'new_name': 'zzx.x'}
30 test(100, {1 |1: 2 + 3})
31 # ++++++++++++++++++++++++++++++++++++++++++++++++++
32 #? 13 text {'new_name': 'zzx.x'}
33 zzx.x = 1 |1
34 test(100, {zzx.x: 2 + 3})
35 # -------------------------------------------------- multiline-1
36 def test():
37 #? 30 text {'new_name': 'x'}
38 return test(1, (30 + b, c)
39 + 1)
40 # ++++++++++++++++++++++++++++++++++++++++++++++++++
41 def test():
42 #? 30 text {'new_name': 'x'}
43 x = (30 + b, c)
44 + 1
45 return test(1, x)
46 # -------------------------------------------------- multiline-2
47 def test():
48 #? 25 text {'new_name': 'x'}
49 return test(1, (30 + b, c)
50 + 1)
51 # ++++++++++++++++++++++++++++++++++++++++++++++++++
52 def test():
53 #? 25 text {'new_name': 'x'}
54 x = 30 + b
55 return test(1, (x, c)
56 + 1)
57 # -------------------------------------------------- for-param-error-1
58 #? 10 error {'new_name': 'x'}
59 def test(p1):
60 return
61 # ++++++++++++++++++++++++++++++++++++++++++++++++++
62 Cannot extract a name that defines something
63 # -------------------------------------------------- for-param-error-2
64 #? 12 error {'new_name': 'x'}
65 def test(p1= 3):
66 return
67 # ++++++++++++++++++++++++++++++++++++++++++++++++++
68 Cannot extract a "param"
69 # -------------------------------------------------- for-param-1
70 #? 12 text {'new_name': 'x'}
71 def test(p1=20):
72 return
73 # ++++++++++++++++++++++++++++++++++++++++++++++++++
74 #? 12 text {'new_name': 'x'}
75 x = 20
76 def test(p1=x):
77 return
78 # -------------------------------------------------- for-something
79 #? 12 text {'new_name': 'x'}
80 def test(p1=20):
81 return
82 # ++++++++++++++++++++++++++++++++++++++++++++++++++
83 #? 12 text {'new_name': 'x'}
84 x = 20
85 def test(p1=x):
86 return
87 # -------------------------------------------------- class-inheritance-1
88 #? 12 text {'new_name': 'x'}
89 class Foo(foo.Bar):
90 pass
91 # ++++++++++++++++++++++++++++++++++++++++++++++++++
92 #? 12 text {'new_name': 'x'}
93 x = foo.Bar
94 class Foo(x):
95 pass
96 # -------------------------------------------------- class-inheritance-2
97 #? 16 text {'new_name': 'x'}
98 class Foo(foo.Bar):
99 pass
100 # ++++++++++++++++++++++++++++++++++++++++++++++++++
101 #? 16 text {'new_name': 'x'}
102 x = foo.Bar
103 class Foo(x):
104 pass
105 # -------------------------------------------------- keyword-pass
106 #? 12 error {'new_name': 'x'}
107 def x(): pass
108 # ++++++++++++++++++++++++++++++++++++++++++++++++++
109 Cannot extract a "simple_stmt"
110 # -------------------------------------------------- keyword-continue
111 #? 5 error {'new_name': 'x'}
112 continue
113 # ++++++++++++++++++++++++++++++++++++++++++++++++++
114 Cannot extract a "simple_stmt"
115 # -------------------------------------------------- keyword-None
116 if 1:
117 #? 4 text {'new_name': 'x'}
118 None
119 # ++++++++++++++++++++++++++++++++++++++++++++++++++
120 if 1:
121 #? 4 text {'new_name': 'x'}
122 x = None
123 x
124 # -------------------------------------------------- with-tuple
125 #? 4 text {'new_name': 'x'}
126 x + 1, 3
127 # ++++++++++++++++++++++++++++++++++++++++++++++++++
128 #? 4 text {'new_name': 'x'}
129 x = x + 1
130 x, 3
131 # -------------------------------------------------- range-1
132 #? 4 text {'new_name': 'x', 'until_column': 9}
133 y + 1, 3
134 # ++++++++++++++++++++++++++++++++++++++++++++++++++
135 #? 4 text {'new_name': 'x', 'until_column': 9}
136 x = y + 1, 3
137 x
138 # -------------------------------------------------- range-2
139 #? 1 text {'new_name': 'x', 'until_column': 3}
140 y + 1, 3
141 # ++++++++++++++++++++++++++++++++++++++++++++++++++
142 #? 1 text {'new_name': 'x', 'until_column': 3}
143 x = y + 1
144 x, 3
145 # -------------------------------------------------- range-3
146 #? 1 text {'new_name': 'x', 'until_column': 6}
147 y + 1, 3
148 # ++++++++++++++++++++++++++++++++++++++++++++++++++
149 #? 1 text {'new_name': 'x', 'until_column': 6}
150 x = y + 1
151 x, 3
152 # -------------------------------------------------- range-4
153 #? 1 text {'new_name': 'x', 'until_column': 1}
154 y + 1, 3
155 # ++++++++++++++++++++++++++++++++++++++++++++++++++
156 #? 1 text {'new_name': 'x', 'until_column': 1}
157 x = y
158 x + 1, 3
159 # -------------------------------------------------- addition-1
160 #? 4 text {'new_name': 'x', 'until_column': 9}
161 z = y + 1 + 2+ 3, 3
162 # ++++++++++++++++++++++++++++++++++++++++++++++++++
163 #? 4 text {'new_name': 'x', 'until_column': 9}
164 x = y + 1
165 z = x + 2+ 3, 3
166 # -------------------------------------------------- addition-2
167 #? 8 text {'new_name': 'x', 'until_column': 12}
168 z = y +1 + 2+ 3, 3
169 # ++++++++++++++++++++++++++++++++++++++++++++++++++
170 #? 8 text {'new_name': 'x', 'until_column': 12}
171 x = 1 + 2
172 z = y +x+ 3, 3
173 # -------------------------------------------------- addition-3
174 #? 10 text {'new_name': 'x', 'until_column': 14}
175 z = y + 1 + 2+ 3, 3
176 # ++++++++++++++++++++++++++++++++++++++++++++++++++
177 #? 10 text {'new_name': 'x', 'until_column': 14}
178 x = 1 + 2+ 3
179 z = y + x, 3
180 # -------------------------------------------------- addition-4
181 #? 13 text {'new_name': 'x', 'until_column': 17}
182 z = y + (1 + 2)+ 3, 3
183 # ++++++++++++++++++++++++++++++++++++++++++++++++++
184 #? 13 text {'new_name': 'x', 'until_column': 17}
185 x = (1 + 2)+ 3
186 z = y + x, 3
187 # -------------------------------------------------- mult-add-1
188 #? 8 text {'new_name': 'x', 'until_column': 11}
189 z = foo(y+1*2+3, 3)
190 # ++++++++++++++++++++++++++++++++++++++++++++++++++
191 #? 8 text {'new_name': 'x', 'until_column': 11}
192 x = y+1
193 z = foo(x*2+3, 3)
194 # -------------------------------------------------- mult-add-2
195 #? 12 text {'new_name': 'x', 'until_column': 15}
196 z = foo(y+1*2+3)
197 # ++++++++++++++++++++++++++++++++++++++++++++++++++
198 #? 12 text {'new_name': 'x', 'until_column': 15}
199 x = 2+3
200 z = foo(y+1*x)
201 # -------------------------------------------------- mult-add-3
202 #? 9 text {'new_name': 'x', 'until_column': 13}
203 z = (y+1*2+3)
204 # ++++++++++++++++++++++++++++++++++++++++++++++++++
205 #? 9 text {'new_name': 'x', 'until_column': 13}
206 x = (y+1*2+3)
207 z = x
208 # -------------------------------------------------- extract-weird-1
209 #? 0 error {'new_name': 'x', 'until_column': 7}
210 foo = 3
211 # ++++++++++++++++++++++++++++++++++++++++++++++++++
212 Cannot extract a "expr_stmt"
213 # -------------------------------------------------- extract-weird-2
214 #? 0 error {'new_name': 'x', 'until_column': 5}
215 def x():
216 foo = 3
217 # ++++++++++++++++++++++++++++++++++++++++++++++++++
218 Cannot extract a "funcdef"
219 # -------------------------------------------------- extract-weird-3
220 def x():
221 #? 4 error {'new_name': 'x', 'until_column': 8}
222 if 1:
223 pass
224 # ++++++++++++++++++++++++++++++++++++++++++++++++++
225 Cannot extract a "if_stmt"
226 # -------------------------------------------------- extract-weird-4
227 #? 4 error {'new_name': 'x', 'until_column': 7}
228 x = foo = 4
229 # ++++++++++++++++++++++++++++++++++++++++++++++++++
230 Cannot extract a name that defines something
231 # -------------------------------------------------- keyword-None
232 #? 4 text {'new_name': 'x', 'until_column': 7}
233 yy = not foo or bar
234 # ++++++++++++++++++++++++++++++++++++++++++++++++++
235 #? 4 text {'new_name': 'x', 'until_column': 7}
236 x = not foo
237 yy = x or bar
238 # -------------------------------------------------- augassign
239 yy = ()
240 #? 6 text {'new_name': 'x', 'until_column': 10}
241 yy += 3, 4
242 # ++++++++++++++++++++++++++++++++++++++++++++++++++
243 yy = ()
244 #? 6 text {'new_name': 'x', 'until_column': 10}
245 x = 3, 4
246 yy += x
247 # -------------------------------------------------- if-else
248 #? 9 text {'new_name': 'x', 'until_column': 22}
249 yy = foo(a if y else b)
250 # ++++++++++++++++++++++++++++++++++++++++++++++++++
251 #? 9 text {'new_name': 'x', 'until_column': 22}
252 x = a if y else b
253 yy = foo(x)
254 # -------------------------------------------------- lambda
255 #? 8 text {'new_name': 'x', 'until_column': 17}
256 y = foo(lambda x: 3, 5)
257 # ++++++++++++++++++++++++++++++++++++++++++++++++++
258 #? 8 text {'new_name': 'x', 'until_column': 17}
259 x = lambda x: 3
260 y = foo(x, 5)