[Pydev-cvs] org.python.pydev.refactoring/src/org/python/pydev/refactoring/coderefactoring/extractme
Brought to you by:
fabioz
Update of /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/coderefactoring/extractmethod In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21605/src/org/python/pydev/refactoring/coderefactoring/extractmethod Modified Files: ExtractMethodRequestProcessor.java ExtractMethodRefactoring.java ExtractMethodChangeProcessor.java Log Message: Synching to latest changes: Pydev <ul> <li><strong>Editor</strong>: Cursor settings no longer overridden</li> <li><strong>Code-completion</strong>: If __all__ is defined with runtime elements (and not only in a single assign statement), it's ignored for code-completion purposes</li> <li><strong>Debugger</strong>: Pythonpath the same in debug and regular modes (sys.path[0] is the same directory as the file run)</li> <li><strong>Debugger</strong>: Persist choices done in the debugger when files from the debugger are not found</li> <li><strong>Interpreter config</strong>: "email" automatically added to the "forced builtins"</li> <li><strong>Parser</strong>: Correctly recognizing absolute import with 3 or more levels</li> <li><strong>Syntax check</strong>: Option to do only on active editor</li> </ul> Also: tabs changed for spaces Index: ExtractMethodRefactoring.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/coderefactoring/extractmethod/ExtractMethodRefactoring.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ExtractMethodRefactoring.java 20 Oct 2007 19:31:04 -0000 1.5 --- ExtractMethodRefactoring.java 27 Sep 2008 20:00:49 -0000 1.6 *************** *** 29,132 **** public class ExtractMethodRefactoring extends AbstractPythonRefactoring { ! private ExtractMethodRequestProcessor requestProcessor; ! private IChangeProcessor changeProcessor; ! private ModuleAdapter parsedExtendedSelection; ! private ModuleAdapter parsedUserSelection; ! private ModuleAdapter module; ! public ExtractMethodRefactoring(RefactoringInfo req) { ! super(req); ! this.parsedExtendedSelection = null; ! this.parsedUserSelection = req.getParsedUserSelection(); ! this.parsedExtendedSelection = req.getParsedExtendedSelection(); ! this.module = req.getModule(); ! validateSelections(); ! try { ! initWizard(); ! } catch (Throwable e) { ! status.addInfo(Messages.infoFixCode); ! } ! } ! private void initWizard() throws Throwable { ! ITextSelection standardSelection = info.getUserSelection(); ! ModuleAdapter standardModule = this.parsedUserSelection; ! if (standardModule == null) { ! standardSelection = info.getExtendedSelection(); ! standardModule = this.parsedExtendedSelection; ! } ! this.requestProcessor = new ExtractMethodRequestProcessor(info.getScopeAdapter(), standardModule, this.getModule(), standardSelection); ! this.pages.add(new ExtractMethodPage(getName(), this.requestProcessor)); ! } ! @Override ! protected List<IChangeProcessor> getChangeProcessors() { ! List<IChangeProcessor> processors = new ArrayList<IChangeProcessor>(); ! this.changeProcessor = new ExtractMethodChangeProcessor(getName(), this.info, this.requestProcessor); ! processors.add(changeProcessor); ! return processors; ! } ! @Override ! public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { ! if (this.requestProcessor.getScopeAdapter() == null || this.requestProcessor.getScopeAdapter() instanceof IClassDefAdapter) { ! status.addFatalError(Messages.extractMethodScopeInvalid); ! return status; ! } ! if (status.getEntries().length > 0) ! return status; ! if (parsedExtendedSelection == null && parsedUserSelection == null) { ! status.addFatalError(Messages.extractMethodIncompleteSelection); ! return status; ! } ! return status; ! } ! private void validateSelections() { ! try { ! if (parsedUserSelection != null) { ! VisitorFactory.validateSelection(parsedUserSelection); ! } ! } catch (SelectionException e) { ! this.parsedUserSelection = null; ! if (parsedExtendedSelection == null) { ! status.addFatalError(e.getMessage()); ! return; ! } ! } ! try { ! if (parsedExtendedSelection != null) { ! VisitorFactory.validateSelection(parsedExtendedSelection); ! } ! } catch (SelectionException e) { ! this.parsedExtendedSelection = null; ! if (parsedUserSelection == null) { ! status.addFatalError(e.getMessage()); ! return; ! } ! } ! } ! public void setModule(ModuleAdapter module) { ! this.module = module; ! } ! public ModuleAdapter getModule() { ! return module; ! } ! @Override ! public String getName() { ! return Messages.extractMethodLabel; ! } } --- 29,132 ---- public class ExtractMethodRefactoring extends AbstractPythonRefactoring { ! private ExtractMethodRequestProcessor requestProcessor; ! private IChangeProcessor changeProcessor; ! private ModuleAdapter parsedExtendedSelection; ! private ModuleAdapter parsedUserSelection; ! private ModuleAdapter module; ! public ExtractMethodRefactoring(RefactoringInfo req) { ! super(req); ! this.parsedExtendedSelection = null; ! this.parsedUserSelection = req.getParsedUserSelection(); ! this.parsedExtendedSelection = req.getParsedExtendedSelection(); ! this.module = req.getModule(); ! validateSelections(); ! try { ! initWizard(); ! } catch (Throwable e) { ! status.addInfo(Messages.infoFixCode); ! } ! } ! private void initWizard() throws Throwable { ! ITextSelection standardSelection = info.getUserSelection(); ! ModuleAdapter standardModule = this.parsedUserSelection; ! if (standardModule == null) { ! standardSelection = info.getExtendedSelection(); ! standardModule = this.parsedExtendedSelection; ! } ! this.requestProcessor = new ExtractMethodRequestProcessor(info.getScopeAdapter(), standardModule, this.getModule(), standardSelection); ! this.pages.add(new ExtractMethodPage(getName(), this.requestProcessor)); ! } ! @Override ! protected List<IChangeProcessor> getChangeProcessors() { ! List<IChangeProcessor> processors = new ArrayList<IChangeProcessor>(); ! this.changeProcessor = new ExtractMethodChangeProcessor(getName(), this.info, this.requestProcessor); ! processors.add(changeProcessor); ! return processors; ! } ! @Override ! public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException { ! if (this.requestProcessor.getScopeAdapter() == null || this.requestProcessor.getScopeAdapter() instanceof IClassDefAdapter) { ! status.addFatalError(Messages.extractMethodScopeInvalid); ! return status; ! } ! if (status.getEntries().length > 0) ! return status; ! if (parsedExtendedSelection == null && parsedUserSelection == null) { ! status.addFatalError(Messages.extractMethodIncompleteSelection); ! return status; ! } ! return status; ! } ! private void validateSelections() { ! try { ! if (parsedUserSelection != null) { ! VisitorFactory.validateSelection(parsedUserSelection); ! } ! } catch (SelectionException e) { ! this.parsedUserSelection = null; ! if (parsedExtendedSelection == null) { ! status.addFatalError(e.getMessage()); ! return; ! } ! } ! try { ! if (parsedExtendedSelection != null) { ! VisitorFactory.validateSelection(parsedExtendedSelection); ! } ! } catch (SelectionException e) { ! this.parsedExtendedSelection = null; ! if (parsedUserSelection == null) { ! status.addFatalError(e.getMessage()); ! return; ! } ! } ! } ! public void setModule(ModuleAdapter module) { ! this.module = module; ! } ! public ModuleAdapter getModule() { ! return module; ! } ! @Override ! public String getName() { ! return Messages.extractMethodLabel; ! } } Index: ExtractMethodRequestProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/coderefactoring/extractmethod/ExtractMethodRequestProcessor.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ExtractMethodRequestProcessor.java 20 Oct 2007 19:31:04 -0000 1.5 --- ExtractMethodRequestProcessor.java 27 Sep 2008 20:00:49 -0000 1.6 *************** *** 23,108 **** public class ExtractMethodRequestProcessor implements IRequestProcessor<ExtractMethodRequest> { ! private int offsetStrategy; ! private String methodName; ! private AbstractScopeNode<?> scopeAdapter; ! private ModuleAdapter parsedSelection; ! private ParameterReturnDeduce deducer; ! private Map<String, String> renameMap; ! private List<String> parameterOrder; ! private ITextSelection selection; private String endLineDelim; ! public ExtractMethodRequestProcessor(AbstractScopeNode<?> scopeAdapter, ModuleAdapter parsedSelection, ModuleAdapter module, ITextSelection selection) { ! initProcessor(scopeAdapter, parsedSelection, module, selection); ! } ! public void initProcessor(AbstractScopeNode<?> scopeAdapter, ModuleAdapter parsedSelection, ModuleAdapter module, ITextSelection selection) { ! this.methodName = "pepticMethod"; ! this.scopeAdapter = scopeAdapter; ! this.selection = selection; ! this.parsedSelection = parsedSelection; ! this.deducer = new ParameterReturnDeduce(this.scopeAdapter, selection, module); ! this.parameterOrder = new ArrayList<String>(); ! parameterOrder.addAll(deducer.getParameters()); ! this.renameMap = new TreeMap<String, String>(); ! initRenamedMap(); this.endLineDelim = module.getEndLineDelimiter(); ! offsetStrategy = IOffsetStrategy.AFTERINIT; ! } ! private void initRenamedMap() { ! for (String variable : deducer.getParameters()) { ! this.renameMap.put(variable, variable); ! } ! } ! public AbstractScopeNode<?> getScopeAdapter() { ! return scopeAdapter; ! } ! public String getMethodName() { ! return methodName; ! } ! public void setMethodName(String methodName) { ! this.methodName = methodName; ! } ! public int getOffsetStrategy() { ! return offsetStrategy; ! } ! public void setOffsetStrategy(int offsetStrategy) { ! this.offsetStrategy = offsetStrategy; ! } ! public List<ExtractMethodRequest> getRefactoringRequests() { ! List<ExtractMethodRequest> requests = new ArrayList<ExtractMethodRequest>(); ! requests.add(new ExtractMethodRequest(this.methodName, this.selection, this.scopeAdapter, this.parsedSelection, parameterOrder, ! deducer.getReturns(), this.renameMap, this.offsetStrategy, this.endLineDelim)); ! return requests; ! } ! public ParameterReturnDeduce getDeducer() { ! return deducer; ! } ! public void setParameterMap(Map<String, String> renameMap) { ! this.renameMap = renameMap; ! } ! public void setParameterOrder(List<String> parameterOrder) { ! this.parameterOrder = parameterOrder; ! } } --- 23,108 ---- public class ExtractMethodRequestProcessor implements IRequestProcessor<ExtractMethodRequest> { ! private int offsetStrategy; ! private String methodName; ! private AbstractScopeNode<?> scopeAdapter; ! private ModuleAdapter parsedSelection; ! private ParameterReturnDeduce deducer; ! private Map<String, String> renameMap; ! private List<String> parameterOrder; ! private ITextSelection selection; private String endLineDelim; ! public ExtractMethodRequestProcessor(AbstractScopeNode<?> scopeAdapter, ModuleAdapter parsedSelection, ModuleAdapter module, ITextSelection selection) { ! initProcessor(scopeAdapter, parsedSelection, module, selection); ! } ! public void initProcessor(AbstractScopeNode<?> scopeAdapter, ModuleAdapter parsedSelection, ModuleAdapter module, ITextSelection selection) { ! this.methodName = "pepticMethod"; ! this.scopeAdapter = scopeAdapter; ! this.selection = selection; ! this.parsedSelection = parsedSelection; ! this.deducer = new ParameterReturnDeduce(this.scopeAdapter, selection, module); ! this.parameterOrder = new ArrayList<String>(); ! parameterOrder.addAll(deducer.getParameters()); ! this.renameMap = new TreeMap<String, String>(); ! initRenamedMap(); this.endLineDelim = module.getEndLineDelimiter(); ! offsetStrategy = IOffsetStrategy.AFTERINIT; ! } ! private void initRenamedMap() { ! for (String variable : deducer.getParameters()) { ! this.renameMap.put(variable, variable); ! } ! } ! public AbstractScopeNode<?> getScopeAdapter() { ! return scopeAdapter; ! } ! public String getMethodName() { ! return methodName; ! } ! public void setMethodName(String methodName) { ! this.methodName = methodName; ! } ! public int getOffsetStrategy() { ! return offsetStrategy; ! } ! public void setOffsetStrategy(int offsetStrategy) { ! this.offsetStrategy = offsetStrategy; ! } ! public List<ExtractMethodRequest> getRefactoringRequests() { ! List<ExtractMethodRequest> requests = new ArrayList<ExtractMethodRequest>(); ! requests.add(new ExtractMethodRequest(this.methodName, this.selection, this.scopeAdapter, this.parsedSelection, parameterOrder, ! deducer.getReturns(), this.renameMap, this.offsetStrategy, this.endLineDelim)); ! return requests; ! } ! public ParameterReturnDeduce getDeducer() { ! return deducer; ! } ! public void setParameterMap(Map<String, String> renameMap) { ! this.renameMap = renameMap; ! } ! public void setParameterOrder(List<String> parameterOrder) { ! this.parameterOrder = parameterOrder; ! } } Index: ExtractMethodChangeProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/src/org/python/pydev/refactoring/coderefactoring/extractmethod/ExtractMethodChangeProcessor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ExtractMethodChangeProcessor.java 20 Oct 2007 19:31:04 -0000 1.3 --- ExtractMethodChangeProcessor.java 27 Sep 2008 20:00:49 -0000 1.4 *************** *** 18,38 **** public class ExtractMethodChangeProcessor extends AbstractFileChangeProcessor<ExtractMethodRequest> { ! public ExtractMethodChangeProcessor(String name, RefactoringInfo info, IRequestProcessor<ExtractMethodRequest> requestProcessor) { ! super(name, info, requestProcessor); ! } ! @Override ! protected void processEdit() { ! for (ExtractMethodRequest req : requestProcessor.getRefactoringRequests()) { ! processExtraction(req); ! } ! } ! private void processExtraction(ExtractMethodRequest req) { ! ExtractMethodEdit extractMethodEdit = new ExtractMethodEdit(req); ! ExtractCallEdit extractCallEdit = new ExtractCallEdit(req); ! ! registerEdit(extractMethodEdit, Messages.extractMethodChangeName); ! registerEdit(extractCallEdit, Messages.extractMethodReplaceWithCall); ! } } --- 18,38 ---- public class ExtractMethodChangeProcessor extends AbstractFileChangeProcessor<ExtractMethodRequest> { ! public ExtractMethodChangeProcessor(String name, RefactoringInfo info, IRequestProcessor<ExtractMethodRequest> requestProcessor) { ! super(name, info, requestProcessor); ! } ! @Override ! protected void processEdit() { ! for (ExtractMethodRequest req : requestProcessor.getRefactoringRequests()) { ! processExtraction(req); ! } ! } ! private void processExtraction(ExtractMethodRequest req) { ! ExtractMethodEdit extractMethodEdit = new ExtractMethodEdit(req); ! ExtractCallEdit extractCallEdit = new ExtractCallEdit(req); ! ! registerEdit(extractMethodEdit, Messages.extractMethodChangeName); ! registerEdit(extractCallEdit, Messages.extractMethodReplaceWithCall); ! } } |