230 lineno = lineno + src.count('\n', last_lineno_pos, start) |
232 lineno = lineno + src.count('\n', last_lineno_pos, start) |
231 last_lineno_pos = start |
233 last_lineno_pos = start |
232 # close all interfaces/modules indented at least as much |
234 # close all interfaces/modules indented at least as much |
233 while classstack and \ |
235 while classstack and \ |
234 classstack[-1][1] >= thisindent: |
236 classstack[-1][1] >= thisindent: |
|
237 if classstack[-1][0] is not None: |
|
238 # record the end line |
|
239 classstack[-1][0].setEndLine(lineno - 1) |
235 del classstack[-1] |
240 del classstack[-1] |
236 if classstack: |
241 if classstack: |
237 # it's an interface/module method |
242 # it's an interface/module method |
238 cur_class = classstack[-1][0] |
243 cur_class = classstack[-1][0] |
239 if isinstance(cur_class, Interface) or isinstance(cur_class, Module): |
244 if isinstance(cur_class, Interface) or isinstance(cur_class, Module): |
240 # it's a method |
245 # it's a method |
241 f = Function(None, meth_name, |
246 f = Function(None, meth_name, |
242 file, lineno, meth_sig) |
247 file, lineno, meth_sig) |
243 cur_class._addmethod(meth_name, f) |
248 cur_class._addmethod(meth_name, f) |
244 # else it's a nested def |
249 # else it's a nested def |
|
250 else: |
|
251 f = None |
245 else: |
252 else: |
246 # it's a function |
253 # it's a function |
247 f = Function(module, meth_name, |
254 f = Function(module, meth_name, |
248 file, lineno, meth_sig) |
255 file, lineno, meth_sig) |
249 if meth_name in dict_counts: |
256 if meth_name in dict_counts: |
250 dict_counts[meth_name] += 1 |
257 dict_counts[meth_name] += 1 |
251 meth_name = "{0}_{1:d}".format(meth_name, dict_counts[meth_name]) |
258 meth_name = "{0}_{1:d}".format(meth_name, dict_counts[meth_name]) |
252 else: |
259 else: |
253 dict_counts[meth_name] = 0 |
260 dict_counts[meth_name] = 0 |
254 dict[meth_name] = f |
261 dict[meth_name] = f |
|
262 if not classstack: |
|
263 if lastGlobalEntry: |
|
264 lastGlobalEntry.setEndLine(lineno - 1) |
|
265 lastGlobalEntry = f |
|
266 if cur_obj and isinstance(cur_obj, Function): |
|
267 cur_obj.setEndLine(lineno - 1) |
|
268 cur_obj = f |
255 classstack.append((f, thisindent)) # Marker for nested fns |
269 classstack.append((f, thisindent)) # Marker for nested fns |
256 |
270 |
257 elif m.start("String") >= 0: |
271 elif m.start("String") >= 0: |
258 pass |
272 pass |
259 |
273 |
265 thisindent = indent |
279 thisindent = indent |
266 indent += 1 |
280 indent += 1 |
267 # close all interfaces/modules indented at least as much |
281 # close all interfaces/modules indented at least as much |
268 while classstack and \ |
282 while classstack and \ |
269 classstack[-1][1] >= thisindent: |
283 classstack[-1][1] >= thisindent: |
|
284 if classstack[-1][0] is not None: |
|
285 # record the end line |
|
286 classstack[-1][0].setEndLine(lineno - 1) |
270 del classstack[-1] |
287 del classstack[-1] |
271 lineno = lineno + src.count('\n', last_lineno_pos, start) |
288 lineno = lineno + src.count('\n', last_lineno_pos, start) |
272 last_lineno_pos = start |
289 last_lineno_pos = start |
273 class_name = m.group("InterfaceName") |
290 class_name = m.group("InterfaceName") |
274 inherit = m.group("InterfaceSupers") |
291 inherit = m.group("InterfaceSupers") |
282 if not classstack: |
299 if not classstack: |
283 dict[class_name] = cur_class |
300 dict[class_name] = cur_class |
284 else: |
301 else: |
285 cls = classstack[-1][0] |
302 cls = classstack[-1][0] |
286 cls._addclass(class_name, cur_class) |
303 cls._addclass(class_name, cur_class) |
|
304 if not classstack: |
|
305 if lastGlobalEntry: |
|
306 lastGlobalEntry.setEndLine(lineno - 1) |
|
307 lastGlobalEntry = cur_class |
|
308 if cur_obj and isinstance(cur_obj, Function): |
|
309 cur_obj.setEndLine(lineno - 1) |
|
310 cur_obj = cur_class |
287 classstack.append((cur_class, thisindent)) |
311 classstack.append((cur_class, thisindent)) |
288 |
312 |
289 elif m.start("Module") >= 0: |
313 elif m.start("Module") >= 0: |
290 # we found a module definition |
314 # we found a module definition |
291 thisindent = indent |
315 thisindent = indent |
292 indent += 1 |
316 indent += 1 |
293 # close all interfaces/modules indented at least as much |
317 # close all interfaces/modules indented at least as much |
294 while classstack and \ |
318 while classstack and \ |
295 classstack[-1][1] >= thisindent: |
319 classstack[-1][1] >= thisindent: |
|
320 if classstack[-1][0] is not None: |
|
321 # record the end line |
|
322 classstack[-1][0].setEndLine(lineno - 1) |
296 del classstack[-1] |
323 del classstack[-1] |
297 lineno = lineno + src.count('\n', last_lineno_pos, start) |
324 lineno = lineno + src.count('\n', last_lineno_pos, start) |
298 last_lineno_pos = start |
325 last_lineno_pos = start |
299 module_name = m.group("ModuleName") |
326 module_name = m.group("ModuleName") |
300 # remember this module |
327 # remember this module |
301 cur_class = Module(module, module_name, file, lineno) |
328 cur_class = Module(module, module_name, file, lineno) |
302 if not classstack: |
329 if not classstack: |
303 dict[module_name] = cur_class |
330 dict[module_name] = cur_class |
|
331 if lastGlobalEntry: |
|
332 lastGlobalEntry.setEndLine(lineno - 1) |
|
333 lastGlobalEntry = cur_class |
|
334 if cur_obj and isinstance(cur_obj, Function): |
|
335 cur_obj.setEndLine(lineno - 1) |
|
336 cur_obj = cur_class |
304 classstack.append((cur_class, thisindent)) |
337 classstack.append((cur_class, thisindent)) |
305 |
338 |
306 elif m.start("Attribute") >= 0: |
339 elif m.start("Attribute") >= 0: |
307 lineno = lineno + src.count('\n', last_lineno_pos, start) |
340 lineno = lineno + src.count('\n', last_lineno_pos, start) |
308 last_lineno_pos = start |
341 last_lineno_pos = start |