Bug 535439 - Extract method doesn't work because of a parent-element check
Summary: Extract method doesn't work because of a parent-element check
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.7.3   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords:
Depends on:
Blocks:
 
Reported: 2018-06-01 04:19 EDT by Andreas Höhmann CLA
Modified: 2022-08-18 17:58 EDT (History)
2 users (show)

See Also:


Attachments
screenshot of the result (90.08 KB, image/png)
2018-06-01 04:19 EDT, Andreas Höhmann CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Höhmann CLA 2018-06-01 04:19:27 EDT
Created attachment 274295 [details]
screenshot of the result

This is my method:

private void internalHighlight(@Nullable final ConfigUiModelCstic<?, ?> cstic, final boolean highlightEnabled) {
    if (cstic == null) {
      // noting to do
      return;
    }
    // currently only one cstic could be highlighted
    removeHighlightFeatureFromAllCstics();
    if (highlightEnabled) {
      highlightOn(cstic);
    } else {
      highlightOff(cstic);
    }
    // ---------------------- START ------------------------------
    // check if tab switch is necessary
    final ConfigurationUiTab selectedConfigurationTab = tabManager.getSelectedConfigurationTab();
    for (final ConfigurationUiTab configurationUiTab : uiModel.getConfigurationUiModel().getVisibleTabs()) {
      if (configurationUiTab != selectedConfigurationTab && tabContainsCstic(configurationUiTab, cstic)) {
        LOGGER.debug("Automatic tab-switch from '{}' to '{}' to show highlighted '{}'", selectedConfigurationTab, configurationUiTab,
            getAbsoluteProductCsticName(cstic.getCstic()));
        tabManager.setSelectedConfigurationTab(configurationUiTab);
        break;
      }
    }
    // ---------------------- END ------------------------------
    LOGGER.debug("Updated highlighted dt-cstics, highlighted cstic is now '{}'", getAbsoluteProductCsticName(cstic.getCstic()));
    eventBus.post(new ConfigurationUiChangedEvent()); // this triggers the ui-rerendering and this then will show the highlighting
  }

I would like to extract a method for the lines between START and END.

But eclipse shows me "Not all selected statements are enclosed by the same parent element".

I don't understand why? :D
Comment 1 Jay Arthanareeswaran CLA 2018-06-04 09:36:58 EDT
I tried with a recent build of 4.8 and I don't see the problem. I don't have 4.7.3 handy at the moment. Can you try with a 4.8 build?

Copying Noopur, who can perhaps tell us what's going on (it she can reproduce i.e.)
Comment 2 Noopur Gupta CLA 2018-06-05 04:15:20 EDT
I could not reproduce this issue with I20180530-2000.
Comment 3 Eclipse Genie CLA 2020-07-08 13:58:56 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 4 Eclipse Genie CLA 2022-08-18 17:58:37 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.