Changed the 'jedi' refactoring process such, that the current file modified by the refactoring is automatically reloaded. eric7

Tue, 16 Jul 2024 16:08:50 +0200

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Tue, 16 Jul 2024 16:08:50 +0200
branch
eric7
changeset 10850
d835f48b9908
parent 10849
78d338b6d89f
child 10851
5c47172bb240

Changed the 'jedi' refactoring process such, that the current file modified by the refactoring is automatically reloaded.

src/eric7/APIs/Python3/eric7.api file | annotate | diff | comparison | revisions
src/eric7/Documentation/Help/source.qch file | annotate | diff | comparison | revisions
src/eric7/Documentation/Help/source.qhp file | annotate | diff | comparison | revisions
src/eric7/Documentation/Source/eric7.QScintilla.Editor.html file | annotate | diff | comparison | revisions
src/eric7/JediInterface/JediClient.py file | annotate | diff | comparison | revisions
src/eric7/JediInterface/JediServer.py file | annotate | diff | comparison | revisions
src/eric7/QScintilla/Editor.py file | annotate | diff | comparison | revisions
--- a/src/eric7/APIs/Python3/eric7.api	Tue Jul 16 15:14:23 2024 +0200
+++ b/src/eric7/APIs/Python3/eric7.api	Tue Jul 16 16:08:50 2024 +0200
@@ -8760,6 +8760,7 @@
 eric7.QScintilla.Editor.Editor.sendSharedEdit?4()
 eric7.QScintilla.Editor.Editor.setAutoCompletionEnabled?4(enable)
 eric7.QScintilla.Editor.Editor.setAutoSpellChecking?4()
+eric7.QScintilla.Editor.Editor.setCheckExternalModificationEnabled?4(enable)
 eric7.QScintilla.Editor.Editor.setFileName?4(name)
 eric7.QScintilla.Editor.Editor.setHighlight?4(startLine, startIndex, endLine, endIndex)
 eric7.QScintilla.Editor.Editor.setLanguage?4(filename, initTextDisplay=True, propagate=True, pyname="")
Binary file src/eric7/Documentation/Help/source.qch has changed
--- a/src/eric7/Documentation/Help/source.qhp	Tue Jul 16 15:14:23 2024 +0200
+++ b/src/eric7/Documentation/Help/source.qhp	Tue Jul 16 16:08:50 2024 +0200
@@ -4996,6 +4996,7 @@
       <keyword name="Editor.sendSharedEdit" id="Editor.sendSharedEdit" ref="eric7.QScintilla.Editor.html#Editor.sendSharedEdit" />
       <keyword name="Editor.setAutoCompletionEnabled" id="Editor.setAutoCompletionEnabled" ref="eric7.QScintilla.Editor.html#Editor.setAutoCompletionEnabled" />
       <keyword name="Editor.setAutoSpellChecking" id="Editor.setAutoSpellChecking" ref="eric7.QScintilla.Editor.html#Editor.setAutoSpellChecking" />
+      <keyword name="Editor.setCheckExternalModificationEnabled" id="Editor.setCheckExternalModificationEnabled" ref="eric7.QScintilla.Editor.html#Editor.setCheckExternalModificationEnabled" />
       <keyword name="Editor.setFileName" id="Editor.setFileName" ref="eric7.QScintilla.Editor.html#Editor.setFileName" />
       <keyword name="Editor.setHighlight" id="Editor.setHighlight" ref="eric7.QScintilla.Editor.html#Editor.setHighlight" />
       <keyword name="Editor.setLanguage" id="Editor.setLanguage" ref="eric7.QScintilla.Editor.html#Editor.setLanguage" />
--- a/src/eric7/Documentation/Source/eric7.QScintilla.Editor.html	Tue Jul 16 15:14:23 2024 +0200
+++ b/src/eric7/Documentation/Source/eric7.QScintilla.Editor.html	Tue Jul 16 16:08:50 2024 +0200
@@ -1754,6 +1754,10 @@
 <td>Public method to set the automatic spell checking.</td>
 </tr>
 <tr>
