Bug 184233 - Expression view does not support alternative content providers
Summary: Expression view does not support alternative content providers
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 3.3   Edit
Hardware: PC Windows XP
: P3 enhancement (vote)
Target Milestone: 3.4 M4   Edit
Assignee: Curtis Windatt CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks: 205334
  Show dependency tree
 
Reported: 2007-04-26 10:23 EDT by Pawel Piech CLA
Modified: 2007-11-14 15:18 EST (History)
2 users (show)

See Also:


Attachments
Patch to address the problem. (15.65 KB, patch)
2007-04-26 10:26 EDT, Pawel Piech CLA
no flags Details | Diff
Patch to fix bug based on 3.4 M2 sources. (8.59 KB, patch)
2007-10-03 14:09 EDT, Pawel Piech CLA
no flags Details | Diff
Updated patch (10.52 KB, patch)
2007-11-14 09:30 EST, Darin Wright CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pawel Piech CLA 2007-04-26 10:23:09 EDT
The input to the expression view is fixed to getViewer().setInput(DebugPlugin.getDefault().getExpressionManager()) inside the ExpressionView.setInitialContent() method.  Since there can be only one IElementContentProvider for the ExpressionManager, there is no way to provide alternative contents in the expression view as in the Variables and Registers views.
Comment 1 Pawel Piech CLA 2007-04-26 10:26:57 EDT
Created attachment 65040 [details]
Patch to address the problem.

The fix in the patch does not change any APIs but it does complicate the content providers for the standard debug model a bit, so hopefully this bug can still be addressed in 3.3.
Comment 2 Darin Wright CLA 2007-04-26 10:53:11 EDT
Some issues:

* Every debug model has to account for the expression view for any one of its debug elements that can be the active context. For example, since the Java thread content provider does not acconut for this, the expression view goes blank when a java thread is selected.
* The view refreshes on each input change which does not currently save/restore expansion state (so all elements are continually collapsing).

Can you just add custom expressions to the manager to get the same effect? Each expression can have custom content, but the root elements would need to be expressions.
Comment 3 Pawel Piech CLA 2007-04-26 13:45:20 EDT
I agree that this is problematic :-(

I was hoping that we could use the expressions view to show variables and registers with the same features as they have in their own views: i.e. custom columns and cell editors.  

Extending IExpression could actually work well... the only sticky point might be the column provider.  Currently there is no column factory registered for IExpressionManager, but if we were to register one, it would apply to all debuggers.
Comment 4 Pawel Piech CLA 2007-04-26 15:29:40 EDT
Another problem is that if we provided our own IExpression implementation, we would not be able to re-use the IWatchExpression objects that are added by the expression view's standard actions.  

I tried to think of another way to solve this problem but I keep running into the fact that there can only be one content provider per element... which has to work in all views.
Comment 5 Darin Wright CLA 2007-04-26 16:12:27 EDT
(In reply to comment #3)

> I was hoping that we could use the expressions view to show variables and
> registers with the same features as they have in their own views: i.e. custom
> columns and cell editors.  

Yes - we've purposely avoided columns in views that show elements from different models at the same time.
Comment 6 Pawel Piech CLA 2007-04-27 13:59:56 EDT
It's too late to do anything about this bug in 3.3, so this is just for future consideration.  With in mind I think there are three possible resolutions to this problem:

1) Leave the expression view as it is.
This means that practially speaking expression view will display only WatchExpression/IVariable/IValue based data.  Custom columns and cell editors that are available in Variables and Registers views are not going to be usable in the expression view.
If our marketing/customers demand that we have a watch view that has the above features, we will just introduce a separate "Watch" view with customizable content.  

2) Apply the patch plus saving/restoring view expansion state.
Custom content would work, but other custom content providers would have a further complication on top of an already complicated set of API requirements.  

3) Introduce a new API/extension point to allow the expression view input and/or content provider to be selectively overriden.  
Whatever mechanism is introduced here, it will at least partially overlap with the functionality of flexible hierarchy itself.  Which kind of begs the question whether it would be better to try to somehow address this in the flexible hierarchy APIs themselves.

