Skip to content

Commit

Permalink
Fix illegal name exception when inlining qualified field name (eclips…
Browse files Browse the repository at this point in the history
…e-jdt#1718)

- fix InlineTempRefactoring.getAlternativeQualification() to not

  calculate qualified alternatives if not dealing with static reference

- fix InlineTempRefactoring.checkClashes() to handle when there are

  qualified alternatives

- add new test to InlineTempTests

- fixes eclipse-jdt#1705
  • Loading branch information
jjohnstn authored and jannisCode committed Oct 22, 2024
1 parent b8fb344 commit 373e4db
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public class CallHierarchyCore {
public static final String PREF_SHOW_ALL_CODE = "PREF_SHOW_ALL_CODE"; //$NON-NLS-1$
public static final String PREF_HIDE_TEST_CODE = "PREF_HIDE_TEST_CODE"; //$NON-NLS-1$
public static final String PREF_SHOW_TEST_CODE_ONLY = "PREF_SHOW_TEST_CODE_ONLY"; //$NON-NLS-1$
public static final String[] PREF_FILTERS = {PREF_SHOW_ALL_CODE, PREF_HIDE_TEST_CODE, PREF_SHOW_TEST_CODE_ONLY};

public static final String PREF_USE_IMPLEMENTORS= "PREF_USE_IMPLEMENTORS"; //$NON-NLS-1$
public static final String PREF_USE_FILTERS= "PREF_USE_FILTERS"; //$NON-NLS-1$
Expand All @@ -72,6 +73,7 @@ public boolean isSearchUsingImplementorsEnabled() {
}

public boolean isShowTestCode() {

return Boolean.parseBoolean(JavaManipulation.getPreference(PREF_SHOW_TEST_CODE_ONLY, null));
}

Expand All @@ -82,6 +84,13 @@ public boolean isShowAll() {
public boolean isHideTestCode() {
return Boolean.parseBoolean(JavaManipulation.getPreference(PREF_HIDE_TEST_CODE, null));
}
public String getActiveFilter() {
for (String string : PREF_FILTERS) { //must be one of the threee
if(Boolean.parseBoolean(JavaManipulation.getPreference(string, null))) {
return string;
}
} return null;
}

public Collection<IJavaElement> getImplementingMethods(IMethod method) {
if (isSearchUsingImplementorsEnabled()) {
Expand Down Expand Up @@ -328,4 +337,5 @@ public static boolean isPossibleInputElement(Object element){

return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ public void setShowTestCode(boolean value) {
settings.setValue(PREF_SHOW_TEST_CODE_ONLY, value);
}

public void setActiveFilter (String string) {
IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore();
for (String s : CallHierarchyCore.PREF_FILTERS) {
if(s == string) {
settings.setValue(s, true);
} else {
settings.setValue(s, false);
}
}

}

public boolean isSearchUsingImplementorsEnabled() {
IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore();
return settings.getBoolean(PREF_USE_IMPLEMENTORS);
Expand Down Expand Up @@ -149,6 +161,7 @@ public boolean isHideTestCode() {
return settings.getBoolean(PREF_HIDE_TEST_CODE);
}


public boolean isShowTestCode() {
IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore();
return settings.getBoolean(PREF_SHOW_TEST_CODE_ONLY);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.eclipse.ui.PlatformUI;

import org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchy;
import org.eclipse.jdt.internal.corext.callhierarchy.CallHierarchyCore;

import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
Expand All @@ -43,7 +44,7 @@ class FiltersDialog extends StatusDialog {
private Button fShowAll;
private Button fHideTest;
private Button fShowTest;

private Button[] buttons = {fShowAll, fHideTest, fShowTest};
protected FiltersDialog(Shell parentShell) {
super(parentShell);
}
Expand Down Expand Up @@ -118,6 +119,10 @@ private void createTestCodeArea(Composite parent) {
layout.numColumns= 1;
radioGroup.setLayout(layout);

for (Button button : buttons) {
button = new Button(radioGroup, SWT.RADIO);
}

fShowAll= new Button(radioGroup, SWT.RADIO);
fShowAll.setText(CallHierarchyMessages.FiltersDialog_ShowAllCode);

Expand Down Expand Up @@ -191,9 +196,18 @@ private void updateFilterFromUI() {
CallHierarchy.getDefault().setFilters(fNames.getText());
CallHierarchy.getDefault().setFilterEnabled(fFilterOnNames.getSelection());

CallHierarchy.getDefault().setShowAll(fShowAll.getSelection());
CallHierarchy.getDefault().setHideTestCode(fHideTest.getSelection());
CallHierarchy.getDefault().setShowTestCode(fShowTest.getSelection());
// CallHierarchy.getDefault().setShowAll(fShowAll.getSelection());
// CallHierarchy.getDefault().setHideTestCode(fHideTest.getSelection());
// CallHierarchy.getDefault().setShowTestCode(fShowTest.getSelection());
String activeFilter;
for (Button button : buttons) {
if(button.getSelection()) {
activeFilter = getString(button);
}
}
activeFilter = ""; //$NON-NLS-1$

CallHierarchy.getDefault().setActiveFilter(activeFilter);
}

/**
Expand All @@ -205,9 +219,18 @@ private void updateUIFromFilter() {
fFilterOnNames.setSelection(CallHierarchy.getDefault().isFilterEnabled());

setSelection();

updateEnabledState();
}
private String getString(Button B) {
if(B == fShowAll) {
return CallHierarchyCore.PREF_SHOW_ALL_CODE;
} else if (B == fHideTest) {
return CallHierarchyCore.PREF_HIDE_TEST_CODE;
} else {
return CallHierarchyCore.PREF_SHOW_TEST_CODE_ONLY;
}
}


/**
Expand Down

0 comments on commit 373e4db

Please sign in to comment.