eric7/JediInterface/JediServer.py

branch
eric7-maintenance
changeset 9111
4ac66b6c33a4
parent 8943
23f9c7b9e18e
child 9192
a763d57e23bc
equal deleted inserted replaced
9049:2b9bd8f97576 9111:4ac66b6c33a4
504 504
505 newName, ok = QInputDialog.getText( 505 newName, ok = QInputDialog.getText(
506 None, 506 None,
507 self.tr("Rename Variable"), 507 self.tr("Rename Variable"),
508 self.tr("Enter the new name for the variable:"), 508 self.tr("Enter the new name for the variable:"),
509 QLineEdit.EchoMode.Normal 509 QLineEdit.EchoMode.Normal,
510 editor.selectedText()
510 ) 511 )
511 512
512 if ok and newName: 513 if ok and newName and self.__vm.checkAllDirty():
513 filename = editor.getFileName() 514 filename = editor.getFileName()
514 line, index = editor.getCursorPosition() 515 line, index = editor.getCursorPosition()
515 source = editor.text() 516 source = editor.text()
516 517
517 self.__ensureActive(idString) 518 self.__ensureActive(idString)
544 self.tr("Extract Variable"), 545 self.tr("Extract Variable"),
545 self.tr("Enter the name for the new variable:"), 546 self.tr("Enter the name for the new variable:"),
546 QLineEdit.EchoMode.Normal 547 QLineEdit.EchoMode.Normal
547 ) 548 )
548 549
549 if ok and newName: 550 if ok and newName and editor.checkDirty():
550 filename = editor.getFileName() 551 filename = editor.getFileName()
551 sLine, sIndex, eLine, eIndex = editor.getSelection() 552 sLine, sIndex, eLine, eIndex = editor.getSelection()
552 source = editor.text() 553 source = editor.text()
553 554
554 self.__ensureActive(idString) 555 self.__ensureActive(idString)
578 if editor: 579 if editor:
579 idString = self.__idString(editor) 580 idString = self.__idString(editor)
580 if not idString: 581 if not idString:
581 return 582 return
582 583
583 filename = editor.getFileName() 584 if editor.checkDirty():
584 line, index = editor.getCursorPosition() 585 filename = editor.getFileName()
585 source = editor.text() 586 line, index = editor.getCursorPosition()
586 587 source = editor.text()
587 self.__ensureActive(idString) 588
588 589 self.__ensureActive(idString)
589 euuid = str(uuid.uuid4()) 590
590 self.__editors[euuid] = editor 591 euuid = str(uuid.uuid4())
591 592 self.__editors[euuid] = editor
592 self.sendJson("inlineVariable", { 593
593 "FileName": filename, 594 self.sendJson("inlineVariable", {
594 "Source": source, 595 "FileName": filename,
595 "Line": line + 1, 596 "Source": source,
596 "Index": index, 597 "Line": line + 1,
597 "Uuid": euuid, 598 "Index": index,
598 }, idString=idString) 599 "Uuid": euuid,
600 }, idString=idString)
599 601
600 @pyqtSlot() 602 @pyqtSlot()
601 def refactoringExtractFunction(self): 603 def refactoringExtractFunction(self):
602 """ 604 """
603 Public slot to extract an expression to a function. 605 Public slot to extract an expression to a function.
613 self.tr("Extract Function"), 615 self.tr("Extract Function"),
614 self.tr("Enter the name for the function:"), 616 self.tr("Enter the name for the function:"),
615 QLineEdit.EchoMode.Normal 617 QLineEdit.EchoMode.Normal
616 ) 618 )
617 619
618 if ok and newName: 620 if ok and newName and editor.checkDirty():
619 filename = editor.getFileName() 621 filename = editor.getFileName()
620 sLine, sIndex, eLine, eIndex = editor.getSelection() 622 sLine, sIndex, eLine, eIndex = editor.getSelection()
621 source = editor.text() 623 source = editor.text()
622 624
623 self.__ensureActive(idString) 625 self.__ensureActive(idString)
850 interpreter = "" 852 interpreter = ""
851 clientEnv = os.environ.copy() 853 clientEnv = os.environ.copy()
852 if "PATH" in clientEnv: 854 if "PATH" in clientEnv:
853 clientEnv["PATH"] = self.__ui.getOriginalPathString() 855 clientEnv["PATH"] = self.__ui.getOriginalPathString()
854 856
855 if (projectLanguage.startswith("Python") or 857 if projectLanguage in ("Python3", "MicroPython", "Cython"):
856 projectLanguage == "MicroPython"): 858 interpreter = self.__ericProject.getProjectInterpreter(
857 # new code using virtual environments 859 resolveGlobal=False)
858 venvManager = ericApp().getObject("VirtualEnvManager") 860 if interpreter:
859 861 execPath = self.__ericProject.getProjectExecPath()
860 # get virtual environment from project first
861 venvName = self.__ericProject.getDebugProperty("VIRTUALENV")
862 if not venvName:
863 # get it from debugger settings next
864 if projectLanguage in ("Python3", "MicroPython", "Cython"):
865 venvName = Preferences.getDebugger("Python3VirtualEnv")
866 if not venvName:
867 venvName, _ = venvManager.getDefaultEnvironment()
868 else:
869 venvName = ""
870 if venvName:
871 interpreter = venvManager.getVirtualenvInterpreter(
872 venvName)
873 execPath = venvManager.getVirtualenvExecPath(venvName)
874 862
875 # build a suitable environment 863 # build a suitable environment
876 if execPath: 864 if execPath:
877 if "PATH" in clientEnv: 865 if "PATH" in clientEnv:
878 clientEnv["PATH"] = os.pathsep.join( 866 clientEnv["PATH"] = os.pathsep.join(

eric ide

mercurial