Bug 20532 - Declaration of member binary type not found
Summary: Declaration of member binary type not found
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 F4   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-06-18 08:46 EDT by Jerome Lanneluc CLA
Modified: 2002-06-20 11:16 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jerome Lanneluc CLA 2002-06-18 08:46:38 EDT
Build 20020617

1. Open type java.applet.Applet$AccessibleApplet.class
2. In Outline, select AccessibleApplet
3. Search for Type Declarations in Workspace
Observe: None is found
Comment 1 Jerome Lanneluc CLA 2002-06-18 08:57:01 EDT
Problem with SearchPattern that doesn't build the right pattern: the enclosing 
type is set to be empty for binary types. It should be the declaring types.

Propose fix:
/**
 * Returns the enclosing type names of the given type.
 */
private static char[][] enclosingTypeNames(IType type) {
	IJavaElement parent = type.getParent();
	switch (parent.getElementType()) {
		case IJavaElement.CLASS_FILE:
			// For a binary type, the parent is not the enclosing 
type, but the declaring type is.
			// (see bug 20532  Declaration of member binary type 
not found)
			IType declaringType = type.getDeclaringType();
			if (declaringType == null) {
				return NO_CHAR_CHAR;
			} else {
				return CharOperation.arrayConcat(
					enclosingTypeNames(declaringType), 
					declaringType.getElementName
().toCharArray());
			}
		case IJavaElement.COMPILATION_UNIT:
			return 	NO_CHAR_CHAR;
		case IJavaElement.TYPE:
			return 	CharOperation.arrayConcat(
				enclosingTypeNames((IType)parent), 
				parent.getElementName().toCharArray());
		default:
			return null;
	}
}
Comment 2 Philipe Mulet CLA 2002-06-18 19:27:12 EDT
Fix is good, indeed binary elements are not structured in the same way as 
source one. Source types are children of compilation unit, even nested types. 
But binary types are individually rooted in their corresponding classfile, 
requiring the pattern creation code to deal with them distinctly.

Fix is simple, just looking at different information (declaring type instead of 
direct parent, which only works for source types).

Should fix for F4
Comment 3 Jerome Lanneluc CLA 2002-06-19 06:31:57 EDT
Indeed fix is simple and affects binary types only.
It should be fixed for F4.
Comment 4 David Audel CLA 2002-06-19 09:40:31 EDT
The problem does not exists in 1.0.
Comment 5 Jerome Lanneluc CLA 2002-06-19 10:10:09 EDT
I cannot reproduce the problem in 20020618 (i.e. without the patch). Not sure 
what happened when I tested. Moreover the method BinaryType.getType(String) 
takes care of this case so this patch is not needed. The patch has also the 
side effect of reporting the declaration in the top level class file, where it 
should be in the member type class file.

So we should not include this patch for F4.
Comment 6 Jerome Lanneluc CLA 2002-06-19 10:16:52 EDT
Sorry, annotated wrong PR. Please ignore previous note.
Comment 7 Olivier Thomann CLA 2002-06-19 12:21:31 EDT
Verified.
Comment 8 Philipe Mulet CLA 2002-06-20 07:27:25 EDT
Fix got approved, released in 20020620.
Comment 9 David Audel CLA 2002-06-20 11:16:45 EDT
Verified.