[Pydev-cvs] org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/con
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-09-27 20:02:15
|
Update of /cvsroot/pydev/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/constructorfield In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21605/tests/org/python/pydev/refactoring/tests/codegenerator/constructorfield Modified Files: MockupConstructorFieldConfig.java MockupConstructorFieldRequestProcessor.java ConstructorFieldTestSuite.java ConstructorFieldTestCase.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: ConstructorFieldTestSuite.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/constructorfield/ConstructorFieldTestSuite.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ConstructorFieldTestSuite.java 20 Oct 2007 19:31:02 -0000 1.3 --- ConstructorFieldTestSuite.java 27 Sep 2008 20:00:47 -0000 1.4 *************** *** 14,29 **** public class ConstructorFieldTestSuite extends AbstractIOTestSuite { ! public static Test suite() { ! TESTDIR = "tests" + File.separator + "python" + File.separator + "codegenerator" + File.separator + "constructorfield"; ! ConstructorFieldTestSuite testSuite = new ConstructorFieldTestSuite(); ! testSuite.createTests(); ! return testSuite; ! } ! @Override ! protected IInputOutputTestCase createTestCase(String testCaseName) { ! return new ConstructorFieldTestCase(testCaseName); ! } } --- 14,29 ---- public class ConstructorFieldTestSuite extends AbstractIOTestSuite { ! public static Test suite() { ! TESTDIR = "tests" + File.separator + "python" + File.separator + "codegenerator" + File.separator + "constructorfield"; ! ConstructorFieldTestSuite testSuite = new ConstructorFieldTestSuite(); ! testSuite.createTests(); ! return testSuite; ! } ! @Override ! protected IInputOutputTestCase createTestCase(String testCaseName) { ! return new ConstructorFieldTestCase(testCaseName); ! } } Index: ConstructorFieldTestCase.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/constructorfield/ConstructorFieldTestCase.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ConstructorFieldTestCase.java 5 Feb 2008 13:07:01 -0000 1.6 --- ConstructorFieldTestCase.java 27 Sep 2008 20:00:47 -0000 1.7 *************** *** 20,83 **** public class ConstructorFieldTestCase extends AbstractIOTestCase { ! private CompletionEnvironmentSetupHelper setupHelper; public ConstructorFieldTestCase(String name) { ! super(name); ! } ! @Override ! public void runTest() throws Throwable { ! setupHelper = new CompletionEnvironmentSetupHelper(); ! setupHelper.setupEnv(); ! try{ ! MockupConstructorFieldConfig config = initConfig(); ! MockupConstructorFieldRequestProcessor requestProcessor = setupRequestProcessor(config); ! IDocument refactoringDoc = applyConstructorUsingFields(requestProcessor); ! this.setTestGenerated(refactoringDoc.get()); ! assertEquals(getExpected(), getGenerated()); ! }finally{ ! setupHelper.tearDownEnv(); ! } ! ! } ! ! private IDocument applyConstructorUsingFields(MockupConstructorFieldRequestProcessor requestProcessor) throws BadLocationException { ! ConstructorMethodEdit constructorEdit = new ConstructorMethodEdit(requestProcessor.getRefactoringRequests().get(0)); ! IDocument refactoringDoc = new Document(getSource()); ! constructorEdit.getEdit().apply(refactoringDoc); ! return refactoringDoc; ! } ! private MockupConstructorFieldRequestProcessor setupRequestProcessor(MockupConstructorFieldConfig config) throws Throwable { ! ModuleAdapter module = setupHelper.createModuleAdapter(this); ! ! List<IClassDefAdapter> classes = module.getClasses(); ! assertTrue(classes.size() > 0); ! MockupConstructorFieldRequestProcessor requestProcessor = new MockupConstructorFieldRequestProcessor(module, config); ! return requestProcessor; ! } ! private MockupConstructorFieldConfig initConfig() { ! MockupConstructorFieldConfig config = null; ! XStream xstream = new XStream(); ! xstream.alias("config", MockupConstructorFieldConfig.class); ! if (getConfig().length() > 0) { ! config = (MockupConstructorFieldConfig) xstream.fromXML(getConfig()); ! } else { ! fail("Could not unserialize configuration"); ! } ! return config; ! } ! @Override ! public String getExpected() { ! return getResult(); ! } } --- 20,83 ---- public class ConstructorFieldTestCase extends AbstractIOTestCase { ! private CompletionEnvironmentSetupHelper setupHelper; public ConstructorFieldTestCase(String name) { ! super(name); ! } ! @Override ! public void runTest() throws Throwable { ! setupHelper = new CompletionEnvironmentSetupHelper(); ! setupHelper.setupEnv(); ! try{ ! MockupConstructorFieldConfig config = initConfig(); ! MockupConstructorFieldRequestProcessor requestProcessor = setupRequestProcessor(config); ! IDocument refactoringDoc = applyConstructorUsingFields(requestProcessor); ! this.setTestGenerated(refactoringDoc.get()); ! assertEquals(getExpected(), getGenerated()); ! }finally{ ! setupHelper.tearDownEnv(); ! } ! ! } ! ! private IDocument applyConstructorUsingFields(MockupConstructorFieldRequestProcessor requestProcessor) throws BadLocationException { ! ConstructorMethodEdit constructorEdit = new ConstructorMethodEdit(requestProcessor.getRefactoringRequests().get(0)); ! IDocument refactoringDoc = new Document(getSource()); ! constructorEdit.getEdit().apply(refactoringDoc); ! return refactoringDoc; ! } ! private MockupConstructorFieldRequestProcessor setupRequestProcessor(MockupConstructorFieldConfig config) throws Throwable { ! ModuleAdapter module = setupHelper.createModuleAdapter(this); ! ! List<IClassDefAdapter> classes = module.getClasses(); ! assertTrue(classes.size() > 0); ! MockupConstructorFieldRequestProcessor requestProcessor = new MockupConstructorFieldRequestProcessor(module, config); ! return requestProcessor; ! } ! private MockupConstructorFieldConfig initConfig() { ! MockupConstructorFieldConfig config = null; ! XStream xstream = new XStream(); ! xstream.alias("config", MockupConstructorFieldConfig.class); ! if (getConfig().length() > 0) { ! config = (MockupConstructorFieldConfig) xstream.fromXML(getConfig()); ! } else { ! fail("Could not unserialize configuration"); ! } ! return config; ! } ! @Override ! public String getExpected() { ! return getResult(); ! } } Index: MockupConstructorFieldRequestProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/constructorfield/MockupConstructorFieldRequestProcessor.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** MockupConstructorFieldRequestProcessor.java 20 Oct 2007 19:31:02 -0000 1.5 --- MockupConstructorFieldRequestProcessor.java 27 Sep 2008 20:00:47 -0000 1.6 *************** *** 16,53 **** public class MockupConstructorFieldRequestProcessor implements IRequestProcessor<ConstructorFieldRequest> { ! private ModuleAdapter module; ! private int classSelection; ! private int offsetStrategy; ! private List<Integer> attributeSelection; ! private MockupConstructorFieldRequestProcessor(ModuleAdapter module, int classSelection, List<Integer> attributeSelection, ! int offsetStrategy) { ! this.module = module; ! this.attributeSelection = attributeSelection; ! this.classSelection = classSelection; ! this.offsetStrategy = offsetStrategy; ! } ! public MockupConstructorFieldRequestProcessor(ModuleAdapter module, MockupConstructorFieldConfig config) { ! this(module, config.getClassSelection(), config.getAttributeSelection(), config.getOffsetStrategy()); ! } ! public List<ConstructorFieldRequest> getRefactoringRequests() { ! IClassDefAdapter clazz = module.getClasses().get(classSelection); ! List<INodeAdapter> attributes = new ArrayList<INodeAdapter>(); ! for (int index : attributeSelection) { ! attributes.add(clazz.getAttributes().get(index)); ! } ! ConstructorFieldRequest req = new ConstructorFieldRequest(clazz, attributes, this.offsetStrategy, "\n"); ! List<ConstructorFieldRequest> requests = new ArrayList<ConstructorFieldRequest>(); ! requests.add(req); ! return requests; ! } } --- 16,53 ---- public class MockupConstructorFieldRequestProcessor implements IRequestProcessor<ConstructorFieldRequest> { ! private ModuleAdapter module; ! private int classSelection; ! private int offsetStrategy; ! private List<Integer> attributeSelection; ! private MockupConstructorFieldRequestProcessor(ModuleAdapter module, int classSelection, List<Integer> attributeSelection, ! int offsetStrategy) { ! this.module = module; ! this.attributeSelection = attributeSelection; ! this.classSelection = classSelection; ! this.offsetStrategy = offsetStrategy; ! } ! public MockupConstructorFieldRequestProcessor(ModuleAdapter module, MockupConstructorFieldConfig config) { ! this(module, config.getClassSelection(), config.getAttributeSelection(), config.getOffsetStrategy()); ! } ! public List<ConstructorFieldRequest> getRefactoringRequests() { ! IClassDefAdapter clazz = module.getClasses().get(classSelection); ! List<INodeAdapter> attributes = new ArrayList<INodeAdapter>(); ! for (int index : attributeSelection) { ! attributes.add(clazz.getAttributes().get(index)); ! } ! ConstructorFieldRequest req = new ConstructorFieldRequest(clazz, attributes, this.offsetStrategy, "\n"); ! List<ConstructorFieldRequest> requests = new ArrayList<ConstructorFieldRequest>(); ! requests.add(req); ! return requests; ! } } Index: MockupConstructorFieldConfig.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.refactoring/tests/org/python/pydev/refactoring/tests/codegenerator/constructorfield/MockupConstructorFieldConfig.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MockupConstructorFieldConfig.java 20 Oct 2007 19:31:02 -0000 1.2 --- MockupConstructorFieldConfig.java 27 Sep 2008 20:00:47 -0000 1.3 *************** *** 11,37 **** public class MockupConstructorFieldConfig { ! private int classSelection; ! private ArrayList<Integer> attributeSelection; ! private int offsetStrategy; ! public MockupConstructorFieldConfig() { ! this.classSelection = 0; ! this.offsetStrategy = IOffsetStrategy.AFTERINIT; ! this.attributeSelection = new ArrayList<Integer>(); ! attributeSelection.add(0); ! } ! public ArrayList<Integer> getAttributeSelection() { ! return attributeSelection; ! } ! public int getClassSelection() { ! return classSelection; ! } ! public int getOffsetStrategy() { ! return offsetStrategy; ! } } --- 11,37 ---- public class MockupConstructorFieldConfig { ! private int classSelection; ! private ArrayList<Integer> attributeSelection; ! private int offsetStrategy; ! public MockupConstructorFieldConfig() { ! this.classSelection = 0; ! this.offsetStrategy = IOffsetStrategy.AFTERINIT; ! this.attributeSelection = new ArrayList<Integer>(); ! attributeSelection.add(0); ! } ! public ArrayList<Integer> getAttributeSelection() { ! return attributeSelection; ! } ! public int getClassSelection() { ! return classSelection; ! } ! public int getOffsetStrategy() { ! return offsetStrategy; ! } } |