Bug 61212 - [search] Search requestor should not populate Java model
Summary: [search] Search requestor should not populate Java model
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo, performance
Depends on: 84210
Blocks:
  Show dependency tree
 
Reported: 2004-05-06 10:15 EDT by Jerome Lanneluc CLA
Modified: 2009-08-30 02:07 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 Jerome Lanneluc CLA 2004-05-06 10:15:50 EDT
I20040506

I noticed that JavaSearchResult.isShownInEditor(...) populates the Java model 
because it uses getUnderlyingResource(). In this particular case, it should 
use getRessource() which is a handle-only method.

In general, the SearchRequestor should not call anything than handle-only 
methods (see Java doc of these methods: if it doesn't say it is a handle-only 
method, it will populate the Java model).

If you need to call non-handle-only methods (like IType.isClass()), JDT Core 
can surely provide an API on SearchMatch that will return the right answer.
Comment 1 Thomas M??der CLA 2004-05-06 10:26:18 EDT
how about getAncestor(COMPILATION_UNIT).getResource())? I need to know whether a
java element is in a certain file.
Comment 2 Jerome Lanneluc CLA 2004-05-06 10:35:51 EDT
As specified in the Java doc, both of these methods are handle-only, so they 
are ok to use.
Comment 3 Thomas M??der CLA 2004-05-06 10:52:53 EDT
fixed. Jerome, could you verify?
Comment 4 Thomas M??der CLA 2004-05-06 11:07:01 EDT
Nope, this is not what I want. What I need is the file that corresponds (i.e. if
it's in a jar, I want null) to the CU or class file that contains the java
element. I was thinking of getCorrespondingResource(), but that's not
handle-only either. Any ideas?
Comment 5 Jerome Lanneluc CLA 2004-05-06 11:17:23 EDT
I'm not sure I understand: you were using getUnderlyingResource() that returns 
null only for an external jar. Why do you need to have it return null for an 
internal jar now? Also getCorrespondingResource() and getUnderlyingResource() 
are equivalent for an ICompilationUnit.
Comment 6 Thomas M??der CLA 2004-05-06 11:38:57 EDT
Just trust me....No, it's because of  bug 57036
Comment 7 Jerome Lanneluc CLA 2004-05-06 11:44:12 EDT
If you need to handle the internal jar separately, then use getAncestor
(IJavaElement.PACKAGE_FRAGMENT_ROOT), cast it to IPackageFragmentRoot, and use 
isArchive().
Comment 8 Thomas M??der CLA 2004-05-06 11:48:10 EDT
That's not handle only either, is it?
Comment 9 Jerome Lanneluc CLA 2004-05-06 11:51:37 EDT
Actually it is. I'm fixing the spec (and I told you to read the spec :-)
Comment 10 Thomas M??der CLA 2004-05-07 04:33:10 EDT
now checking isArchive & otherwise using getResource().
Comment 11 Jerome Lanneluc CLA 2004-05-07 04:36:11 EDT
So you never ask for IType.isClass() (to show the class icon) ?
Comment 12 Thomas M??der CLA 2004-05-07 04:42:13 EDT
Only in the label provider. If you're using the tree view, the java model
doensn't get populated (and that's the scalable way to search). Otherwise, I
don't see what I can do.
Comment 13 Jerome Lanneluc CLA 2004-05-07 04:49:19 EDT
That's why I offered to add new APIs on the SearchMatch classes so that the 
label provider can ask the SearchMatch instead of the IJavaElement. I just 
need to know which ones.

The rational is: we knew the answer to these questions when the SearchEngine 
found the matches. If we keep them on the search matches, it avoids to re-
parse all matches.
Comment 14 Thomas M??der CLA 2004-05-07 05:29:46 EDT
I'm using the regular AppearanceAwareLabelProvider. As far as I'm concerned,
they're using all kinds of non-handle info. 
Comment 15 Dirk Baeumer CLA 2004-05-07 06:23:10 EDT
The problem I see is that we render the enclosing element not the search match 
itself. So putting this info onto the search match seems strange to me. So we 
would provide methods on search match that belong to an IJavaElement. Wouldn't 
it make more sense to have something like a IJavaElementInfo which contains 
this information.

But as Thomas said this isn't an issue with the tree since we only populate 
the search model for those elements we render in the UI. 
Comment 16 Jerome Lanneluc CLA 2004-05-07 06:34:15 EDT
Instead of passing around an IJavaElementInfo, you could pass a SearchMatch. 
This is one level of indirection less.

In the case of the flat hierarchy view, if you have 10,000 matches my concern 
was that you would render 10,000 elements. If you render only 5 (assuming that 
my list is 5 items high), then I'm happy.
Comment 17 Jerome Lanneluc CLA 2004-05-12 12:39:34 EDT
JavaSearchResult.getFile(Object) still uses getUnderlyingResource()
Comment 18 Thomas M??der CLA 2004-05-14 05:38:57 EDT
No, if you have matches in 100000 elements, 100000 elements will be rendered
(and therefore the java model populated). The workaround is to switch to the
tree layout for large result sets. Changing that is way beyond a simple bug
report (it will result in a loss of function). 
I changed the file adapter to not use getUnderlyingResource() anymore.
Comment 19 Philipe Mulet CLA 2004-05-14 06:20:30 EDT
The original problem isn't fixed, you should *not* populate the JavaModel for 
free. This is a serious performance issue.
Comment 20 Thomas M??der CLA 2004-05-14 06:32:39 EDT
I cannot fix this PR without serious loss of function. Dirk, please advise.
Comment 21 Philipe Mulet CLA 2004-05-14 06:35:55 EDT
To clarify, the problem isn't fixed because there is a workaround.
Comment 22 Dirk Baeumer CLA 2004-05-14 07:15:02 EDT
Switching to a non Java element based implementation requires:

- full new rendering support for Java elements which aren't Java elements
- unclear what happens to decorators (CVS, binary, ...)
- action and action contributions via XML. If we don't have Java elements 
  although we render them in the UI, actions contributed to Java elements 
  will not show up in the search result view.

A solution for this problem could be special IJavaElement. We could call them
value elements. Those elements have enough information to be rendered in the
UI but still implement IJavaElement. This is basically the same JDT/UI would 
have to do but would not require to double the whole rendering and action 
support story in the UI.

Regarding 3.0: no further action is planned. We recommend using the tree view 
anyway and 2.1 had the same behaviour.
Comment 23 Philipe Mulet CLA 2004-05-14 10:25:08 EDT
Fake elements would be highly dangerous to provide, as they could be used to 
feed subsequent APIs, and we'd have to add support wherever this could occur. 
Furthermore, this could be troublesome when dealing with true handle elements 
as well. This is a no go from our standpoint.
Comment 24 Dirk Baeumer CLA 2004-05-14 10:41:19 EDT
But you are requesting that we are going to implement those "fake" elements in 
the UI world which is harder for use to do than for you.
Comment 25 Philipe Mulet CLA 2004-05-14 10:57:48 EDT
All I am asking is that you render search matches directly, and not elements. 
We could add more info to the search matches themselves, and/or some notion of 
groups. But we wouldn't go and reimplement true Java element variations which 
wouldn't be handle based. We don't want to deal with interactions between fake 
and true Java elements.
Comment 26 Dirk Baeumer CLA 2004-05-14 11:12:44 EDT
I don't think people will be happy if we remove the function from search and 
only render matches whithout relation to its container.
Comment 27 Philipe Mulet CLA 2004-05-14 16:04:28 EDT
Search matches could carry all the information you need to perform the 
grouping. This information would however not be in the form of IJavaElement 
due to the reasons mentionned before.
Comment 28 Dirk Baeumer CLA 2004-05-16 11:34:42 EDT
If this elements are Java element then UI has to double all the code for 
rendering, label decoration and action management. Philippe, I don't think 
that doubling all that code is the right thing to do.
Comment 29 Philipe Mulet CLA 2004-05-16 16:21:15 EDT
Right, but doubling the JavaModel just to deal with an implementation detail 
in search result view isn't an option either.
Comment 30 Dirk Baeumer CLA 2004-05-17 03:15:53 EDT
Another idea is to use the new virutal table support from SWT. That would mean 
that we only populate the Java Model with those elements that are visible. 
Unfortunatelly, JFace doesn't support SWT virtual tables yet. Following the 
path would avoid code doubling in both Java/Core and Java/UI.
Comment 31 Tod Creasey CLA 2005-03-07 11:57:16 EST
Adding my name to the cc list as we are now tracking performance issues more
closely. Please remove the performance keyword if this is not a performance bug.
Comment 32 Dirk Baeumer CLA 2005-04-06 05:59:59 EDT
Fixing bug 90392 would also solve the issues in search since we would use the
binding key to render the element in the UI instead of going for the Java
element itself.
Comment 33 Jerome Lanneluc CLA 2005-04-11 06:02:19 EDT
Bug 90392 is now fixed, but I believe you still need bug 90621 (storing the
binding key in mementos) to be fixed.
Comment 34 Jerome Lanneluc CLA 2005-04-11 06:05:08 EDT
Also note that some questions like isClass() will still have the cost of opening
the Java element (the binding key in the resolved element doesn't have this
information). Do you still need to answer such questions ? If you do, please
enter a feature request to have this information returned in the SearchMatch.
Comment 35 Dirk Baeumer CLA 2005-04-11 06:44:40 EDT
Bug 90621 is necessary when we switch between search result sets and only for
the element to be searched for. For rendering a single set, this is not necessary. 
Comment 36 Dirk Baeumer CLA 2005-04-11 06:59:40 EDT
Jerome, we are not directly asking isClass. We are going through the flags. We
need this information to render the correct icon (class, interface, enum or
annotation) However I guess that this will open the element as well.

Adding this information to the SearchMatch will currently not help. The reason
is that the search view doesn't render matches, it renders Java elements as
gouping elements. We do this since plug-ins wanted to add entries to the context
menu and we don't have search match object for the grouping element. Before we
add this information to the search match I first have to investigate if we can
leverage this information and what this would mean for the overall architecture.

Is the same true for the ITypes in a type hierarchy. There we access the flags
as well to render the right icon.
And we are 
Comment 37 Jerome Lanneluc CLA 2005-04-11 07:06:15 EDT
Yes, asking for the flags of the IType will open the Java element.

For the hierarchy, ITypeHierarchy#getCachedFlags(IType) was added in 2.0 to
handle the rendering of icon.
Comment 38 Dirk Baeumer CLA 2005-04-11 07:29:50 EDT
Martin enlighted this to me as well.
Comment 39 Dirk Baeumer CLA 2006-04-05 06:25:33 EDT
Martin I am handing this over to you. 

To basically be able to not resolve the Jave model we need more resolved information on the handles. I will leave it up to you to either close this one or to leave it open as a reminder.
Comment 40 Martin Aeschlimann CLA 2006-04-05 08:57:53 EDT
I think the virtual table is the solution. Bug 84210.
Comment 41 Denis Roy CLA 2009-08-30 02:07:16 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.