+<td><a href="#Editor.setCheckExternalModificationEnabled">setCheckExternalModificationEnabled</a></td>
+<td>Public method to enable or disable the check for external modifications.</td>
+</tr>
+<tr>
 <td><a href="#Editor.setFileName">setFileName</a></td>
 <td>Public method to set the file name of the current file.</td>
 </tr>
@@ -7455,6 +7459,20 @@
         Public method to set the automatic spell checking.
 </p>
 
+<a NAME="Editor.setCheckExternalModificationEnabled" ID="Editor.setCheckExternalModificationEnabled"></a>
+<h4>Editor.setCheckExternalModificationEnabled</h4>
+<b>setCheckExternalModificationEnabled</b>(<i>enable</i>)
+<p>
+        Public method to enable or disable the check for external modifications.
+</p>
+
+<dl>
+
+<dt><i>enable</i> (bool)</dt>
+<dd>
+flag indicating the new enabled state
+</dd>
+</dl>
 <a NAME="Editor.setFileName" ID="Editor.setFileName"></a>
 <h4>Editor.setFileName</h4>
 <b>setFileName</b>(<i>name</i>)
--- a/src/eric7/JediInterface/JediClient.py	Tue Jul 16 15:14:23 2024 +0200
+++ b/src/eric7/JediInterface/JediClient.py	Tue Jul 16 16:08:50 2024 +0200
@@ -582,6 +582,7 @@
 
         result = {
             "result": ok,
+            "Uuid": uid,
         }
         result.update(errorDict)
 
--- a/src/eric7/JediInterface/JediServer.py	Tue Jul 16 15:14:23 2024 +0200
+++ b/src/eric7/JediInterface/JediServer.py	Tue Jul 16 16:08:50 2024 +0200
@@ -700,6 +700,8 @@
             editor = self.__editors[uid]
             idString = self.__idString(editor)
 
+            editor.setCheckExternalModificationEnabled(False)
+
             self.sendJson(
                 "applyRefactoring",
                 {
@@ -708,8 +710,6 @@
                 idString=idString,
             )
 
-            del self.__editors[uid]
-
     def __cancelRefactoring(self, uid):
         """
         Private method to cancel a given refactoring.
@@ -746,6 +746,15 @@
                     "<p>The refactoring could not be applied.</p><p>Reason: {0}</p>"
                 ).format(result["ErrorString"]),
             )
+        else:
+            with contextlib.suppress(KeyError):
+                self.__editors[result["Uuid"]].reload()
+                self.__editors[result["Uuid"]].setCheckExternalModificationEnabled(
+                    True
+                )
+
+        with contextlib.suppress(KeyError):
+            del self.__editors[result["Uuid"]]
 
     #######################################################################
     ## Methods below handle the network connection
--- a/src/eric7/QScintilla/Editor.py	Tue Jul 16 15:14:23 2024 +0200
+++ b/src/eric7/QScintilla/Editor.py	Tue Jul 16 16:08:50 2024 +0200
@@ -329,6 +329,8 @@
         # true if we are propagating a lines changed event
         self.__hasTaskMarkers = False
         # no task markers present
+        self.__checkExternalModification = True
+        # check and reload or warn when modified externally
 
         self.macros = {}  # list of defined macros
         self.curMacro = None
@@ -8380,13 +8382,22 @@
             or self.isReadOnly()
         )
 
+    def setCheckExternalModificationEnabled(self, enable):
+        """
+        Public method to enable or disable the check for external modifications.
+
+        @param enable flag indicating the new enabled state
+        @type bool
+        """
+        self.__checkExternalModification = enable
+
     @pyqtSlot()
     def checkRereadFile(self):
         """
         Public slot to check, if the file needs to be re-read, and refresh it if
         needed.
         """
-        if self.checkModificationTime():
+        if self.__checkExternalModification and self.checkModificationTime():
             if Preferences.getEditor("AutoReopen") and not self.isModified():
                 self.__refresh()
             else:

eric ide

mercurial