Thread: [Pydev-cvs] org.python.pydev/tests_navigator/org/python/pydev/navigator PythonPathNatureStub.java,
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-07-31 01:47:31
|
Update of /cvsroot/pydev/org.python.pydev/tests_navigator/org/python/pydev/navigator In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31519/tests_navigator/org/python/pydev/navigator Modified Files: PythonPathNatureStub.java FolderStub.java PythonModelProviderTest.java Log Message: <li>Fixed NPE when creating editor with no interpreter configured</li> <li>Hyperlink works in the same way that F3 (saves file before search)</li> <li>Fixed problem while navigating pydev package explorer ( https://sourceforge.net/tracker/index.php?func=detail&aid=2008015&group_id=85796&atid=577329 )</li> <li>Applied patch that fixes race condition in PythonNature (thanks to Radim Kubacki)</li> <li><strong>Eclipse 3.4</strong>: Move / rename working</li> Index: FolderStub.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_navigator/org/python/pydev/navigator/FolderStub.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** FolderStub.java 28 Jun 2008 13:29:19 -0000 1.5 --- FolderStub.java 31 Jul 2008 01:47:36 -0000 1.6 *************** *** 30,41 **** private File folder; private ProjectStub project; public FolderStub(ProjectStub stub, File parentFile) { ! Assert.isTrue(parentFile.exists() && parentFile.isDirectory()); ! this.project = stub; ! this.folder = parentFile; } public IContainer getParent() { return project.getFolder(this.folder.getParentFile()); } --- 30,50 ---- private File folder; private ProjectStub project; + private IContainer parent; public FolderStub(ProjectStub stub, File parentFile) { ! this(stub, null, parentFile); ! } ! ! public FolderStub(ProjectStub stub, IContainer parent, File parentFile) { ! Assert.isTrue(parentFile.exists() && parentFile.isDirectory()); ! this.project = stub; ! this.folder = parentFile; ! this.parent = parent; } public IContainer getParent() { + if(parent != null){ + return parent; + } return project.getFolder(this.folder.getParentFile()); } Index: PythonModelProviderTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_navigator/org/python/pydev/navigator/PythonModelProviderTest.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PythonModelProviderTest.java 10 May 2008 16:29:24 -0000 1.10 --- PythonModelProviderTest.java 31 Jul 2008 01:47:36 -0000 1.11 *************** *** 15,20 **** --- 15,22 ---- import org.eclipse.ui.navigator.PipelinedViewerUpdate; import org.python.pydev.core.IPythonPathNature; + import org.python.pydev.core.REF; import org.python.pydev.core.TestDependent; import org.python.pydev.navigator.elements.IWrappedResource; + import org.python.pydev.navigator.elements.PythonFolder; import org.python.pydev.navigator.elements.PythonProjectSourceFolder; import org.python.pydev.navigator.elements.PythonSourceFolder; *************** *** 28,35 **** PythonModelProviderTest test = new PythonModelProviderTest(); test.setUp(); ! test.testProjectIsRoot2(); test.tearDown(); ! junit.textui.TestRunner.run(PythonModelProviderTest.class); } catch (Throwable e) { e.printStackTrace(); --- 30,38 ---- PythonModelProviderTest test = new PythonModelProviderTest(); test.setUp(); ! test.testFolderToSourceFolder2(); test.tearDown(); + System.out.println("OK"); ! // junit.textui.TestRunner.run(PythonModelProviderTest.class); } catch (Throwable e) { e.printStackTrace(); *************** *** 350,352 **** --- 353,523 ---- } + + public void testAddSourceFolderToSourceFolder() throws Exception { + final HashSet<String> pythonPathSet = new HashSet<String>(); + pythonPathSet.add(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot/source"); + String source2Folder = TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot/source2"; + + File f = new File(source2Folder); + if(f.exists()){ + f.delete(); + } + + pythonPathSet.add(source2Folder); //still not created! + PythonNature nature = createNature(pythonPathSet); + + project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot"), nature, false); + provider = new PythonModelProvider(); + Object[] children1 = provider.getChildren(project); + assertEquals(1, children1.length); + assertTrue(children1[0] instanceof PythonSourceFolder); + + Set set = new HashSet(); + + f.mkdir(); + try { + FolderStub source2FolderFile = new FolderStub(project, f); + set.add(source2FolderFile); + provider.interceptAdd(new PipelinedShapeModification(project, set)); + + assertEquals(1, set.size()); + assertTrue(set.iterator().next() instanceof PythonSourceFolder); + } finally { + f.delete(); + } + } + + public void testFolderToSourceFolder() throws Exception { + final HashSet<String> pythonPathSet = new HashSet<String>(); + pythonPathSet.add(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot/source"); + String source2Folder = TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot/source2"; + + File f = new File(source2Folder); + File f1 = new File(f, "childFolder"); + + if(f1.exists()){ + f1.delete(); + } + if(f.exists()){ + f.delete(); + } + + pythonPathSet.add(source2Folder); //still not created! + PythonNature nature = createNature(pythonPathSet); + + project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot"), nature, false); + provider = new PythonModelProvider(); + Object[] children1 = provider.getChildren(project); + assertEquals(1, children1.length); + assertTrue(children1[0] instanceof PythonSourceFolder); + + + f.mkdir(); + f1.mkdir(); + try { + FolderStub source2FolderFile = new FolderStub(project, f); + FolderStub source2FolderChild = new FolderStub(project, source2FolderFile, f1); + + Set set = new HashSet(); + set.add(source2FolderChild); + provider.interceptAdd(new PipelinedShapeModification(source2FolderFile, set)); + + assertEquals(1, set.size()); + PythonFolder c = (PythonFolder) set.iterator().next(); + PythonSourceFolder sourceFolder = c.getSourceFolder(); + assertTrue(sourceFolder instanceof PythonSourceFolder); + + set.clear(); + set.add(source2FolderChild); + provider.interceptAdd(new PipelinedShapeModification(source2FolderFile, set)); + } finally { + f1.delete(); + f.delete(); + } + } + + public void testFolderToSourceFolder2() throws Exception { + final HashSet<String> pythonPathSet = new HashSet<String>(); + pythonPathSet.add(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot/source"); + String source2Folder = TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot/source2"; + + File f = new File(source2Folder); + File f1 = new File(f, "childFolder"); + File f2 = new File(f1, "rechildFolder"); + + if(f2.exists()){ + f2.delete(); + } + + if(f1.exists()){ + f1.delete(); + } + if(f.exists()){ + f.delete(); + } + + pythonPathSet.add(source2Folder); //still not created! + PythonNature nature = createNature(pythonPathSet); + + project = new ProjectStub(new File(TestDependent.TEST_PYSRC_NAVIGATOR_LOC+"projroot"), nature, false); + provider = new PythonModelProvider(); + Object[] children1 = provider.getChildren(project); + assertEquals(1, children1.length); + assertTrue(children1[0] instanceof PythonSourceFolder); + + + f.mkdir(); + f1.mkdir(); + f2.mkdir(); + try { + FolderStub source2FolderFile = new FolderStub(project, f); + FolderStub source2FolderChild = new FolderStub(project, source2FolderFile, f1); + FolderStub source2FolderReChild = new FolderStub(project, source2FolderChild, f2); + + Set set = new HashSet(); + set.add(source2FolderReChild); + provider.interceptAdd(new PipelinedShapeModification(source2FolderChild, set)); + + assertEquals(1, set.size()); + PythonFolder c = (PythonFolder) set.iterator().next(); + PythonSourceFolder sourceFolder = c.getSourceFolder(); + assertTrue(sourceFolder instanceof PythonSourceFolder); + + set.clear(); + set.add(source2FolderChild); + provider.interceptRemove(new PipelinedShapeModification(source2FolderFile, set)); + assertTrue(set.iterator().next() instanceof PythonFolder); + // System.out.println(set); + + set.clear(); + set.add(source2FolderReChild); + provider.interceptAdd(new PipelinedShapeModification(source2FolderChild, set)); + assertTrue(set.iterator().next() instanceof PythonFolder); + // System.out.println(set); + + + set.clear(); + set.add(source2FolderChild); + provider.interceptRemove(new PipelinedShapeModification(source2FolderFile, set)); + assertTrue(set.iterator().next() instanceof PythonFolder); + // System.out.println(set); + + + set.clear(); + set.add(source2FolderReChild); + provider.interceptAdd(new PipelinedShapeModification(source2FolderChild, set)); + assertTrue(set.iterator().next() instanceof PythonFolder); + // System.out.println(set); + + + + + + } finally { + f2.delete(); + f1.delete(); + f.delete(); + } + } + } Index: PythonPathNatureStub.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests_navigator/org/python/pydev/navigator/PythonPathNatureStub.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonPathNatureStub.java 10 Mar 2007 14:32:45 -0000 1.1 --- PythonPathNatureStub.java 31 Jul 2008 01:47:36 -0000 1.2 *************** *** 7,10 **** --- 7,11 ---- import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; + import org.python.pydev.core.IPythonNature; import org.python.pydev.core.IPythonPathNature; *************** *** 41,45 **** } ! public void setProject(IProject project) { throw new RuntimeException("Not impl"); --- 42,46 ---- } ! public void setProject(IProject project, IPythonNature nature) { throw new RuntimeException("Not impl"); |