Bug 90392 - [model] More resolved information for Java elements
Summary: [model] More resolved information for Java elements
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1 M7   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2005-04-05 18:31 EDT by Dirk Baeumer CLA
Modified: 2006-04-05 08:57 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dirk Baeumer CLA 2005-04-05 18:31:19 EDT
M6

With 5.0 rendering Java elements in the UI which have type arguments (types and
methods) requires "opening" the element to access the type argument information.

JDT/UI first tries to use the information provided by the resolved binding key
(e.g. method getKey()) to render this information. However, the elements are
most of the time unresolved. 

Especially in type hieraries and search where a lot of Java elements are created
providing this information will speed-up rendering these elements in the UI.
Comment 1 Dirk Baeumer CLA 2005-04-05 18:31:57 EDT
"Opening" the Java element is even required to find out if a element has type
parameters.
Comment 2 Jerome Lanneluc CLA 2005-04-10 12:01:28 EDT
Changed HierarchyResolver to create resolved handles from the reference bindings.
Changed TypeHierarchyTests and HierarchyOnWorkingCopiesTests to show resolved
handles in the hierarchies.
Comment 3 Dirk Baeumer CLA 2005-04-11 05:53:27 EDT
Jerome, does this already include that we transparently get the information
through the get methods on IJavaElement.
Comment 4 Jerome Lanneluc CLA 2005-04-11 05:59:09 EDT
Not yet. See bug 90778.
Comment 5 Jerome Lanneluc CLA 2005-04-11 05:59:37 EDT
Changed search to create resolved elements too. Search tests remain unchanged as
they use a custom print of the returned Java elements.
Comment 6 Philipe Mulet CLA 2005-04-11 11:39:33 EDT
Reopening. Due to element handle lifecycles, it may be dangereous to cache this
information inside the handles directly. Handles could become obsoleted along
type hierarchie existence, or search match; and clients would be fooled by
obsolete information cached onto stale element handles.

Cached information should go directly into type hierarchy and/or search match
objects, since the cached information is intimately tied with the lifecycle of
these entities.
Comment 7 Philipe Mulet CLA 2005-04-11 11:40:01 EDT
This requires PMC approval to proceed to changes within M7
Comment 8 Jerome Lanneluc CLA 2005-04-11 12:05:25 EDT
We want to add the following API on ITypeHierarchy:

/**
 * Returns the type parameters associated with the given type 
 * (would be equivalent to <code>IType#getTypeParameters()</code>),
 * or <code>null</code> if this information wasn't cached on the hierarchy 
 * during its computation.
 * 
 * @param type the given type
 * @return the cached type parameters for this type
 * @see ITypeParameter
 * @since 3.1
 */
ITypeParameter[] getCachedTypeParameters(IType type);
Comment 9 Jerome Lanneluc CLA 2005-04-11 12:09:43 EDT
Ideally we would add the same kind of information on SearchMatch. However since
the default for the search view is the hierarchical mode, it is unclear if the
performance gain would be worth it.
Comment 10 Jerome Lanneluc CLA 2005-04-11 12:38:12 EDT
Another approach is to ignore the binding key in JDT Core (i.e. we behave as if
it was an unresolved handle), and let the client use the binding key.

This means that we need to store the flags inside the binding key, and add a new
API on BindingKey to retrieve the flags. Note this would be useful for search
only (as the type hierarchy already caches these flags).
Comment 11 Jerome Lanneluc CLA 2005-04-12 04:33:48 EDT
Invastigating how to speed up search result rendering, it looks like it is going
to be more work than adding the flags in the binding key and adding a new API on
BindingKey.

When a search result is displayed, at least the following APIs are called (which
causes opening of Java elements):
- IMethod#getFlags()
- IMethod#exists()
- IMethod#isConstructor()
- IType#getTypeParameters()
- IMethod#getDeclaringType()#isEnum() (this one is problematic as the declaring
type of a resolved method is not resolved for now).
Comment 12 Dirk Baeumer CLA 2005-04-12 04:58:37 EDT
Jerome, 

