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

Bug 370590

Summary: [Compatibility] In CDT, the buttons inside the macro explorer are disabled
Product: [Eclipse Project] Platform Reporter: Marc-André Laperle <malaperle>
Component: UIAssignee: Paul Webster <pwebster>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: daniel_megert, pwebster, remy.suen
Version: 4.2   
Target Milestone: 4.2.2   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on:    
Bug Blocks: 331444    
Attachments:
Description Flags
LegacyHandlerService patch v1
none
Workaround for CDT none

Description Marc-André Laperle CLA 2012-02-03 13:06:11 EST
Using Build id: 20120202-1513 (Juno M5 C/C++)

1. Create a c++ project and paste this code

#define FOO(a) a++
#define BAR(a) FOO(a)

int main() {
  int b;
  BAR(b); // hover on BAR
  return 0;
}

2. Hover on BAR in main, click on the hover window to open macro explorer.
3. Buttons are disabled at the bottom the window.

It works correctly with Indigo SR2-RC2.
Comment 1 Remy Suen CLA 2012-02-03 14:26:33 EST
(In reply to comment #0)
> It works correctly with Indigo SR2-RC2.

Also confirmed to be working with 3.8M5. Will poke around.

Cool feature, by the way. :)
Comment 2 Remy Suen CLA 2012-02-03 14:56:54 EST
When we try to look for the "org.eclipse.cdt.ui.hover.backwardMacroExpansion" handler, we don't find anything so mark the item as being disabled.
Comment 3 Remy Suen CLA 2012-02-03 16:04:13 EST
Looks like the handlers are activated globally.
http://git.eclipse.org/c/cdt/org.eclipse.cdt.git/tree/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java?id=d2ba7a5b346d568eb26a84666b15c2a944dea8fc

IWorkbench workbench= PlatformUI.getWorkbench();
fHandlerService= (IHandlerService) workbench.getService(IHandlerService.class);
fContextService= (IContextService) workbench.getService(IContextService.class);
fContextActivation= fContextService.activateContext(CONTEXT_ID_MACRO_EXPANSION_HOVER);
fHandlerActivations= new ArrayList<IHandlerActivation>();
fHandlerActivations.add(fHandlerService.activateHandler(COMMAND_ID_EXPANSION_BACK, backwardHandler));
fHandlerActivations.add(fHandlerService.activateHandler(COMMAND_ID_EXPANSION_FORWARD, forwardHandler));
fHandlerActivations.add(fHandlerService.activateHandler(ICEditorActionDefinitionIds.OPEN_DECL, gotoDefinitionHandler));
Comment 4 Remy Suen CLA 2012-02-07 09:12:34 EST
The items are created first and then the handlers are registered. Our CCIs don't seem to be notified of this fact so the items stay disabled.
Comment 5 Remy Suen CLA 2012-03-06 15:02:47 EST
Created attachment 212158 [details]
LegacyHandlerService patch v1

If we force an event to be fired when the handler becomes active this problem goes away.
Comment 6 Marc-André Laperle CLA 2012-09-22 14:47:38 EDT
Created attachment 221376 [details]
Workaround for CDT

Patch for CDT in case the bug is not fixed in Platform for 4.2.2.
Comment 8 Paul Webster CLA 2013-01-17 12:57:10 EST
In M20130116-1800

PW