Summary: | Package disapears when disconnected from CVS repopsitory | ||
---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Christopher Nelson <christopher_nelson> |
Component: | Core | Assignee: | Philipe Mulet <philippe_mulet> |
Status: | VERIFIED FIXED | QA Contact: | |
Severity: | normal | ||
Priority: | P3 | CC: | curtis_d'entremont, James_Moody |
Version: | 2.0 | ||
Target Milestone: | 2.0 F3 | ||
Hardware: | PC | ||
OS: | Windows 2000 | ||
Whiteboard: |
Description
Christopher Nelson
2002-06-03 19:26:39 EDT
can reproduce in 0706. The .project file is correct and still shows the java nature. Also the project is still adorned with the J in the navigator. Closing and reopening the project in the navigator brings the project back in the packages view. Moving to JDT core for investigation. Was able to reproduce this one scenario. Problem is element type computation which keep the project element type once inside a java project, and until it enters a package fragment root. Therefore, if a folder is removed (CVS), then the project is thought to be removed completely. Changing the element type computation has other implication which we cannot change at this point. However, DeltaProcessor#createElement is also causing trouble, since due to the incorrect element type, it may answer a project element for something else (like non-java resource nested inside). When tracing this scenario, it appears that currentElement was set to the project being touched, but the changed resource was the .project or a CVS folder. However, the element creation code got fooled into thinking this was the project being removed since it was still rooted onto it (current element had been positionned prior to this point). Investigating adding protection on element creation. Proposed fix: DeltaProcessor#createElement [ /** * Creates the openables corresponding to this resource. * Returns null if none was found. */ protected Openable createElement(IResource resource, int elementType, IJavaProject project) { if (resource == null) return null; IPath path = resource.getFullPath(); IJavaElement element = null; switch (elementType) { case IJavaElement.JAVA_PROJECT: // note that non-java resources rooted the project level will also enter this code with // an elementType JAVA_PROJECT (see #elementType (...)). if (resource instanceof IProject){ this.popUntilPrefixOf(path); if (this.currentElement != null && this.currentElement.getElementType() == IJavaElement.JAVA_PROJECT && ((IJavaProject) this.currentElement).getProject().equals(resource)) { return this.currentElement; } if (project != null && project.getProject().equals(resource)){ element = (Openable)project; break; } IProject proj = (IProject)resource; boolean isOpened = proj.isOpen(); if (isOpened && this.hasJavaNature (proj)) { element = JavaCore.create(proj); } else { // java project may have been been closed or removed (look for // element amongst old java project s list). element = (Openable) manager.getJavaModel().findJavaProject(proj); } } break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: element = project == null ? JavaCore.create (resource) : project.getPackageFragmentRoot(resource); break; case IJavaElement.PACKAGE_FRAGMENT: // find the element that encloses the resource this.popUntilPrefixOf(path); if (this.currentElement == null) { element = JavaModelManager.getJavaModelManager().create(resource, project); } else { // find the root IPackageFragmentRoot root = this.currentElement.getPackageFragmentRoot(); if (root == null) { element = JavaModelManager.getJavaModelManager().create(resource, project); } else if (! JavaModelManager.conflictsWithOutputLocation(path, (JavaProject) root.getJavaProject())) { // create package handle IPath pkgPath = path.removeFirstSegments(root.getPath().segmentCount()); String pkg = Util.packageName (pkgPath); if (pkg == null) return null; element = root.getPackageFragment(pkg); } } break; case IJavaElement.COMPILATION_UNIT: case IJavaElement.CLASS_FILE: // find the element that encloses the resource this.popUntilPrefixOf(path); if (this.currentElement == null) { element = element = JavaModelManager.getJavaModelManager().create(resource, project); } else { // find the package IPackageFragment pkgFragment = null; switch (this.currentElement.getElementType()) { case IJavaElement.PACKAGE_FRAGMENT_ROOT: IPackageFragmentRoot root = (IPackageFragmentRoot)this.currentElement; IPath rootPath = root.getPath(); IPath pkgPath = path.removeLastSegments(1); String pkgName = Util.packageName(pkgPath.removeFirstSegments(rootPath.segmentCount())); if (pkgName != null) { pkgFragment = root.getPackageFragment(pkgName); } break; case IJavaElement.PACKAGE_FRAGMENT: Openable pkg = (Openable)this.currentElement; if (pkg.getPath().equals (path.removeLastSegments(1))) { pkgFragment = (IPackageFragment)pkg; } // else case of package x which is a prefix of x.y break; case IJavaElement.COMPILATION_UNIT: case IJavaElement.CLASS_FILE: pkgFragment = (IPackageFragment)this.currentElement.getParent(); break; } if (pkgFragment == null) { element = JavaModelManager.getJavaModelManager().create(resource, project); } else { if (elementType == IJavaElement.COMPILATION_UNIT) { // create compilation unit handle // fileName validation has been done in elementType(IResourceDelta, int, boolean) String fileName = path.lastSegment(); element = pkgFragment.getCompilationUnit(fileName); } else { // create class file handle // fileName validation has been done in elementType(IResourceDelta, int, boolean) String fileName = path.lastSegment(); element = pkgFragment.getClassFile(fileName); } } } break; } if (element == null) { return null; } else { this.currentElement = (Openable)element; return this.currentElement; } } ] Also got fix from Jerome for #elementType which got fooled by a description change (fooled into thinking this was a nature change). Fixed. *** Bug 19586 has been marked as a duplicate of this bug. *** *** Bug 19676 has been marked as a duplicate of this bug. *** Verified. |