thanks for the info. I will look into why we call
IMethod#getDeclaringType()#isEnum().
Comment 13 Dirk Baeumer CLA 2005-04-12 05:19:18 EDT
We call IMethod#getDeclaringType()#isEnum() to render a private icon for the
constrcutor if flags say that it has default visibility. 

First we can change the && to first check if it has default visibility and then
ask for isEnum. 

Jerome, the flags in the bindings are these preceise (e.g. compiler flags) or
source flags. So for 

enum EE {
   EE() {
   }
}

will the flags tell us that foo has default visibility or is private.
Comment 14 Dirk Baeumer CLA 2005-04-12 05:20:40 EDT
wanted to say that EE has default visibility or is private
Comment 15 Jerome Lanneluc CLA 2005-04-12 05:29:15 EDT
The flags will be the compiler binding flags, so it will tell you if EE has
default visibility or is private.
Comment 16 Dirk Baeumer CLA 2005-04-12 05:43:35 EDT
OK. If the flags are preceise then we don't have to reach to the declaring type
of a method or field to decide on its icon. We simply use the flags.

I looked into bet implementing this an instead of mangling it into the current
Label provide I will create a new one that works on the binding key (like we
have one for IBinding).
Comment 17 Dirk Baeumer CLA 2005-04-12 05:49:01 EDT
Jerome, can you imagine how the new API would look like on binding key. Then I
can start looking at what it means to implement the label provider.
Comment 18 Jerome Lanneluc CLA 2005-04-12 05:55:24 EDT
I think it would be BindingKey#getFlags() and would return an int (that you can
decode using the Flags class).
Comment 19 Jerome Lanneluc CLA 2005-04-14 06:00:27 EDT
Internal support released, but it is currently turned off. To turn it on, change
Binding#USE_ACCESS_FLAGS_IN_BINDING_KEY to true.
Comment 20 Jerome Lanneluc CLA 2005-04-14 06:08:52 EDT
To summarize, the folling new APIs would be needed by JDT UI:
- BindingKey#getFlags()
- BindingKey#isConstructor()
Comment 21 Jerome Lanneluc CLA 2005-04-26 04:54:44 EDT
Still waiting on PMC approval on this API addition.
Comment 22 Erich Gamma CLA 2005-04-26 05:01:39 EDT
apologies, but this looked like work in progress the last time I've looked.

To summarize you are looking for approval for:

Additions to BindingKey:
- BindingKey#getFlags()
- BindingKey#isConstructor()

Additions to ITypeHierarchy:
ITypeParameter[] getCachedTypeParameters(IType type);
Comment 23 Erich Gamma CLA 2005-04-26 05:15:45 EDT
The additions from comment #22 are approved
Comment 24 Jerome Lanneluc CLA 2005-04-26 05:29:49 EDT
Sorry for the confusion Erich. We actually only need:
- BindingKey#getFlags()
- BindingKey#isConstructor()

I'm adding these APIs right now.
Comment 25 Jerome Lanneluc CLA 2005-04-26 09:42:52 EDT
Added the 2 APIs.
Added corresponding tests BindingKeyTests#test034() to test037().
Comment 26 Philipe Mulet CLA 2005-04-28 07:03:34 EDT
After more discussions with JDT/UI, we came to conclusion that these additions
are not suitable; since it may cache element structural information into keys,
leaving  clients with difficult decisions as to whether to trust the key or the
element.

The only interest for having it on the key is to cache some information avoiding
populating the model, and is not mandated by the normal binding key contract,
i.e. identify uniquely a type binding. 

Therefore, it should not be added. If such information was requested again, it
should end up in a different spot. Something we could imagine post 3.1 is to
precache this information directly into Java elements (pre/partially initialized
element infos), and hiding the complexity to clients who could blindly trust the
elements to reflect reality.
Comment 27 Jerome Lanneluc CLA 2005-04-28 07:27:17 EDT
Removed the 2 APIs and corresponding tests.