eric6/Utilities/ClassBrowsers/idlclbr.py

changeset 7690
a59680062837
parent 7685
0b6e8c0d6403
child 7699
d338c533f5f0
equal deleted inserted replaced
7689:147236d850a4 7690:a59680062837
197 """ 197 """
198 ClbrBaseClasses.Attribute.__init__(self, module, name, file, lineno) 198 ClbrBaseClasses.Attribute.__init__(self, module, name, file, lineno)
199 VisibilityMixin.__init__(self) 199 VisibilityMixin.__init__(self)
200 200
201 201
202 # TODO: extract scan function (see pyclbr)
203 def readmodule_ex(module, path=None): 202 def readmodule_ex(module, path=None):
204 """ 203 """
205 Read a CORBA IDL file and return a dictionary of classes, functions and 204 Read a CORBA IDL file and return a dictionary of classes, functions and
206 modules. 205 modules.
207 206
212 @return the resulting dictionary 211 @return the resulting dictionary
213 @rtype dict 212 @rtype dict
214 """ 213 """
215 global _modules 214 global _modules
216 215
217 dictionary = {}
218 dict_counts = {}
219
220 if module in _modules: 216 if module in _modules:
221 # we've seen this file before... 217 # we've seen this file before...
222 return _modules[module] 218 return _modules[module]
223 219
224 # search the path for the file 220 # search the path for the file
227 f, file, (suff, mode, type) = ClassBrowsers.find_module(module, fullpath) 223 f, file, (suff, mode, type) = ClassBrowsers.find_module(module, fullpath)
228 if f: 224 if f:
229 f.close() 225 f.close()
230 if type not in SUPPORTED_TYPES: 226 if type not in SUPPORTED_TYPES:
231 # not CORBA IDL source, can't do anything with this module 227 # not CORBA IDL source, can't do anything with this module
232 _modules[module] = dictionary 228 _modules[module] = {}
233 return dictionary 229 return {}
234 230
235 _modules[module] = dictionary
236 classstack = [] # stack of (class, indent) pairs
237 indent = 0
238 try: 231 try:
239 src = Utilities.readEncodedFile(file)[0] 232 src = Utilities.readEncodedFile(file)[0]
240 except (UnicodeError, IOError): 233 except (UnicodeError, IOError):
241 # can't do anything with this module 234 # can't do anything with this module
242 _modules[module] = dictionary 235 _modules[module] = {}
243 return dictionary 236 return {}
237
238 _modules[module] = scan(src, file, module)
239 return _modules[module]
240
241
242 def scan(src, file, module):
243 """
244 Public method to scan the given source text.
245
246 @param src source text to be scanned
247 @type str
248 @param file file name associated with the source text
249 @type str
250 @param module module name associated with the source text
251 @type str
252 @return dictionary containing the extracted data
253 @rtype dict
254 """
244 # convert eol markers the Python style 255 # convert eol markers the Python style
245 src = src.replace("\r\n", "\n").replace("\r", "\n") 256 src = src.replace("\r\n", "\n").replace("\r", "\n")
246 257
258 dictionary = {}
259 dict_counts = {}
260
261 classstack = [] # stack of (class, indent) pairs
262 indent = 0
263
247 lineno, last_lineno_pos = 1, 0 264 lineno, last_lineno_pos = 1, 0
248 lastGlobalEntry = None 265 lastGlobalEntry = None
249 cur_obj = None 266 cur_obj = None
250 i = 0 267 i = 0
251 while True: 268 while True:

eric ide

mercurial