----
Option 1 is obviously least favorable to us, but I can also see some valid arguments for it.  Option 2 and 3 are pretty much equivalent in terms of functionality, so it's just a matter of deciding on the correct architecture.
Comment 7 Darin Wright CLA 2007-04-27 14:10:10 EDT
marking assigned for future consideration.
Comment 8 Pawel Piech CLA 2007-06-11 14:58:28 EDT
Comment on attachment 65040 [details]
Patch to address the problem.

I submitted an updated patch for bug 184057, which includes changes needed to address this bug.
Comment 9 Curtis Windatt CLA 2007-06-12 14:48:19 EDT
The updated patch (which should be separate from bug 184057 and attached here) needs further review.  The patch will require the content providers of debuggers to call the super class or provide expression information.
Comment 10 Pawel Piech CLA 2007-06-12 15:02:01 EDT
An alternative method to address this bug would be to use a view input "proxy" as has the been suggested in bug 176627.  

A proxy could supply a default content provider and would eliminate the need to change the default adapters for the standard model.
Comment 11 Pawel Piech CLA 2007-10-03 14:09:32 EDT
Created attachment 79663 [details]
Patch to fix bug based on 3.4 M2 sources.

I created a new fix for this bug based on the new IViewerInputProvider interface.  This patch does not require any changes in the content providers for the standard debug model elements.  

With this patch, a debugger which needs to customize contents of the expressions view will need to provider its own implementation of IViewerInputProvider, which in turn will provide an alternative input object into the view (as opposed to the default: ExpressionManager instance).
Comment 12 Darin Wright CLA 2007-10-03 15:06:02 EDT
Consdier for 3.4
Comment 13 Darin Wright CLA 2007-11-14 09:30:22 EST
Created attachment 82873 [details]
Updated patch

Patch adds IViewerInputProvider adapters for IDebugElement, IProcess, ILaunch so the viewew does not go "empty" when a non-stack frame element is selected. The default "viewer input provider" was provided, but the other elements were not adapted to it.
Comment 14 Darin Wright CLA 2007-11-14 09:51:20 EST
Applied patch with modification to contributed adapters for standard debug elements.
Comment 15 Darin Wright CLA 2007-11-14 09:51:35 EST
Please verify, Curtis.
Comment 16 Pawel Piech CLA 2007-11-14 10:04:31 EST
Thank You!

But I also discovered another flaw with this patch recently:  when the view is hidden, VariablesView.becomesHidden() calls setViewerInput(null).  Since ExpressionView.setViewerInput() overrides setViewerInput() to re-set input to ExpressionManager, the view ends up evaluating expressions when the view is not visible.

In our product patch we didn't use the DefaultInputProvider, so overriding setViewerInput() was necessary to populate the view for non-DSF debug models, but I think in this patch, it's not necessary to do to override setViewerInput().

BTW, what we did to work around this problem is to add

    protected void becomesHidden() {
        super.setViewerInput(null);
    }

to ExpressionView, but this makes an assumption about what is in super.becomesHidden() so it's not ideal.
Comment 17 Darin Wright CLA 2007-11-14 10:10:20 EST
Re-open to address updating while hidden.
Comment 18 Pawel Piech CLA 2007-11-14 11:44:04 EST
Also, I think with this patch, it's not necessary to override becomesVisible()
anymore either, because contextActivated() will override it anyway.
Comment 19 Darin Wright CLA 2007-11-14 14:22:31 EST
Fix is to set the input to the expression manager when the active context is null or empty. No longer need to override becomesVisible() or setViewerInput(), and can get rid of setInitialContent().
Comment 20 Darin Wright CLA 2007-11-14 14:22:46 EST
Please verify, Curtis.
Comment 21 Pawel Piech CLA 2007-11-14 15:04:48 EST
Many thanks :-)
Comment 22 Curtis Windatt CLA 2007-11-14 15:18:59 EST
Verified.