def register_proposal(proposal, debug=False): """Register the proposal with the quick assistant. IN: proposal: <AssistantProposal> The object that holds all relevant information and does all the necessary work for the proposal. force = False: <bool> If False (default), we will not attempt to re-register the assist proposal if an assist proposal with the same tag is already registered. If True, then we will override the registered proposal with our own. This is mainly useful for debugging. OUT: None. """ from org.python.pydev.editor.correctionassist import PythonCorrectionProcessor #@UnresolvedImport bTagInUse = PythonCorrectionProcessor.hasAdditionalAssist(proposal.tag) if debug or not bTagInUse: oInterface = AssistantInterface(proposal) PythonCorrectionProcessor.addAdditionalAssist(proposal.tag, oInterface)
def run(self): self.assign_to_attribs_helper.run() systemGlobals[ 'AssignToAttribsOfSelfAction'] = AssignToAttribsOfSelfAction import assign_params_to_attributes_action #---------------------------------------------------------------------------------------------- Bind it to Ctrl+2, a sDescription = 'Assign method params to attribs of self' assign_to_attribs_helper = assign_params_to_attributes_action.AssignToAttribsOfSelf( editor) editor.addOfflineActionListener( ACTIVATION_STRING, AssignToAttribsOfSelfAction(assign_to_attribs_helper), sDescription, WAIT_FOR_ENTER) #------------------------------------------------------------------------------------------------- Bind it to Ctrl+1 if created_class: #This has to be done only once when the class is created. from org.python.pydev.editor.correctionassist import PythonCorrectionProcessor #@UnresolvedImport ASSIGN_PARAMS_TO_ATTRIBUTES_ASSIST = 'ASSIGN_PARAMS_TO_ATTRIBUTES_ASSIST' if not PythonCorrectionProcessor.hasAdditionalAssist( ASSIGN_PARAMS_TO_ATTRIBUTES_ASSIST): import assign_params_to_attributes_assist assist = assign_params_to_attributes_assist.AssistAssignParamsToAttributes( ) PythonCorrectionProcessor.addAdditionalAssist( ASSIGN_PARAMS_TO_ATTRIBUTES_ASSIST, assist)
def __init__(self, assign_to_attribs_helper): Action.__init__(self) self.assign_to_attribs_helper = assign_to_attribs_helper def run(self): self.assign_to_attribs_helper.run() #======================================================================================================================= # Actually bind the actions #======================================================================================================================= if cmd == 'onCreateActions' or (DEBUG and cmd == 'onSave'): from org.python.pydev.editor.correctionassist import PythonCorrectionProcessor #@UnresolvedImport import assign_params_to_attributes_action as helper import assign_params_to_attributes_assist #---------------------------------------------------------------------------------------------- Bind it to Ctrl+2, a sDescription = 'Assign method params to attribs of self' assign_to_attribs_helper = helper.AssignToAttribsOfSelf(editor) editor.addOfflineActionListener( ACTIVATION_STRING, AssignToAttribsOfSelfAction(assign_to_attribs_helper), sDescription, WAIT_FOR_ENTER) #------------------------------------------------------------------------------------------------- Bind it to Ctrl+1 ASSIGN_PARAMS_TO_ATTRIBUTES_ASSIST = 'ASSIGN_PARAMS_TO_ATTRIBUTES_ASSIST' if not PythonCorrectionProcessor.hasAdditionalAssist(ASSIGN_PARAMS_TO_ATTRIBUTES_ASSIST): assist = assign_params_to_attributes_assist.AssistAssignParamsToAttributes() PythonCorrectionProcessor.addAdditionalAssist(ASSIGN_PARAMS_TO_ATTRIBUTES_ASSIST, assist)