src/eric7/Utilities/ClassBrowsers/ClbrBaseClasses.py

branch
eric7
changeset 10677
6ee2e475490c
parent 10439
21c28b0f9e41
child 11090
f5f5f5803935
equal deleted inserted replaced
10676:d1479a4f1426 10677:6ee2e475490c
11 class _ClbrBase: 11 class _ClbrBase:
12 """ 12 """
13 Class implementing the base of all class browser objects. 13 Class implementing the base of all class browser objects.
14 """ 14 """
15 15
16 def __init__(self, module, name, file, lineno): 16 def __init__(self, module, name, file, lineno, col_offset=0):
17 """ 17 """
18 Constructor 18 Constructor
19 19
20 @param module name of the module containing this object 20 @param module name of the module containing this object
21 @type str 21 @type str
22 @param name name of this object 22 @param name name of this object
23 @type str 23 @type str
24 @param file filename containing this object 24 @param file file name containing this object
25 @type str 25 @type str
26 @param lineno linenumber of the object definition 26 @param lineno line number of the object definition
27 @type int 27 @type int
28 @param col_offset column number of the object definition (defaults to 0)
29 @type int (optional)
28 """ 30 """
29 self.module = module 31 self.module = module
30 self.name = name 32 self.name = name
31 self.file = file 33 self.file = file
32 self.lineno = lineno 34 self.lineno = lineno
35 self.coloffset = col_offset
36
33 self.endlineno = -1 # marker for "not set" 37 self.endlineno = -1 # marker for "not set"
34 38
35 def setEndLine(self, endLineNo): 39 def setEndLine(self, endLineNo):
36 """ 40 """
37 Public method to set the ending line number. 41 Public method to set the ending line number.
45 class ClbrBase(_ClbrBase): 49 class ClbrBase(_ClbrBase):
46 """ 50 """
47 Class implementing the base of all complex class browser objects. 51 Class implementing the base of all complex class browser objects.
48 """ 52 """
49 53
50 def __init__(self, module, name, file, lineno): 54 def __init__(self, module, name, file, lineno, col_offset=0):
51 """ 55 """
52 Constructor 56 Constructor
53 57
54 @param module name of the module containing this object 58 @param module name of the module containing this object
55 @type str 59 @type str
56 @param name name of this object 60 @param name name of this object
57 @type str 61 @type str
58 @param file filename containing this object 62 @param file file name containing this object
59 @type str 63 @type str
60 @param lineno linenumber of the object definition 64 @param lineno line number of the object definition
61 @type int 65 @type int
62 """ 66 @param col_offset column number of the object definition (defaults to 0)
63 _ClbrBase.__init__(self, module, name, file, lineno) 67 @type int (optional)
68 """
69 _ClbrBase.__init__(self, module, name, file, lineno, col_offset=col_offset)
64 self.methods = {} 70 self.methods = {}
65 self.attributes = {} 71 self.attributes = {}
66 self.classes = {} 72 self.classes = {}
67 self.globals = {} 73 self.globals = {}
68 74
209 class Attribute(_ClbrBase): 215 class Attribute(_ClbrBase):
210 """ 216 """
211 Class to represent an attribute. 217 Class to represent an attribute.
212 """ 218 """
213 219
214 def __init__(self, module, name, file, lineno): 220 def __init__(self, module, name, file, lineno, col_offset=0):
215 """ 221 """
216 Constructor 222 Constructor
217 223
218 @param module name of the module containing this attribute 224 @param module name of the module containing this attribute
219 @type str 225 @type str
220 @param name name of this attribute 226 @param name name of this attribute
221 @type str 227 @type str
222 @param file filename containing this attribute 228 @param file file name containing this attribute
223 @type str 229 @type str
224 @param lineno line number of the attribute definition 230 @param lineno line number of the attribute definition
225 @type int 231 @type int
226 """ 232 @param col_offset column number of the attribute definition (defaults to 0)
227 _ClbrBase.__init__(self, module, name, file, lineno) 233 @type int (optional)
234 """
235 _ClbrBase.__init__(self, module, name, file, lineno, col_offset=col_offset)
228 236
229 self.linenos = [lineno] 237 self.linenos = [lineno]
230 238
231 def addAssignment(self, lineno): 239 def addAssignment(self, lineno):
232 """ 240 """
242 class Class(ClbrBase): 250 class Class(ClbrBase):
243 """ 251 """
244 Class to represent a class. 252 Class to represent a class.
245 """ 253 """
246 254
247 def __init__(self, module, name, superClasses, file, lineno): 255 def __init__(self, module, name, superClasses, file, lineno, col_offset=0):
248 """ 256 """
249 Constructor 257 Constructor
250 258
251 @param module name of the module containing this class 259 @param module name of the module containing this class
252 @type str 260 @type str
253 @param name name of this class 261 @param name name of this class
254 @type str 262 @type str
255 @param superClasses list of class names this class is inherited from 263 @param superClasses list of class names this class is inherited from
256 @type list of str 264 @type list of str
257 @param file filename containing this class 265 @param file file name containing this class
258 @type str 266 @type str
259 @param lineno line number of the class definition 267 @param lineno line number of the class definition
260 @type int 268 @type int
261 """ 269 @param col_offset column number of the class definition (defaults to 0)
262 ClbrBase.__init__(self, module, name, file, lineno) 270 @type int (optional)
271 """
272 ClbrBase.__init__(self, module, name, file, lineno, col_offset=col_offset)
263 if superClasses is None: 273 if superClasses is None:
264 superClasses = [] 274 superClasses = []
265 self.super = superClasses 275 self.super = superClasses
266 276
267 277
268 class Module(ClbrBase): 278 class Module(ClbrBase):
269 """ 279 """
270 Class to represent a module. 280 Class to represent a module.
271 """ 281 """
272 282
273 def __init__(self, module, name, file, lineno): 283 def __init__(self, module, name, file, lineno, col_offset=0):
274 """ 284 """
275 Constructor 285 Constructor
276 286
277 @param module name of the module containing this module 287 @param module name of the module containing this module
278 @type str 288 @type str
279 @param name name of this module 289 @param name name of this module
280 @type str 290 @type str
281 @param file filename containing this module 291 @param file file name containing this module
282 @type str 292 @type str
283 @param lineno line number of the module definition 293 @param lineno line number of the module definition
284 @type int 294 @type int
285 """ 295 @param col_offset column number of the module definition (defaults to 0)
286 ClbrBase.__init__(self, module, name, file, lineno) 296 @type int (optional)
297 """
298 ClbrBase.__init__(self, module, name, file, lineno, col_offset=col_offset)
287 299
288 300
289 class Function(ClbrBase): 301 class Function(ClbrBase):
290 """ 302 """
291 Class to represent a function or method. 303 Class to represent a function or method.
299 self, 311 self,
300 module, 312 module,
301 name, 313 name,
302 file, 314 file,
303 lineno, 315 lineno,
316 col_offset=0,
304 signature="", 317 signature="",
305 separator=",", 318 separator=",",
306 modifierType=General, 319 modifierType=General,
307 annotation="", 320 annotation="",
308 ): 321 ):
311 324
312 @param module name of the module containing this function 325 @param module name of the module containing this function
313 @type str 326 @type str
314 @param name name of this function 327 @param name name of this function
315 @type str 328 @type str
316 @param file filename containing this function 329 @param file file name containing this function
317 @type str 330 @type str
318 @param lineno line number of the function definition 331 @param lineno line number of the function definition
319 @type int 332 @type int
333 @param col_offset column number of the function definition (defaults to 0)
334 @type int (optional)
320 @param signature parameter list of the function 335 @param signature parameter list of the function
321 @type str 336 @type str
322 @param separator string separating the parameters of the function 337 @param separator string separating the parameters of the function
323 @type str 338 @type str
324 @param modifierType type of the function 339 @param modifierType type of the function
325 @type int 340 @type int
326 @param annotation function return annotation 341 @param annotation function return annotation
327 @type str 342 @type str
328 """ 343 """
329 ClbrBase.__init__(self, module, name, file, lineno) 344 ClbrBase.__init__(self, module, name, file, lineno, col_offset=col_offset)
330 self.parameters = [e.strip() for e in signature.split(separator)] 345 self.parameters = [e.strip() for e in signature.split(separator)]
331 self.modifier = modifierType 346 self.modifier = modifierType
332 self.annotation = annotation 347 self.annotation = annotation
333 348
334 349
341 """ 356 """
342 Constructor 357 Constructor
343 358
344 @param module name of the module containing this coding statement 359 @param module name of the module containing this coding statement
345 @type str 360 @type str
346 @param file filename containing this coding statement 361 @param file file name containing this coding statement
347 @type str 362 @type str
348 @param lineno line number of the coding definition 363 @param lineno line number of the coding definition
349 @type int 364 @type int
350 @param coding character coding of the source file 365 @param coding character coding of the source file
351 @type str 366 @type str
358 class Enum(ClbrBase): 373 class Enum(ClbrBase):
359 """ 374 """
360 Class to represent an enum definition. 375 Class to represent an enum definition.
361 """ 376 """
362 377
363 def __init__(self, module, name, file, lineno): 378 def __init__(self, module, name, file, lineno, col_offset=0):
364 """ 379 """
365 Constructor 380 Constructor
366 381
367 @param module name of the module containing this enum 382 @param module name of the module containing this enum
368 @type str 383 @type str
369 @param name name of this enum 384 @param name name of this enum
370 @type str 385 @type str
371 @param file filename containing this enum 386 @param file file name containing this enum
372 @type str 387 @type str
373 @param lineno line number of the enum definition 388 @param lineno line number of the enum definition
374 @type int 389 @type int
375 """ 390 @param col_offset column number of the enum definition (defaults to 0)
376 ClbrBase.__init__(self, module, name, file, lineno) 391 @type int (optional)
392 """
393 ClbrBase.__init__(self, module, name, file, lineno, col_offset=col_offset)

eric ide

mercurial