Debian Codegraph @

test/completion/usages.py

raw symbols SCIP
1 """
2 Renaming tests. This means search for references.
3 I always leave a little bit of space to add room for additions, because the
4 results always contain position informations.
5 """
6 #< 4 (0,4), (3,0), (5,0), (12,4), (14,5), (15,0), (17,0), (19,0)
7 def abcd(): pass
8
9 #< 0 (-3,4), (0,0), (2,0), (9,4), (11,5), (12,0), (14,0), (16,0)
10 abcd.d.a.bsaasd.abcd.d
11
12 abcd
13 # unicode chars shouldn't be a problem.
14 x['smörbröd'].abcd
15
16 # With the new parser these statements are not recognized as stateents, because
17 # they are not valid Python.
18 if 1:
19 abcd =
20 else:
21 (abcd) =
22 abcd =
23 #< (-17,4), (-14,0), (-12,0), (0,0), (2,0), (-2,0), (-3,5), (-5,4)
24 abcd
25
26 abcd = 5
27
28
29 Abc = 3
30
31 #< 6 (-3,0), (0,6), (2,4), (5,8), (17,0)
32 class Abc():
33 #< (-5,0), (-2,6), (0,4), (2,8), (3,8), (15,0)
34 Abc
35
36 def Abc(self):
37 Abc; self.c = 3
38
39 #< 17 (0,16), (2,8)
40 def a(self, Abc):
41 #< 10 (-2,16), (0,8)
42 Abc
43
44 #< 19 (0,18), (2,8)
45 def self_test(self):
46 #< 12 (-2,18), (0,8)
47 self.b
48
49 Abc.d.Abc
50
51
52 #< 4 (0,4), (5,1)
53 def blubi():
54 pass
55
56
57 #< (-5,4), (0,1)
58 @blubi
59 def a(): pass
60
61
62 #< 0 (0,0), (1,0)
63 set_object_var = object()
64 set_object_var.var = 1
65
66 def func(a, b):
67 a = 12
68 #< 4 (0,4), (3,8)
69 c = a
70 if True:
71 #< 8 (-3,4), (0,8)
72 c = b
73
74 response = 5
75 #< 0 (-2,0), (0,0), (1,0), (2,0), (4,0)
76 response = HttpResponse(mimetype='application/pdf')
77 response['Content-Disposition'] = 'attachment; filename=%s.pdf' % id
78 response.write(pdf)
79 #< (-6,0), (-4,0), (-3,0), (-2,0), (0,0)
80 response
81
82
83 # -----------------
84 # imports
85 # -----------------
86 #< (0,7), (3,0)
87 import module_not_exists
88
89 #< (-3,7), (0,0)
90 module_not_exists
91
92
93 #< ('import_tree.rename1', 1,0), (0,24), (3,0), (6,17), ('import_tree.rename2', 4,17), (11,17), (14,17), ('imports', 72, 16)
94 from import_tree import rename1
95
96 #< (0,8), ('import_tree.rename1',3,0), ('import_tree.rename2',4,32), ('import_tree.rename2',6,0), (3,32), (8,32), (5,0)
97 rename1.abc
98
99 #< (-3,8), ('import_tree.rename1', 3,0), ('import_tree.rename2', 4,32), ('import_tree.rename2', 6,0), (0,32), (5,32), (2,0)
100 from import_tree.rename1 import abc
101 #< (-5,8), (-2,32), ('import_tree.rename1', 3,0), ('import_tree.rename2', 4,32), ('import_tree.rename2', 6,0), (0,0), (3,32)
102 abc
103
104 #< 20 ('import_tree.rename1', 1,0), ('import_tree.rename2', 4,17), (-11,24), (-8,0), (-5,17), (0,17), (3,17), ('imports', 72, 16)
105 from import_tree.rename1 import abc
106
107 #< (0, 32),
108 from import_tree.rename1 import not_existing
109
110 # Shouldn't raise an error or do anything weird.
111 from not_existing import *
112
113 # -----------------
114 # classes
115 # -----------------
116
117 class TestMethods(object):
118 #< 8 (0,8), (2,13)
119 def a_method(self):
120 #< 13 (-2,8), (0,13)
121 self.a_method()
122 #< 13 (2,8), (0,13), (3,13)
123 self.b_method()
124
125 def b_method(self):
126 self.b_method
127
128
129 class TestClassVar(object):
130 #< 4 (0,4), (5,13), (7,21)
131 class_v = 1
132 def a(self):
133 class_v = 1
134
135 #< (-5,4), (0,13), (2,21)
136 self.class_v
137 #< (-7,4), (-2,13), (0,21)
138 TestClassVar.class_v
139 #< (0,8), (-7, 8)
140 class_v
141
142 class TestInstanceVar():
143 def a(self):
144 #< 13 (4,13), (0,13)
145 self._instance_var = 3
146
147 def b(self):
148 #< (-4,13), (0,13)
149 self._instance_var
150 # A call to self used to trigger an error, because it's also a trailer
151 # with two children.
152 self()
153
154
155 class NestedClass():
156 def __getattr__(self, name):
157 return self
158
159 # Shouldn't find a definition, because there's other `instance`.
160 #< (0, 14),
161 NestedClass().instance
162
163
164 # -----------------
165 # inheritance
166 # -----------------
167 class Super(object):
168 #< 4 (0,4), (23,18), (25,13)
169 base_class = 1
170 #< 4 (0,4),
171 class_var = 1
172
173 #< 8 (0,8),
174 def base_method(self):
175 #< 13 (0,13), (20,13)
176 self.base_var = 1
177 #< 13 (0,13),
178 self.instance_var = 1
179
180 #< 8 (0,8),
181 def just_a_method(self): pass
182
183
184 #< 20 (0,16), (-18,6)
185 class TestClass(Super):
186 #< 4 (0,4),
187 class_var = 1
188
189 def x_method(self):
190
191 #< (0,18), (2,13), (-23,4)
192 TestClass.base_class
193 #< (-2,18), (0,13), (-25,4)
194 self.base_class
195 #< (-20,13), (0,13)
196 self.base_var
197 #< (0, 18),
198 TestClass.base_var
199
200
201 #< 13 (5,13), (0,13)
202 self.instance_var = 3
203
204 #< 9 (0,8),
205 def just_a_method(self):
206 #< (-5,13), (0,13)
207 self.instance_var
208
209
210 # -----------------
211 # properties
212 # -----------------
213 class TestProperty:
214
215 @property
216 #< 10 (0,8), (5,13)
217 def prop(self):
218 return 1
219
220 def a(self):
221 #< 13 (-5,8), (0,13)
222 self.prop
223
224 @property
225 #< 13 (0,8), (4,5), (6,8), (11,13)
226 def rw_prop(self):
227 return self._rw_prop
228
229 #< 8 (-4,8), (0,5), (2,8), (7,13)
230 @rw_prop.setter
231 #< 8 (-6,8), (-2,5), (0,8), (5,13)
232 def rw_prop(self, value):
233 self._rw_prop = value
234
235 def b(self):
236 #< 13 (-11,8), (-7,5), (-5,8), (0,13)
237 self.rw_prop
238
239 # -----------------
240 # *args, **kwargs
241 # -----------------
242 #< 11 (1,11), (0,8)
243 def f(**kwargs):
244 return kwargs
245
246
247 # -----------------
248 # No result
249 # -----------------
250 if isinstance(j, int):
251 #< (0, 4),
252 j
253
254 # -----------------
255 # Dynamic Param Search
256 # -----------------
257
258 class DynamicParam():
259 def foo(self):
260 return
261
262 def check(instance):
263 #< 13 (-5,8), (0,13)
264 instance.foo()
265
266 check(DynamicParam())
267
268 # -----------------
269 # Compiled Objects
270 # -----------------
271
272 import _sre
273
274 # TODO reenable this, it's currently not working, because of 2/3
275 # inconsistencies in typeshed (_sre exists in typeshed/2, but not in
276 # typeshed/3).
277 ##< 0 (-3,7), (0,0), ('_sre', None, None)
278 _sre
279
280 # -----------------
281 # on syntax
282 # -----------------
283
284 #< 0
285 import undefined
286
287 # -----------------
288 # comprehensions
289 # -----------------
290
291 #< 0 (0,0), (2,12)
292 x = 32
293 #< 12 (-2,0), (0,12)
294 [x for x in x]
295
296 #< 0 (0,0), (2,1), (2,12)
297 y = 32
298 #< 12 (-2,0), (0,1), (0,12)
299 [y for b in y]
300
301
302 #< 1 (0,1), (0,7)
303 [x for x in something]
304 #< 7 (0,1), (0,7)
305 [x for x in something]
306
307 z = 3
308 #< 1 (0,1), (0,10)
309 {z:1 for z in something}
310 #< 10 (0,1), (0,10)
311 {z:1 for z in something}
312
313 #< 8 (0,6), (0, 40)
314 [[x + nested_loopv2 for x in bar()] for nested_loopv2 in baz()]
315
316 #< 25 (0,20), (0, 65)
317 (("*" if abs(foo(x, nested_loopv1)) else " " for x in bar()) for nested_loopv1 in baz())
318
319
320 def whatever_func():
321 zzz = 3
322 if UNDEFINED:
323 zzz = 5
324 if UNDEFINED2:
325 #< (3, 8), (4, 4), (0, 12), (-3, 8), (-5, 4)
326 zzz
327 else:
328 #< (0, 8), (1, 4), (-3, 12), (-6, 8), (-8, 4)
329 zzz
330 zzz
331
332 # -----------------
333 # global
334 # -----------------
335
336 def global_usage1():
337 #< (0, 4), (4, 11), (6, 4), (9, 8), (12, 4)
338 my_global
339
340 def global_definition():
341 #< (-4, 4), (0, 11), (2, 4), (5, 8), (8, 4)
342 global my_global
343 #< 4 (-6, 4), (-2, 11), (0, 4), (3, 8), (6, 4)
344 my_global = 3
345 if WHATEVER:
346 #< 8 (-9, 4), (-5, 11), (-3, 4), (0, 8), (3, 4)
347 my_global = 4
348
349 def global_usage2()
350 my_global
351
352 def not_global(my_global):
353 my_global
354
355 class DefinitelyNotGlobal:
356 def my_global(self):
357 def my_global(self):
358 pass
359
360 # -----------------
361 # stubs
362 # -----------------
363
364 from stub_folder import with_stub
365 #< ('stub:stub_folder.with_stub', 5, 4), ('stub_folder.with_stub', 5, 4), (0, 10)
366 with_stub.stub_function
367 from stub_folder.with_stub_folder.nested_stub_only import in_stub_only
368 #< ('stub:stub_folder.with_stub_folder.nested_stub_only', 2, 4), ('stub:stub_folder.with_stub_folder.nested_stub_only', 4, 4), ('stubs', 64, 17), (-2, 58), (0, 0)
369 in_stub_only
370 from stub_folder.with_stub_folder.nested_with_stub import in_python
371 #< ('stub_folder.with_stub_folder.nested_with_stub', 1, 0), ('stubs', 68, 17), (-2, 58), (0, 0)
372 in_python
373 from stub_folder.with_stub_folder.nested_with_stub import in_both
374 #< ('stub_folder.with_stub_folder.nested_with_stub', 2, 0), ('stub:stub_folder.with_stub_folder.nested_with_stub', 2, 0), ('stubs', 66, 17), (-2, 58), (0, 0)
375 in_both
376
377 # -----------------
378 # across directories
379 # -----------------
380
381 #< 8 (0, 0), (3, 4), ('import_tree.references', 1, 21), ('import_tree.references', 5, 4)
382 usage_definition = 1
383 if False:
384 #< 8 (-3, 0), (0, 4), ('import_tree.references', 1, 21), ('import_tree.references', 5, 4)
385 usage_definition()
386
387 # -----------------
388 # stdlib stuff
389 # -----------------
390
391 import socket
392 #< (1, 21), (0, 7), ('socket', ..., 6), ('stub:socket', ..., 6), ('imports', ..., 7)
393 socket.SocketIO
394 some_socket = socket.SocketIO()