Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 429630

Summary: Detecting Primary types in JavaProject after file deletion
Product: [Eclipse Project] JDT Reporter: shankha banerjee <shankhba>
Component: CoreAssignee: JDT-Core-Inbox <jdt-core-inbox>
Status: CLOSED WONTFIX QA Contact: Jay Arthanareeswaran <jarthana>
Severity: normal    
Priority: P3 CC: jarthana, shankhba
Version: 4.4   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
URL: https://bugs.eclipse.org/bugs/show_bug.cgi?id=405026#c11
See Also: https://bugs.eclipse.org/bugs/show_bug.cgi?id=405026
Whiteboard: stalebug

Description shankha banerjee CLA 2014-03-05 01:51:20 EST
Please have a look at:
Bug 405026, Comment 11.

"For testBug351498(), we should:
- fix the last comment (tell that CU Bug.b351498 doesn't exist any more)
- append an assertNull for type "p.Bug" (to clarify that not even the primary type is there any more)"

The following test case should succeed:

public void testBug351498() throws CoreException, InterruptedException {
	IContentType javaContentType = Platform.getContentTypeManager().getContentType(JavaCore.JAVA_SOURCE_CONTENT_TYPE);
	try {
		// Create project and file
		assertNotNull("We should have got a Java Source content type!", javaContentType);
		javaContentType.addFileSpec("b351498", IContentType.FILE_EXTENSION_SPEC);
		IJavaProject javaProject = createJavaProject("P");
		createFolder("/P/p");
		// How come there is not .java extension.
		String filePath = "/P/p/Bug.b351498";
		createFile(
			filePath,
			"package p;\n" +
			"public class Bug {}\n" +
			"class Secondary {}\n" +
			"class AnotherSecondary{}\n" +
			""
		);
		waitUntilIndexesReady();
		
		// Get the secondary type
		IType type = javaProject.findType("p.Secondary", new NullProgressMonitor());
		assertNotNull("We should have found the secondary type!", type);
		
		// Remove file extension
		// The file is being deleted. What are the set of actions to be taken based on this
		// so that 
		javaContentType.removeFileSpec("b351498", IContentType.FILE_EXTENSION_SPEC);
		
		// CompilationUnit Bug.b351498 does not exists any more.
		type = javaProject.findType("p.Secondary", new NullProgressMonitor());
		assertNull("We should have not found the secondary type!", type);

		type = javaProject.findType("p.Bug");
		assertNull("PrimaryType should also be not avalaible!", type);
	} finally {
		deleteProject("P");
	}
}


This test case is a modified form of ClassNameTests#testBug351498.

Thanks
Comment 1 Jay Arthanareeswaran CLA 2014-03-24 00:34:59 EDT
Shankha, is this something a test only fix? If so, can you take care of this for M7? TIA.
Comment 2 shankha banerjee CLA 2014-03-24 01:01:56 EDT
I will take care of it. This is not a test only fix. 

The issue is after deletion of the file the primary type associated with the project should also be not available.
Comment 3 Eclipse Genie CLA 2019-02-06 01:20:34 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.