eric6/Utilities/ClassBrowsers/jsclbr.py

changeset 7690
a59680062837
parent 7685
0b6e8c0d6403
child 7781
607a6098cb44
--- a/eric6/Utilities/ClassBrowsers/jsclbr.py	Fri Sep 04 18:48:52 2020 +0200
+++ b/eric6/Utilities/ClassBrowsers/jsclbr.py	Fri Sep 04 18:50:43 2020 +0200
@@ -279,7 +279,6 @@
                                   self.__file, var.line))
 
 
-# TODO: extract scan function (see pyclbr)
 def readmodule_ex(module, path=None):
     """
     Read a JavaScript file and return a dictionary of functions and variables.
@@ -290,8 +289,6 @@
     """
     global _modules
     
-    dictionary = {}
-
     if module in _modules:
         # we've seen this file before...
         return _modules[module]
@@ -304,19 +301,38 @@
         f.close()
     if type not in SUPPORTED_TYPES:
         # not CORBA IDL source, can't do anything with this module
-        _modules[module] = dictionary
-        return dictionary
+        _modules[module] = {}
+        return {}
 
-    _modules[module] = dictionary
     try:
         src = Utilities.readEncodedFile(file)[0]
     except (UnicodeError, IOError):
         # can't do anything with this module
-        _modules[module] = dictionary
-        return dictionary
+        _modules[module] = {}
+        return {}
+    
+    _modules[module] = scan(src, file, module)
+    return _modules[module]
+
+
+def scan(src, file, module):
+    """
+    Public method to scan the given source text.
+    
+    @param src source text to be scanned
+    @type str
+    @param file file name associated with the source text
+    @type str
+    @param module module name associated with the source text
+    @type str
+    @return dictionary containing the extracted data
+    @rtype dict
+    """
     # convert eol markers the Python style
     src = src.replace("\r\n", "\n").replace("\r", "\n")
     
+    dictionary = {}
+
     visitor = Visitor(src, module, file)
     dictionary = visitor.parse()
     _modules[module] = dictionary

eric ide

mercurial