Extended the module parser to record each line a variable/attribute is assigned to.

Wed, 07 Sep 2011 18:18:00 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Wed, 07 Sep 2011 18:18:00 +0200
changeset 1302
95538c8d07c1
parent 1300
9083f6b7ea3b
child 1303
6018d7ac3aec

Extended the module parser to record each line a variable/attribute is assigned to.

APIs/Python3/eric5.api file | annotate | diff | comparison | revisions
Documentation/Help/source.qch file | annotate | diff | comparison | revisions
Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
Documentation/Source/eric5.Utilities.ModuleParser.html file | annotate | diff | comparison | revisions
Utilities/ModuleParser.py file | annotate | diff | comparison | revisions
--- a/APIs/Python3/eric5.api	Wed Sep 07 18:08:56 2011 +0200
+++ b/APIs/Python3/eric5.api	Wed Sep 07 18:18:00 2011 +0200
@@ -6637,6 +6637,7 @@
 eric5.Utilities.ClassBrowsers.rbclbr.readmodule_ex?4(module, path=[])
 eric5.Utilities.ClassBrowsers.readmodule?4(module, path=[], isPyFile=False)
 eric5.Utilities.CodingError?1(coding)
+eric5.Utilities.ModuleParser.Attribute.addAssignment?4(lineno)
 eric5.Utilities.ModuleParser.Attribute?1(module, name, file, lineno, isSignal=False)
 eric5.Utilities.ModuleParser.Class.addAttribute?4(name, attr)
 eric5.Utilities.ModuleParser.Class.addDescription?4(description)
Binary file Documentation/Help/source.qch has changed
--- a/Documentation/Help/source.qhp	Wed Sep 07 18:08:56 2011 +0200
+++ b/Documentation/Help/source.qhp	Wed Sep 07 18:18:00 2011 +0200
@@ -2526,6 +2526,7 @@
       <keyword name="resetParsedModule" id="resetParsedModule" ref="eric5.Utilities.ModuleParser.html#resetParsedModule" />
       <keyword name="resetParsedModules" id="resetParsedModules" ref="eric5.Utilities.ModuleParser.html#resetParsedModules" />
       <keyword name="Attribute (Constructor)" id="Attribute (Constructor)" ref="eric5.Utilities.ModuleParser.html#Attribute.__init__" />
+      <keyword name="Attribute.addAssignment" id="Attribute.addAssignment" ref="eric5.Utilities.ModuleParser.html#Attribute.addAssignment" />
       <keyword name="Class (Constructor)" id="Class (Constructor)" ref="eric5.Utilities.ModuleParser.html#Class.__init__" />
       <keyword name="Class.addAttribute" id="Class.addAttribute" ref="eric5.Utilities.ModuleParser.html#Class.addAttribute" />
       <keyword name="Class.addDescription" id="Class.addDescription" ref="eric5.Utilities.ModuleParser.html#Class.addDescription" />
--- a/Documentation/Source/eric5.Utilities.ModuleParser.html	Wed Sep 07 18:08:56 2011 +0200
+++ b/Documentation/Source/eric5.Utilities.ModuleParser.html	Wed Sep 07 18:18:00 2011 +0200
@@ -99,6 +99,9 @@
 <tr>
 <td><a href="#Attribute.__init__">Attribute</a></td>
 <td>Constructor</td>
+</tr><tr>
+<td><a href="#Attribute.addAssignment">addAssignment</a></td>
+<td>Public method to add another assignment line number.</td>
 </tr>
 </table>
 <h3>Static Methods</h3>
@@ -122,11 +125,21 @@
 name of file containing this function (string)
 </dd><dt><i>lineno</i></dt>
 <dd>
-linenumber of the function definition (integer)
+linenumber of the first attribute assignment (integer)
 </dd><dt><i>isSignal=</i></dt>
 <dd>
 flag indicating a signal definition (boolean)
 </dd>
+</dl><a NAME="Attribute.addAssignment" ID="Attribute.addAssignment"></a>
+<h4>Attribute.addAssignment</h4>
+<b>addAssignment</b>(<i>lineno</i>)
+<p>
+        Public method to add another assignment line number.
+</p><dl>
+<dt><i>lineno</i></dt>
+<dd>
+linenumber of the additional attribute assignment (integer)
+</dd>
 </dl>
 <div align="right"><a href="#top">Up</a></div>
 <hr /><hr />
--- a/Utilities/ModuleParser.py	Wed Sep 07 18:08:56 2011 +0200
+++ b/Utilities/ModuleParser.py	Wed Sep 07 18:18:00 2011 +0200
@@ -436,6 +436,8 @@
         """
         if not name in self.globals:
             self.globals[name] = attr
+        else:
+            self.globals[name].addAssignment(attr.lineno)
     
     def addDescription(self, description):
         """
@@ -1171,6 +1173,8 @@
         """
         if not name in self.attributes:
             self.attributes[name] = attr
+        else:
+            self.attributes[name].addAssignment(attr.lineno)
     
     def getAttribute(self, name):
         """
@@ -1193,6 +1197,8 @@
         """
         if not name in self.globals:
             self.globals[name] = attr
+        else:
+            self.globals[name].addAssignment(attr.lineno)
     
     def addDescription(self, description):
         """
@@ -1289,7 +1295,7 @@
         @param module name of module containing this function (string)
         @param name name of the function (string)
         @param file name of file containing this function (string)
-        @param lineno linenumber of the function definition (integer)
+        @param lineno linenumber of the first attribute assignment (integer)
         @keyparam isSignal flag indicating a signal definition (boolean)
         """
         self.module = module
@@ -1298,6 +1304,16 @@
         self.lineno = lineno
         self.isSignal = isSignal
         self.setPublic()
+        self.linenos = [lineno]
+    
+    def addAssignment(self, lineno):
+        """
+        Public method to add another assignment line number.
+        
+        @param lineno linenumber of the additional attribute assignment (integer)
+        """
+        if lineno not in self.linenos:
+            self.linenos.append(lineno)
 
 
 def readModule(module, path=[], inpackage=False, basename="",

eric ide

mercurial