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

Bug 339806

Summary: ChainCompletionContext: expected type is null on array types
Product: z_Archived Reporter: Andreas Kaluza <andreas>
Component: RecommendersAssignee: Marcel Bruch <marcel.bruch>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Andreas Kaluza CLA 2011-03-12 16:40:23 EST
The computation of the expected type in the ChainCompletionContext will lead to null if the chain completion is triggered on an array type. A test case is the method2 in the CompletionOnArrayMemberAccessInMethod class (*.tests.fixtures.rcp.codecompletion.chain).

Problem: Look at the toJdtType method in the JavaElementResolver class. The output is null, which should not happen. In the mentioned test case the input is [Ljava/util/concurrent/atomic/AtomicInteger. This input could not be found in the cache (IType jdtType = (IType) cache.get(recType); --> null).
Comment 1 Marcel Bruch CLA 2011-03-14 05:08:07 EDT
I investigated this issue. Unfortunately JDT does not allow you to specify ITypes that have an array dimension, e.g., there is no IType MyType[] in JDT. 

I may return either the array base type (MyType) or the type "Array". the latter seems reasonable but not perfect. I would prefer to return null or even throw an exception if someone puts an array type in here.

Looking at Marko's JDT implementation shows how he dealt with this issue (see class TypeWithArrayDepth).

How can I support you further?
Comment 2 Andreas Kaluza CLA 2011-03-14 06:14:12 EDT
fixed