issue_id
int64
2.03k
426k
title
stringlengths
9
251
body
stringlengths
1
32.8k
status
stringclasses
6 values
after_fix_sha
stringlengths
7
7
project_name
stringclasses
6 values
repo_url
stringclasses
6 values
repo_name
stringclasses
6 values
language
stringclasses
1 value
issue_url
null
before_fix_sha
null
pull_url
null
commit_datetime
timestamp[us, tz=UTC]
report_datetime
timestamp[us, tz=UTC]
updated_file
stringlengths
2
187
file_content
stringlengths
0
368k
60,714
Bug 60714 Call Hierarchy: display search scope in view title
Call Hierarchy should display the current search scope in the view title, like the Search View does. E.g.: Members calling 'updateView()' - in Workspace Calls from 'updateView()' - in Working Set: my projects
resolved fixed
1854c92
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T07:45:19Z
2004-05-03T07:40:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchScopeWorkspaceAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * Jesper Kamstrup Linnet ([email protected]) - initial API and implementation * (report 36180: Callers/Callees view) ******************************************************************************/ package org.eclipse.jdt.internal.ui.callhierarchy; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; class SearchScopeWorkspaceAction extends SearchScopeAction { public SearchScopeWorkspaceAction(SearchScopeActionGroup group) { super(group, CallHierarchyMessages.getString("SearchScopeActionGroup.workspace.text")); //$NON-NLS-1$ setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.workspace.tooltip")); //$NON-NLS-1$ WorkbenchHelp.setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION); } public IJavaSearchScope getSearchScope() { return SearchEngine.createWorkspaceScope(); } /* (non-Javadoc) * @see org.eclipse.jdt.internal.ui.callhierarchy.SearchScopeActionGroup.SearchScopeAction#getSearchScopeType() */ public int getSearchScopeType() { return SearchScopeActionGroup.SEARCH_SCOPE_TYPE_WORKSPACE; } }
60,849
Bug 60849 [projection] NPE when opening pref page
plugin-export I200404281424.from20040503_1936 running with my existing development workspace Open the preference page and select the Java editor page java.lang.NullPointerException at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at java.lang.NullPointerException.<init>(NullPointerException.java:60) at org.eclipse.jdt.internal.ui.preferences.FoldingConfigurationBlock.restoreFromPreferences(FoldingConfigurationBlock.java:343) at org.eclipse.jdt.internal.ui.preferences.FoldingConfigurationBlock.initialize(FoldingConfigurationBlock.java:316) at org.eclipse.jdt.internal.ui.preferences.JavaEditorPreferencePage.initialize(JavaEditorPreferencePage.java:1499) at org.eclipse.jdt.internal.ui.preferences.JavaEditorPreferencePage.createContents(JavaEditorPreferencePage.java:1443) at org.eclipse.jface.preference.PreferencePage.createControl(PreferencePage.java:217) at org.eclipse.jdt.internal.ui.preferences.JavaEditorPreferencePage.createControl(JavaEditorPreferencePage.java:410) at org.eclipse.jface.preference.PreferenceDialog$12.run(PreferenceDialog.java:1021) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java) at org.eclipse.core.runtime.Platform.run(Platform.java) at org.eclipse.jface.preference.PreferenceDialog.showPage(PreferenceDialog.java:1016) at org.eclipse.jface.preference.PreferenceDialog$9.selectionChanged(PreferenceDialog.java:576) at org.eclipse.jface.viewers.StructuredViewer$3.run(StructuredViewer.java:431) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java) at org.eclipse.core.runtime.Platform.run(Platform.java) at org.eclipse.jface.viewers.StructuredViewer.firePostSelectionChanged(StructuredViewer.java:429) at org.eclipse.jface.viewers.StructuredViewer.handlePostSelect(StructuredViewer.java:680) at org.eclipse.jface.viewers.StructuredViewer$5.widgetSelected(StructuredViewer.java:698) at org.eclipse.jface.util.OpenStrategy.firePostSelectionEvent(OpenStrategy.java:198) at org.eclipse.jface.util.OpenStrategy.access$4(OpenStrategy.java:193) at org.eclipse.jface.util.OpenStrategy$3.run(OpenStrategy.java:334) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:648) at org.eclipse.ui.internal.OpenPreferencesAction.run(OpenPreferencesAction.java:72) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:240) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:117) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:79) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:41) at java.lang.reflect.Method.invoke(Method.java:386) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
3b6528d
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T08:59:50Z
2004-05-04T08:40:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorPreferencePage.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.preferences; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.text.Collator; import java.util.ArrayList; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import java.util.SortedSet; import java.util.StringTokenizer; import java.util.TreeSet; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Preferences; import org.eclipse.swt.SWT; import org.eclipse.swt.events.KeyEvent; import org.eclipse.swt.events.KeyListener; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.layout.RowLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.TabFolder; import org.eclipse.swt.widgets.TabItem; import org.eclipse.swt.widgets.Text; import org.eclipse.jface.action.Action; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.preference.PreferencePage; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.source.SourceViewer; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.texteditor.AnnotationPreference; import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.ui.texteditor.MarkerAnnotationPreferences; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.text.JavaSourceViewerConfiguration; import org.eclipse.jdt.ui.text.JavaTextTools; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.dialogs.StatusInfo; import org.eclipse.jdt.internal.ui.dialogs.StatusUtil; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer; import org.eclipse.jdt.internal.ui.text.ChainedPreferenceStore; import org.eclipse.jdt.internal.ui.text.IJavaPartitions; import org.eclipse.jdt.internal.ui.text.PreferencesAdapter; import org.eclipse.jdt.internal.ui.util.TabFolderLayout; /** * The page for setting the editor options. */ public class JavaEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { private static final String BOLD= PreferenceConstants.EDITOR_BOLD_SUFFIX; private static final String COMPILER_TASK_TAGS= JavaCore.COMPILER_TASK_TAGS; private static final String DELIMITER= PreferencesMessages.getString("JavaEditorPreferencePage.navigation.delimiter"); //$NON-NLS-1$ /** The keys of the overlay store. */ public final OverlayPreferenceStore.OverlayKey[] fKeys; private final String[][] fSyntaxColorListModel= new String[][] { { PreferencesMessages.getString("JavaEditorPreferencePage.multiLineComment"), PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.singleLineComment"), PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.returnKeyword"), PreferenceConstants.EDITOR_JAVA_KEYWORD_RETURN_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.keywords"), PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.strings"), PreferenceConstants.EDITOR_STRING_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.methodNames"), PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.operators"), PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.others"), PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.javaCommentTaskTags"), PreferenceConstants.EDITOR_TASK_TAG_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.javaDocKeywords"), PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.javaDocHtmlTags"), PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.javaDocLinks"), PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR }, //$NON-NLS-1$ { PreferencesMessages.getString("JavaEditorPreferencePage.javaDocOthers"), PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR } //$NON-NLS-1$ }; private final String[][] fAppearanceColorListModel= new String[][] { {PreferencesMessages.getString("JavaEditorPreferencePage.lineNumberForegroundColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR, null}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"), PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR, null}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.currentLineHighlighColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR, null}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColor2"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, null}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR, null}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_COLOR, null}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.selectionForegroundColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.selectionBackgroundColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR}, //$NON-NLS-1$ }; private final String[][] fAnnotationColorListModel; private final String[][] fContentAssistColorListModel= new String[][] { {PreferencesMessages.getString("JavaEditorPreferencePage.backgroundForCompletionProposals"), PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND }, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.foregroundForCompletionProposals"), PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND }, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.backgroundForMethodParameters"), PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND }, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.foregroundForMethodParameters"), PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND }, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.backgroundForCompletionReplacement"), PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND }, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.foregroundForCompletionReplacement"), PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND } //$NON-NLS-1$ }; private final String[][] fAnnotationDecorationListModel= new String[][] { {PreferencesMessages.getString("JavaEditorPreferencePage.AnnotationDecoration.NONE"), AnnotationPreference.STYLE_NONE}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.AnnotationDecoration.SQUIGGLES"), AnnotationPreference.STYLE_SQUIGGLES}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.AnnotationDecoration.UNDERLINE"), AnnotationPreference.STYLE_UNDERLINE}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.AnnotationDecoration.BOX"), AnnotationPreference.STYLE_BOX}, //$NON-NLS-1$ {PreferencesMessages.getString("JavaEditorPreferencePage.AnnotationDecoration.IBEAM"), AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$ }; private OverlayPreferenceStore fOverlayStore; private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock; private MarkOccurrencesConfigurationBlock fOccurrencesConfigurationBlock; private FoldingConfigurationBlock fFoldingConfigurationBlock; /** * Quick diff preferences. * @since 3.0 */ private QuickdiffConfigurationBlock fQuickDiffBlock; private Map fColorButtons= new HashMap(); private Map fCheckBoxes= new HashMap(); private SelectionListener fCheckBoxListener= new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { Button button= (Button) e.widget; fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection()); } }; private Map fTextFields= new HashMap(); private ModifyListener fTextFieldListener= new ModifyListener() { public void modifyText(ModifyEvent e) { Text text= (Text) e.widget; fOverlayStore.setValue((String) fTextFields.get(text), text.getText()); } }; private ArrayList fNumberFields= new ArrayList(); private ModifyListener fNumberFieldListener= new ModifyListener() { public void modifyText(ModifyEvent e) { numberFieldChanged((Text) e.widget); } }; private List fSyntaxColorList; private List fAppearanceColorList; private List fContentAssistColorList; private List fAnnotationList; private ColorEditor fSyntaxForegroundColorEditor; private ColorEditor fAppearanceColorEditor; private Button fAppearanceColorDefault; private ColorEditor fAnnotationForegroundColorEditor; private ColorEditor fContentAssistColorEditor; private ColorEditor fBackgroundColorEditor; private Button fBackgroundDefaultRadioButton; private Button fBackgroundCustomRadioButton; private Button fBackgroundColorButton; private Button fBoldCheckBox; private SourceViewer fPreviewViewer; private Color fBackgroundColor; private Control fAutoInsertDelayText; private Control fAutoInsertJavaTriggerText; private Control fAutoInsertJavaDocTriggerText; private Label fAutoInsertDelayLabel; private Label fAutoInsertJavaTriggerLabel; private Label fAutoInsertJavaDocTriggerLabel; private Button fShowInTextCheckBox; private Combo fDecorationStyleCombo; private Button fHighlightInTextCheckBox; private Button fShowInOverviewRulerCheckBox; private Button fShowInVerticalRulerCheckBox; private Text fBrowserLikeLinksKeyModifierText; private Button fBrowserLikeLinksCheckBox; private StatusInfo fBrowserLikeLinksKeyModifierStatus; private Button fCompletionInsertsRadioButton; private Button fCompletionOverwritesRadioButton; /** * Tells whether the fields are initialized. * @since 3.0 */ private boolean fFieldsInitialized= false; /** * List of master/slave listeners when there's a dependency. * * @see #createDependency(Button, String, Control) * @since 3.0 */ private ArrayList fMasterSlaveListeners= new ArrayList(); /** * Creates a new preference page. */ public JavaEditorPreferencePage() { setDescription(PreferencesMessages.getString("JavaEditorPreferencePage.description")); //$NON-NLS-1$ setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore()); MarkerAnnotationPreferences markerAnnotationPreferences= new MarkerAnnotationPreferences(); fKeys= createOverlayStoreKeys(markerAnnotationPreferences); fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys); fAnnotationColorListModel= createAnnotationTypeListModel(markerAnnotationPreferences); } private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) { ArrayList overlayKeys= new ArrayList(); Iterator e= preferences.getAnnotationPreferences().iterator(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FOREGROUND_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOREGROUND_DEFAULT_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BACKGROUND_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_KEYWORD_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_KEYWORD_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_STRING_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STRING_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_DEFAULT_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_DEFAULT_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TASK_TAG_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_TASK_TAG_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_METHOD_NAME_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_METHOD_NAME_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_KEYWORD_RETURN_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_KEYWORD_RETURN_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVA_OPERATOR_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVA_OPERATOR_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_KEYWORD_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_TAG_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_TAG_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_LINKS_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_LINKS_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_JAVADOC_DEFAULT_BOLD)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MATCHING_BRACKETS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WIDE_CARET)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FIND_SCOPE_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_LINK_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CORRECTION_INDICATION)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SPACES_FOR_TABS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOACTIVATION)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_AUTOINSERT)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_BACKGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_REPLACEMENT_FOREGROUND)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_CASE_SENSITIVITY)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_ADDIMPORT)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_INSERT_COMPLETION)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.CODEASSIST_PREFIX_COMPLETION)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_PASTE)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_STRINGS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACKETS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_BRACES)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_CLOSE_JAVADOCS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_WRAP_STRINGS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ESCAPE_STRINGS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_HOME_END)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_SEMICOLON)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_TAB)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SMART_OPENING_BRACE)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER)); while (e.hasNext()) { AnnotationPreference info= (AnnotationPreference) e.next(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey())); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey())); if (info.getHighlightPreferenceKey() != null) overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey())); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey())); if (info.getVerticalRulerPreferenceKey() != null) overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getVerticalRulerPreferenceKey())); if (info.getTextStylePreferenceKey() != null) overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey())); } OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; overlayKeys.toArray(keys); return keys; } /* * @see IWorkbenchPreferencePage#init() */ public void init(IWorkbench workbench) { } /* * @see PreferencePage#createControl(Composite) */ public void createControl(Composite parent) { super.createControl(parent); WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE); } private void handleSyntaxColorListSelection() { int i= fSyntaxColorList.getSelectionIndex(); String key= fSyntaxColorListModel[i][1]; RGB rgb= PreferenceConverter.getColor(fOverlayStore, key); fSyntaxForegroundColorEditor.setColorValue(rgb); fBoldCheckBox.setSelection(fOverlayStore.getBoolean(key + BOLD)); } private void handleAppearanceColorListSelection() { int i= fAppearanceColorList.getSelectionIndex(); String key= fAppearanceColorListModel[i][1]; RGB rgb= PreferenceConverter.getColor(fOverlayStore, key); fAppearanceColorEditor.setColorValue(rgb); updateAppearanceColorWidgets(fAppearanceColorListModel[i][2]); } private void updateAppearanceColorWidgets(String systemDefaultKey) { if (systemDefaultKey == null) { fAppearanceColorDefault.setSelection(false); fAppearanceColorDefault.setVisible(false); fAppearanceColorEditor.getButton().setEnabled(true); } else { boolean systemDefault= fOverlayStore.getBoolean(systemDefaultKey); fAppearanceColorDefault.setSelection(systemDefault); fAppearanceColorDefault.setVisible(true); fAppearanceColorEditor.getButton().setEnabled(!systemDefault); } } private void handleContentAssistColorListSelection() { int i= fContentAssistColorList.getSelectionIndex(); String key= fContentAssistColorListModel[i][1]; RGB rgb= PreferenceConverter.getColor(fOverlayStore, key); fContentAssistColorEditor.setColorValue(rgb); } private void handleAnnotationListSelection() { int i= fAnnotationList.getSelectionIndex(); String key= fAnnotationColorListModel[i][1]; RGB rgb= PreferenceConverter.getColor(fOverlayStore, key); fAnnotationForegroundColorEditor.setColorValue(rgb); key= fAnnotationColorListModel[i][2]; boolean showInText = fOverlayStore.getBoolean(key); fShowInTextCheckBox.setSelection(showInText); key= fAnnotationColorListModel[i][6]; if (key != null) { fDecorationStyleCombo.setEnabled(showInText); for (int j= 0; j < fAnnotationDecorationListModel.length; j++) { String value= fOverlayStore.getString(key); if (fAnnotationDecorationListModel[j][1].equals(value)) { fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]); break; } } } else { fDecorationStyleCombo.setEnabled(false); fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set selection to squiggles if the key is not there (legacy support) } key= fAnnotationColorListModel[i][3]; fShowInOverviewRulerCheckBox.setSelection(fOverlayStore.getBoolean(key)); key= fAnnotationColorListModel[i][4]; if (key != null) { fHighlightInTextCheckBox.setSelection(fOverlayStore.getBoolean(key)); fHighlightInTextCheckBox.setEnabled(true); } else fHighlightInTextCheckBox.setEnabled(false); key= fAnnotationColorListModel[i][5]; if (key != null) { fShowInVerticalRulerCheckBox.setSelection(fOverlayStore.getBoolean(key)); fShowInVerticalRulerCheckBox.setEnabled(true); } else { fShowInVerticalRulerCheckBox.setSelection(true); fShowInVerticalRulerCheckBox.setEnabled(false); } } private Control createSyntaxPage(Composite parent) { Composite colorComposite= new Composite(parent, SWT.NULL); colorComposite.setLayout(new GridLayout()); Group backgroundComposite= new Group(colorComposite, SWT.SHADOW_ETCHED_IN); backgroundComposite.setLayout(new RowLayout()); backgroundComposite.setText(PreferencesMessages.getString("JavaEditorPreferencePage.backgroundColor"));//$NON-NLS-1$ SelectionListener backgroundSelectionListener= new SelectionListener() { public void widgetSelected(SelectionEvent e) { boolean custom= fBackgroundCustomRadioButton.getSelection(); fBackgroundColorButton.setEnabled(custom); fOverlayStore.setValue(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR, !custom); } public void widgetDefaultSelected(SelectionEvent e) {} }; fBackgroundDefaultRadioButton= new Button(backgroundComposite, SWT.RADIO | SWT.LEFT); fBackgroundDefaultRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$ fBackgroundDefaultRadioButton.addSelectionListener(backgroundSelectionListener); fBackgroundCustomRadioButton= new Button(backgroundComposite, SWT.RADIO | SWT.LEFT); fBackgroundCustomRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.custom")); //$NON-NLS-1$ fBackgroundCustomRadioButton.addSelectionListener(backgroundSelectionListener); fBackgroundColorEditor= new ColorEditor(backgroundComposite); fBackgroundColorButton= fBackgroundColorEditor.getButton(); Label label= new Label(colorComposite, SWT.LEFT); label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.foreground")); //$NON-NLS-1$ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite editorComposite= new Composite(colorComposite, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 2; layout.marginHeight= 0; layout.marginWidth= 0; editorComposite.setLayout(layout); GridData gd= new GridData(GridData.FILL_BOTH); editorComposite.setLayoutData(gd); fSyntaxColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); gd= new GridData(GridData.FILL_BOTH); gd.heightHint= convertHeightInCharsToPixels(5); fSyntaxColorList.setLayoutData(gd); Composite stylesComposite= new Composite(editorComposite, SWT.NONE); layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; layout.numColumns= 2; stylesComposite.setLayout(layout); stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); label= new Label(stylesComposite, SWT.LEFT); label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$ gd= new GridData(); gd.horizontalAlignment= GridData.BEGINNING; label.setLayoutData(gd); fSyntaxForegroundColorEditor= new ColorEditor(stylesComposite); Button foregroundColorButton= fSyntaxForegroundColorEditor.getButton(); gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; foregroundColorButton.setLayoutData(gd); fBoldCheckBox= new Button(stylesComposite, SWT.CHECK); fBoldCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.bold")); //$NON-NLS-1$ gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; gd.horizontalSpan= 2; fBoldCheckBox.setLayoutData(gd); label= new Label(colorComposite, SWT.LEFT); label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.preview")); //$NON-NLS-1$ label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Control previewer= createPreviewer(colorComposite); gd= new GridData(GridData.FILL_BOTH); gd.widthHint= convertWidthInCharsToPixels(20); gd.heightHint= convertHeightInCharsToPixels(5); previewer.setLayoutData(gd); fSyntaxColorList.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { handleSyntaxColorListSelection(); } }); foregroundColorButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fSyntaxColorList.getSelectionIndex(); String key= fSyntaxColorListModel[i][1]; PreferenceConverter.setValue(fOverlayStore, key, fSyntaxForegroundColorEditor.getColorValue()); } }); fBackgroundColorButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { PreferenceConverter.setValue(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, fBackgroundColorEditor.getColorValue()); } }); fBoldCheckBox.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fSyntaxColorList.getSelectionIndex(); String key= fSyntaxColorListModel[i][1]; fOverlayStore.setValue(key + BOLD, fBoldCheckBox.getSelection()); } }); return colorComposite; } private Control createPreviewer(Composite parent) { IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore, new PreferencesAdapter(createTemporaryCorePreferenceStore()) }); fPreviewViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, store); JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools(); JavaSourceViewerConfiguration configuration= new JavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING); fPreviewViewer.configure(configuration); Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT); fPreviewViewer.getTextWidget().setFont(font); new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store); fPreviewViewer.setEditable(false); String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$ IDocument document= new Document(content); tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); fPreviewViewer.setDocument(document); return fPreviewViewer.getControl(); } private Preferences createTemporaryCorePreferenceStore() { Preferences result= new Preferences(); result.setValue(COMPILER_TASK_TAGS, "TASK"); //$NON-NLS-1$ return result; } private Control createAppearancePage(Composite parent) { Composite appearanceComposite= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 2; appearanceComposite.setLayout(layout); String label= PreferencesMessages.getString("JavaEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$ addTextField(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true); label= PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$ addTextField(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true); label= PreferencesMessages.getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.highlightMatchingBrackets"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MATCHING_BRACKETS, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.quickassist.lightbulb"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_QUICKASSIST_LIGHTBULB, 0); //$NON-NLS-1$ label= PreferencesMessages.getString("JavaEditorPreferencePage.accessibility.disableCustomCarets"); //$NON-NLS-1$ Button master= addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.accessibility.wideCaret"); //$NON-NLS-1$ Button slave= addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WIDE_CARET, 0); createDependency(master, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS, slave); label= PreferencesMessages.getString("JavaEditorPreferencePage.annotationRollover"); //$NON-NLS-1$ addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER, 0); //$NON-NLS-1$ Label l= new Label(appearanceComposite, SWT.LEFT ); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; gd.heightHint= convertHeightInCharsToPixels(1) / 2; l.setLayoutData(gd); l= new Label(appearanceComposite, SWT.LEFT); l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$ gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; l.setLayoutData(gd); Composite editorComposite= new Composite(appearanceComposite, SWT.NONE); layout= new GridLayout(); layout.numColumns= 2; layout.marginHeight= 0; layout.marginWidth= 0; editorComposite.setLayout(layout); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); gd.horizontalSpan= 2; editorComposite.setLayoutData(gd); fAppearanceColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); gd.heightHint= convertHeightInCharsToPixels(8); fAppearanceColorList.setLayoutData(gd); Composite stylesComposite= new Composite(editorComposite, SWT.NONE); layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; layout.numColumns= 2; stylesComposite.setLayout(layout); stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); l= new Label(stylesComposite, SWT.LEFT); l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.color")); //$NON-NLS-1$ gd= new GridData(); gd.horizontalAlignment= GridData.BEGINNING; l.setLayoutData(gd); fAppearanceColorEditor= new ColorEditor(stylesComposite); Button foregroundColorButton= fAppearanceColorEditor.getButton(); gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; foregroundColorButton.setLayoutData(gd); SelectionListener colorDefaultSelectionListener= new SelectionListener() { public void widgetSelected(SelectionEvent e) { boolean systemDefault= fAppearanceColorDefault.getSelection(); fAppearanceColorEditor.getButton().setEnabled(!systemDefault); int i= fAppearanceColorList.getSelectionIndex(); String key= fAppearanceColorListModel[i][2]; if (key != null) fOverlayStore.setValue(key, systemDefault); } public void widgetDefaultSelected(SelectionEvent e) {} }; fAppearanceColorDefault= new Button(stylesComposite, SWT.CHECK); fAppearanceColorDefault.setText(PreferencesMessages.getString("JavaEditorPreferencePage.systemDefault")); //$NON-NLS-1$ gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; gd.horizontalSpan= 2; fAppearanceColorDefault.setLayoutData(gd); fAppearanceColorDefault.setVisible(false); fAppearanceColorDefault.addSelectionListener(colorDefaultSelectionListener); fAppearanceColorList.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { handleAppearanceColorListSelection(); } }); foregroundColorButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fAppearanceColorList.getSelectionIndex(); String key= fAppearanceColorListModel[i][1]; PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue()); } }); return appearanceComposite; } private Control createAnnotationsPage(Composite parent) { Composite composite= new Composite(parent, SWT.NULL); GridLayout layout= new GridLayout(); layout.numColumns= 2; composite.setLayout(layout); String text= PreferencesMessages.getString("JavaEditorPreferencePage.analyseAnnotationsWhileTyping"); //$NON-NLS-1$ addCheckBox(composite, text, PreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0); text= PreferencesMessages.getString("JavaEditorPreferencePage.showQuickFixables"); //$NON-NLS-1$ addCheckBox(composite, text, PreferenceConstants.EDITOR_CORRECTION_INDICATION, 0); addFiller(composite); Label label= new Label(composite, SWT.LEFT); label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotationPresentationOptions")); //$NON-NLS-1$ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; label.setLayoutData(gd); Composite editorComposite= new Composite(composite, SWT.NONE); layout= new GridLayout(); layout.numColumns= 2; layout.marginHeight= 0; layout.marginWidth= 0; editorComposite.setLayout(layout); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); gd.horizontalSpan= 2; editorComposite.setLayoutData(gd); fAnnotationList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); gd.heightHint= convertHeightInCharsToPixels(10); fAnnotationList.setLayoutData(gd); Composite optionsComposite= new Composite(editorComposite, SWT.NONE); layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; layout.numColumns= 2; optionsComposite.setLayout(layout); optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); fShowInTextCheckBox= new Button(optionsComposite, SWT.CHECK); fShowInTextCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotations.showInText")); //$NON-NLS-1$ gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; gd.horizontalSpan= 2; fShowInTextCheckBox.setLayoutData(gd); fDecorationStyleCombo= new Combo(optionsComposite, SWT.READ_ONLY); for(int i= 0; i < fAnnotationDecorationListModel.length; i++) fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]); gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; gd.horizontalSpan= 2; gd.horizontalIndent= 20; fDecorationStyleCombo.setLayoutData(gd); fHighlightInTextCheckBox= new Button(optionsComposite, SWT.CHECK); fHighlightInTextCheckBox.setText(PreferencesMessages.getString("TextEditorPreferencePage.annotations.highlightInText")); //$NON-NLS-1$ gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; gd.horizontalSpan= 2; fHighlightInTextCheckBox.setLayoutData(gd); fShowInOverviewRulerCheckBox= new Button(optionsComposite, SWT.CHECK); fShowInOverviewRulerCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotations.showInOverviewRuler")); //$NON-NLS-1$ gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; gd.horizontalSpan= 2; fShowInOverviewRulerCheckBox.setLayoutData(gd); fShowInVerticalRulerCheckBox= new Button(optionsComposite, SWT.CHECK); fShowInVerticalRulerCheckBox.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotations.showInVerticalRuler")); //$NON-NLS-1$ gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; gd.horizontalSpan= 2; fShowInVerticalRulerCheckBox.setLayoutData(gd); label= new Label(optionsComposite, SWT.LEFT); label.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotations.color")); //$NON-NLS-1$ gd= new GridData(); gd.horizontalAlignment= GridData.BEGINNING; label.setLayoutData(gd); fAnnotationForegroundColorEditor= new ColorEditor(optionsComposite); Button foregroundColorButton= fAnnotationForegroundColorEditor.getButton(); gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; foregroundColorButton.setLayoutData(gd); fAnnotationList.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { handleAnnotationListSelection(); } }); fShowInTextCheckBox.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fAnnotationList.getSelectionIndex(); String key= fAnnotationColorListModel[i][2]; fOverlayStore.setValue(key, fShowInTextCheckBox.getSelection()); String decorationKey= fAnnotationColorListModel[i][6]; fDecorationStyleCombo.setEnabled(decorationKey != null && fShowInTextCheckBox.getSelection()); } }); fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fAnnotationList.getSelectionIndex(); String key= fAnnotationColorListModel[i][4]; fOverlayStore.setValue(key, fHighlightInTextCheckBox.getSelection()); } }); fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fAnnotationList.getSelectionIndex(); String key= fAnnotationColorListModel[i][3]; fOverlayStore.setValue(key, fShowInOverviewRulerCheckBox.getSelection()); } }); fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fAnnotationList.getSelectionIndex(); String key= fAnnotationColorListModel[i][5]; fOverlayStore.setValue(key, fShowInVerticalRulerCheckBox.getSelection()); } }); foregroundColorButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fAnnotationList.getSelectionIndex(); String key= fAnnotationColorListModel[i][1]; PreferenceConverter.setValue(fOverlayStore, key, fAnnotationForegroundColorEditor.getColorValue()); } }); fDecorationStyleCombo.addSelectionListener(new SelectionListener() { /* * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetDefaultSelected(SelectionEvent e) { // do nothing } /* * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) */ public void widgetSelected(SelectionEvent e) { int i= fAnnotationList.getSelectionIndex(); String key= fAnnotationColorListModel[i][6]; if (key != null) { for (int j= 0; j < fAnnotationDecorationListModel.length; j++) { if (fAnnotationDecorationListModel[j][0].equals(fDecorationStyleCombo.getText())) { fOverlayStore.setValue(key, fAnnotationDecorationListModel[j][1]); break; } } } } }); return composite; } private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) { ArrayList listModelItems= new ArrayList(); SortedSet sortedPreferences= new TreeSet(new Comparator() { /* * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(Object o1, Object o2) { if (!(o2 instanceof AnnotationPreference)) return -1; if (!(o1 instanceof AnnotationPreference)) return 1; AnnotationPreference a1= (AnnotationPreference)o1; AnnotationPreference a2= (AnnotationPreference)o2; return Collator.getInstance().compare(a1.getPreferenceLabel(), a2.getPreferenceLabel()); } }); sortedPreferences.addAll(preferences.getAnnotationPreferences()); Iterator e= sortedPreferences.iterator(); while (e.hasNext()) { AnnotationPreference info= (AnnotationPreference) e.next(); if (info.isIncludeOnPreferencePage()) listModelItems.add(new String[] { info.getPreferenceLabel(), info.getColorPreferenceKey(), info.getTextPreferenceKey(), info.getOverviewRulerPreferenceKey(), info.getHighlightPreferenceKey(), info.getVerticalRulerPreferenceKey(), info.getTextStylePreferenceKey()}); } String[][] items= new String[listModelItems.size()][]; listModelItems.toArray(items); return items; } private Control createTypingPage(Composite parent) { Composite composite= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.numColumns= 1; composite.setLayout(layout); String label= PreferencesMessages.getString("JavaEditorPreferencePage.overwriteMode"); //$NON-NLS-1$ addCheckBox(composite, label, PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE, 1); addFiller(composite); label= PreferencesMessages.getString("JavaEditorPreferencePage.smartHomeEnd"); //$NON-NLS-1$ addCheckBox(composite, label, PreferenceConstants.EDITOR_SMART_HOME_END, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.subWordNavigation"); //$NON-NLS-1$ addCheckBox(composite, label, PreferenceConstants.EDITOR_SUB_WORD_NAVIGATION, 1); addFiller(composite); Group group= new Group(composite, SWT.NONE); layout= new GridLayout(); layout.numColumns= 2; group.setLayout(layout); group.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.description")); //$NON-NLS-1$ label= PreferencesMessages.getString("JavaEditorPreferencePage.wrapStrings"); //$NON-NLS-1$ Button master= addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.escapeStrings"); //$NON-NLS-1$ Button slave= addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS, 1); createDependency(master, PreferenceConstants.EDITOR_WRAP_STRINGS, slave); label= PreferencesMessages.getString("JavaEditorPreferencePage.smartPaste"); //$NON-NLS-1$ addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_PASTE, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.insertSpaceForTabs"); //$NON-NLS-1$ addCheckBox(group, label, PreferenceConstants.EDITOR_SPACES_FOR_TABS, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.closeStrings"); //$NON-NLS-1$ addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_STRINGS, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.closeBrackets"); //$NON-NLS-1$ addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACKETS, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.closeBraces"); //$NON-NLS-1$ addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_BRACES, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.closeJavaDocs"); //$NON-NLS-1$ master= addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.addJavaDocTags"); //$NON-NLS-1$ slave= addCheckBox(group, label, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1); createDependency(master, PreferenceConstants.EDITOR_CLOSE_JAVADOCS, slave); label= PreferencesMessages.getString("JavaEditorPreferencePage.typing.smartSemicolon"); //$NON-NLS-1$ addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_SEMICOLON, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.typing.smartOpeningBrace"); //$NON-NLS-1$ addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_OPENING_BRACE, 1); label= PreferencesMessages.getString("JavaEditorPreferencePage.typing.smartTab"); //$NON-NLS-1$ addCheckBox(group, label, PreferenceConstants.EDITOR_SMART_TAB, 1); // label= PreferencesMessages.getString("JavaEditorPreferencePage.formatJavaDocs"); //$NON-NLS-1$ // addCheckBox(group, label, PreferenceConstants.EDITOR_FORMAT_JAVADOCS, 1); return composite; } private void addFiller(Composite composite) { Label filler= new Label(composite, SWT.LEFT ); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; gd.heightHint= convertHeightInCharsToPixels(1) / 2; filler.setLayoutData(gd); } private static void indent(Control control) { GridData gridData= new GridData(); gridData.horizontalIndent= 20; control.setLayoutData(gridData); } private void createDependency(final Button master, String masterKey, final Control slave) { indent(slave); boolean masterState= fOverlayStore.getBoolean(masterKey); slave.setEnabled(masterState); SelectionListener listener= new SelectionListener() { public void widgetSelected(SelectionEvent e) { slave.setEnabled(master.getSelection()); } public void widgetDefaultSelected(SelectionEvent e) {} }; master.addSelectionListener(listener); fMasterSlaveListeners.add(listener); } private Control createContentAssistPage(Composite parent) { Composite contentAssistComposite= new Composite(parent, SWT.NULL); GridLayout layout= new GridLayout(); layout.numColumns= 2; contentAssistComposite.setLayout(layout); addCompletionRadioButtons(contentAssistComposite); String label; label= PreferencesMessages.getString("JavaEditorPreferencePage.insertSingleProposalsAutomatically"); //$NON-NLS-1$ addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOINSERT, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.completePrefixes"); //$NON-NLS-1$ addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_PREFIX_COMPLETION, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.showOnlyProposalsVisibleInTheInvocationContext"); //$NON-NLS-1$ addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_SHOW_VISIBLE_PROPOSALS, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.presentProposalsInAlphabeticalOrder"); //$NON-NLS-1$ addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ORDER_PROPOSALS, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.automaticallyAddImportInsteadOfQualifiedName"); //$NON-NLS-1$ addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_ADDIMPORT, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.fillArgumentNamesOnMethodCompletion"); //$NON-NLS-1$ Button master= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, 0); label= PreferencesMessages.getString("JavaEditorPreferencePage.guessArgumentNamesOnMethodCompletion"); //$NON-NLS-1$ Button slave= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, 0); createDependency(master, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, slave); label= PreferencesMessages.getString("JavaEditorPreferencePage.enableAutoActivation"); //$NON-NLS-1$ final Button autoactivation= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION, 0); autoactivation.addSelectionListener(new SelectionAdapter(){ public void widgetSelected(SelectionEvent e) { updateAutoactivationControls(); } }); Control[] labelledTextField; label= PreferencesMessages.getString("JavaEditorPreferencePage.autoActivationDelay"); //$NON-NLS-1$ labelledTextField= addLabelledTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_DELAY, 4, 0, true); fAutoInsertDelayLabel= getLabelControl(labelledTextField); fAutoInsertDelayText= getTextControl(labelledTextField); label= PreferencesMessages.getString("JavaEditorPreferencePage.autoActivationTriggersForJava"); //$NON-NLS-1$ labelledTextField= addLabelledTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVA, 4, 0, false); fAutoInsertJavaTriggerLabel= getLabelControl(labelledTextField); fAutoInsertJavaTriggerText= getTextControl(labelledTextField); label= PreferencesMessages.getString("JavaEditorPreferencePage.autoActivationTriggersForJavaDoc"); //$NON-NLS-1$ labelledTextField= addLabelledTextField(contentAssistComposite, label, PreferenceConstants.CODEASSIST_AUTOACTIVATION_TRIGGERS_JAVADOC, 4, 0, false); fAutoInsertJavaDocTriggerLabel= getLabelControl(labelledTextField); fAutoInsertJavaDocTriggerText= getTextControl(labelledTextField); Label l= new Label(contentAssistComposite, SWT.LEFT); l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist.colorOptions")); //$NON-NLS-1$ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan= 2; l.setLayoutData(gd); Composite editorComposite= new Composite(contentAssistComposite, SWT.NONE); layout= new GridLayout(); layout.numColumns= 2; layout.marginHeight= 0; layout.marginWidth= 0; editorComposite.setLayout(layout); gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL); gd.horizontalSpan= 2; editorComposite.setLayoutData(gd); fContentAssistColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL); gd.heightHint= convertHeightInCharsToPixels(8); fContentAssistColorList.setLayoutData(gd); Composite stylesComposite= new Composite(editorComposite, SWT.NONE); layout= new GridLayout(); layout.marginHeight= 0; layout.marginWidth= 0; layout.numColumns= 2; stylesComposite.setLayout(layout); stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); l= new Label(stylesComposite, SWT.LEFT); l.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist.color")); //$NON-NLS-1$ gd= new GridData(); gd.horizontalAlignment= GridData.BEGINNING; l.setLayoutData(gd); fContentAssistColorEditor= new ColorEditor(stylesComposite); Button colorButton= fContentAssistColorEditor.getButton(); gd= new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment= GridData.BEGINNING; colorButton.setLayoutData(gd); fContentAssistColorList.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { handleContentAssistColorListSelection(); } }); colorButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { int i= fContentAssistColorList.getSelectionIndex(); String key= fContentAssistColorListModel[i][1]; PreferenceConverter.setValue(fOverlayStore, key, fContentAssistColorEditor.getColorValue()); } }); return contentAssistComposite; } private void addCompletionRadioButtons(Composite contentAssistComposite) { Composite completionComposite= new Composite(contentAssistComposite, SWT.NONE); GridData ccgd= new GridData(); ccgd.horizontalSpan= 2; completionComposite.setLayoutData(ccgd); GridLayout ccgl= new GridLayout(); ccgl.marginWidth= 0; ccgl.numColumns= 2; completionComposite.setLayout(ccgl); SelectionListener completionSelectionListener= new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean insert= fCompletionInsertsRadioButton.getSelection(); fOverlayStore.setValue(PreferenceConstants.CODEASSIST_INSERT_COMPLETION, insert); } }; fCompletionInsertsRadioButton= new Button(completionComposite, SWT.RADIO | SWT.LEFT); fCompletionInsertsRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionInserts")); //$NON-NLS-1$ fCompletionInsertsRadioButton.setLayoutData(new GridData()); fCompletionInsertsRadioButton.addSelectionListener(completionSelectionListener); fCompletionOverwritesRadioButton= new Button(completionComposite, SWT.RADIO | SWT.LEFT); fCompletionOverwritesRadioButton.setText(PreferencesMessages.getString("JavaEditorPreferencePage.completionOverwrites")); //$NON-NLS-1$ fCompletionOverwritesRadioButton.setLayoutData(new GridData()); fCompletionOverwritesRadioButton.addSelectionListener(completionSelectionListener); } private Control createNavigationPage(Composite parent) { Composite composite= new Composite(parent, SWT.NULL); GridLayout layout= new GridLayout(); layout.numColumns= 2; composite.setLayout(layout); String text= PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinks"); //$NON-NLS-1$ fBrowserLikeLinksCheckBox= addCheckBox(composite, text, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS, 0); fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() { public void widgetSelected(SelectionEvent e) { boolean state= fBrowserLikeLinksCheckBox.getSelection(); fBrowserLikeLinksKeyModifierText.setEnabled(state); handleBrowserLikeLinksKeyModifierModified(); } public void widgetDefaultSelected(SelectionEvent e) { } }); // Text field for modifier string text= PreferencesMessages.getString("JavaEditorPreferencePage.navigation.browserLikeLinksKeyModifier"); //$NON-NLS-1$ fBrowserLikeLinksKeyModifierText= addTextField(composite, text, PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER, 20, 0, false); fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT); if (computeStateMask(fOverlayStore.getString(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER)) == -1) { // Fix possible illegal modifier string int stateMask= fOverlayStore.getInt(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK); if (stateMask == -1) fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$ else fBrowserLikeLinksKeyModifierText.setText(EditorUtility.getModifierString(stateMask)); } fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() { private boolean isModifierCandidate; public void keyPressed(KeyEvent e) { isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask == 0; } public void keyReleased(KeyEvent e) { if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {// && e.time -time < 1000) { String modifierString= fBrowserLikeLinksKeyModifierText.getText(); Point selection= fBrowserLikeLinksKeyModifierText.getSelection(); int i= selection.x - 1; while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) { i--; } boolean needsPrefixDelimiter= i > -1 && !String.valueOf(modifierString.charAt(i)).equals(DELIMITER); i= selection.y; while (i < modifierString.length() && Character.isWhitespace(modifierString.charAt(i))) { i++; } boolean needsPostfixDelimiter= i < modifierString.length() && !String.valueOf(modifierString.charAt(i)).equals(DELIMITER); String insertString; if (needsPrefixDelimiter && needsPostfixDelimiter) insertString= PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifierAndDelimiter", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$ else if (needsPrefixDelimiter) insertString= PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertDelimiterAndModifier", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$ else if (needsPostfixDelimiter) insertString= PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.insertModifierAndDelimiter", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$ else insertString= Action.findModifierString(e.stateMask); fBrowserLikeLinksKeyModifierText.insert(insertString); } } }); fBrowserLikeLinksKeyModifierText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { handleBrowserLikeLinksKeyModifierModified(); } }); return composite; } private void handleBrowserLikeLinksKeyModifierModified() { String modifiers= fBrowserLikeLinksKeyModifierText.getText(); int stateMask= computeStateMask(modifiers); if (fBrowserLikeLinksCheckBox.getSelection() && (stateMask == -1 || (stateMask & SWT.SHIFT) != 0)) { if (stateMask == -1) fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR, PreferencesMessages.getFormattedString("JavaEditorPreferencePage.navigation.modifierIsNotValid", modifiers)); //$NON-NLS-1$ else fBrowserLikeLinksKeyModifierStatus= new StatusInfo(IStatus.ERROR, PreferencesMessages.getString("JavaEditorPreferencePage.navigation.shiftIsDisabled")); //$NON-NLS-1$ setValid(false); StatusUtil.applyToStatusLine(this, fBrowserLikeLinksKeyModifierStatus); } else { fBrowserLikeLinksKeyModifierStatus= new StatusInfo(); updateStatus(fBrowserLikeLinksKeyModifierStatus); } } private IStatus getBrowserLikeLinksKeyModifierStatus() { if (fBrowserLikeLinksKeyModifierStatus == null) fBrowserLikeLinksKeyModifierStatus= new StatusInfo(); return fBrowserLikeLinksKeyModifierStatus; } /** * Computes the state mask for the given modifier string. * * @param modifiers the string with the modifiers, separated by '+', '-', ';', ',' or '.' * @return the state mask or -1 if the input is invalid */ private int computeStateMask(String modifiers) { if (modifiers == null) return -1; if (modifiers.length() == 0) return SWT.NONE; int stateMask= 0; StringTokenizer modifierTokenizer= new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$ while (modifierTokenizer.hasMoreTokens()) { int modifier= EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken()); if (modifier == 0 || (stateMask & modifier) == modifier) return -1; stateMask= stateMask | modifier; } return stateMask; } /* * @see PreferencePage#createContents(Composite) */ protected Control createContents(Composite parent) { initializeDefaultColors(); fJavaEditorHoverConfigurationBlock= new JavaEditorHoverConfigurationBlock(this, fOverlayStore); fOccurrencesConfigurationBlock= new MarkOccurrencesConfigurationBlock(this, fOverlayStore); fFoldingConfigurationBlock= new FoldingConfigurationBlock(fOverlayStore); fOverlayStore.load(); fOverlayStore.start(); TabFolder folder= new TabFolder(parent, SWT.NONE); folder.setLayout(new TabFolderLayout()); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); TabItem item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.general")); //$NON-NLS-1$ item.setControl(createAppearancePage(folder)); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.colors")); //$NON-NLS-1$ item.setControl(createSyntaxPage(folder)); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.codeAssist")); //$NON-NLS-1$ item.setControl(createContentAssistPage(folder)); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.annotationsTab.title")); //$NON-NLS-1$ item.setControl(createAnnotationsPage(folder)); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.typing.tabTitle")); //$NON-NLS-1$ item.setControl(createTypingPage(folder)); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.hoverTab.title")); //$NON-NLS-1$ item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder)); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.occurrencesTab.title")); //$NON-NLS-1$ item.setControl(fOccurrencesConfigurationBlock.createControl(folder)); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title")); //$NON-NLS-1$ item.setControl(createNavigationPage(folder)); item= new TabItem(folder, SWT.NONE); item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.quickdiff.title")); //$NON-NLS-1$ fQuickDiffBlock= new QuickdiffConfigurationBlock(fOverlayStore, "JavaEditorPreferencePage", new QuickdiffConfigurationBlock.IMessages() { //$NON-NLS-1$ public String getString(String key) { return PreferencesMessages.getString(key); } }); item.setControl(fQuickDiffBlock.createControl(folder)); if (Boolean.getBoolean("org.eclipse.jdt.internal.ui.projection")) { //$NON-NLS-1$ item= new TabItem(folder, SWT.NONE); item.setText("&Folding"); item.setControl(fFoldingConfigurationBlock.createControl(folder)); } initialize(); Dialog.applyDialogFont(folder); return folder; } private void initialize() { initializeFields(); for (int i= 0; i < fSyntaxColorListModel.length; i++) fSyntaxColorList.add(fSyntaxColorListModel[i][0]); fSyntaxColorList.getDisplay().asyncExec(new Runnable() { public void run() { if (fSyntaxColorList != null && !fSyntaxColorList.isDisposed()) { fSyntaxColorList.select(0); handleSyntaxColorListSelection(); } } }); for (int i= 0; i < fAppearanceColorListModel.length; i++) fAppearanceColorList.add(fAppearanceColorListModel[i][0]); fAppearanceColorList.getDisplay().asyncExec(new Runnable() { public void run() { if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) { fAppearanceColorList.select(0); handleAppearanceColorListSelection(); } } }); for (int i= 0; i < fAnnotationColorListModel.length; i++) fAnnotationList.add(fAnnotationColorListModel[i][0]); fAnnotationList.getDisplay().asyncExec(new Runnable() { public void run() { if (fAnnotationList != null && !fAnnotationList.isDisposed()) { fAnnotationList.select(0); handleAnnotationListSelection(); } } }); for (int i= 0; i < fContentAssistColorListModel.length; i++) fContentAssistColorList.add(fContentAssistColorListModel[i][0]); fContentAssistColorList.getDisplay().asyncExec(new Runnable() { public void run() { if (fContentAssistColorList != null && !fContentAssistColorList.isDisposed()) { fContentAssistColorList.select(0); handleContentAssistColorListSelection(); } } }); fQuickDiffBlock.initialize(); fOccurrencesConfigurationBlock.initialize(); fFoldingConfigurationBlock.initialize(); } private void initializeFields() { Iterator e= fColorButtons.keySet().iterator(); while (e.hasNext()) { ColorEditor c= (ColorEditor) e.next(); String key= (String) fColorButtons.get(c); RGB rgb= PreferenceConverter.getColor(fOverlayStore, key); c.setColorValue(rgb); } e= fCheckBoxes.keySet().iterator(); while (e.hasNext()) { Button b= (Button) e.next(); String key= (String) fCheckBoxes.get(b); b.setSelection(fOverlayStore.getBoolean(key)); } e= fTextFields.keySet().iterator(); while (e.hasNext()) { Text t= (Text) e.next(); String key= (String) fTextFields.get(t); t.setText(fOverlayStore.getString(key)); } RGB rgb= PreferenceConverter.getColor(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR); fBackgroundColorEditor.setColorValue(rgb); boolean default_= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_BACKGROUND_DEFAULT_COLOR); fBackgroundDefaultRadioButton.setSelection(default_); fBackgroundCustomRadioButton.setSelection(!default_); fBackgroundColorButton.setEnabled(!default_); boolean completionInserts= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION); fCompletionInsertsRadioButton.setSelection(completionInserts); fCompletionOverwritesRadioButton.setSelection(! completionInserts); fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection()); updateAutoactivationControls(); fFieldsInitialized= true; updateStatus(validatePositiveNumber("0")); //$NON-NLS-1$ // Update slaves Iterator iter= fMasterSlaveListeners.iterator(); while (iter.hasNext()) { SelectionListener listener= (SelectionListener)iter.next(); listener.widgetSelected(null); } fQuickDiffBlock.initializeFields(); } private void initializeDefaultColors() { if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_BACKGROUND_COLOR)) { RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(); PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb); PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_BACKGROUND_COLOR, rgb); } if (!getPreferenceStore().contains(PreferenceConstants.EDITOR_FOREGROUND_COLOR)) { RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB(); PreferenceConverter.setDefault(fOverlayStore, PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb); PreferenceConverter.setDefault(getPreferenceStore(), PreferenceConstants.EDITOR_FOREGROUND_COLOR, rgb); } if (!getPreferenceStore().contains(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR)) { RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION).getRGB(); PreferenceConverter.setDefault(fOverlayStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR, rgb); PreferenceConverter.setDefault(getPreferenceStore(), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR, rgb); } if (!getPreferenceStore().contains(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR)) { RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT).getRGB(); PreferenceConverter.setDefault(fOverlayStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR, rgb); PreferenceConverter.setDefault(getPreferenceStore(), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR, rgb); } } private void updateAutoactivationControls() { boolean autoactivation= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_AUTOACTIVATION); fAutoInsertDelayText.setEnabled(autoactivation); fAutoInsertDelayLabel.setEnabled(autoactivation); fAutoInsertJavaTriggerText.setEnabled(autoactivation); fAutoInsertJavaTriggerLabel.setEnabled(autoactivation); fAutoInsertJavaDocTriggerText.setEnabled(autoactivation); fAutoInsertJavaDocTriggerLabel.setEnabled(autoactivation); } /* * @see PreferencePage#performOk() */ public boolean performOk() { fJavaEditorHoverConfigurationBlock.performOk(); fOccurrencesConfigurationBlock.performOk(); fQuickDiffBlock.performOk(); fFoldingConfigurationBlock.performOk(); fOverlayStore.setValue(PreferenceConstants.EDITOR_BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK, computeStateMask(fBrowserLikeLinksKeyModifierText.getText())); fOverlayStore.propagate(); JavaPlugin.getDefault().savePluginPreferences(); return true; } /* * @see PreferencePage#performDefaults() */ protected void performDefaults() { fOverlayStore.loadDefaults(); initializeFields(); handleSyntaxColorListSelection(); handleAppearanceColorListSelection(); handleAnnotationListSelection(); handleContentAssistColorListSelection(); fJavaEditorHoverConfigurationBlock.performDefaults(); fOccurrencesConfigurationBlock.performDefaults(); fQuickDiffBlock.performDefaults(); fFoldingConfigurationBlock.performDefaults(); super.performDefaults(); fPreviewViewer.invalidateTextPresentation(); } /* * @see DialogPage#dispose() */ public void dispose() { fFoldingConfigurationBlock.dispose(); if (fOverlayStore != null) { fOverlayStore.stop(); fOverlayStore= null; } if (fBackgroundColor != null && !fBackgroundColor.isDisposed()) fBackgroundColor.dispose(); super.dispose(); } private Button addCheckBox(Composite parent, String label, String key, int indentation) { Button checkBox= new Button(parent, SWT.CHECK); checkBox.setText(label); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); gd.horizontalIndent= indentation; gd.horizontalSpan= 2; checkBox.setLayoutData(gd); checkBox.addSelectionListener(fCheckBoxListener); fCheckBoxes.put(checkBox, key); return checkBox; } private Text addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) { return getTextControl(addLabelledTextField(composite, label, key, textLimit, indentation, isNumber)); } private static Label getLabelControl(Control[] labelledTextField){ return (Label)labelledTextField[0]; } private static Text getTextControl(Control[] labelledTextField){ return (Text)labelledTextField[1]; } /** * Returns an array of size 2: * - first element is of type <code>Label</code> * - second element is of type <code>Text</code> * Use <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls. * * @param composite the parent composite * @param label the text field's label * @param key the preference key * @param textLimit the text limit * @param indentation the field's indentation * @param isNumber <code>true</code> iff this text field is used to e4dit a number * @return */ private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) { Label labelControl= new Label(composite, SWT.NONE); labelControl.setText(label); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); gd.horizontalIndent= indentation; labelControl.setLayoutData(gd); Text textControl= new Text(composite, SWT.BORDER | SWT.SINGLE); gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); gd.widthHint= convertWidthInCharsToPixels(textLimit + 1); textControl.setLayoutData(gd); textControl.setTextLimit(textLimit); fTextFields.put(textControl, key); if (isNumber) { fNumberFields.add(textControl); textControl.addModifyListener(fNumberFieldListener); } else { textControl.addModifyListener(fTextFieldListener); } return new Control[]{labelControl, textControl}; } private String loadPreviewContentFromFile(String filename) { String line; String separator= System.getProperty("line.separator"); //$NON-NLS-1$ StringBuffer buffer= new StringBuffer(512); BufferedReader reader= null; try { reader= new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(filename))); while ((line= reader.readLine()) != null) { buffer.append(line); buffer.append(separator); } } catch (IOException io) { JavaPlugin.log(io); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) {} } } return buffer.toString(); } private void numberFieldChanged(Text textControl) { String number= textControl.getText(); IStatus status= validatePositiveNumber(number); if (!status.matches(IStatus.ERROR)) fOverlayStore.setValue((String) fTextFields.get(textControl), number); updateStatus(status); } private IStatus validatePositiveNumber(String number) { StatusInfo status= new StatusInfo(); if (number.length() == 0) { status.setError(PreferencesMessages.getString("JavaEditorPreferencePage.empty_input")); //$NON-NLS-1$ } else { try { int value= Integer.parseInt(number); if (value < 0) status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$ } catch (NumberFormatException e) { status.setError(PreferencesMessages.getFormattedString("JavaEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$ } } return status; } void updateStatus(IStatus status) { if (!fFieldsInitialized) return; if (!status.matches(IStatus.ERROR)) { for (int i= 0; i < fNumberFields.size(); i++) { Text text= (Text) fNumberFields.get(i); IStatus s= validatePositiveNumber(text.getText()); status= StatusUtil.getMoreSevere(s, status); } } status= StatusUtil.getMoreSevere(fOccurrencesConfigurationBlock.getStatus(), status); status= StatusUtil.getMoreSevere(fJavaEditorHoverConfigurationBlock.getStatus(), status); status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(), status); setValid(!status.matches(IStatus.ERROR)); StatusUtil.applyToStatusLine(this, status); } }
59,045
Bug 59045 no more support to reuse editors
The old search provided the option Window>Preferences>Workbench>Search>"Reuse Editors to Show Matches". This option is no longer honored by the new search implementation. This is a loss of function and we have to revive this option.
resolved fixed
2dbe3f4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T13:57:33Z
2004-04-19T10:20:00Z
org.eclipse.jdt.ui/ui
59,045
Bug 59045 no more support to reuse editors
The old search provided the option Window>Preferences>Workbench>Search>"Reuse Editors to Show Matches". This option is no longer honored by the new search implementation. This is a loss of function and we have to revive this option.
resolved fixed
2dbe3f4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T13:57:33Z
2004-04-19T10:20:00Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/search/NLSSearchEditorOpener.java
59,045
Bug 59045 no more support to reuse editors
The old search provided the option Window>Preferences>Workbench>Search>"Reuse Editors to Show Matches". This option is no longer honored by the new search implementation. This is a loss of function and we have to revive this option.
resolved fixed
2dbe3f4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T13:57:33Z
2004-04-19T10:20:00Z
org.eclipse.jdt.ui/ui
59,045
Bug 59045 no more support to reuse editors
The old search provided the option Window>Preferences>Workbench>Search>"Reuse Editors to Show Matches". This option is no longer honored by the new search implementation. This is a loss of function and we have to revive this option.
resolved fixed
2dbe3f4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T13:57:33Z
2004-04-19T10:20:00Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/search/NLSSearchResultPage.java
59,045
Bug 59045 no more support to reuse editors
The old search provided the option Window>Preferences>Workbench>Search>"Reuse Editors to Show Matches". This option is no longer honored by the new search implementation. This is a loss of function and we have to revive this option.
resolved fixed
2dbe3f4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T13:57:33Z
2004-04-19T10:20:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchEditorOpener.java
59,045
Bug 59045 no more support to reuse editors
The old search provided the option Window>Preferences>Workbench>Search>"Reuse Editors to Show Matches". This option is no longer honored by the new search implementation. This is a loss of function and we have to revive this option.
resolved fixed
2dbe3f4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T13:57:33Z
2004-04-19T10:20:00Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchResultPage.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.search; import java.text.MessageFormat; import java.util.HashMap; import java.util.HashSet; import java.util.Set; import java.util.StringTokenizer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility; import org.eclipse.jdt.internal.ui.viewsupport.ProblemTableViewer; import org.eclipse.jdt.internal.ui.viewsupport.ProblemTreeViewer; import org.eclipse.jdt.ui.search.IMatchPresentation; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; import org.eclipse.jface.viewers.DecoratingLabelProvider; import org.eclipse.jface.viewers.StructuredViewer; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.ViewerSorter; import org.eclipse.search.ui.IContextMenuConstants; import org.eclipse.search.ui.ISearchResult; import org.eclipse.search.ui.ISearchResultViewPart; import org.eclipse.search.ui.NewSearchUI; import org.eclipse.search.ui.SearchUI; import org.eclipse.search.ui.text.AbstractTextSearchResult; import org.eclipse.search.ui.text.AbstractTextSearchViewPage; import org.eclipse.search.ui.text.Match; import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.TableItem; import org.eclipse.swt.widgets.Widget; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IMemento; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.ide.IDE; import org.eclipse.ui.part.IPageSite; import org.eclipse.ui.texteditor.ITextEditor; public class JavaSearchResultPage extends AbstractTextSearchViewPage { private static final String KEY_GROUPING= "org.eclipse.jdt.search.resultpage.grouping"; //$NON-NLS-1$ private static final String KEY_SORTING= "org.eclipse.jdt.search.resultpage.sorting"; //$NON-NLS-1$ private static final String KEY_FILTERS= "org.eclipse.jdt.search.resultpage.filters"; //$NON-NLS-1$ private static final String GROUP_GROUPING= "org.eclipse.jdt.search.resultpage.grouping"; //$NON-NLS-1$ private NewSearchViewActionGroup fActionGroup; private JavaSearchContentProvider fContentProvider; private int fCurrentSortOrder; private SortAction fSortByNameAction; private SortAction fSortByParentName; private SortAction fSortByPathAction; private GroupAction fGroupTypeAction; private GroupAction fGroupFileAction; private GroupAction fGroupPackageAction; private GroupAction fGroupProjectAction; private int fCurrentGrouping; private Set fMatchFilters= new HashSet(); private FilterAction[] fFilterActions; public JavaSearchResultPage() { initSortActions(); initGroupingActions(); initFilterActions(); } private void initFilterActions() { MatchFilter[] allFilters= MatchFilter.allFilters(); fFilterActions= new FilterAction[allFilters.length]; for (int i= 0; i < fFilterActions.length; i++) { fFilterActions[i]= new FilterAction(this, allFilters[i]); } } private void initSortActions() { fSortByNameAction= new SortAction(SearchMessages.getString("JavaSearchResultPage.sortByName"), this, SortingLabelProvider.SHOW_ELEMENT_CONTAINER); //$NON-NLS-1$ fSortByPathAction= new SortAction(SearchMessages.getString("JavaSearchResultPage.sortByPath"), this, SortingLabelProvider.SHOW_PATH); //$NON-NLS-1$ fSortByParentName= new SortAction(SearchMessages.getString("JavaSearchResultPage.sortByParentName"), this, SortingLabelProvider.SHOW_CONTAINER_ELEMENT); //$NON-NLS-1$ } private void initGroupingActions() { fGroupProjectAction= new GroupAction(SearchMessages.getString("JavaSearchResultPage.groupby_project"), SearchMessages.getString("JavaSearchResultPage.groupby_project.tooltip"), this, LevelTreeContentProvider.LEVEL_PROJECT); //$NON-NLS-1$ //$NON-NLS-2$ JavaPluginImages.setLocalImageDescriptors(fGroupProjectAction, "prj_mode.gif"); //$NON-NLS-1$ fGroupPackageAction= new GroupAction(SearchMessages.getString("JavaSearchResultPage.groupby_package"), SearchMessages.getString("JavaSearchResultPage.groupby_package.tooltip"), this, LevelTreeContentProvider.LEVEL_PACKAGE); //$NON-NLS-1$ //$NON-NLS-2$ JavaPluginImages.setLocalImageDescriptors(fGroupPackageAction, "package_mode.gif"); //$NON-NLS-1$ fGroupFileAction= new GroupAction(SearchMessages.getString("JavaSearchResultPage.groupby_file"), SearchMessages.getString("JavaSearchResultPage.groupby_file.tooltip"), this, LevelTreeContentProvider.LEVEL_FILE); //$NON-NLS-1$ //$NON-NLS-2$ JavaPluginImages.setLocalImageDescriptors(fGroupFileAction, "file_mode.gif"); //$NON-NLS-1$ fGroupTypeAction= new GroupAction(SearchMessages.getString("JavaSearchResultPage.groupby_type"), SearchMessages.getString("JavaSearchResultPage.groupby_type.tooltip"), this, LevelTreeContentProvider.LEVEL_TYPE); //$NON-NLS-1$ //$NON-NLS-2$ JavaPluginImages.setLocalImageDescriptors(fGroupTypeAction, "type_mode.gif"); //$NON-NLS-1$ } public void setViewPart(ISearchResultViewPart part) { super.setViewPart(part); fActionGroup= new NewSearchViewActionGroup(part); } public void showMatch(Match match, int offset, int length) throws PartInitException { IEditorPart editor= null; Object element= match.getElement(); if (element instanceof IJavaElement) { IJavaElement javaElement= (IJavaElement) element; try { editor= EditorUtility.openInEditor(javaElement, false); } catch (PartInitException e1) { return; } catch (JavaModelException e1) { return; } } else if (element instanceof IFile) { editor= IDE.openEditor(JavaPlugin.getActivePage(), (IFile) element, false); } if (editor instanceof ITextEditor) { ITextEditor textEditor= (ITextEditor) editor; textEditor.selectAndReveal(offset, length); } else if (editor != null){ if (element instanceof IFile) { IFile file= (IFile) element; showWithMarker(editor, file, offset, length); } } else { JavaSearchResult result= (JavaSearchResult) getInput(); IMatchPresentation participant= result.getSearchParticpant(element); if (participant != null) participant.showMatch(match, offset, length); } } private void showWithMarker(IEditorPart editor, IFile file, int offset, int length) throws PartInitException { try { IMarker marker= file.createMarker(SearchUI.SEARCH_MARKER); HashMap attributes= new HashMap(4); attributes.put(IMarker.CHAR_START, new Integer(offset)); attributes.put(IMarker.CHAR_END, new Integer(offset + length)); marker.setAttributes(attributes); IDE.gotoMarker(editor, marker); marker.delete(); } catch (CoreException e) { throw new PartInitException(SearchMessages.getString("JavaSearchResultPage.error.marker"), e); //$NON-NLS-1$ } } protected void fillContextMenu(IMenuManager mgr) { super.fillContextMenu(mgr); addSortActions(mgr); fActionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection())); fActionGroup.fillContextMenu(mgr); } private void addFilterActions(IMenuManager viewMenu) { String filteringGroup= "Filtering"; //$NON-NLS-1$ viewMenu.add(new Separator(filteringGroup)); MenuManager mgr= new MenuManager(SearchMessages.getString("JavaSearchResultPage.filter.submenu")); //$NON-NLS-1$ for (int i= 0; i < fFilterActions.length; i++) { mgr.add(fFilterActions[i]); } viewMenu.appendToGroup(filteringGroup, mgr); } private void addSortActions(IMenuManager mgr) { if (getLayout() != FLAG_LAYOUT_FLAT) return; MenuManager sortMenu= new MenuManager(SearchMessages.getString("JavaSearchResultPage.sortBylabel")); //$NON-NLS-1$ sortMenu.add(fSortByNameAction); sortMenu.add(fSortByPathAction); sortMenu.add(fSortByParentName); fSortByNameAction.setChecked(fCurrentSortOrder == fSortByNameAction.getSortOrder()); fSortByPathAction.setChecked(fCurrentSortOrder == fSortByPathAction.getSortOrder()); fSortByParentName.setChecked(fCurrentSortOrder == fSortByParentName.getSortOrder()); mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, sortMenu); } protected void fillToolbar(IToolBarManager tbm) { super.fillToolbar(tbm); if (getLayout() != FLAG_LAYOUT_FLAT) addGroupActions(tbm); } private void addGroupActions(IToolBarManager mgr) { mgr.appendToGroup(IContextMenuConstants.GROUP_VIEWER_SETUP, new Separator(GROUP_GROUPING)); mgr.appendToGroup(GROUP_GROUPING, fGroupProjectAction); mgr.appendToGroup(GROUP_GROUPING, fGroupPackageAction); mgr.appendToGroup(GROUP_GROUPING, fGroupFileAction); mgr.appendToGroup(GROUP_GROUPING, fGroupTypeAction); updateGroupingActions(); } private void updateGroupingActions() { fGroupProjectAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_PROJECT); fGroupPackageAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_PACKAGE); fGroupFileAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_FILE); fGroupTypeAction.setChecked(fCurrentGrouping == LevelTreeContentProvider.LEVEL_TYPE); } public void dispose() { fActionGroup.dispose(); super.dispose(); } protected void elementsChanged(Object[] objects) { if (fContentProvider != null) fContentProvider.elementsChanged(objects); } protected void clear() { if (fContentProvider != null) fContentProvider.clear(); } protected void configureTableViewer(TableViewer viewer) { viewer.setUseHashlookup(true); viewer.setLabelProvider(new DecoratingLabelProvider(new SortingLabelProvider(this), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator())); fContentProvider=new JavaSearchTableContentProvider(this); viewer.setContentProvider(fContentProvider); setSortOrder(fCurrentSortOrder); } protected void configureTreeViewer(TreeViewer viewer) { viewer.setUseHashlookup(true); viewer.setSorter(new ViewerSorter()); viewer.setLabelProvider(new DecoratingLabelProvider(new PostfixLabelProvider(this), PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator())); fContentProvider= new LevelTreeContentProvider(this, fCurrentGrouping); viewer.setContentProvider(fContentProvider); } protected TreeViewer createTreeViewer(Composite parent) { return new ProblemTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); } class MyProblemTable extends ProblemTableViewer { MyProblemTable(Composite parent, int flags) { super(parent, flags); } protected void internalRefresh(Object element, boolean updateLabels) { if (element == null || equals(element, getRoot())) { // the parent // in the code below, it is important to do all disassociates // before any associates, since a later disassociate can undo an earlier associate // e.g. if (a, b) is replaced by (b, a), the disassociate of b to item 1 could undo // the associate of b to item 0. Object[] children = getSortedChildren(getRoot()); getTable().removeAll(); // add any remaining elements for (int i = 0; i < children.length; ++i) { updateItem(new TableItem(getTable(), SWT.NONE, i), children[i]); } } else { Widget w = findItem(element); if (w != null) { updateItem(w, element); } } } } protected TableViewer createTableViewer(Composite parent) { return new ProblemTableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); } void setSortOrder(int order) { fCurrentSortOrder= order; StructuredViewer viewer= getViewer(); viewer.getControl().setRedraw(false); DecoratingLabelProvider dlp= (DecoratingLabelProvider) viewer.getLabelProvider(); ((SortingLabelProvider)dlp.getLabelProvider()).setOrder(order); if (order == SortingLabelProvider.SHOW_ELEMENT_CONTAINER) { viewer.setSorter(new NameSorter()); } else if (order == SortingLabelProvider.SHOW_PATH) { viewer.setSorter(new PathSorter()); } else viewer.setSorter(new ParentSorter()); viewer.getControl().setRedraw(true); getSettings().put(KEY_SORTING, fCurrentSortOrder); } public void init(IPageSite site) { super.init(site); fActionGroup.fillActionBars(site.getActionBars()); addFilterActions(site.getActionBars().getMenuManager()); } /** * Precondition here: the viewer must be showing a tree with a LevelContentProvider. * @param order */ void setGrouping(int grouping) { fCurrentGrouping= grouping; StructuredViewer viewer= getViewer(); LevelTreeContentProvider cp= (LevelTreeContentProvider) viewer.getContentProvider(); cp.setLevel(grouping); updateGroupingActions(); getSettings().put(KEY_GROUPING, fCurrentGrouping); } protected StructuredViewer getViewer() { // override so that it's visible in the package. return super.getViewer(); } /* (non-Javadoc) * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#restoreState(org.eclipse.ui.IMemento) */ public void restoreState(IMemento memento) { super.restoreState(memento); try { fCurrentSortOrder= getSettings().getInt(KEY_SORTING); } catch (NumberFormatException e) { fCurrentSortOrder= SortingLabelProvider.SHOW_ELEMENT_CONTAINER; } try { fCurrentGrouping= getSettings().getInt(KEY_GROUPING); } catch (NumberFormatException e) { fCurrentGrouping= LevelTreeContentProvider.LEVEL_PACKAGE; } String encodedFilters= getSettings().get(KEY_FILTERS); restoreFilters(encodedFilters); if (memento != null) { Integer value= memento.getInteger(KEY_GROUPING); if (value != null) fCurrentGrouping= value.intValue(); value= memento.getInteger(KEY_SORTING); if (value != null) fCurrentSortOrder= value.intValue(); encodedFilters= memento.getString(KEY_FILTERS); restoreFilters(encodedFilters); } } private void restoreFilters(String encodedFilters) { if (encodedFilters != null) { fMatchFilters.clear(); String[] decodedFilters= decodeFiltersString(encodedFilters); for (int i= 0; i < decodedFilters.length; i++) { MatchFilter filter= findMatchFilter(decodedFilters[i]); if (filter != null) fMatchFilters.add(filter); } } updateFilterActions(); } private MatchFilter findMatchFilter(String id) { MatchFilter[] allFilters= MatchFilter.allFilters(); for (int i= 0; i < allFilters.length; i++) { if (allFilters[i].getID().equals(id)) return allFilters[i]; } return null; } /* (non-Javadoc) * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#saveState(org.eclipse.ui.IMemento) */ public void saveState(IMemento memento) { super.saveState(memento); memento.putInteger(KEY_GROUPING, fCurrentGrouping); memento.putInteger(KEY_SORTING, fCurrentSortOrder); memento.putString(KEY_FILTERS, encodeFilters()); } void addMatchFilter(MatchFilter filter) { fMatchFilters.add(filter); filtersChanged(); } void removeMatchFilter(MatchFilter filter) { fMatchFilters.remove(filter); filtersChanged(); } private void filtersChanged() { StructuredViewer viewer= getViewer(); JavaSearchContentProvider cp= (JavaSearchContentProvider) viewer.getContentProvider(); cp.filtersChanged(getMatchFilters()); updateFilterActions(); getViewPart().updateLabel(); getSettings().put(KEY_FILTERS, encodeFilters()); } private void updateFilterActions() { for (int i= 0; i < fFilterActions.length; i++) { fFilterActions[i].updateCheckState(); } getSite().getActionBars().updateActionBars(); getSite().getActionBars().getMenuManager().updateAll(true); } private String encodeFilters() { StringBuffer buf= new StringBuffer(); MatchFilter[] enabledFilters= getMatchFilters(); buf.append(enabledFilters.length); for (int i= 0; i < enabledFilters.length; i++) { buf.append(';'); buf.append(enabledFilters[i].getID()); } return buf.toString(); } private String[] decodeFiltersString(String encodedString) { StringTokenizer tokenizer= new StringTokenizer(encodedString, ";"); //$NON-NLS-1$ int count= Integer.valueOf(tokenizer.nextToken()).intValue(); String[] ids= new String[count]; for (int i= 0; i < count; i++) { ids[i]= tokenizer.nextToken(); } return ids; } boolean hasMatchFilter(MatchFilter filter) { return fMatchFilters.contains(filter); } MatchFilter[] getMatchFilters() { MatchFilter[] filters= new MatchFilter[fMatchFilters.size()]; return (MatchFilter[]) fMatchFilters.toArray(filters); } public int getDisplayedMatchCount(Object element) { if (getMatchFilters().length == 0) return super.getDisplayedMatchCount(element); Match[] matches= super.getDisplayedMatches(element); int count= 0; for (int i= 0; i < matches.length; i++) { if (!isFiltered(matches[i])) count++; } return count; } public Match[] getDisplayedMatches(Object element) { if (getMatchFilters().length == 0) return super.getDisplayedMatches(element); Match[] matches= super.getDisplayedMatches(element); int count= 0; for (int i= 0; i < matches.length; i++) { if (isFiltered(matches[i])) matches[i]= null; else count++; } Match[] filteredMatches= new Match[count]; int writeIndex= 0; for (int i= 0; i < matches.length; i++) { if (matches[i] != null) filteredMatches[writeIndex++]= matches[i]; } return filteredMatches; } private boolean isFiltered(Match match) { MatchFilter[] filters= getMatchFilters(); for (int j= 0; j < filters.length; j++) { if (filters[j].filters((JavaElementMatch) match)) return true; } return false; } public void setInput(ISearchResult search, Object viewState) { updateFilterEnablement((JavaSearchResult)search); super.setInput(search, viewState); } private void updateFilterEnablement(JavaSearchResult result) { for (int i= 0; i < fFilterActions.length; i++) { fFilterActions[i].setEnabled(shouldEnable(result, fFilterActions[i])); } } private boolean shouldEnable(JavaSearchResult result, FilterAction filterAction) { if (result == null) { return false; } JavaSearchQuery query= (JavaSearchQuery) result.getQuery(); if (query == null) return false; return filterAction.getFilter().isApplicable(query); } private boolean isQueryRunning() { AbstractTextSearchResult result= getInput(); if (result != null) { return NewSearchUI.isQueryRunning(result.getQuery()); } return false; } public String getLabel() { String label= super.getLabel(); int matchFilterCount= getMatchFiltersCount(); if (matchFilterCount > 0) { if (isQueryRunning()) { String message= SearchMessages.getString("JavaSearchResultPage.filtered.message"); //$NON-NLS-1$ return MessageFormat.format(message, new Object[] { label }); } else { String message= SearchMessages.getString("JavaSearchResultPage.filteredWithCount.message"); //$NON-NLS-1$ return MessageFormat.format(message, new Object[] { label, new Integer(getFilteredMatchCount()) }); } } return label; } private int getMatchFiltersCount() { MatchFilter[] filters= getMatchFilters(); AbstractTextSearchResult result= getInput(); if (result == null) return 0; int filterCount= 0; for (int i= 0; i < filters.length; i++) { if (filters[i].isApplicable((JavaSearchQuery) result.getQuery())) filterCount++; } return filterCount; } private int getFilteredMatchCount() { AbstractTextSearchResult result= getInput(); if (result == null) return 0; Object[] elements= result.getElements(); int count= 0; for (int i= 0; i < elements.length; i++) { count+= getDisplayedMatchCount(elements[i]); } return count; } }
60,101
Bug 60101 Sort by parent path should take method name into account
build i0420:0800 - I do a Java Search and sort the results by Parent Path - I believe the secondary sort consideration should be the method name - this would make the results sorted alphabetically Here are the currently results. Note I removed part of the package name to make the list clearer. (#addChild is out of order alphabetically) I'm not sure what order its listed in...#addChild is at the beginning of the java file so its not by order of appearance in the file. preferences.EclipsePreferences.childrenNames() preferences.EclipsePreferences.getChild(String) (2 matches) preferences.EclipsePreferences.getChildren() (2 matches) preferences.EclipsePreferences.removeNode(IEclipsePreferences) (4 matches) preferences.EclipsePreferences.addChild(String, IEclipsePreferences) (3 matches) preferences.RootPreferences.getChild(String) (2 matches)
resolved fixed
44ee3a2
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T15:59:40Z
2004-04-27T15:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/ParentSorter.java
/******************************************************************************* * Copyright (c) 2000, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.search; import org.eclipse.core.resources.IResource; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IType; import org.eclipse.jface.viewers.Viewer; public class ParentSorter extends NameSorter { public int compare(Viewer viewer, Object e1, Object e2) { String leftParent= getParentName(e1); String rightParent= getParentName(e2); return collator.compare(leftParent, rightParent); } private String getParentName(Object element) { if (element instanceof IJavaElement) { IJavaElement parent= ((IJavaElement)element).getParent(); if (parent instanceof IType) return ((IType)parent).getFullyQualifiedName(); if (parent != null) return parent.getElementName(); } if (element instanceof IResource) { IResource parent= ((IResource)element).getParent(); if (parent != null) return parent.getName(); } return ""; //$NON-NLS-1$ } }
60,101
Bug 60101 Sort by parent path should take method name into account
build i0420:0800 - I do a Java Search and sort the results by Parent Path - I believe the secondary sort consideration should be the method name - this would make the results sorted alphabetically Here are the currently results. Note I removed part of the package name to make the list clearer. (#addChild is out of order alphabetically) I'm not sure what order its listed in...#addChild is at the beginning of the java file so its not by order of appearance in the file. preferences.EclipsePreferences.childrenNames() preferences.EclipsePreferences.getChild(String) (2 matches) preferences.EclipsePreferences.getChildren() (2 matches) preferences.EclipsePreferences.removeNode(IEclipsePreferences) (4 matches) preferences.EclipsePreferences.addChild(String, IEclipsePreferences) (3 matches) preferences.RootPreferences.getChild(String) (2 matches)
resolved fixed
44ee3a2
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T15:59:40Z
2004-04-27T15:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/PathSorter.java
/******************************************************************************* * Copyright (c) 2000, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.search; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jface.viewers.Viewer; public class PathSorter extends NameSorter { public int compare(Viewer viewer, Object e1, Object e2) { IPath path1= getPath(e1); IPath path2=getPath(e2); return compare(path1, path2); } /** * @param e1 * @return */ private IPath getPath(Object element) { if (element instanceof IJavaElement) return ((IJavaElement)element).getPath(); if (element instanceof IResource) return ((IResource)element).getFullPath(); return new Path(""); //$NON-NLS-1$ } protected int compare(IPath path1, IPath path2) { int segmentCount= Math.min(path1.segmentCount(), path2.segmentCount()); for (int i= 0; i < segmentCount; i++) { int value= collator.compare(path1.segment(i), path2.segment(i)); if (value != 0) return value; } return path1.segmentCount() - path2.segmentCount(); } }
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/base/JDTChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/AddToClasspathChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/CompilationUnitReorgChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/CopyCompilationUnitChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/CopyPackageChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/CopyPackageFragmentRootChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/CopyResourceChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/CreatePackageChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeleteFolderChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeleteFromClasspathChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/DeletePackageFragmentRootChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/MoveCompilationUnitChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/MovePackageChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/MovePackageFragmentRootChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/PackageFragmentRootReorgChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/RenameResourceChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/changes/CreateFileChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/changes/DeleteFileChange.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/JavaDeleteProcessor.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/core
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgPolicyFactory.java
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
org.eclipse.jdt.ui/ui
56,870
Bug 56870 copied file not shown in package explorer / java browser [ccp]
If I use copy/paste on a file, the new file will not be shown in the Package Explorer unless I close and reopen the project. Nor will it be shown in the "Java Browsing", it will - though - be shown in the Navigator (resource perspective). I'm currently running 3M8 Build id: 200403261517 on W2k Funny thing though, the "team" part flags the package as being dirty, i.e. the ">" is prepended to the package in the package explorer. Kind regards
verified fixed
cf2c148
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-04T20:41:03Z
2004-03-31T08:00:00Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/RefactoringExecutionHelper.java
54,946
Bug 54946 Contextual launch contribution should not set adaptable=true
The contextual launch contribution sets adaptable=true (see below). This means the selection is always converted to an IResource. This results in a loss of information, since then the enablement can only be expressed in terms of IResource and not in terms of the original type. For exampe, the JUnit contextual launch needs to support launching an individual IMethod. It should be up to the enablement expression to do the adaptation. <extension point="org.eclipse.ui.popupMenus"> <objectContribution objectClass="org.eclipse.core.resources.IResource" adaptable="true" id="org.eclipse.debug.ui.contextualLaunch"> <action label="%LaunchMenu.label" style="pulldown" class="org.eclipse.debug.internal.ui.actions.ContextualLaunchObjectActionDelega te" menubarPath="additions" enablesFor="1" id="org.eclipse.debug.ui.contextualLaunch.submenu"> </action> </objectContribution> </extension>
verified fixed
fc6312a
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T03:30:53Z
2004-03-16T09:40:00Z
org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JavaTypeExtender.java
/******************************************************************************* * Copyright (c) 2004 International Business Machines Corp. and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v0.5 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v05.html * * Contributors: * IBM Corporation - initial API and implementation ******************************************************************************/ package org.eclipse.jdt.internal.junit.ui; import org.eclipse.core.expressions.PropertyTester; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.junit.util.TestSearchEngine; /** * Contributes an "isTest" property for ITypes. */ public class JavaTypeExtender extends PropertyTester { private static final String IS_TEST= "isTest"; //$NON-NLS-1$ /** * @inheritDoc */ public boolean test(Object receiver, String method, Object[] args, Object expectedValue) { IType type= (IType)receiver; try { if (IS_TEST.equals(method)) return TestSearchEngine.isTestOrTestSuite(type); } catch (JavaModelException e) { return false; } return false; } }
60,414
Bug 60414 Should generate IMarker if editor doesn't provide AnnotationModel
To be backward compatible with existing multi page editors we should generate temporary search markers if the text editor doesn't support Annotation models.
resolved fixed
80272e2
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T08:57:26Z
2004-04-29T14:46:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchPage.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.search; import java.io.BufferedReader; import java.io.IOException; import java.io.StringReader; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Set; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IField; import org.eclipse.jdt.core.IImportDeclaration; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMethod; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.IJavaSearchConstants; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.SelectionConverter; import org.eclipse.jdt.internal.ui.browsing.LogicalPackage; import org.eclipse.jdt.internal.ui.preferences.PreferencePageSupport; import org.eclipse.jdt.internal.ui.preferences.SearchParticipantsPreferencePage; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.internal.ui.util.RowLayouter; import org.eclipse.jdt.ui.search.ElementQuerySpecification; import org.eclipse.jdt.ui.search.PatternQuerySpecification; import org.eclipse.jdt.ui.search.QuerySpecification; import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.DialogPage; import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.util.Assert; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.search.ui.ISearchPage; import org.eclipse.search.ui.ISearchPageContainer; import org.eclipse.search.ui.ISearchResultViewEntry; import org.eclipse.search.ui.NewSearchUI; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.model.IWorkbenchAdapter; public class JavaSearchPage extends DialogPage implements ISearchPage, IJavaSearchConstants { private static class SearchPatternData { private int searchFor; private int limitTo; private String pattern; private boolean isCaseSensitive; private IJavaElement javaElement; private int scope; private IWorkingSet[] workingSets; public SearchPatternData(int searchFor, int limitTo, boolean isCaseSensitive, String pattern, IJavaElement element) { this(searchFor, limitTo, pattern, isCaseSensitive, element, ISearchPageContainer.WORKSPACE_SCOPE, null); } public SearchPatternData(int s, int l, String p, boolean i, IJavaElement element, int scope, IWorkingSet[] workingSets) { setSearchFor(s); setLimitTo(l); setPattern(p); setCaseSensitive(i); setJavaElement(element); this.setScope(scope); this.setWorkingSets(workingSets); } public void setCaseSensitive(boolean isCaseSensitive) { this.isCaseSensitive= isCaseSensitive; } public boolean isCaseSensitive() { return isCaseSensitive; } public void setJavaElement(IJavaElement javaElement) { this.javaElement= javaElement; } public IJavaElement getJavaElement() { return javaElement; } public void setLimitTo(int limitTo) { this.limitTo= limitTo; } public int getLimitTo() { return limitTo; } public void setPattern(String pattern) { this.pattern= pattern; } public String getPattern() { return pattern; } public void setScope(int scope) { this.scope= scope; } public int getScope() { return scope; } public void setSearchFor(int searchFor) { this.searchFor= searchFor; } public int getSearchFor() { return searchFor; } public void setWorkingSets(IWorkingSet[] workingSets) { this.workingSets= workingSets; } public IWorkingSet[] getWorkingSets() { return workingSets; } } public static final String PARTICIPANT_EXTENSION_POINT= "org.eclipse.jdt.ui.queryParticipants"; //$NON-NLS-1$ public static final String EXTENSION_POINT_ID= "org.eclipse.jdt.ui.JavaSearchPage"; //$NON-NLS-1$ // Dialog store id constants private final static String PAGE_NAME= "JavaSearchPage"; //$NON-NLS-1$ private final static String STORE_CASE_SENSITIVE= PAGE_NAME + "CASE_SENSITIVE"; //$NON-NLS-1$ private static List fgPreviousSearchPatterns= new ArrayList(20); private SearchPatternData fInitialData; private IStructuredSelection fStructuredSelection; private IJavaElement fJavaElement; private boolean fFirstTime= true; private IDialogSettings fDialogSettings; private boolean fIsCaseSensitive; private Combo fPattern; private ISearchPageContainer fContainer; private Button fCaseSensitive; private Button[] fSearchFor; private String[] fSearchForText= { SearchMessages.getString("SearchPage.searchFor.type"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.method"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.package"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.constructor"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.searchFor.field")}; //$NON-NLS-1$ private Button[] fLimitTo; private String[] fLimitToText= { SearchMessages.getString("SearchPage.limitTo.declarations"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.limitTo.implementors"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.limitTo.references"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.limitTo.allOccurrences"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.limitTo.readReferences"), //$NON-NLS-1$ SearchMessages.getString("SearchPage.limitTo.writeReferences")}; //$NON-NLS-1$ //---- Action Handling ------------------------------------------------ public boolean performAction() { if (true) return performNewSearch(); if (JavaPlugin.useNewSearch()) { return performNewSearch(); } else { return performOldSearch(); } } private boolean performOldSearch() { org.eclipse.search.ui.SearchUI.activateSearchResultView(); SearchPatternData data= getPatternData(); IWorkspace workspace= JavaPlugin.getWorkspace(); // Setup search scope IJavaSearchScope scope= null; String scopeDescription= ""; //$NON-NLS-1$ switch (getContainer().getSelectedScope()) { case ISearchPageContainer.WORKSPACE_SCOPE: scopeDescription= SearchMessages.getString("WorkspaceScope"); //$NON-NLS-1$ scope= SearchEngine.createWorkspaceScope(); break; case ISearchPageContainer.SELECTION_SCOPE: scopeDescription= SearchMessages.getString("SelectionScope"); //$NON-NLS-1$ scope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(fStructuredSelection); break; case ISearchPageContainer.SELECTED_PROJECTS_SCOPE: scope= JavaSearchScopeFactory.getInstance().createJavaProjectSearchScope(fStructuredSelection); IProject[] projects= JavaSearchScopeFactory.getInstance().getProjects(scope); if (projects.length > 1) scopeDescription= SearchMessages.getFormattedString("EnclosingProjectsScope", projects[0].getName()); //$NON-NLS-1$ else if (projects.length == 1) scopeDescription= SearchMessages.getFormattedString("EnclosingProjectScope", projects[0].getName()); //$NON-NLS-1$ else scopeDescription= SearchMessages.getFormattedString("EnclosingProjectScope", ""); //$NON-NLS-1$ //$NON-NLS-2$ break; case ISearchPageContainer.WORKING_SET_SCOPE: IWorkingSet[] workingSets= getContainer().getSelectedWorkingSets(); // should not happen - just to be sure if (workingSets == null || workingSets.length < 1) return false; scopeDescription= SearchMessages.getFormattedString("WorkingSetScope", SearchUtil.toString(workingSets)); //$NON-NLS-1$ scope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(getContainer().getSelectedWorkingSets()); SearchUtil.updateLRUWorkingSets(getContainer().getSelectedWorkingSets()); } JavaSearchResultCollector collector= new JavaSearchResultCollector(); JavaSearchOperation op= null; if (data.getJavaElement() != null && getPattern().equals(fInitialData.getPattern())) { op= new JavaSearchOperation(workspace, data.getJavaElement(), data.getLimitTo(), scope, scopeDescription, collector); if (data.getLimitTo() == IJavaSearchConstants.REFERENCES) SearchUtil.warnIfBinaryConstant(data.getJavaElement(), getShell()); } else { data.setJavaElement(null); op= new JavaSearchOperation(workspace, data.getPattern(), data.isCaseSensitive(), data.getSearchFor(), data.getLimitTo(), scope, scopeDescription, collector); } Shell shell= getControl().getShell(); try { getContainer().getRunnableContext().run(true, true, op); } catch (InvocationTargetException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); //$NON-NLS-2$ //$NON-NLS-1$ return false; } catch (InterruptedException ex) { return false; } return true; } private boolean performNewSearch() { org.eclipse.search.ui.NewSearchUI.activateSearchResultView(); SearchPatternData data= getPatternData(); // Setup search scope IJavaSearchScope scope= null; String scopeDescription= ""; //$NON-NLS-1$ switch (getContainer().getSelectedScope()) { case ISearchPageContainer.WORKSPACE_SCOPE: scopeDescription= SearchMessages.getString("WorkspaceScope"); //$NON-NLS-1$ scope= SearchEngine.createWorkspaceScope(); break; case ISearchPageContainer.SELECTION_SCOPE: scopeDescription= SearchMessages.getString("SelectionScope"); //$NON-NLS-1$ scope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(fStructuredSelection); break; case ISearchPageContainer.SELECTED_PROJECTS_SCOPE: scope= JavaSearchScopeFactory.getInstance().createJavaProjectSearchScope(fStructuredSelection); IProject[] projects= JavaSearchScopeFactory.getInstance().getProjects(scope); if (projects.length >= 1) { if (projects.length == 1) scopeDescription= SearchMessages.getFormattedString("EnclosingProjectScope", projects[0].getName()); //$NON-NLS-1$ else scopeDescription= SearchMessages.getFormattedString("EnclosingProjectsScope", projects[0].getName()); //$NON-NLS-1$ } else scopeDescription= SearchMessages.getFormattedString("EnclosingProjectScope", ""); //$NON-NLS-1$ //$NON-NLS-2$ break; case ISearchPageContainer.WORKING_SET_SCOPE: IWorkingSet[] workingSets= getContainer().getSelectedWorkingSets(); // should not happen - just to be sure if (workingSets == null || workingSets.length < 1) return false; scopeDescription= SearchMessages.getFormattedString("WorkingSetScope", SearchUtil.toString(workingSets)); //$NON-NLS-1$ scope= JavaSearchScopeFactory.getInstance().createJavaSearchScope(getContainer().getSelectedWorkingSets()); SearchUtil.updateLRUWorkingSets(getContainer().getSelectedWorkingSets()); } JavaSearchQuery textSearchJob= null; QuerySpecification querySpec= null; if (data.getJavaElement() != null && getPattern().equals(fInitialData.getPattern())) { if (data.getLimitTo() == IJavaSearchConstants.REFERENCES) SearchUtil.warnIfBinaryConstant(data.getJavaElement(), getShell()); querySpec= new ElementQuerySpecification(data.getJavaElement(), data.getLimitTo(), scope, scopeDescription); } else { querySpec= new PatternQuerySpecification(data.getPattern(), data.getSearchFor(), data.isCaseSensitive(), data.getLimitTo(), scope, scopeDescription); data.setJavaElement(null); } textSearchJob= new JavaSearchQuery(querySpec); new SearchResultUpdater((JavaSearchResult) textSearchJob.getSearchResult()); NewSearchUI.runQuery(textSearchJob); return true; } private int getLimitTo() { for (int i= 0; i < fLimitTo.length; i++) { if (fLimitTo[i].getSelection()) return i; } return -1; } private void setLimitTo(int searchFor) { fLimitTo[DECLARATIONS].setEnabled(true); fLimitTo[IMPLEMENTORS].setEnabled(false); fLimitTo[REFERENCES].setEnabled(true); fLimitTo[ALL_OCCURRENCES].setEnabled(true); fLimitTo[READ_ACCESSES].setEnabled(false); fLimitTo[WRITE_ACCESSES].setEnabled(false); if (!(searchFor == TYPE || searchFor == INTERFACE) && fLimitTo[IMPLEMENTORS].getSelection()) { fLimitTo[IMPLEMENTORS].setSelection(false); fLimitTo[REFERENCES].setSelection(true); } if (!(searchFor == FIELD) && (getLimitTo() == READ_ACCESSES || getLimitTo() == WRITE_ACCESSES)) { fLimitTo[getLimitTo()].setSelection(false); fLimitTo[REFERENCES].setSelection(true); } switch (searchFor) { case TYPE: case INTERFACE: fLimitTo[IMPLEMENTORS].setEnabled(true); break; case FIELD: fLimitTo[READ_ACCESSES].setEnabled(true); fLimitTo[WRITE_ACCESSES].setEnabled(true); break; default : break; } } private String[] getPreviousSearchPatterns() { // Search results are not persistent int patternCount= fgPreviousSearchPatterns.size(); String [] patterns= new String[patternCount]; for (int i= 0; i < patternCount; i++) patterns[i]= ((SearchPatternData) fgPreviousSearchPatterns.get(patternCount - 1 - i)).getPattern(); return patterns; } private int getSearchFor() { for (int i= 0; i < fSearchFor.length; i++) { if (fSearchFor[i].getSelection()) return i; } Assert.isTrue(false, "shouldNeverHappen"); //$NON-NLS-1$ return -1; } private String getPattern() { return fPattern.getText(); } /** * Return search pattern data and update previous searches. * An existing entry will be updated. */ private SearchPatternData getPatternData() { String pattern= getPattern(); SearchPatternData match= null; int i= 0; int size= fgPreviousSearchPatterns.size(); while (match == null && i < size) { match= (SearchPatternData) fgPreviousSearchPatterns.get(i); i++; if (!pattern.equals(match.getPattern())) match= null; } if (match == null) { match= new SearchPatternData( getSearchFor(), getLimitTo(), pattern, fCaseSensitive.getSelection(), fJavaElement, getContainer().getSelectedScope(), getContainer().getSelectedWorkingSets()); fgPreviousSearchPatterns.add(match); } else { match.setSearchFor(getSearchFor()); match.setLimitTo(getLimitTo()); match.setCaseSensitive(fCaseSensitive.getSelection()); match.setJavaElement(fJavaElement); match.setScope(getContainer().getSelectedScope()); match.setWorkingSets(getContainer().getSelectedWorkingSets()); } return match; } /* * Implements method from IDialogPage */ public void setVisible(boolean visible) { if (visible && fPattern != null) { if (fFirstTime) { fFirstTime= false; // Set item and text here to prevent page from resizing fPattern.setItems(getPreviousSearchPatterns()); initSelections(); } fPattern.setFocus(); getContainer().setPerformActionEnabled(fPattern.getText().length() > 0); } super.setVisible(visible); } public boolean isValid() { return true; } //---- Widget creation ------------------------------------------------ /** * Creates the page's content. */ public void createControl(Composite parent) { initializeDialogUnits(parent); readConfiguration(); GridData gd; Composite result= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(2, false); layout.horizontalSpacing= 10; result.setLayout(layout); result.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); RowLayouter layouter= new RowLayouter(layout.numColumns); gd= new GridData(); gd.horizontalAlignment= GridData.FILL; gd.verticalAlignment= GridData.VERTICAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_FILL; layouter.setDefaultGridData(gd, 0); layouter.setDefaultGridData(gd, 1); layouter.setDefaultSpan(); layouter.perform(createExpression(result)); layouter.perform(createSearchFor(result), createLimitTo(result), -1); createParticipants(result); SelectionAdapter javaElementInitializer= new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { if (getSearchFor() == fInitialData.getSearchFor()) fJavaElement= fInitialData.getJavaElement(); else fJavaElement= null; setLimitTo(getSearchFor()); updateCaseSensitiveCheckbox(); } }; fSearchFor[TYPE].addSelectionListener(javaElementInitializer); fSearchFor[METHOD].addSelectionListener(javaElementInitializer); fSearchFor[FIELD].addSelectionListener(javaElementInitializer); fSearchFor[CONSTRUCTOR].addSelectionListener(javaElementInitializer); fSearchFor[PACKAGE].addSelectionListener(javaElementInitializer); setControl(result); Dialog.applyDialogFont(result); WorkbenchHelp.setHelp(result, IJavaHelpContextIds.JAVA_SEARCH_PAGE); initSelections(); } private void createParticipants(Composite result) { if (!SearchParticipantsPreferencePage.hasAnyParticipants()) return; Button selectParticipants= new Button(result, SWT.PUSH); selectParticipants.setText(SearchMessages.getString("SearchPage.select_participants.label")); //$NON-NLS-1$ GridData gd= new GridData(); gd.verticalAlignment= GridData.VERTICAL_ALIGN_BEGINNING; gd.horizontalAlignment= GridData.HORIZONTAL_ALIGN_END; gd.grabExcessHorizontalSpace= false; gd.horizontalAlignment= GridData.END; gd.horizontalSpan= 2; selectParticipants.setLayoutData(gd); selectParticipants.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { PreferencePageSupport.showPreferencePage(getShell(), "org.eclipse.jdt.ui.preferences.SearchParticipantsPreferencePage", new SearchParticipantsPreferencePage()); //$NON-NLS-1$ } }); } private Control createExpression(Composite parent) { Composite result= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(2, false); result.setLayout(layout); GridData gd= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); gd.horizontalSpan= 2; gd.horizontalIndent= 0; result.setLayoutData(gd); // Pattern text + info Label label= new Label(result, SWT.LEFT); label.setText(SearchMessages.getString("SearchPage.expression.label")); //$NON-NLS-1$ gd= new GridData(GridData.BEGINNING); gd.horizontalSpan= 2; // gd.horizontalIndent= -gd.horizontalIndent; label.setLayoutData(gd); // Pattern combo fPattern= new Combo(result, SWT.SINGLE | SWT.BORDER); fPattern.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { handlePatternSelected(); } }); fPattern.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent e) { getContainer().setPerformActionEnabled(getPattern().length() > 0); updateCaseSensitiveCheckbox(); } }); gd= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); // limit preferred size gd.widthHint= convertWidthInCharsToPixels(50); gd.horizontalIndent= -gd.horizontalIndent; fPattern.setLayoutData(gd); // Ignore case checkbox fCaseSensitive= new Button(result, SWT.CHECK); fCaseSensitive.setText(SearchMessages.getString("SearchPage.expression.caseSensitive")); //$NON-NLS-1$ gd= new GridData(); fCaseSensitive.setLayoutData(gd); fCaseSensitive.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fIsCaseSensitive= fCaseSensitive.getSelection(); writeConfiguration(); } }); return result; } private void updateCaseSensitiveCheckbox() { if (fInitialData != null && getPattern().equals(fInitialData.getPattern()) && fJavaElement != null) { fCaseSensitive.setEnabled(false); fCaseSensitive.setSelection(true); } else { fCaseSensitive.setEnabled(true); fCaseSensitive.setSelection(fIsCaseSensitive); } } private void handlePatternSelected() { if (fPattern.getSelectionIndex() < 0) return; int index= fgPreviousSearchPatterns.size() - 1 - fPattern.getSelectionIndex(); fInitialData= (SearchPatternData) fgPreviousSearchPatterns.get(index); for (int i= 0; i < fSearchFor.length; i++) fSearchFor[i].setSelection(false); for (int i= 0; i < fLimitTo.length; i++) fLimitTo[i].setSelection(false); fSearchFor[fInitialData.getSearchFor()].setSelection(true); setLimitTo(fInitialData.getSearchFor()); fLimitTo[fInitialData.getLimitTo()].setSelection(true); fPattern.setText(fInitialData.getPattern()); fIsCaseSensitive= fInitialData.isCaseSensitive(); fJavaElement= fInitialData.getJavaElement(); fCaseSensitive.setEnabled(fJavaElement == null); fCaseSensitive.setSelection(fInitialData.isCaseSensitive()); if (fInitialData.getWorkingSets() != null) getContainer().setSelectedWorkingSets(fInitialData.getWorkingSets()); else getContainer().setSelectedScope(fInitialData.getScope()); } private Control createSearchFor(Composite parent) { Group result= new Group(parent, SWT.NONE); result.setText(SearchMessages.getString("SearchPage.searchFor.label")); //$NON-NLS-1$ GridLayout layout= new GridLayout(); layout.numColumns= 3; result.setLayout(layout); fSearchFor= new Button[fSearchForText.length]; for (int i= 0; i < fSearchForText.length; i++) { Button button= new Button(result, SWT.RADIO); button.setText(fSearchForText[i]); fSearchFor[i]= button; } // Fill with dummy radio buttons Button filler= new Button(result, SWT.RADIO); filler.setVisible(false); filler= new Button(result, SWT.RADIO); filler.setVisible(false); return result; } private Control createLimitTo(Composite parent) { Group result= new Group(parent, SWT.NONE); result.setText(SearchMessages.getString("SearchPage.limitTo.label")); //$NON-NLS-1$ GridLayout layout= new GridLayout(); layout.numColumns= 2; result.setLayout(layout); fLimitTo= new Button[fLimitToText.length]; for (int i= 0; i < fLimitToText.length; i++) { Button button= new Button(result, SWT.RADIO); button.setText(fLimitToText[i]); fLimitTo[i]= button; } return result; } private void initSelections() { fStructuredSelection= asStructuredSelection(); fInitialData= tryStructuredSelection(fStructuredSelection); if (fInitialData == null) fInitialData= trySimpleTextSelection(getContainer().getSelection()); if (fInitialData == null) fInitialData= getDefaultInitValues(); fJavaElement= fInitialData.getJavaElement(); fCaseSensitive.setSelection(fInitialData.isCaseSensitive()); fCaseSensitive.setEnabled(fInitialData.getJavaElement() == null); fSearchFor[fInitialData.getSearchFor()].setSelection(true); setLimitTo(fInitialData.getSearchFor()); fLimitTo[fInitialData.getLimitTo()].setSelection(true); fPattern.setText(fInitialData.getPattern()); } private SearchPatternData tryStructuredSelection(IStructuredSelection selection) { if (selection == null || selection.size() > 1) return null; Object o= selection.getFirstElement(); if (o instanceof IJavaElement) { return determineInitValuesFrom((IJavaElement)o); } else if (o instanceof ISearchResultViewEntry) { IJavaElement element= SearchUtil.getJavaElement(((ISearchResultViewEntry)o).getSelectedMarker()); return determineInitValuesFrom(element); } else if (o instanceof LogicalPackage) { LogicalPackage lp= (LogicalPackage)o; return new SearchPatternData(PACKAGE, REFERENCES, fIsCaseSensitive, lp.getElementName(), null); } else if (o instanceof IAdaptable) { IJavaElement element= (IJavaElement)((IAdaptable)o).getAdapter(IJavaElement.class); if (element != null) { return determineInitValuesFrom(element); } else { IWorkbenchAdapter adapter= (IWorkbenchAdapter)((IAdaptable)o).getAdapter(IWorkbenchAdapter.class); if (adapter != null) return new SearchPatternData(TYPE, REFERENCES, fIsCaseSensitive, adapter.getLabel(o), null); } } return null; } private SearchPatternData determineInitValuesFrom(IJavaElement element) { if (element == null) return null; int searchFor= UNKNOWN; int limitTo= UNKNOWN; String pattern= null; switch (element.getElementType()) { case IJavaElement.PACKAGE_FRAGMENT: searchFor= PACKAGE; limitTo= REFERENCES; pattern= element.getElementName(); break; case IJavaElement.PACKAGE_FRAGMENT_ROOT: searchFor= PACKAGE; limitTo= REFERENCES; pattern= element.getElementName(); break; case IJavaElement.PACKAGE_DECLARATION: searchFor= PACKAGE; limitTo= REFERENCES; pattern= element.getElementName(); break; case IJavaElement.IMPORT_DECLARATION: pattern= element.getElementName(); IImportDeclaration declaration= (IImportDeclaration)element; if (declaration.isOnDemand()) { searchFor= PACKAGE; int index= pattern.lastIndexOf('.'); pattern= pattern.substring(0, index); } else { searchFor= TYPE; } limitTo= DECLARATIONS; break; case IJavaElement.TYPE: searchFor= TYPE; limitTo= REFERENCES; pattern= JavaModelUtil.getFullyQualifiedName((IType)element); break; case IJavaElement.COMPILATION_UNIT: ICompilationUnit cu= (ICompilationUnit)element; String mainTypeName= element.getElementName().substring(0, element.getElementName().indexOf(".")); //$NON-NLS-1$ IType mainType= cu.getType(mainTypeName); mainTypeName= JavaModelUtil.getTypeQualifiedName(mainType); try { mainType= JavaModelUtil.findTypeInCompilationUnit(cu, mainTypeName); if (mainType == null) { // fetch type which is declared first in the file IType[] types= cu.getTypes(); if (types.length > 0) mainType= types[0]; else break; } } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$ break; } searchFor= TYPE; element= mainType; limitTo= REFERENCES; pattern= JavaModelUtil.getFullyQualifiedName(mainType); break; case IJavaElement.CLASS_FILE: IClassFile cf= (IClassFile)element; try { mainType= cf.getType(); } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$ break; } if (mainType == null) break; element= mainType; searchFor= TYPE; limitTo= REFERENCES; pattern= JavaModelUtil.getFullyQualifiedName(mainType); break; case IJavaElement.FIELD: searchFor= FIELD; limitTo= REFERENCES; IType type= ((IField)element).getDeclaringType(); StringBuffer buffer= new StringBuffer(); buffer.append(JavaModelUtil.getFullyQualifiedName(type)); buffer.append('.'); buffer.append(element.getElementName()); pattern= buffer.toString(); break; case IJavaElement.METHOD: searchFor= METHOD; try { IMethod method= (IMethod)element; if (method.isConstructor()) searchFor= CONSTRUCTOR; } catch (JavaModelException ex) { ExceptionHandler.handle(ex, SearchMessages.getString("Search.Error.javaElementAccess.title"), SearchMessages.getString("Search.Error.javaElementAccess.message")); //$NON-NLS-2$ //$NON-NLS-1$ break; } limitTo= REFERENCES; pattern= PrettySignature.getMethodSignature((IMethod)element); break; } if (searchFor != UNKNOWN && limitTo != UNKNOWN && pattern != null) return new SearchPatternData(searchFor, limitTo, true, pattern, element); return null; } private SearchPatternData trySimpleTextSelection(ISelection selection) { SearchPatternData result= null; if (selection instanceof ITextSelection) { BufferedReader reader= new BufferedReader(new StringReader(((ITextSelection)selection).getText())); String text; try { text= reader.readLine(); if (text == null) text= ""; //$NON-NLS-1$ } catch (IOException ex) { text= ""; //$NON-NLS-1$ } result= new SearchPatternData(TYPE, REFERENCES, fIsCaseSensitive, text, null); } return result; } private SearchPatternData getDefaultInitValues() { return new SearchPatternData(TYPE, REFERENCES, fIsCaseSensitive, "", null); //$NON-NLS-1$ } /* * Implements method from ISearchPage */ public void setContainer(ISearchPageContainer container) { fContainer= container; } /** * Returns the search page's container. */ private ISearchPageContainer getContainer() { return fContainer; } /** * Returns the structured selection from the selection. */ private IStructuredSelection asStructuredSelection() { IWorkbenchWindow wbWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (wbWindow != null) { IWorkbenchPage page= wbWindow.getActivePage(); if (page != null) { IWorkbenchPart part= page.getActivePart(); if (part != null) try { return SelectionConverter.getStructuredSelection(part); } catch (JavaModelException ex) { // ignore handled by return } } } return StructuredSelection.EMPTY; } //--------------- Configuration handling -------------- /** * Returns the page settings for this Java search page. * * @return the page settings to be used */ private IDialogSettings getDialogSettings() { IDialogSettings settings= JavaPlugin.getDefault().getDialogSettings(); fDialogSettings= settings.getSection(PAGE_NAME); if (fDialogSettings == null) fDialogSettings= settings.addNewSection(PAGE_NAME); return fDialogSettings; } /** * Initializes itself from the stored page settings. */ private void readConfiguration() { IDialogSettings s= getDialogSettings(); fIsCaseSensitive= s.getBoolean(STORE_CASE_SENSITIVE); } private void collectConcernedProjects(Set projects, ISelection selection) { if (!(selection instanceof IStructuredSelection)) return; IStructuredSelection structuredSelection= (IStructuredSelection)selection; Iterator elements= structuredSelection.iterator(); while (elements.hasNext()) { IProject project= getProject(elements.next()); if (project != null) projects.add(project); } } /** * Stores it current configuration in the dialog store. */ private void writeConfiguration() { IDialogSettings s= getDialogSettings(); s.put(STORE_CASE_SENSITIVE, fIsCaseSensitive); } private void collectConcernedProjects(Set projects, IWorkingSet[] workingSets) { for (int i= 0; i < workingSets.length; i++) collectConcernedProjects(projects, workingSets[i]); } private void collectConcernedProjects(Set projects, IWorkingSet workingSet) { IAdaptable[] adaptables= workingSet.getElements(); for (int i= 0; i < adaptables.length; i++) { IProject project= getProject(adaptables[i]); if (project != null) projects.add(project); } } private void collectConcernedProjects(Set projects, IWorkspace workspace) { IProject[] allProjects= workspace.getRoot().getProjects(); for (int i= 0; i < allProjects.length; i++) { if (allProjects[i].isAccessible()) projects.add(allProjects[i]); } } private IProject getProject(Object element) { if (element instanceof ISearchResultViewEntry) element= ((ISearchResultViewEntry)element).getGroupByKey(); if (element instanceof IAdaptable) { IAdaptable adaptable= (IAdaptable)element; IProject project= (IProject) adaptable.getAdapter(IProject.class); if (project != null) return project; IResource resource= (IResource) adaptable.getAdapter(IResource.class); if (resource != null) project= resource.getProject(); if (project != null) return project; } return null; } }
60,414
Bug 60414 Should generate IMarker if editor doesn't provide AnnotationModel
To be backward compatible with existing multi page editors we should generate temporary search markers if the text editor doesn't support Annotation models.
resolved fixed
80272e2
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T08:57:26Z
2004-04-29T14:46:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindAction.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.actions; import java.lang.reflect.InvocationTargetException; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IWorkspaceDescription; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.ILocalVariable; import org.eclipse.jdt.core.IMember; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.search.IJavaSearchScope; import org.eclipse.jdt.core.search.SearchEngine; import org.eclipse.swt.widgets.Shell; import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.window.Window; import org.eclipse.ui.IWorkbenchSite; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.ElementListSelectionDialog; import org.eclipse.search.ui.NewSearchUI; import org.eclipse.search.ui.SearchUI; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.actions.ActionUtil; import org.eclipse.jdt.internal.ui.actions.SelectionConverter; import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor; import org.eclipse.jdt.internal.ui.search.JavaSearchDescription; import org.eclipse.jdt.internal.ui.search.JavaSearchOperation; import org.eclipse.jdt.internal.ui.search.JavaSearchQuery; import org.eclipse.jdt.internal.ui.search.JavaSearchResultCollector; import org.eclipse.jdt.internal.ui.search.SearchMessages; import org.eclipse.jdt.internal.ui.search.SearchUtil; import org.eclipse.jdt.internal.ui.util.ExceptionHandler; import org.eclipse.jdt.ui.JavaElementLabelProvider; import org.eclipse.jdt.ui.search.ElementQuerySpecification; /** * Abstract class for Java search actions. * <p> * Note: This class is for internal use only. Clients should not use this class. * </p> * * @since 2.0 */ public abstract class FindAction extends SelectionDispatchAction { // A dummy which can't be selected in the UI private static final IJavaElement RETURN_WITHOUT_BEEP= JavaCore.create(JavaPlugin.getWorkspace().getRoot()); private Class[] fValidTypes; private JavaEditor fEditor; FindAction(IWorkbenchSite site, String label, Class[] validTypes) { super(site); setText(label); fValidTypes= validTypes; } FindAction(JavaEditor editor, String label, Class[] validTypes) { this (editor.getEditorSite(), label, validTypes); fEditor= editor; setEnabled(SelectionConverter.canOperateOn(fEditor)); } private boolean canOperateOn(IStructuredSelection sel) { return sel != null && !sel.isEmpty() && canOperateOn(getJavaElement(sel, true)); } boolean canOperateOn(IJavaElement element) { if (fValidTypes == null || fValidTypes.length == 0) return false; if (element != null) { for (int i= 0; i < fValidTypes.length; i++) { if (fValidTypes[i].isInstance(element)) { if (element.getElementType() == IJavaElement.PACKAGE_FRAGMENT) return hasChildren((IPackageFragment)element); else return true; } } } return false; } private boolean hasChildren(IPackageFragment packageFragment) { try { return packageFragment.hasChildren(); } catch (JavaModelException ex) { return false; } } private IJavaElement getJavaElement(IJavaElement o, boolean silent) { if (o == null) return null; switch (o.getElementType()) { case IJavaElement.COMPILATION_UNIT: if (silent) return (ICompilationUnit)o; else return findType((ICompilationUnit)o, silent); case IJavaElement.CLASS_FILE: return findType((IClassFile)o); default: return o; } } private IJavaElement getJavaElement(IMarker marker, boolean silent) { return getJavaElement(SearchUtil.getJavaElement(marker), silent); } private IJavaElement getJavaElement(Object o, boolean silent) { if (o instanceof IJavaElement) return getJavaElement((IJavaElement)o, silent); else if (o instanceof IMarker) return getJavaElement((IMarker)o, silent); else if (o instanceof ISelection) return getJavaElement((IStructuredSelection)o, silent); else if (SearchUtil.isISearchResultViewEntry(o)) return getJavaElement(SearchUtil.getJavaElement(o), silent); return null; } IJavaElement getJavaElement(IStructuredSelection selection, boolean silent) { if (selection.size() == 1) // Selection only enabled if one element selected. return getJavaElement(selection.getFirstElement(), silent); return null; } private void showOperationUnavailableDialog() { MessageDialog.openInformation(getShell(), SearchMessages.getString("JavaElementAction.operationUnavailable.title"), getOperationUnavailableMessage()); //$NON-NLS-1$ } String getOperationUnavailableMessage() { return SearchMessages.getString("JavaElementAction.operationUnavailable.generic"); //$NON-NLS-1$ } private IJavaElement findType(ICompilationUnit cu, boolean silent) { IType[] types= null; try { types= cu.getAllTypes(); } catch (JavaModelException ex) { // silent mode ExceptionHandler.log(ex, SearchMessages.getString("JavaElementAction.error.open.message")); //$NON-NLS-1$ if (silent) return RETURN_WITHOUT_BEEP; else return null; } if (types.length == 1 || (silent && types.length > 0)) return types[0]; if (silent) return RETURN_WITHOUT_BEEP; if (types.length == 0) return null; String title= SearchMessages.getString("JavaElementAction.typeSelectionDialog.title"); //$NON-NLS-1$ String message = SearchMessages.getString("JavaElementAction.typeSelectionDialog.message"); //$NON-NLS-1$ int flags= (JavaElementLabelProvider.SHOW_DEFAULT); ElementListSelectionDialog dialog= new ElementListSelectionDialog(getShell(), new JavaElementLabelProvider(flags)); dialog.setTitle(title); dialog.setMessage(message); dialog.setElements(types); if (dialog.open() == Window.OK) return (IType)dialog.getFirstResult(); else return RETURN_WITHOUT_BEEP; } private IType findType(IClassFile cf) { IType mainType; try { mainType= cf.getType(); } catch (JavaModelException ex) { ExceptionHandler.log(ex, SearchMessages.getString("JavaElementAction.error.open.message")); //$NON-NLS-1$ return null; } return mainType; } /* * Method declared on SelectionChangedAction. */ public void run(IStructuredSelection selection) { IJavaElement element= getJavaElement(selection, false); if (element == null || !element.exists()) { showOperationUnavailableDialog(); return; } else if (element == RETURN_WITHOUT_BEEP) return; run(element); } /* * Method declared on SelectionChangedAction. */ public void run(ITextSelection selection) { if (!ActionUtil.isProcessable(getShell(), fEditor)) return; try { String title= SearchMessages.getString("SearchElementSelectionDialog.title"); //$NON-NLS-1$ String message= SearchMessages.getString("SearchElementSelectionDialog.message"); //$NON-NLS-1$ IJavaElement[] elements= SelectionConverter.codeResolve(fEditor); if (elements.length > 0 && canOperateOn(elements[0])) { IJavaElement element= elements[0]; if (elements.length > 1) element= SelectionConverter.codeResolve(fEditor, getShell(), title, message); if (element != null) run(element); } else showOperationUnavailableDialog(); } catch (JavaModelException ex) { JavaPlugin.log(ex); String title= SearchMessages.getString("Search.Error.search.title"); //$NON-NLS-1$ String message= SearchMessages.getString("Search.Error.codeResolve"); //$NON-NLS-1$ ErrorDialog.openError(getShell(), title, message, ex.getStatus()); } } /* * Method declared on SelectionChangedAction. */ public void selectionChanged(IStructuredSelection selection) { setEnabled(canOperateOn(selection)); } /* * Method declared on SelectionChangedAction. */ public void selectionChanged(ITextSelection selection) { } /** * Executes this action for the given java element. * @param javaElement The java element to be found. */ public void run(IJavaElement element) { if (!ActionUtil.isProcessable(getShell(), element)) return; // if (JavaPlugin.getDefault().getPreferenceStore().getBoolean(WorkInProgressPreferencePage.PREF_BGSEARCH)) { if (true) { try { performNewSearch(element); } catch (JavaModelException ex) { ExceptionHandler.handle(ex, getShell(), SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); //$NON-NLS-1$ //$NON-NLS-2$ } } else { SearchUI.activateSearchResultView(); Shell shell= JavaPlugin.getActiveWorkbenchShell(); JavaSearchOperation op= null; try { op= makeOperation(element); if (op == null) return; } catch (JavaModelException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); //$NON-NLS-1$ //$NON-NLS-2$ return; } IWorkspaceDescription workspaceDesc= JavaPlugin.getWorkspace().getDescription(); boolean isAutoBuilding= workspaceDesc.isAutoBuilding(); if (isAutoBuilding) { // disable auto-build during search operation workspaceDesc.setAutoBuilding(false); try { JavaPlugin.getWorkspace().setDescription(workspaceDesc); } catch (CoreException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.setDescription.title"), SearchMessages.getString("Search.Error.setDescription.message")); //$NON-NLS-1$ //$NON-NLS-2$ } } try { PlatformUI.getWorkbench().getProgressService().run(true, true, op); } catch (InvocationTargetException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.search.title"), SearchMessages.getString("Search.Error.search.message")); //$NON-NLS-1$ //$NON-NLS-2$ } catch(InterruptedException e) { // means it's cancelled } finally { if (isAutoBuilding) { // enable auto-building again workspaceDesc= JavaPlugin.getWorkspace().getDescription(); workspaceDesc.setAutoBuilding(true); try { JavaPlugin.getWorkspace().setDescription(workspaceDesc); } catch (CoreException ex) { ExceptionHandler.handle(ex, shell, SearchMessages.getString("Search.Error.setDescription.title"), SearchMessages.getString("Search.Error.setDescription.message")); //$NON-NLS-1$ //$NON-NLS-2$ } } } } } private void performNewSearch(IJavaElement element) throws JavaModelException { JavaSearchQuery query= createJob(element); if (query != null) { NewSearchUI.activateSearchResultView(); NewSearchUI.runQuery(query); } } JavaSearchQuery createJob(IJavaElement element) throws JavaModelException { return new JavaSearchQuery(new ElementQuerySpecification(element, getLimitTo(), getScope(element), getScopeDescription(element))); } Object createSearchDescription(IJavaElement element) { IType type= getType(element); return new JavaSearchDescription(getLimitTo(), element, null, getScopeDescription(type)); } JavaSearchOperation makeOperation(IJavaElement element) throws JavaModelException { return new JavaSearchOperation(JavaPlugin.getWorkspace(), element, getLimitTo(), getScope(element), getScopeDescription(element), getCollector()); } abstract int getLimitTo(); JavaSearchResultCollector getCollector() { return new JavaSearchResultCollector(); } String getScopeDescription(IJavaElement element) { return SearchMessages.getString("WorkspaceScope"); //$NON-NLS-1$ } IJavaSearchScope getScope(IJavaElement element) throws JavaModelException { return SearchEngine.createWorkspaceScope(); } IType getType(IJavaElement element) { if (element == null) return null; IType type= null; if (element.getElementType() == IJavaElement.TYPE) type= (IType)element; else if (element instanceof IMember) type= ((IMember)element).getDeclaringType(); else if (element instanceof ILocalVariable) { type= (IType)element.getAncestor(IJavaElement.TYPE); } if (type != null) { ICompilationUnit cu= type.getCompilationUnit(); if (cu == null) return type; IType wcType= (IType) getWorkingCopy(type); if (wcType != null) return wcType; else return type; } return null; } /** * Tries to find the given element in a working copy. */ private IJavaElement getWorkingCopy(IJavaElement input) { // TODO: With new working copy story: original == working copy. // Note that the previous code could result in a reconcile as side effect. Should check if that // is still required. return input; } }
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
org.eclipse.jdt.ui.tests.refactoring/test
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
cases/org/eclipse/jdt/ui/tests/nls/NLSHintTest.java
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
org.eclipse.jdt.ui.tests.refactoring/test
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
cases/org/eclipse/jdt/ui/tests/nls/NlsRefactoringCheckFinalConditionsTest.java
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
org.eclipse.jdt.ui.tests.refactoring/test
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
cases/org/eclipse/jdt/ui/tests/nls/NlsRefactoringCreateChangeTest.java
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
org.eclipse.jdt.ui/core
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSHint.java
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
org.eclipse.jdt.ui/core
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSInfo.java
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
org.eclipse.jdt.ui/core
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/nls/NLSRefactoring.java
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
org.eclipse.jdt.ui/ui
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/ExternalizeWizardPage.java
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
org.eclipse.jdt.ui/ui
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/NLSAccessorConfigurationDialog.java
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
org.eclipse.jdt.ui/ui
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/PackageFragmentSelection.java
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
org.eclipse.jdt.ui/ui
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/PackageSelectionStringButtonAdapter.java
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
org.eclipse.jdt.ui/ui
60,799
Bug 60799 NPE trying to externalize strings [refactoring] [nls]
I got the following NPE when I tried to externalize strings in N20040430 java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring.getPropertyFileP ath(NLSRefactoring.java:248) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.updateAccesso rFieldLabels(ExternalizeWizardPage.java:525) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createAccesso rInfoComposite(ExternalizeWizardPage.java:518) at org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizardPage.createControl (ExternalizeWizardPage.java:453) at org.eclipse.jface.wizard.Wizard.createPageControls(Wizard.java:171) at org.eclipse.jface.wizard.WizardDialog.createPageControls (WizardDialog.java:539) at org.eclipse.jface.wizard.WizardDialog.createContents (WizardDialog.java:449) at org.eclipse.jface.window.Window.create(Window.java:348) at org.eclipse.jface.dialogs.Dialog.create(Dialog.java:935) at org.eclipse.jface.window.Window.open(Window.java:637) at org.eclipse.ltk.ui.refactoring.RefactoringWizardOpenOperation.run (RefactoringWizardOpenOperation.java:114) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:40) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.openExternalizeStringsWizar d(ExternalizeStringsAction.java:151) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:122) at org.eclipse.jdt.ui.actions.ExternalizeStringsAction.run (ExternalizeStringsAction.java:112) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:212) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:612) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:564) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:483) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:796) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2592) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2270) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1353) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1324) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:240) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:140) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:90) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:283) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:242) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:119) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke (NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke (DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:324) at org.eclipse.core.launcher.Main.basicRun(Main.java:269) at org.eclipse.core.launcher.Main.run(Main.java:700) at org.eclipse.core.launcher.Main.main(Main.java:684)
resolved fixed
1f9a0f9
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T10:38:40Z
2004-05-03T18:46:40Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/SourceFirstPackageSelectionDialogField.java
44,280
Bug 44280 Add regex content assist support for File search page
I20031007
resolved fixed
7da3d4f
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T14:30:53Z
2003-10-07T09:46:40Z
org.eclipse.jdt.ui/core
44,280
Bug 44280 Add regex content assist support for File search page
I20031007
resolved fixed
7da3d4f
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T14:30:53Z
2003-10-07T09:46:40Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/util/QualifiedNameFinder.java
44,280
Bug 44280 Add regex content assist support for File search page
I20031007
resolved fixed
7da3d4f
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T14:30:53Z
2003-10-07T09:46:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/FilterDialog.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.search; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Stack; import org.eclipse.jdt.internal.ui.IJavaHelpContextIds; import org.eclipse.jdt.internal.ui.util.SWTUtil; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckboxTableViewer; import org.eclipse.jface.viewers.ICheckStateListener; import org.eclipse.jface.viewers.ILabelProvider; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; import org.eclipse.ui.dialogs.SelectionDialog; import org.eclipse.ui.help.WorkbenchHelp; public class FilterDialog extends SelectionDialog { private String[] fEnabledFilterIds; private static MatchFilter[] fgBuiltInFilters= new MatchFilter[] { new ReadFilter(), new WriteFilter(), new ImportFilter() }; ; private CheckboxTableViewer fCheckBoxList; private JavaSearchResultPage fPage; private Stack fFilterDescriptorChangeHistory; /** * Creates a dialog to customize Java element filters. * * @param shell the parent shell * @param viewId the id of the view * @param enablePatterns <code>true</code> if pattern filters are enabled * @param patterns the filter patterns * @param enabledFilterIds the Ids of the enabled filters */ public FilterDialog( Shell shell, JavaSearchResultPage page) { super(shell); fPage= page; fFilterDescriptorChangeHistory= new Stack(); setShellStyle(getShellStyle() | SWT.RESIZE); } protected void configureShell(Shell shell) { setTitle("Match Filters"); setMessage("Select Match Filters"); super.configureShell(shell); WorkbenchHelp.setHelp(shell, IJavaHelpContextIds.CUSTOM_FILTERS_DIALOG); } /** * Overrides method in Dialog * * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(Composite) */ protected Control createDialogArea(Composite parent) { initializeDialogUnits(parent); // create a composite with standard margins and spacing Composite composite= new Composite(parent, SWT.NONE); GridLayout layout= new GridLayout(); layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN); layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN); layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING); layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING); composite.setLayout(layout); composite.setLayoutData(new GridData(GridData.FILL_BOTH)); composite.setFont(parent.getFont()); Composite group= composite; createCheckBoxList(group); applyDialogFont(parent); return parent; } private void createCheckBoxList(Composite parent) { // Filler new Label(parent, SWT.NONE); Label info= new Label(parent, SWT.LEFT); info.setText("info text"); //$NON-NLS-1$ fCheckBoxList= CheckboxTableViewer.newCheckList(parent, SWT.BORDER); GridData data= new GridData(GridData.FILL_BOTH); data.heightHint= fCheckBoxList.getTable().getItemHeight() * 10; fCheckBoxList.getTable().setLayoutData(data); fCheckBoxList.setLabelProvider(createLabelPrivder()); fCheckBoxList.setContentProvider(new ArrayContentProvider()); fCheckBoxList.setInput(fgBuiltInFilters); setInitialSelections(fPage.getMatchFilters()); List initialSelection= getInitialElementSelections(); if (initialSelection != null && !initialSelection.isEmpty()) checkInitialSelections(); // Description info= new Label(parent, SWT.LEFT); info.setText("Filter Description"); final Text description= new Text(parent, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER | SWT.V_SCROLL); data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint= convertHeightInCharsToPixels(3); description.setLayoutData(data); fCheckBoxList.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { ISelection selection= event.getSelection(); if (selection instanceof IStructuredSelection) { Object selectedElement= ((IStructuredSelection)selection).getFirstElement(); if (selectedElement instanceof MatchFilter) description.setText(((MatchFilter)selectedElement).getDescription()); } } }); fCheckBoxList.addCheckStateListener(new ICheckStateListener() { /* * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent) */ public void checkStateChanged(CheckStateChangedEvent event) { Object element= event.getElement(); if (element instanceof MatchFilter) { // renew if already touched if (fFilterDescriptorChangeHistory.contains(element)) fFilterDescriptorChangeHistory.remove(element); fFilterDescriptorChangeHistory.push(element); } }}); addSelectionButtons(parent); } private void addSelectionButtons(Composite composite) { Composite buttonComposite= new Composite(composite, SWT.RIGHT); GridLayout layout= new GridLayout(); layout.numColumns= 2; buttonComposite.setLayout(layout); GridData data= new GridData(GridData.HORIZONTAL_ALIGN_END | GridData.GRAB_HORIZONTAL); data.grabExcessHorizontalSpace= true; composite.setData(data); // Select All button String label= "Select All"; Button selectButton= createButton(buttonComposite, IDialogConstants.SELECT_ALL_ID, label, false); SWTUtil.setButtonDimensionHint(selectButton); SelectionListener listener= new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fCheckBoxList.setAllChecked(true); fFilterDescriptorChangeHistory.clear(); for (int i= 0; i < fgBuiltInFilters.length; i++) fFilterDescriptorChangeHistory.push(fgBuiltInFilters[i]); } }; selectButton.addSelectionListener(listener); // De-select All button label= "Deselect All"; Button deselectButton= createButton(buttonComposite, IDialogConstants.DESELECT_ALL_ID, label, false); SWTUtil.setButtonDimensionHint(deselectButton); listener= new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { fCheckBoxList.setAllChecked(false); fFilterDescriptorChangeHistory.clear(); for (int i= 0; i < fgBuiltInFilters.length; i++) fFilterDescriptorChangeHistory.push(fgBuiltInFilters[i]); } }; deselectButton.addSelectionListener(listener); } private void checkInitialSelections() { Iterator itemsToCheck= getInitialElementSelections().iterator(); while (itemsToCheck.hasNext()) fCheckBoxList.setChecked(itemsToCheck.next(),true); } protected void okPressed() { if (fgBuiltInFilters != null) { ArrayList result= new ArrayList(); for (int i= 0; i < fgBuiltInFilters.length; ++i) { if (fCheckBoxList.getChecked(fgBuiltInFilters[i])) result.add(fgBuiltInFilters[i]); } setResult(result); } super.okPressed(); } private ILabelProvider createLabelPrivder() { return new LabelProvider() { public Image getImage(Object element) { return null; } public String getText(Object element) { if (element instanceof MatchFilter) return ((MatchFilter)element).getName(); else return null; } }; } // ---------- result handling ---------- /** * @return a stack with the filter descriptor check history * @since 3.0 */ public Stack getFilterDescriptorChangeHistory() { return fFilterDescriptorChangeHistory; } }
44,280
Bug 44280 Add regex content assist support for File search page
I20031007
resolved fixed
7da3d4f
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T14:30:53Z
2003-10-07T09:46:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchResult.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.search; import java.text.MessageFormat; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IParent; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; import org.eclipse.jdt.ui.search.IMatchPresentation; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.search.ui.ISearchQuery; import org.eclipse.search.ui.text.AbstractTextSearchResult; import org.eclipse.search.ui.text.IEditorMatchAdapter; import org.eclipse.search.ui.text.IFileMatchAdapter; import org.eclipse.search.ui.text.Match; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; public class JavaSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter { private JavaSearchQuery fQuery; private Map fElementsToParticipants; public JavaSearchResult(JavaSearchQuery query) { fQuery= query; fElementsToParticipants= new HashMap(); } public ImageDescriptor getImageDescriptor() { return fQuery.getImageDescriptor(); } /* (non-Javadoc) * @see org.eclipse.search.ui.ISearchCategory#getText(org.eclipse.search.core.basic.ITextSearchResult) */ public String getLabel() { int matchCount= getMatchCount(); String format= null; if (matchCount == 1) return fQuery.getSingularLabel(); else format= fQuery.getPluralLabelPattern(); return MessageFormat.format(format, new Object[] { new Integer(matchCount) }); } public String getTooltip() { return getLabel(); } public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) { IEditorInput editorInput= editor.getEditorInput(); if (editorInput instanceof IFileEditorInput) { IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput; return computeContainedMatches(result, fileEditorInput.getFile()); } else if (editorInput instanceof IClassFileEditorInput) { IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) editorInput; Set matches= new HashSet(); collectMatches(matches, classFileEditorInput.getClassFile()); return (Match[]) matches.toArray(new Match[matches.size()]); } return null; } public Match[] computeContainedMatches(AbstractTextSearchResult result, IFile file) { IJavaElement javaElement= JavaCore.create(file); Set matches= new HashSet(); collectMatches(matches, javaElement); return (Match[]) matches.toArray(new Match[matches.size()]); } private void collectMatches(Set matches, IJavaElement element) { Match[] m= getMatches(element); if (m.length != 0) { for (int i= 0; i < m.length; i++) { matches.add(m[i]); } } if (element instanceof IParent) { IParent parent= (IParent) element; try { IJavaElement[] children= parent.getChildren(); for (int i= 0; i < children.length; i++) { collectMatches(matches, children[i]); } } catch (JavaModelException e) { // we will not be tracking these results } } } /* (non-Javadoc) * @see org.eclipse.search.ui.ISearchResultCategory#getFile(java.lang.Object) */ public IFile getFile(Object element) { if (element instanceof IJavaElement) { IJavaElement javaElement= (IJavaElement) element; try { element= javaElement.getUnderlyingResource(); } catch (JavaModelException e) { // we can't get a resource for this. } } if (element instanceof IFile) return (IFile)element; return null; } /* (non-Javadoc) * @see org.eclipse.search2.ui.text.IStructureProvider#isShownInEditor(org.eclipse.search2.ui.text.Match, org.eclipse.ui.IEditorPart) */ public boolean isShownInEditor(Match match, IEditorPart editor) { IEditorInput editorInput= editor.getEditorInput(); if (match.getElement() instanceof IJavaElement) { IJavaElement je= (IJavaElement) match.getElement(); if (editorInput instanceof IFileEditorInput) { try { return ((IFileEditorInput)editorInput).getFile().equals(je.getUnderlyingResource()); } catch (JavaModelException e) { return false; } } else if (editorInput instanceof IClassFileEditorInput) { return ((IClassFileEditorInput)editorInput).getClassFile().equals(je.getAncestor(IJavaElement.CLASS_FILE)); } } else if (match.getElement() instanceof IFile) { if (editorInput instanceof IFileEditorInput) { return ((IFileEditorInput)editorInput).getFile().equals(match.getElement()); } } return false; } /* (non-Javadoc) * @see org.eclipse.search.ui.ISearchResult#getQuery() */ public ISearchQuery getQuery() { return fQuery; } synchronized IMatchPresentation getSearchParticpant(Object element) { return (IMatchPresentation) fElementsToParticipants.get(element); } boolean addMatch(Match match, IMatchPresentation participant) { Object element= match.getElement(); if (fElementsToParticipants.get(element) != null) { // TODO must access the participant id / label to properly report the error. JavaPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), 0, "A second search participant was found for an element", null)); //$NON-NLS-1$ return false; } fElementsToParticipants.put(element, participant); addMatch(match); return true; } public void removeAll() { synchronized(this) { fElementsToParticipants.clear(); } super.removeAll(); } public void removeMatch(Match match) { synchronized(this) { if (getMatchCount(match.getElement()) == 1) fElementsToParticipants.remove(match.getElement()); } super.removeMatch(match); } public IFileMatchAdapter getFileMatchAdapter() { return this; } public IEditorMatchAdapter getEditorMatchAdapter() { return this; } }
44,280
Bug 44280 Add regex content assist support for File search page
I20031007
resolved fixed
7da3d4f
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T14:30:53Z
2003-10-07T09:46:40Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/TextSearchLabelProvider.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.search; import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.search.ui.text.AbstractTextSearchViewPage; public abstract class TextSearchLabelProvider extends LabelProvider { private AbstractTextSearchViewPage fPage; public TextSearchLabelProvider(AbstractTextSearchViewPage page) { fPage= page; } public final String getText(Object element) { int matchCount= fPage.getInput().getMatchCount(element); String text= doGetText(element); if (matchCount < 2) return text; else return text + " (" + matchCount + " matches)"; } protected abstract String doGetText(Object element); }
37,954
Bug 37954 Copying source folders deletes target folders [reorg] [ccp]
I have to Java projects, which I wanted to merge into one Java project. Both have the same source folder for Java source (project/src). - Right click on the Java source folder of the source project and select copy. - Right click on the target project and select paste The is a warning displayed "Target already has a folder 'src'. Overwrite?" and the option Yes/No/Cancel. When clicking Yes, a progress monitor is displayed that shows "deleting 'src'" The displayed warning doesn't they anything about that a target folder will be cleared before copying the new folder. This is NOT EXPECTED and WRONG BEHAVIOR. When copying a folder in the Windows Explorer and the target folder already exists, than Windows Explorer doesn't delete the target before copying. It simply adds the new files to the target folder. This is default behavior on every OS and on every File Manager. I expect Eclipse to behave the same way and not to delete the target folder before copying!!!
resolved fixed
b2351b4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T21:24:26Z
2003-05-22T05:06:40Z
org.eclipse.jdt.ui.tests.refactoring/test
37,954
Bug 37954 Copying source folders deletes target folders [reorg] [ccp]
I have to Java projects, which I wanted to merge into one Java project. Both have the same source folder for Java source (project/src). - Right click on the Java source folder of the source project and select copy. - Right click on the target project and select paste The is a warning displayed "Target already has a folder 'src'. Overwrite?" and the option Yes/No/Cancel. When clicking Yes, a progress monitor is displayed that shows "deleting 'src'" The displayed warning doesn't they anything about that a target folder will be cleared before copying the new folder. This is NOT EXPECTED and WRONG BEHAVIOR. When copying a folder in the Windows Explorer and the target folder already exists, than Windows Explorer doesn't delete the target before copying. It simply adds the new files to the target folder. This is default behavior on every OS and on every File Manager. I expect Eclipse to behave the same way and not to delete the target folder before copying!!!
resolved fixed
b2351b4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T21:24:26Z
2003-05-22T05:06:40Z
cases/org/eclipse/jdt/ui/tests/reorg/MockReorgQueries.java
37,954
Bug 37954 Copying source folders deletes target folders [reorg] [ccp]
I have to Java projects, which I wanted to merge into one Java project. Both have the same source folder for Java source (project/src). - Right click on the Java source folder of the source project and select copy. - Right click on the target project and select paste The is a warning displayed "Target already has a folder 'src'. Overwrite?" and the option Yes/No/Cancel. When clicking Yes, a progress monitor is displayed that shows "deleting 'src'" The displayed warning doesn't they anything about that a target folder will be cleared before copying the new folder. This is NOT EXPECTED and WRONG BEHAVIOR. When copying a folder in the Windows Explorer and the target folder already exists, than Windows Explorer doesn't delete the target before copying. It simply adds the new files to the target folder. This is default behavior on every OS and on every File Manager. I expect Eclipse to behave the same way and not to delete the target folder before copying!!!
resolved fixed
b2351b4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T21:24:26Z
2003-05-22T05:06:40Z
org.eclipse.jdt.ui/core
37,954
Bug 37954 Copying source folders deletes target folders [reorg] [ccp]
I have to Java projects, which I wanted to merge into one Java project. Both have the same source folder for Java source (project/src). - Right click on the Java source folder of the source project and select copy. - Right click on the target project and select paste The is a warning displayed "Target already has a folder 'src'. Overwrite?" and the option Yes/No/Cancel. When clicking Yes, a progress monitor is displayed that shows "deleting 'src'" The displayed warning doesn't they anything about that a target folder will be cleared before copying the new folder. This is NOT EXPECTED and WRONG BEHAVIOR. When copying a folder in the Windows Explorer and the target folder already exists, than Windows Explorer doesn't delete the target before copying. It simply adds the new files to the target folder. This is default behavior on every OS and on every File Manager. I expect Eclipse to behave the same way and not to delete the target folder before copying!!!
resolved fixed
b2351b4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T21:24:26Z
2003-05-22T05:06:40Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/IReorgQueries.java
37,954
Bug 37954 Copying source folders deletes target folders [reorg] [ccp]
I have to Java projects, which I wanted to merge into one Java project. Both have the same source folder for Java source (project/src). - Right click on the Java source folder of the source project and select copy. - Right click on the target project and select paste The is a warning displayed "Target already has a folder 'src'. Overwrite?" and the option Yes/No/Cancel. When clicking Yes, a progress monitor is displayed that shows "deleting 'src'" The displayed warning doesn't they anything about that a target folder will be cleared before copying the new folder. This is NOT EXPECTED and WRONG BEHAVIOR. When copying a folder in the Windows Explorer and the target folder already exists, than Windows Explorer doesn't delete the target before copying. It simply adds the new files to the target folder. This is default behavior on every OS and on every File Manager. I expect Eclipse to behave the same way and not to delete the target folder before copying!!!
resolved fixed
b2351b4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T21:24:26Z
2003-05-22T05:06:40Z
org.eclipse.jdt.ui/core
37,954
Bug 37954 Copying source folders deletes target folders [reorg] [ccp]
I have to Java projects, which I wanted to merge into one Java project. Both have the same source folder for Java source (project/src). - Right click on the Java source folder of the source project and select copy. - Right click on the target project and select paste The is a warning displayed "Target already has a folder 'src'. Overwrite?" and the option Yes/No/Cancel. When clicking Yes, a progress monitor is displayed that shows "deleting 'src'" The displayed warning doesn't they anything about that a target folder will be cleared before copying the new folder. This is NOT EXPECTED and WRONG BEHAVIOR. When copying a folder in the Windows Explorer and the target folder already exists, than Windows Explorer doesn't delete the target before copying. It simply adds the new files to the target folder. This is default behavior on every OS and on every File Manager. I expect Eclipse to behave the same way and not to delete the target folder before copying!!!
resolved fixed
b2351b4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T21:24:26Z
2003-05-22T05:06:40Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/OverwriteHelper.java
37,954
Bug 37954 Copying source folders deletes target folders [reorg] [ccp]
I have to Java projects, which I wanted to merge into one Java project. Both have the same source folder for Java source (project/src). - Right click on the Java source folder of the source project and select copy. - Right click on the target project and select paste The is a warning displayed "Target already has a folder 'src'. Overwrite?" and the option Yes/No/Cancel. When clicking Yes, a progress monitor is displayed that shows "deleting 'src'" The displayed warning doesn't they anything about that a target folder will be cleared before copying the new folder. This is NOT EXPECTED and WRONG BEHAVIOR. When copying a folder in the Windows Explorer and the target folder already exists, than Windows Explorer doesn't delete the target before copying. It simply adds the new files to the target folder. This is default behavior on every OS and on every File Manager. I expect Eclipse to behave the same way and not to delete the target folder before copying!!!
resolved fixed
b2351b4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T21:24:26Z
2003-05-22T05:06:40Z
org.eclipse.jdt.ui/core
37,954
Bug 37954 Copying source folders deletes target folders [reorg] [ccp]
I have to Java projects, which I wanted to merge into one Java project. Both have the same source folder for Java source (project/src). - Right click on the Java source folder of the source project and select copy. - Right click on the target project and select paste The is a warning displayed "Target already has a folder 'src'. Overwrite?" and the option Yes/No/Cancel. When clicking Yes, a progress monitor is displayed that shows "deleting 'src'" The displayed warning doesn't they anything about that a target folder will be cleared before copying the new folder. This is NOT EXPECTED and WRONG BEHAVIOR. When copying a folder in the Windows Explorer and the target folder already exists, than Windows Explorer doesn't delete the target before copying. It simply adds the new files to the target folder. This is default behavior on every OS and on every File Manager. I expect Eclipse to behave the same way and not to delete the target folder before copying!!!
resolved fixed
b2351b4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T21:24:26Z
2003-05-22T05:06:40Z
refactoring/org/eclipse/jdt/internal/corext/refactoring/reorg/ReorgPolicyFactory.java
37,954
Bug 37954 Copying source folders deletes target folders [reorg] [ccp]
I have to Java projects, which I wanted to merge into one Java project. Both have the same source folder for Java source (project/src). - Right click on the Java source folder of the source project and select copy. - Right click on the target project and select paste The is a warning displayed "Target already has a folder 'src'. Overwrite?" and the option Yes/No/Cancel. When clicking Yes, a progress monitor is displayed that shows "deleting 'src'" The displayed warning doesn't they anything about that a target folder will be cleared before copying the new folder. This is NOT EXPECTED and WRONG BEHAVIOR. When copying a folder in the Windows Explorer and the target folder already exists, than Windows Explorer doesn't delete the target before copying. It simply adds the new files to the target folder. This is default behavior on every OS and on every File Manager. I expect Eclipse to behave the same way and not to delete the target folder before copying!!!
resolved fixed
b2351b4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T21:24:26Z
2003-05-22T05:06:40Z
org.eclipse.jdt.ui/ui
37,954
Bug 37954 Copying source folders deletes target folders [reorg] [ccp]
I have to Java projects, which I wanted to merge into one Java project. Both have the same source folder for Java source (project/src). - Right click on the Java source folder of the source project and select copy. - Right click on the target project and select paste The is a warning displayed "Target already has a folder 'src'. Overwrite?" and the option Yes/No/Cancel. When clicking Yes, a progress monitor is displayed that shows "deleting 'src'" The displayed warning doesn't they anything about that a target folder will be cleared before copying the new folder. This is NOT EXPECTED and WRONG BEHAVIOR. When copying a folder in the Windows Explorer and the target folder already exists, than Windows Explorer doesn't delete the target before copying. It simply adds the new files to the target folder. This is default behavior on every OS and on every File Manager. I expect Eclipse to behave the same way and not to delete the target folder before copying!!!
resolved fixed
b2351b4
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-06T21:24:26Z
2003-05-22T05:06:40Z
refactoring/org/eclipse/jdt/internal/ui/refactoring/reorg/ReorgQueries.java
57,036
Bug 57036 New Search shows annotations in internal jar (for matches in class file)
3.0 M8 - import org.junit as binary plug-in project - search for references to type "TestListener" - select the library junit.jar - from context menu, choose Open With > Text Editor -> invalid "matches" are shown in the editor Problem is probably in JavaSearchResult#getFile(Object), which should not getUnderlyingResource() for JavaElements not in a ICompilationUnit.
resolved fixed
b7f20c0
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-07T08:21:52Z
2004-04-01T14:33:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchResult.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.search; import java.text.MessageFormat; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IParent; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.javaeditor.IClassFileEditorInput; import org.eclipse.jdt.ui.search.IMatchPresentation; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.search.ui.ISearchQuery; import org.eclipse.search.ui.text.AbstractTextSearchResult; import org.eclipse.search.ui.text.IEditorMatchAdapter; import org.eclipse.search.ui.text.IFileMatchAdapter; import org.eclipse.search.ui.text.Match; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IFileEditorInput; public class JavaSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter { private JavaSearchQuery fQuery; private Map fElementsToParticipants; public JavaSearchResult(JavaSearchQuery query) { fQuery= query; fElementsToParticipants= new HashMap(); } public ImageDescriptor getImageDescriptor() { return fQuery.getImageDescriptor(); } /* (non-Javadoc) * @see org.eclipse.search.ui.ISearchCategory#getText(org.eclipse.search.core.basic.ITextSearchResult) */ public String getLabel() { int matchCount= getMatchCount(); String format= null; if (matchCount == 1) return fQuery.getSingularLabel(); else format= fQuery.getPluralLabelPattern(); return MessageFormat.format(format, new Object[] { new Integer(matchCount) }); } public String getTooltip() { return getLabel(); } public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) { IEditorInput editorInput= editor.getEditorInput(); if (editorInput instanceof IFileEditorInput) { IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput; return computeContainedMatches(result, fileEditorInput.getFile()); } else if (editorInput instanceof IClassFileEditorInput) { IClassFileEditorInput classFileEditorInput= (IClassFileEditorInput) editorInput; Set matches= new HashSet(); collectMatches(matches, classFileEditorInput.getClassFile()); return (Match[]) matches.toArray(new Match[matches.size()]); } return null; } public Match[] computeContainedMatches(AbstractTextSearchResult result, IFile file) { IJavaElement javaElement= JavaCore.create(file); Set matches= new HashSet(); collectMatches(matches, javaElement); return (Match[]) matches.toArray(new Match[matches.size()]); } private void collectMatches(Set matches, IJavaElement element) { Match[] m= getMatches(element); if (m.length != 0) { for (int i= 0; i < m.length; i++) { matches.add(m[i]); } } if (element instanceof IParent) { IParent parent= (IParent) element; try { IJavaElement[] children= parent.getChildren(); for (int i= 0; i < children.length; i++) { collectMatches(matches, children[i]); } } catch (JavaModelException e) { // we will not be tracking these results } } } /* (non-Javadoc) * @see org.eclipse.search.ui.ISearchResultCategory#getFile(java.lang.Object) */ public IFile getFile(Object element) { if (element instanceof IJavaElement) { IJavaElement javaElement= (IJavaElement) element; try { element= javaElement.getUnderlyingResource(); } catch (JavaModelException e) { // we can't get a resource for this. } } if (element instanceof IFile) return (IFile)element; return null; } /* (non-Javadoc) * @see org.eclipse.search2.ui.text.IStructureProvider#isShownInEditor(org.eclipse.search2.ui.text.Match, org.eclipse.ui.IEditorPart) */ public boolean isShownInEditor(Match match, IEditorPart editor) { IEditorInput editorInput= editor.getEditorInput(); if (match.getElement() instanceof IJavaElement) { IJavaElement je= (IJavaElement) match.getElement(); if (editorInput instanceof IFileEditorInput) { IFile inputFile= ((IFileEditorInput)editorInput).getFile(); IResource matchFile= null; ICompilationUnit cu= (ICompilationUnit) je.getAncestor(IJavaElement.COMPILATION_UNIT); if (cu != null) { matchFile= cu.getResource(); } else { IClassFile cf= (IClassFile) je.getAncestor(IJavaElement.CLASS_FILE); if (cf != null) matchFile= cf.getResource(); } if (matchFile != null) return inputFile.equals(matchFile); else return false; } else if (editorInput instanceof IClassFileEditorInput) { return ((IClassFileEditorInput)editorInput).getClassFile().equals(je.getAncestor(IJavaElement.CLASS_FILE)); } } else if (match.getElement() instanceof IFile) { if (editorInput instanceof IFileEditorInput) { return ((IFileEditorInput)editorInput).getFile().equals(match.getElement()); } } return false; } /* (non-Javadoc) * @see org.eclipse.search.ui.ISearchResult#getQuery() */ public ISearchQuery getQuery() { return fQuery; } synchronized IMatchPresentation getSearchParticpant(Object element) { return (IMatchPresentation) fElementsToParticipants.get(element); } boolean addMatch(Match match, IMatchPresentation participant) { Object element= match.getElement(); if (fElementsToParticipants.get(element) != null) { // TODO must access the participant id / label to properly report the error. JavaPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, JavaPlugin.getPluginId(), 0, "A second search participant was found for an element", null)); //$NON-NLS-1$ return false; } fElementsToParticipants.put(element, participant); addMatch(match); return true; } public void removeAll() { synchronized(this) { fElementsToParticipants.clear(); } super.removeAll(); } public void removeMatch(Match match) { synchronized(this) { if (getMatchCount(match.getElement()) == 1) fElementsToParticipants.remove(match.getElement()); } super.removeMatch(match); } public IFileMatchAdapter getFileMatchAdapter() { return this; } public IEditorMatchAdapter getEditorMatchAdapter() { return this; } }
38,089
Bug 38089 Suggest 'Add exception to supertype' when overriden method has more exceptions than superclass [quick assist]
If I have the two classes: public class A { public void method() { } } public class B extends A { public void method() throws Wobbly { } } then I (obviously) get a compile time error. However, it would be useful if the suggestion list (currently empty) could add options o Add exception to superclass implementation o Surround internally with try/catch You would then end up with (either): public class A { public void method() throws Wobbly { } } public class B extends A { public void method() throws Wobbly { } } or public class A { public void method() { } } public class B extends A { public void method() { try { } catch (Wobbly w) { // use uncaught exception code generation } } } Both would be useful options, but I'd recommend that adding an exception to the superclass' implementation is the preferred one of the two, in much the same way that the preferred unhandled exception is to declare a throws rather than a try/catch
resolved fixed
748ed52
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-07T08:37:54Z
2003-05-25T10:53:20Z
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/TypeMismatchQuickFixTests.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.tests.quickfix; import java.util.ArrayList; import java.util.Hashtable; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.tests.core.ProjectTestSetup; import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal; public class TypeMismatchQuickFixTests extends QuickFixTest { private static final Class THIS= TypeMismatchQuickFixTests.class; private IJavaProject fJProject1; private IPackageFragmentRoot fSourceFolder; public TypeMismatchQuickFixTests(String name) { super(name); } public static Test allTests() { return new ProjectTestSetup(new TestSuite(THIS)); } public static Test suite() { if (true) { return allTests(); } else { TestSuite suite= new TestSuite(); suite.addTest(new TypeMismatchQuickFixTests("testTypeMismatchForInterface2")); return new ProjectTestSetup(suite); } } protected void setUp() throws Exception { Hashtable options= JavaCore.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, String.valueOf(99)); options.put(JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER, JavaCore.ERROR); JavaCore.setOptions(options); IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); JavaPlugin.getDefault().getCodeTemplateStore().findTemplate(CodeTemplateContextType.CATCHBLOCK).setPattern(""); JavaPlugin.getDefault().getCodeTemplateStore().findTemplate(CodeTemplateContextType.CONSTRUCTORSTUB).setPattern(""); JavaPlugin.getDefault().getCodeTemplateStore().findTemplate(CodeTemplateContextType.METHODSTUB).setPattern(""); fJProject1= ProjectTestSetup.getProject(); fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src"); } protected void tearDown() throws Exception { JavaProjectHelper.clear(fJProject1, ProjectTestSetup.getDefaultClasspath()); } public void testTypeMismatchInVarDecl() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Object o) {\n"); buf.append(" Thread th= o;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Object o) {\n"); buf.append(" Thread th= (Thread) o;\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Object o) {\n"); buf.append(" Object th= o;\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Thread o) {\n"); buf.append(" Thread th= o;\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testTypeMismatchInVarDecl2() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.List;\n"); buf.append("public class Container {\n"); buf.append(" public List[] getLists() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("Container.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.ArrayList;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Container c) {\n"); buf.append(" ArrayList[] lists= c.getLists();\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.ArrayList;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Container c) {\n"); buf.append(" ArrayList[] lists= (ArrayList[]) c.getLists();\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.ArrayList;\n"); buf.append("import java.util.List;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Container c) {\n"); buf.append(" List[] lists= c.getLists();\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.ArrayList;\n"); buf.append("import java.util.List;\n"); buf.append("public class Container {\n"); buf.append(" public ArrayList[] getLists() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testTypeMismatchInVarDecl3() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" Thread th= foo();\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 0); } public void testTypeMismatchInVarDecl4() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.List;\n"); buf.append("public class Container {\n"); buf.append(" public List getLists()[] {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("Container.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.ArrayList;\n"); buf.append("public class E extends Container {\n"); buf.append(" public void foo() {\n"); buf.append(" ArrayList[] lists= super.getLists();\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.ArrayList;\n"); buf.append("public class E extends Container {\n"); buf.append(" public void foo() {\n"); buf.append(" ArrayList[] lists= (ArrayList[]) super.getLists();\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.ArrayList;\n"); buf.append("import java.util.List;\n"); buf.append("public class E extends Container {\n"); buf.append(" public void foo() {\n"); buf.append(" List[] lists= super.getLists();\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.ArrayList;\n"); buf.append("import java.util.List;\n"); buf.append("public class Container {\n"); buf.append(" public ArrayList[] getLists() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testTypeMismatchForInterface1() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class Container {\n"); buf.append(" public static Container getContainer() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("Container.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.List;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" List list= Container.getContainer();\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 4); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.List;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" Container list= Container.getContainer();\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.List;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" List list= (List) Container.getContainer();\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("import java.util.List;\n"); buf.append("\n"); buf.append("public class Container {\n"); buf.append(" public static List getContainer() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(3); String preview4= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("import java.util.List;\n"); buf.append("\n"); buf.append("public class Container implements List {\n"); buf.append(" public static Container getContainer() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); String expected4= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3, preview4 }, new String[] { expected1, expected2, expected3, expected4 }); } public void testTypeMismatchForInterface2() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class Container {\n"); buf.append(" public static Container getContainer() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("Container.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Collections;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" Collections.reverse(Container.getContainer());\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Collections;\n"); buf.append("import java.util.List;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" Collections.reverse((List) Container.getContainer());\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("import java.util.List;\n"); buf.append("\n"); buf.append("public class Container {\n"); buf.append(" public static List getContainer() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("import java.util.List;\n"); buf.append("\n"); buf.append("public class Container implements List {\n"); buf.append(" public static Container getContainer() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testTypeMismatchInFieldDecl() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" int time= System.currentTimeMillis();\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" int time= (int) System.currentTimeMillis();\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" long time= System.currentTimeMillis();\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } public void testTypeMismatchInAssignment() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Iterator;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Iterator iter) {\n"); buf.append(" String str;\n"); buf.append(" str= iter.next();\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Iterator;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Iterator iter) {\n"); buf.append(" String str;\n"); buf.append(" str= (String) iter.next();\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Iterator;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Iterator iter) {\n"); buf.append(" Object str;\n"); buf.append(" str= iter.next();\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } public void testTypeMismatchInAssignment2() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Iterator;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Iterator iter) {\n"); buf.append(" String str, str2;\n"); buf.append(" str= iter.next();\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Iterator;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Iterator iter) {\n"); buf.append(" String str, str2;\n"); buf.append(" str= (String) iter.next();\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Iterator;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Iterator iter) {\n"); buf.append(" String str2;\n"); buf.append(" Object str;\n"); buf.append(" str= iter.next();\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } public void testTypeMismatchInExpression() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.List;\n"); buf.append("public class E {\n"); buf.append(" public String[] foo(List list) {\n"); buf.append(" return list.toArray(new List[list.size()]);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.List;\n"); buf.append("public class E {\n"); buf.append(" public String[] foo(List list) {\n"); buf.append(" return (String[]) list.toArray(new List[list.size()]);\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.List;\n"); buf.append("public class E {\n"); buf.append(" public Object[] foo(List list) {\n"); buf.append(" return list.toArray(new List[list.size()]);\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } public void testCastOnCastExpression() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.ArrayList;\n"); buf.append("import java.util.List;\n"); buf.append("public class E {\n"); buf.append(" public void foo(List list) {\n"); buf.append(" ArrayList a= (Cloneable) list;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.ArrayList;\n"); buf.append("import java.util.List;\n"); buf.append("public class E {\n"); buf.append(" public void foo(List list) {\n"); buf.append(" ArrayList a= (ArrayList) list;\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.ArrayList;\n"); buf.append("import java.util.List;\n"); buf.append("public class E {\n"); buf.append(" public void foo(List list) {\n"); buf.append(" Cloneable a= (Cloneable) list;\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } public void testMismatchingReturnType1() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class Base {\n"); buf.append(" public String getName() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("Base.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E extends Base {\n"); buf.append(" public char[] getName() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E extends Base {\n"); buf.append(" public String getName() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class Base {\n"); buf.append(" public char[] getName() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } public void testMismatchingReturnType2() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.List;\n"); buf.append("public interface IBase {\n"); buf.append(" List getCollection();\n"); buf.append("}\n"); pack1.createCompilationUnit("IBase.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E implements IBase {\n"); buf.append(" public String[] getCollection() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("import java.util.List;\n"); buf.append("\n"); buf.append("public class E implements IBase {\n"); buf.append(" public List getCollection() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.List;\n"); buf.append("public interface IBase {\n"); buf.append(" String[] getCollection();\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } }
38,089
Bug 38089 Suggest 'Add exception to supertype' when overriden method has more exceptions than superclass [quick assist]
If I have the two classes: public class A { public void method() { } } public class B extends A { public void method() throws Wobbly { } } then I (obviously) get a compile time error. However, it would be useful if the suggestion list (currently empty) could add options o Add exception to superclass implementation o Surround internally with try/catch You would then end up with (either): public class A { public void method() throws Wobbly { } } public class B extends A { public void method() throws Wobbly { } } or public class A { public void method() { } } public class B extends A { public void method() { try { } catch (Wobbly w) { // use uncaught exception code generation } } } Both would be useful options, but I'd recommend that adding an exception to the superclass' implementation is the preferred one of the two, in much the same way that the preferred unhandled exception is to declare a throws rather than a try/catch
resolved fixed
748ed52
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-07T08:37:54Z
2003-05-25T10:53:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ChangeMethodSignatureProposal.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.correction; import java.util.ArrayList; import java.util.List; import org.eclipse.core.runtime.CoreException; import org.eclipse.swt.graphics.Image; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.NamingConventions; import org.eclipse.jdt.core.dom.*; import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; import org.eclipse.jdt.core.dom.rewrite.ListRewrite; import org.eclipse.jdt.internal.corext.codemanipulation.ImportRewrite; import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory; import org.eclipse.jdt.internal.corext.dom.ASTNodes; import org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer; public class ChangeMethodSignatureProposal extends LinkedCorrectionProposal { public static interface ChangeDescription { } public static class SwapDescription implements ChangeDescription { int index; public SwapDescription(int index) { this.index= index; } } public static class RemoveDescription implements ChangeDescription { } private static class ModifyDescription implements ChangeDescription { String name; ITypeBinding type; SingleVariableDeclaration resultingNode; public ModifyDescription(ITypeBinding type, String name) { this.type= type; this.name= name; } } public static class EditDescription extends ModifyDescription { public EditDescription(ITypeBinding type, String name) { super(type, name); } } public static class InsertDescription extends ModifyDescription { public InsertDescription(ITypeBinding type, String name) { super(type, name); } } private ASTNode fInvocationNode; private IMethodBinding fSenderBinding; private ChangeDescription[] fParameterChanges; public ChangeMethodSignatureProposal(String label, ICompilationUnit targetCU, ASTNode invocationNode, IMethodBinding binding, ChangeDescription[] changes, int relevance, Image image) { super(label, targetCU, null, relevance, image); fInvocationNode= invocationNode; fSenderBinding= binding; fParameterChanges= changes; } protected ASTRewrite getRewrite() throws CoreException { CompilationUnit astRoot= (CompilationUnit) fInvocationNode.getRoot(); ASTNode methodDecl= astRoot.findDeclaringNode(fSenderBinding); ASTNode newMethodDecl= null; boolean isInDifferentCU; if (methodDecl != null) { isInDifferentCU= false; newMethodDecl= methodDecl; } else { isInDifferentCU= true; ASTParser astParser= ASTParser.newParser(AST.JLS2); astParser.setSource(getCompilationUnit()); astParser.setResolveBindings(true); astRoot= (CompilationUnit) astParser.createAST(null); newMethodDecl= astRoot.findDeclaringNode(fSenderBinding.getKey()); } if (newMethodDecl instanceof MethodDeclaration) { ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST()); modifySignature(rewrite, (MethodDeclaration) newMethodDecl, isInDifferentCU); return rewrite; } return null; } private void modifySignature(ASTRewrite rewrite, MethodDeclaration methodDecl, boolean isInDifferentCU) throws CoreException { AST ast= methodDecl.getAST(); ArrayList usedNames= new ArrayList(); boolean hasCreatedVariables= false; IVariableBinding[] declaredFields= fSenderBinding.getDeclaringClass().getDeclaredFields(); for (int i= 0; i < declaredFields.length; i++) { // avoid to take parameter names that are equal to field names usedNames.add(declaredFields[i].getName()); } ImportRewrite imports= getImportRewrite(); ListRewrite listRewrite= rewrite.getListRewrite(methodDecl, MethodDeclaration.PARAMETERS_PROPERTY); List parameters= methodDecl.parameters(); // old parameters int k= 0; // index over the oldParameters for (int i= 0; i < fParameterChanges.length; i++) { ChangeDescription curr= fParameterChanges[i]; if (curr == null) { SingleVariableDeclaration oldParam= (SingleVariableDeclaration) parameters.get(k); usedNames.add(oldParam.getName().getIdentifier()); k++; } else if (curr instanceof InsertDescription) { InsertDescription desc= (InsertDescription) curr; SingleVariableDeclaration newNode= ast.newSingleVariableDeclaration(); String type= imports.addImport(desc.type); newNode.setType(ASTNodeFactory.newType(ast, type)); // remember to set name later desc.resultingNode= newNode; hasCreatedVariables= true; listRewrite.insertAt(newNode, i, null); } else if (curr instanceof RemoveDescription) { listRewrite.remove((ASTNode) parameters.get(k), null); k++; } else if (curr instanceof EditDescription) { EditDescription desc= (EditDescription) curr; SingleVariableDeclaration newNode= ast.newSingleVariableDeclaration(); String type= imports.addImport(desc.type); newNode.setType(ASTNodeFactory.newType(ast, type)); // remember to set name later desc.resultingNode= newNode; hasCreatedVariables= true; listRewrite.replace((ASTNode) parameters.get(k), newNode, null); k++; } else if (curr instanceof SwapDescription) { SingleVariableDeclaration decl1= (SingleVariableDeclaration) parameters.get(k); SingleVariableDeclaration decl2= (SingleVariableDeclaration) parameters.get(((SwapDescription) curr).index); rewrite.replace(decl1, rewrite.createCopyTarget(decl2), null); rewrite.replace(decl2, rewrite.createCopyTarget(decl1), null); usedNames.add(decl1.getName().getIdentifier()); k++; } } if (!hasCreatedVariables) { return; } if (methodDecl.getBody() != null) { // avoid take a name of a local variable inside CompilationUnit root= (CompilationUnit) methodDecl.getRoot(); IBinding[] bindings= (new ScopeAnalyzer(root)).getDeclarationsAfter(methodDecl.getBody().getStartPosition(), ScopeAnalyzer.VARIABLES); for (int i= 0; i < bindings.length; i++) { usedNames.add(bindings[i].getName()); } } fixupNames(rewrite, usedNames, isInDifferentCU); } private void fixupNames(ASTRewrite rewrite, ArrayList usedNames, boolean isInDifferentCU) { AST ast= rewrite.getAST(); // set names for new parameters for (int i= 0; i < fParameterChanges.length; i++) { ChangeDescription curr= fParameterChanges[i]; if (curr instanceof ModifyDescription) { ModifyDescription desc= (ModifyDescription) curr; SingleVariableDeclaration var= desc.resultingNode; String suggestedName= desc.name; String typeKey= "param_type_" + i; //$NON-NLS-1$ String nameKey= "param_name_" + i; //$NON-NLS-1$ // collect name suggestions String favourite= null; String[] excludedNames= (String[]) usedNames.toArray(new String[usedNames.size()]); if (suggestedName != null) { favourite= StubUtility.suggestArgumentName(getCompilationUnit().getJavaProject(), suggestedName, excludedNames); addLinkedPositionProposal(nameKey, favourite, null); } Type type= var.getType(); int dim= 0; if (type.isArrayType()) { dim= ((ArrayType) type).getDimensions(); type= ((ArrayType) type).getElementType(); } String[] suggestedNames= NamingConventions.suggestArgumentNames(getCompilationUnit().getJavaProject(), "", ASTNodes.asString(type), dim, excludedNames); //$NON-NLS-1$ for (int k= 0; k < suggestedNames.length; k++) { addLinkedPositionProposal(nameKey, suggestedNames[k], null); } if (favourite == null) { favourite= suggestedNames[0]; } var.setName(ast.newSimpleName(favourite)); usedNames.add(favourite); // collect type suggestions ITypeBinding[] bindings= ASTResolving.getRelaxingTypes(ast, desc.type); for (int k= 0; k < bindings.length; k++) { addLinkedPositionProposal(typeKey, bindings[k]); } addLinkedPosition(rewrite.track(var.getType()), false, typeKey); addLinkedPosition(rewrite.track(var.getName()), false, nameKey); } } } }
38,089
Bug 38089 Suggest 'Add exception to supertype' when overriden method has more exceptions than superclass [quick assist]
If I have the two classes: public class A { public void method() { } } public class B extends A { public void method() throws Wobbly { } } then I (obviously) get a compile time error. However, it would be useful if the suggestion list (currently empty) could add options o Add exception to superclass implementation o Surround internally with try/catch You would then end up with (either): public class A { public void method() throws Wobbly { } } public class B extends A { public void method() throws Wobbly { } } or public class A { public void method() { } } public class B extends A { public void method() { try { } catch (Wobbly w) { // use uncaught exception code generation } } } Both would be useful options, but I'd recommend that adding an exception to the superclass' implementation is the preferred one of the two, in much the same way that the preferred unhandled exception is to declare a throws rather than a try/catch
resolved fixed
748ed52
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-07T08:37:54Z
2003-05-25T10:53:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/QuickFixProcessor.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.correction; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import org.eclipse.core.runtime.CoreException; import org.eclipse.jdt.core.IBuffer; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.compiler.IProblem; import org.eclipse.jdt.ui.text.java.IInvocationContext; import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal; import org.eclipse.jdt.ui.text.java.IProblemLocation; import org.eclipse.jdt.ui.text.java.IQuickFixProcessor; /** */ public class QuickFixProcessor implements IQuickFixProcessor { public boolean hasCorrections(ICompilationUnit cu, int problemId) { switch (problemId) { case IProblem.UnterminatedString: case IProblem.UnusedImport: case IProblem.DuplicateImport: case IProblem.CannotImportPackage: case IProblem.ConflictingImport: case IProblem.ImportNotFound: case IProblem.UndefinedMethod: case IProblem.UndefinedConstructor: case IProblem.ParameterMismatch: case IProblem.MethodButWithConstructorName: case IProblem.UndefinedField: case IProblem.UndefinedName: case IProblem.PublicClassMustMatchFileName: case IProblem.PackageIsNotExpectedPackage: case IProblem.UndefinedType: case IProblem.FieldTypeNotFound: case IProblem.ArgumentTypeNotFound: case IProblem.ReturnTypeNotFound: case IProblem.SuperclassNotFound: case IProblem.ExceptionTypeNotFound: case IProblem.InterfaceNotFound: case IProblem.TypeMismatch: case IProblem.UnhandledException: case IProblem.UnreachableCatch: case IProblem.InvalidCatchBlockSequence: case IProblem.VoidMethodReturnsValue: case IProblem.ShouldReturnValue: case IProblem.MissingReturnType: case IProblem.NonExternalizedStringLiteral: case IProblem.NonStaticAccessToStaticField: case IProblem.NonStaticAccessToStaticMethod: case IProblem.StaticMethodRequested: case IProblem.NonStaticFieldFromStaticInvocation: case IProblem.InstanceMethodDuringConstructorInvocation: case IProblem.InstanceFieldDuringConstructorInvocation: case IProblem.NotVisibleMethod: case IProblem.NotVisibleConstructor: case IProblem.NotVisibleType: case IProblem.SuperclassNotVisible: case IProblem.InterfaceNotVisible: case IProblem.FieldTypeNotVisible: case IProblem.ArgumentTypeNotVisible: case IProblem.ReturnTypeNotVisible: case IProblem.ExceptionTypeNotVisible: case IProblem.NotVisibleField: case IProblem.ImportNotVisible: case IProblem.BodyForAbstractMethod: case IProblem.AbstractMethodInAbstractClass: case IProblem.AbstractMethodMustBeImplemented: case IProblem.BodyForNativeMethod: case IProblem.OuterLocalMustBeFinal: case IProblem.UninitializedLocalVariable: case IProblem.UndefinedConstructorInDefaultConstructor: case IProblem.UnhandledExceptionInDefaultConstructor: case IProblem.NotVisibleConstructorInDefaultConstructor: case IProblem.FieldTypeAmbiguous: case IProblem.ArgumentTypeAmbiguous: case IProblem.ExceptionTypeAmbiguous: case IProblem.ReturnTypeAmbiguous: case IProblem.SuperclassAmbiguous: case IProblem.InterfaceAmbiguous: case IProblem.AmbiguousType: case IProblem.UnusedPrivateMethod: case IProblem.UnusedPrivateConstructor: case IProblem.UnusedPrivateField: case IProblem.UnusedPrivateType: case IProblem.LocalVariableIsNeverUsed: case IProblem.ArgumentIsNeverUsed: case IProblem.MethodRequiresBody: case IProblem.NeedToEmulateFieldReadAccess: case IProblem.NeedToEmulateFieldWriteAccess: case IProblem.NeedToEmulateMethodAccess: case IProblem.NeedToEmulateConstructorAccess: case IProblem.SuperfluousSemicolon: case IProblem.UnnecessaryCast: case IProblem.UnnecessaryArgumentCast: case IProblem.UnnecessaryInstanceof: case IProblem.IndirectAccessToStaticField: case IProblem.IndirectAccessToStaticMethod: case IProblem.Task: case IProblem.UnusedMethodDeclaredThrownException: case IProblem.UnusedConstructorDeclaredThrownException: case IProblem.UnqualifiedFieldAccess: case IProblem.JavadocMissing: case IProblem.JavadocMissingParamTag: case IProblem.JavadocMissingReturnTag: case IProblem.JavadocMissingThrowsTag: case IProblem.JavadocUndefinedType: case IProblem.JavadocAmbiguousType: case IProblem.JavadocNotVisibleType: case IProblem.NonBlankFinalLocalAssignment: case IProblem.DuplicateFinalLocalInitialization: case IProblem.FinalFieldAssignment: case IProblem.DuplicateBlankFinalFieldInitialization: case IProblem.AnonymousClassCannotExtendFinalClass: case IProblem.ClassExtendFinalClass: case IProblem.FinalMethodCannotBeOverridden: case IProblem.InheritedMethodReducesVisibility: case IProblem.MethodReducesVisibility: case IProblem.OverridingNonVisibleMethod: case IProblem.CannotOverrideAStaticMethodWithAnInstanceMethod: case IProblem.CannotHideAnInstanceMethodWithAStaticMethod: case IProblem.LocalVariableHidingLocalVariable: case IProblem.LocalVariableHidingField: case IProblem.FieldHidingLocalVariable: case IProblem.FieldHidingField: case IProblem.ArgumentHidingLocalVariable: case IProblem.ArgumentHidingField: case IProblem.IllegalModifierForInterfaceMethod: case IProblem.IllegalModifierForInterface: case IProblem.IllegalModifierForClass: case IProblem.IllegalModifierForInterfaceField: case IProblem.IllegalModifierForMemberInterface: case IProblem.IllegalModifierForMemberClass: case IProblem.IllegalModifierForLocalClass: case IProblem.IllegalModifierForArgument: case IProblem.IllegalModifierForField: case IProblem.IllegalModifierForMethod: case IProblem.IllegalModifierForVariable: case IProblem.IllegalVisibilityModifierForInterfaceMemberType: case IProblem.IncompatibleReturnType: return true; default: return false; } } private static int moveBack(int offset, int start, String ignoreCharacters, ICompilationUnit cu) { try { IBuffer buf= cu.getBuffer(); while (offset >= start) { if (ignoreCharacters.indexOf(buf.getChar(offset - 1)) == -1) { //$NON-NLS-1$ return offset; } offset--; } } catch(JavaModelException e) { } return start; } /* (non-Javadoc) * @see IAssistProcessor#getCorrections(org.eclipse.jdt.internal.ui.text.correction.IAssistContext, org.eclipse.jdt.internal.ui.text.correction.IProblemLocation[]) */ public IJavaCompletionProposal[] getCorrections(IInvocationContext context, IProblemLocation[] locations) throws CoreException { if (locations == null || locations.length == 0) { return null; } HashSet handledProblems= new HashSet(locations.length); ArrayList resultingCollections= new ArrayList(); for (int i= 0; i < locations.length; i++) { IProblemLocation curr= locations[i]; Integer id= new Integer(curr.getProblemId()); if (handledProblems.add(id)) { process(context, curr, resultingCollections); } } return (IJavaCompletionProposal[]) resultingCollections.toArray(new IJavaCompletionProposal[resultingCollections.size()]); } private void process(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException { int id= problem.getProblemId(); if (id == 0) { // no proposals for none-problem locations return; } switch (id) { case IProblem.UnterminatedString: String quoteLabel= CorrectionMessages.getString("JavaCorrectionProcessor.addquote.description"); //$NON-NLS-1$ int pos= moveBack(problem.getOffset() + problem.getLength(), problem.getOffset(), "\n\r", context.getCompilationUnit()); //$NON-NLS-1$ proposals.add(new ReplaceCorrectionProposal(quoteLabel, context.getCompilationUnit(), pos, 0, "\"", 0)); //$NON-NLS-1$ break; case IProblem.UnusedImport: case IProblem.DuplicateImport: case IProblem.CannotImportPackage: case IProblem.ConflictingImport: ReorgCorrectionsSubProcessor.removeImportStatementProposals(context, problem, proposals); break; case IProblem.ImportNotFound: ReorgCorrectionsSubProcessor.importNotFoundProposals(context, problem, proposals); ReorgCorrectionsSubProcessor.removeImportStatementProposals(context, problem, proposals); break; case IProblem.UndefinedMethod: UnresolvedElementsSubProcessor.getMethodProposals(context, problem, false, proposals); break; case IProblem.UndefinedConstructor: UnresolvedElementsSubProcessor.getConstructorProposals(context, problem, proposals); break; case IProblem.ParameterMismatch: UnresolvedElementsSubProcessor.getMethodProposals(context, problem, true, proposals); break; case IProblem.MethodButWithConstructorName: ReturnTypeSubProcessor.addMethodWithConstrNameProposals(context, problem, proposals); break; case IProblem.UndefinedField: case IProblem.UndefinedName: UnresolvedElementsSubProcessor.getVariableProposals(context, problem, proposals); break; case IProblem.FieldTypeAmbiguous: case IProblem.ArgumentTypeAmbiguous: case IProblem.ExceptionTypeAmbiguous: case IProblem.ReturnTypeAmbiguous: case IProblem.SuperclassAmbiguous: case IProblem.InterfaceAmbiguous: case IProblem.AmbiguousType: case IProblem.JavadocAmbiguousType: UnresolvedElementsSubProcessor.getAmbiguosTypeReferenceProposals(context, problem, proposals); break; case IProblem.PublicClassMustMatchFileName: ReorgCorrectionsSubProcessor.getWrongTypeNameProposals(context, problem, proposals); break; case IProblem.PackageIsNotExpectedPackage: ReorgCorrectionsSubProcessor.getWrongPackageDeclNameProposals(context, problem, proposals); break; case IProblem.UndefinedType: case IProblem.FieldTypeNotFound: case IProblem.ArgumentTypeNotFound: case IProblem.ReturnTypeNotFound: case IProblem.SuperclassNotFound: case IProblem.ExceptionTypeNotFound: case IProblem.InterfaceNotFound: case IProblem.JavadocUndefinedType: UnresolvedElementsSubProcessor.getTypeProposals(context, problem, proposals); break; case IProblem.TypeMismatch: TypeMismatchSubProcessor.addTypeMismatchProposals(context, problem, proposals); break; case IProblem.IncompatibleReturnType: TypeMismatchSubProcessor.addIncompatibleReturnTypeProposals(context, problem, proposals); break; case IProblem.UnhandledException: LocalCorrectionsSubProcessor.addUncaughtExceptionProposals(context, problem, proposals); break; case IProblem.UnreachableCatch: case IProblem.InvalidCatchBlockSequence: LocalCorrectionsSubProcessor.addUnreachableCatchProposals(context, problem, proposals); break; case IProblem.VoidMethodReturnsValue: ReturnTypeSubProcessor.addVoidMethodReturnsProposals(context, problem, proposals); break; case IProblem.MissingReturnType: ReturnTypeSubProcessor.addMissingReturnTypeProposals(context, problem, proposals); break; case IProblem.ShouldReturnValue: ReturnTypeSubProcessor.addMissingReturnStatementProposals(context, problem, proposals); break; case IProblem.NonExternalizedStringLiteral: LocalCorrectionsSubProcessor.addNLSProposals(context, problem, proposals); break; case IProblem.NonStaticAccessToStaticField: case IProblem.NonStaticAccessToStaticMethod: case IProblem.IndirectAccessToStaticField: case IProblem.IndirectAccessToStaticMethod: LocalCorrectionsSubProcessor.addCorrectAccessToStaticProposals(context, problem, proposals); break; case IProblem.StaticMethodRequested: case IProblem.NonStaticFieldFromStaticInvocation: case IProblem.InstanceMethodDuringConstructorInvocation: case IProblem.InstanceFieldDuringConstructorInvocation: ModifierCorrectionSubProcessor.addNonAccessibleReferenceProposal(context, problem, proposals, ModifierCorrectionSubProcessor.TO_STATIC, 5); break; case IProblem.NonBlankFinalLocalAssignment: case IProblem.DuplicateFinalLocalInitialization: case IProblem.FinalFieldAssignment: case IProblem.DuplicateBlankFinalFieldInitialization: case IProblem.AnonymousClassCannotExtendFinalClass: case IProblem.ClassExtendFinalClass: ModifierCorrectionSubProcessor.addNonAccessibleReferenceProposal(context, problem, proposals, ModifierCorrectionSubProcessor.TO_NON_FINAL, 9); break; case IProblem.InheritedMethodReducesVisibility: case IProblem.MethodReducesVisibility: case IProblem.OverridingNonVisibleMethod: ModifierCorrectionSubProcessor.addChangeOverriddenModfierProposal(context, problem, proposals, ModifierCorrectionSubProcessor.TO_VISIBLE); break; case IProblem.FinalMethodCannotBeOverridden: ModifierCorrectionSubProcessor.addChangeOverriddenModfierProposal(context, problem, proposals, ModifierCorrectionSubProcessor.TO_NON_FINAL); break; case IProblem.CannotOverrideAStaticMethodWithAnInstanceMethod: ModifierCorrectionSubProcessor.addChangeOverriddenModfierProposal(context, problem, proposals, ModifierCorrectionSubProcessor.TO_NON_STATIC); break; case IProblem.CannotHideAnInstanceMethodWithAStaticMethod: case IProblem.IllegalModifierForInterfaceMethod: case IProblem.IllegalModifierForInterface: case IProblem.IllegalModifierForClass: case IProblem.IllegalModifierForInterfaceField: case IProblem.IllegalModifierForMemberInterface: case IProblem.IllegalModifierForMemberClass: case IProblem.IllegalModifierForLocalClass: case IProblem.IllegalModifierForArgument: case IProblem.IllegalModifierForField: case IProblem.IllegalModifierForMethod: case IProblem.IllegalModifierForVariable: case IProblem.IllegalVisibilityModifierForInterfaceMemberType: ModifierCorrectionSubProcessor.addRemoveInvalidModfiersProposal(context, problem, proposals, 5); break; case IProblem.NotVisibleMethod: case IProblem.NotVisibleConstructor: case IProblem.NotVisibleType: case IProblem.SuperclassNotVisible: case IProblem.InterfaceNotVisible: case IProblem.FieldTypeNotVisible: case IProblem.ArgumentTypeNotVisible: case IProblem.ReturnTypeNotVisible: case IProblem.ExceptionTypeNotVisible: case IProblem.NotVisibleField: case IProblem.ImportNotVisible: case IProblem.JavadocNotVisibleType: ModifierCorrectionSubProcessor.addNonAccessibleReferenceProposal(context, problem, proposals, ModifierCorrectionSubProcessor.TO_VISIBLE, 10); break; case IProblem.BodyForAbstractMethod: case IProblem.AbstractMethodInAbstractClass: ModifierCorrectionSubProcessor.addAbstractMethodProposals(context, problem, proposals); break; case IProblem.AbstractMethodMustBeImplemented: LocalCorrectionsSubProcessor.addUnimplementedMethodsProposals(context, problem, proposals); break; case IProblem.BodyForNativeMethod: ModifierCorrectionSubProcessor.addNativeMethodProposals(context, problem, proposals); break; case IProblem.MethodRequiresBody: ModifierCorrectionSubProcessor.addMethodRequiresBodyProposals(context, problem, proposals); break; case IProblem.OuterLocalMustBeFinal: ModifierCorrectionSubProcessor.addNonFinalLocalProposal(context, problem, proposals); break; case IProblem.UninitializedLocalVariable: LocalCorrectionsSubProcessor.addUninitializedLocalVariableProposal(context, problem, proposals); break; case IProblem.UnhandledExceptionInDefaultConstructor: case IProblem.UndefinedConstructorInDefaultConstructor: case IProblem.NotVisibleConstructorInDefaultConstructor: LocalCorrectionsSubProcessor.addConstructorFromSuperclassProposal(context, problem, proposals); break; case IProblem.UnusedPrivateMethod: case IProblem.UnusedPrivateConstructor: case IProblem.UnusedPrivateField: case IProblem.UnusedPrivateType: case IProblem.LocalVariableIsNeverUsed: case IProblem.ArgumentIsNeverUsed: LocalCorrectionsSubProcessor.addUnusedMemberProposal(context, problem, proposals); break; case IProblem.NeedToEmulateFieldReadAccess: case IProblem.NeedToEmulateFieldWriteAccess: case IProblem.NeedToEmulateMethodAccess: case IProblem.NeedToEmulateConstructorAccess: ModifierCorrectionSubProcessor.addNonAccessibleReferenceProposal(context, problem, proposals, ModifierCorrectionSubProcessor.TO_NON_PRIVATE, 5); break; case IProblem.SuperfluousSemicolon: LocalCorrectionsSubProcessor.addSuperfluousSemicolonProposal(context, problem, proposals); break; case IProblem.UnnecessaryCast: case IProblem.UnnecessaryArgumentCast: LocalCorrectionsSubProcessor.addUnnecessaryCastProposal(context, problem, proposals); break; case IProblem.UnnecessaryInstanceof: LocalCorrectionsSubProcessor.addUnnecessaryInstanceofProposal(context, problem, proposals); break; case IProblem.UnusedMethodDeclaredThrownException: case IProblem.UnusedConstructorDeclaredThrownException: LocalCorrectionsSubProcessor.addUnnecessaryThrownExceptionProposal(context, problem, proposals); break; case IProblem.UnqualifiedFieldAccess: LocalCorrectionsSubProcessor.addUnqualifiedFieldAccessProposal(context, problem, proposals); break; case IProblem.Task: proposals.add(new TaskMarkerProposal(context.getCompilationUnit(), problem, 10)); break; case IProblem.JavadocMissing: JavadocTagsSubProcessor.getMissingJavadocCommentProposals(context, problem, proposals); break; case IProblem.JavadocMissingParamTag: case IProblem.JavadocMissingReturnTag: case IProblem.JavadocMissingThrowsTag: JavadocTagsSubProcessor.getMissingJavadocTagProposals(context, problem, proposals); break; case IProblem.LocalVariableHidingLocalVariable: case IProblem.LocalVariableHidingField: case IProblem.FieldHidingLocalVariable: case IProblem.FieldHidingField: case IProblem.ArgumentHidingLocalVariable: case IProblem.ArgumentHidingField: LocalCorrectionsSubProcessor.addHidingVariablesProposals(context, problem, proposals); case IProblem.IncompatibleExceptionInThrowsClause: case IProblem.IncompatibleExceptionInInheritedMethodThrowsClause: default: } } }
38,089
Bug 38089 Suggest 'Add exception to supertype' when overriden method has more exceptions than superclass [quick assist]
If I have the two classes: public class A { public void method() { } } public class B extends A { public void method() throws Wobbly { } } then I (obviously) get a compile time error. However, it would be useful if the suggestion list (currently empty) could add options o Add exception to superclass implementation o Surround internally with try/catch You would then end up with (either): public class A { public void method() throws Wobbly { } } public class B extends A { public void method() throws Wobbly { } } or public class A { public void method() { } } public class B extends A { public void method() { try { } catch (Wobbly w) { // use uncaught exception code generation } } } Both would be useful options, but I'd recommend that adding an exception to the superclass' implementation is the preferred one of the two, in much the same way that the preferred unhandled exception is to declare a throws rather than a try/catch
resolved fixed
748ed52
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-07T08:37:54Z
2003-05-25T10:53:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/TypeMismatchSubProcessor.java
/******************************************************************************* * Copyright (c) 2000, 2004 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.correction; import java.util.Collection; import org.eclipse.core.runtime.CoreException; import org.eclipse.swt.graphics.Image; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.dom.*; import org.eclipse.jdt.core.dom.PrimitiveType.Code; import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; import org.eclipse.jdt.ui.text.java.IInvocationContext; import org.eclipse.jdt.ui.text.java.IProblemLocation; import org.eclipse.jdt.internal.corext.codemanipulation.ImportRewrite; import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory; import org.eclipse.jdt.internal.corext.dom.Bindings; import org.eclipse.jdt.internal.corext.dom.TypeRules; import org.eclipse.jdt.internal.ui.JavaPluginImages; /** * */ public class TypeMismatchSubProcessor { private TypeMismatchSubProcessor() { } public static void addTypeMismatchProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException { String[] args= problem.getProblemArguments(); if (args.length != 2) { return; } ICompilationUnit cu= context.getCompilationUnit(); String castTypeName= args[1]; CompilationUnit astRoot= context.getASTRoot(); ASTNode selectedNode= problem.getCoveredNode(astRoot); if (!(selectedNode instanceof Expression)) { return; } Expression nodeToCast= (Expression) selectedNode; Name receiverNode= null; ITypeBinding castTypeBinding= null; int parentNodeType= selectedNode.getParent().getNodeType(); if (parentNodeType == ASTNode.ASSIGNMENT) { Assignment assign= (Assignment) selectedNode.getParent(); Expression leftHandSide= assign.getLeftHandSide(); if (selectedNode.equals(leftHandSide)) { nodeToCast= assign.getRightHandSide(); } castTypeBinding= assign.getLeftHandSide().resolveTypeBinding(); if (leftHandSide instanceof Name) { receiverNode= (Name) leftHandSide; } } else if (parentNodeType == ASTNode.VARIABLE_DECLARATION_FRAGMENT) { VariableDeclarationFragment frag= (VariableDeclarationFragment) selectedNode.getParent(); if (selectedNode.equals(frag.getName())) { nodeToCast= frag.getInitializer(); IVariableBinding varBinding= frag.resolveBinding(); if (varBinding != null) { castTypeBinding= varBinding.getType(); } receiverNode= frag.getName(); } } else { // try to find the binding corresponding to 'castTypeName' ITypeBinding guessedCastTypeBinding= ASTResolving.guessBindingForReference(nodeToCast); if (guessedCastTypeBinding != null && castTypeName.equals(guessedCastTypeBinding.getQualifiedName())) { castTypeBinding= guessedCastTypeBinding; } } ITypeBinding binding= nodeToCast.resolveTypeBinding(); if (binding == null || canCast(castTypeName, castTypeBinding, binding)) { proposals.add(createCastProposal(context, castTypeName, nodeToCast, 5)); } ITypeBinding currBinding= nodeToCast.resolveTypeBinding(); if (currBinding == null || "void".equals(currBinding.getName())) { //$NON-NLS-1$ return; } // change method return statement to actual type if (parentNodeType == ASTNode.RETURN_STATEMENT) { BodyDeclaration decl= ASTResolving.findParentBodyDeclaration(selectedNode); if (decl instanceof MethodDeclaration) { MethodDeclaration methodDeclaration= (MethodDeclaration) decl; currBinding= Bindings.normalizeTypeBinding(currBinding); if (currBinding == null) { currBinding= astRoot.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } ASTRewrite rewrite= ASTRewrite.create(methodDeclaration.getAST()); ImportRewrite imports= new ImportRewrite(cu); String returnTypeName= imports.addImport(currBinding); Type newReturnType= ASTNodeFactory.newType(astRoot.getAST(), returnTypeName); rewrite.replace(methodDeclaration.getReturnType(), newReturnType, null); String label= CorrectionMessages.getFormattedString("TypeMismatchSubProcessor.changereturntype.description", currBinding.getName()); //$NON-NLS-1$ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, 6, image); proposal.setImportRewrite(imports); String returnKey= "return"; //$NON-NLS-1$ proposal.addLinkedPosition(rewrite.track(newReturnType), true, returnKey); ITypeBinding[] typeSuggestions= ASTResolving.getRelaxingTypes(astRoot.getAST(), currBinding); for (int i= 0; i < typeSuggestions.length; i++) { proposal.addLinkedPositionProposal(returnKey, typeSuggestions[i]); } proposals.add(proposal); } } if (receiverNode != null) { currBinding= Bindings.normalizeTypeBinding(currBinding); if (currBinding == null) { currBinding= astRoot.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } addChangeSenderTypeProposals(context, receiverNode, currBinding, true, 4, proposals); } if (castTypeBinding != null) { addChangeSenderTypeProposals(context, nodeToCast, castTypeBinding, false, 5, proposals); } } public static void addChangeSenderTypeProposals(IInvocationContext context, Expression nodeToCast, ITypeBinding castTypeBinding, boolean isAssingedNode, int relevance, Collection proposals) throws JavaModelException { IBinding callerBinding= null; switch (nodeToCast.getNodeType()) { case ASTNode.METHOD_INVOCATION: callerBinding= ((MethodInvocation) nodeToCast).resolveMethodBinding(); break; case ASTNode.SUPER_METHOD_INVOCATION: callerBinding= ((SuperMethodInvocation) nodeToCast).resolveMethodBinding(); break; case ASTNode.FIELD_ACCESS: callerBinding= ((FieldAccess) nodeToCast).resolveFieldBinding(); break; case ASTNode.SUPER_FIELD_ACCESS: callerBinding= ((SuperFieldAccess) nodeToCast).resolveFieldBinding(); break; case ASTNode.SIMPLE_NAME: case ASTNode.QUALIFIED_NAME: callerBinding= ((Name) nodeToCast).resolveBinding(); break; } ICompilationUnit cu= context.getCompilationUnit(); CompilationUnit astRoot= context.getASTRoot(); ICompilationUnit targetCu= null; ITypeBinding declaringType= null; if (callerBinding instanceof IVariableBinding) { IVariableBinding variableBinding= (IVariableBinding) callerBinding; if (!variableBinding.isField()) { targetCu= cu; } else { declaringType= variableBinding.getDeclaringClass(); } } else if (callerBinding instanceof IMethodBinding) { IMethodBinding methodBinding= (IMethodBinding) callerBinding; if (!methodBinding.isConstructor()) { declaringType= methodBinding.getDeclaringClass(); } } if (declaringType != null && declaringType.isFromSource()) { targetCu= ASTResolving.findCompilationUnitForBinding(cu, astRoot, declaringType); } if (targetCu != null) { proposals.add(new TypeChangeCompletionProposal(targetCu, callerBinding, astRoot, castTypeBinding, isAssingedNode, relevance)); } // add interface to resulting type if (!isAssingedNode) { ITypeBinding nodeType= nodeToCast.resolveTypeBinding(); if (castTypeBinding.isInterface() && nodeType != null && nodeType.isClass() && !nodeType.isAnonymous() && nodeType.isFromSource()) { ICompilationUnit nodeCu= ASTResolving.findCompilationUnitForBinding(cu, astRoot, nodeType); if (nodeCu != null) { proposals.add(new ImplementInterfaceProposal(nodeCu, nodeType, astRoot, castTypeBinding, relevance - 1)); } } } } private static boolean canCast(String castTarget, ITypeBinding castTypeBinding, ITypeBinding bindingToCast) { if (castTypeBinding != null) { return TypeRules.canCast(castTypeBinding, bindingToCast); } bindingToCast= Bindings.normalizeTypeBinding(bindingToCast); if (bindingToCast == null) { return false; } int arrStart= castTarget.indexOf('['); if (arrStart != -1) { if (!bindingToCast.isArray()) { return "java.lang.Object".equals(bindingToCast.getQualifiedName()); //$NON-NLS-1$ } castTarget= castTarget.substring(0, arrStart); bindingToCast= bindingToCast.getElementType(); if (bindingToCast.isPrimitive() && !castTarget.equals(bindingToCast.getName())) { return false; // can't cast arrays of primitive types into each other } } Code targetCode= PrimitiveType.toCode(castTarget); if (bindingToCast.isPrimitive()) { Code castCode= PrimitiveType.toCode(bindingToCast.getName()); if (castCode == targetCode) { return true; } return (targetCode != null && targetCode != PrimitiveType.BOOLEAN && castCode != PrimitiveType.BOOLEAN); } else { return targetCode == null; // can not check } } public static ASTRewriteCorrectionProposal createCastProposal(IInvocationContext context, String castType, Expression nodeToCast, int relevance) throws CoreException { ICompilationUnit cu= context.getCompilationUnit(); CompilationUnit astRoot= context.getASTRoot(); ASTRewrite rewrite= ASTRewrite.create(nodeToCast.getAST()); ImportRewrite imports= new ImportRewrite(cu); String label; String simpleCastType= imports.addImport(castType); if (nodeToCast.getNodeType() == ASTNode.CAST_EXPRESSION) { label= CorrectionMessages.getFormattedString("TypeMismatchSubProcessor.changecast.description", castType); //$NON-NLS-1$ CastExpression expression= (CastExpression) nodeToCast; rewrite.replace(expression.getType(), rewrite.createStringPlaceholder(simpleCastType, ASTNode.SIMPLE_TYPE), null); } else { label= CorrectionMessages.getFormattedString("TypeMismatchSubProcessor.addcast.description", castType); //$NON-NLS-1$ Expression expressionCopy= (Expression) rewrite.createCopyTarget(nodeToCast); int nodeType= nodeToCast.getNodeType(); if (nodeType == ASTNode.INFIX_EXPRESSION || nodeType == ASTNode.CONDITIONAL_EXPRESSION || nodeType == ASTNode.ASSIGNMENT || nodeType == ASTNode.INSTANCEOF_EXPRESSION) { // nodes have weaker precedence than cast ParenthesizedExpression parenthesizedExpression= astRoot.getAST().newParenthesizedExpression(); parenthesizedExpression.setExpression(expressionCopy); expressionCopy= parenthesizedExpression; } Type typeCopy= (Type) rewrite.createStringPlaceholder(simpleCastType, ASTNode.SIMPLE_TYPE); CastExpression castExpression= astRoot.getAST().newCastExpression(); castExpression.setExpression(expressionCopy); castExpression.setType(typeCopy); rewrite.replace(nodeToCast, castExpression, null); } Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, relevance, image); //$NON-NLS-1$ proposal.setImportRewrite(imports); return proposal; } public static void addIncompatibleReturnTypeProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws JavaModelException { CompilationUnit astRoot= context.getASTRoot(); ASTNode selectedNode= problem.getCoveredNode(astRoot); if (selectedNode instanceof SimpleName) { selectedNode= selectedNode.getParent(); } if (!(selectedNode instanceof MethodDeclaration)) { return; } MethodDeclaration decl= (MethodDeclaration) selectedNode; IMethodBinding binding= decl.resolveBinding(); if (binding == null) { return; } IMethodBinding overridden= Bindings.findMethodDefininition(binding); if (overridden == null || overridden.getReturnType() == binding.getReturnType()) { return; } ITypeBinding declaringType= overridden.getDeclaringClass(); ICompilationUnit cu= context.getCompilationUnit(); proposals.add(new TypeChangeCompletionProposal(cu, binding, astRoot, overridden.getReturnType(), false, 8)); ICompilationUnit targetCu= cu; if (declaringType != null && declaringType.isFromSource()) { targetCu= ASTResolving.findCompilationUnitForBinding(cu, astRoot, declaringType); } if (targetCu != null) { proposals.add(new TypeChangeCompletionProposal(targetCu, overridden, astRoot, binding.getReturnType(), false, 7)); } } }
38,089
Bug 38089 Suggest 'Add exception to supertype' when overriden method has more exceptions than superclass [quick assist]
If I have the two classes: public class A { public void method() { } } public class B extends A { public void method() throws Wobbly { } } then I (obviously) get a compile time error. However, it would be useful if the suggestion list (currently empty) could add options o Add exception to superclass implementation o Surround internally with try/catch You would then end up with (either): public class A { public void method() throws Wobbly { } } public class B extends A { public void method() throws Wobbly { } } or public class A { public void method() { } } public class B extends A { public void method() { try { } catch (Wobbly w) { // use uncaught exception code generation } } } Both would be useful options, but I'd recommend that adding an exception to the superclass' implementation is the preferred one of the two, in much the same way that the preferred unhandled exception is to declare a throws rather than a try/catch
resolved fixed
748ed52
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-07T08:37:54Z
2003-05-25T10:53:20Z
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/UnresolvedElementsSubProcessor.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation * Renaud Waldura &lt;[email protected]&gt; - New class/interface with wizard *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.correction; import java.util.ArrayList; import java.util.Collection; import java.util.List; import org.eclipse.core.runtime.CoreException; import org.eclipse.swt.graphics.Image; import org.eclipse.ui.ISharedImages; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IType; import org.eclipse.jdt.core.JavaModelException; import org.eclipse.jdt.core.Signature; import org.eclipse.jdt.core.dom.*; import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; import org.eclipse.jdt.ui.text.java.IInvocationContext; import org.eclipse.jdt.ui.text.java.IProblemLocation; import org.eclipse.jdt.internal.corext.codemanipulation.ImportRewrite; import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility; import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory; import org.eclipse.jdt.internal.corext.dom.Bindings; import org.eclipse.jdt.internal.corext.dom.ScopeAnalyzer; import org.eclipse.jdt.internal.corext.dom.TypeRules; import org.eclipse.jdt.internal.corext.util.JavaModelUtil; import org.eclipse.jdt.internal.corext.util.Strings; import org.eclipse.jdt.internal.corext.util.TypeFilter; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.JavaPluginImages; import org.eclipse.jdt.internal.ui.text.correction.ChangeMethodSignatureProposal.ChangeDescription; import org.eclipse.jdt.internal.ui.text.correction.ChangeMethodSignatureProposal.EditDescription; import org.eclipse.jdt.internal.ui.text.correction.ChangeMethodSignatureProposal.InsertDescription; import org.eclipse.jdt.internal.ui.text.correction.ChangeMethodSignatureProposal.RemoveDescription; import org.eclipse.jdt.internal.ui.text.correction.ChangeMethodSignatureProposal.SwapDescription; public class UnresolvedElementsSubProcessor { public static void getVariableProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException { ICompilationUnit cu= context.getCompilationUnit(); CompilationUnit astRoot= context.getASTRoot(); ASTNode selectedNode= problem.getCoveredNode(astRoot); if (selectedNode == null) { return; } // type that defines the variable ITypeBinding binding= null; ITypeBinding declaringTypeBinding= Bindings.getBindingOfParentType(selectedNode); if (declaringTypeBinding == null) { return; } // possible type kind of the node boolean suggestVariableProposals= true; int typeKind= 0; while (selectedNode instanceof ParenthesizedExpression) { selectedNode= ((ParenthesizedExpression) selectedNode).getExpression(); } Name node= null; switch (selectedNode.getNodeType()) { case ASTNode.SIMPLE_NAME: node= (SimpleName) selectedNode; ASTNode parent= node.getParent(); if (parent instanceof MethodInvocation && node.equals(((MethodInvocation)parent).getExpression())) { typeKind= SimilarElementsRequestor.CLASSES; } else if (parent instanceof SimpleType) { suggestVariableProposals= false; typeKind= SimilarElementsRequestor.REF_TYPES; } else if (parent instanceof QualifiedName) { Name qualifier= ((QualifiedName) parent).getQualifier(); if (qualifier != node) { binding= qualifier.resolveTypeBinding(); } else { typeKind= SimilarElementsRequestor.REF_TYPES; } ASTNode outerParent= parent.getParent(); while (outerParent instanceof QualifiedName) { outerParent= outerParent.getParent(); } if (outerParent instanceof SimpleType) { typeKind= SimilarElementsRequestor.REF_TYPES; suggestVariableProposals= false; } } break; case ASTNode.QUALIFIED_NAME: QualifiedName qualifierName= (QualifiedName) selectedNode; ITypeBinding qualifierBinding= qualifierName.getQualifier().resolveTypeBinding(); if (qualifierBinding != null) { node= qualifierName.getName(); binding= qualifierBinding; } else { node= qualifierName.getQualifier(); typeKind= SimilarElementsRequestor.REF_TYPES; suggestVariableProposals= node.isSimpleName(); } if (selectedNode.getParent() instanceof SimpleType) { typeKind= SimilarElementsRequestor.REF_TYPES; suggestVariableProposals= false; } break; case ASTNode.FIELD_ACCESS: FieldAccess access= (FieldAccess) selectedNode; Expression expression= access.getExpression(); if (expression != null) { binding= expression.resolveTypeBinding(); if (binding != null) { node= access.getName(); } } break; case ASTNode.SUPER_FIELD_ACCESS: binding= declaringTypeBinding.getSuperclass(); node= ((SuperFieldAccess) selectedNode).getName(); break; default: } if (node == null) { return; } // add type proposals if (typeKind != 0) { int relevance= Character.isUpperCase(ASTResolving.getSimpleName(node).charAt(0)) ? 3 : 0; addSimilarTypeProposals(typeKind, cu, node, relevance + 1, proposals); addNewTypeProposals(cu, node, SimilarElementsRequestor.REF_TYPES, relevance, proposals); } if (!suggestVariableProposals) { return; } SimpleName simpleName= node.isSimpleName() ? (SimpleName) node : ((QualifiedName) node).getName(); boolean isWriteAccess= ASTResolving.isWriteAccess(node); // similar variables addSimilarVariableProposals(cu, astRoot, simpleName, isWriteAccess, proposals); // new fields addNewFieldProposals(cu, astRoot, binding, declaringTypeBinding, simpleName, isWriteAccess, proposals); // new parameters and local variables if (binding == null) { addNewVariableProposals(cu, node, simpleName, proposals); } } private static void addNewVariableProposals(ICompilationUnit cu, Name node, SimpleName simpleName, Collection proposals) { String name= simpleName.getIdentifier(); BodyDeclaration bodyDeclaration= ASTResolving.findParentBodyDeclaration(node); int type= bodyDeclaration.getNodeType(); if (type == ASTNode.METHOD_DECLARATION) { int relevance= StubUtility.hasParameterName(cu.getJavaProject(), name) ? 8 : 5; String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createparameter.description", simpleName.getIdentifier()); //$NON-NLS-1$ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL); proposals.add(new NewVariableCompletionProposal(label, cu, NewVariableCompletionProposal.PARAM, simpleName, null, relevance, image)); } if (type == ASTNode.METHOD_DECLARATION || type == ASTNode.INITIALIZER) { int relevance= StubUtility.hasLocalVariableName(cu.getJavaProject(), name) ? 10 : 7; String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createlocal.description", simpleName.getIdentifier()); //$NON-NLS-1$ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL); proposals.add(new NewVariableCompletionProposal(label, cu, NewVariableCompletionProposal.LOCAL, simpleName, null, relevance, image)); } if (node.getParent().getNodeType() == ASTNode.ASSIGNMENT) { Assignment assignment= (Assignment) node.getParent(); if (assignment.getLeftHandSide() == node && assignment.getParent().getNodeType() == ASTNode.EXPRESSION_STATEMENT) { ASTNode statement= assignment.getParent(); ASTRewrite rewrite= ASTRewrite.create(statement.getAST()); rewrite.remove(statement, null); String label= CorrectionMessages.getString("UnresolvedElementsSubProcessor.removestatement.description"); //$NON-NLS-1$ Image image= JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE); ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, 4, image); proposals.add(proposal); } } } private static void addNewFieldProposals(ICompilationUnit cu, CompilationUnit astRoot, ITypeBinding binding, ITypeBinding declaringTypeBinding, SimpleName simpleName, boolean isWriteAccess, Collection proposals) throws JavaModelException { // new variables ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, binding); ITypeBinding senderBinding= binding != null ? binding : declaringTypeBinding; if (!senderBinding.isFromSource() || targetCU == null || !JavaModelUtil.isEditable(targetCU)) { return; } ITypeBinding outsideAnonymous= null; if (binding == null && senderBinding.isAnonymous()) { ASTNode anonymDecl= astRoot.findDeclaringNode(senderBinding); if (anonymDecl != null) { ITypeBinding bind= Bindings.getBindingOfParentType(anonymDecl.getParent()); if (!bind.isAnonymous()) { outsideAnonymous= bind; } } } String name= simpleName.getIdentifier(); int relevance= StubUtility.hasFieldName(cu.getJavaProject(), name) ? 9 : 6; String label; Image image; if (binding == null) { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createfield.description", name); //$NON-NLS-1$ image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE); } else { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createfield.other.description", new Object[] { name, binding.getName() } ); //$NON-NLS-1$ image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC); } proposals.add(new NewVariableCompletionProposal(label, targetCU, NewVariableCompletionProposal.FIELD, simpleName, senderBinding, relevance, image)); // create field in outer class (if inside anonymous) if (outsideAnonymous != null) { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createfield.other.description", new Object[] { name, outsideAnonymous.getName() } ); //$NON-NLS-1$ image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC); proposals.add(new NewVariableCompletionProposal(label, targetCU, NewVariableCompletionProposal.FIELD, simpleName, outsideAnonymous, relevance + 1, image)); } // create constant if (!isWriteAccess) { relevance= StubUtility.hasConstantName(name) ? 9 : 4; ITypeBinding target= (outsideAnonymous != null) ? outsideAnonymous : senderBinding; if (binding == null) { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createconst.description", name); //$NON-NLS-1$ image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PRIVATE); } else { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createconst.other.description", new Object[] { name, binding.getName() } ); //$NON-NLS-1$ image= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC); } proposals.add(new NewVariableCompletionProposal(label, targetCU, NewVariableCompletionProposal.CONST_FIELD, simpleName, target, relevance, image)); } } private static void addSimilarVariableProposals(ICompilationUnit cu, CompilationUnit astRoot, SimpleName node, boolean isWriteAccess, Collection proposals) { IBinding[] varsInScope= (new ScopeAnalyzer(astRoot)).getDeclarationsInScope(node, ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY); if (varsInScope.length > 0) { // avoid corrections like int i= i; String otherNameInAssign= null; ASTNode parent= node.getParent(); if (parent.getNodeType() == ASTNode.VARIABLE_DECLARATION_FRAGMENT) { // node must be initializer otherNameInAssign= ((VariableDeclarationFragment) parent).getName().getIdentifier(); } else if (parent.getNodeType() == ASTNode.ASSIGNMENT) { Assignment assignment= (Assignment) parent; if (isWriteAccess && assignment.getRightHandSide() instanceof SimpleName) { otherNameInAssign= ((SimpleName) assignment.getRightHandSide()).getIdentifier(); } else if (!isWriteAccess && assignment.getLeftHandSide() instanceof SimpleName) { otherNameInAssign= ((SimpleName) assignment.getLeftHandSide()).getIdentifier(); } } ITypeBinding guessedType= ASTResolving.guessBindingForReference(node); if (astRoot.getAST().resolveWellKnownType("java.lang.Object") == guessedType) { //$NON-NLS-1$ guessedType= null; // too many suggestions } String identifier= node.getIdentifier(); for (int i= 0; i < varsInScope.length; i++) { IVariableBinding curr= (IVariableBinding) varsInScope[i]; String currName= curr.getName(); boolean isFinal= Modifier.isFinal(curr.getModifiers()); if (!currName.equals(otherNameInAssign) && !(isFinal && curr.isField() && isWriteAccess)) { int relevance= 0; if (NameMatcher.isSimilarName(currName, identifier)) { relevance += 3; // variable with a similar name than the unresolved variable } if (currName.equalsIgnoreCase(identifier)) { relevance+= 5; } ITypeBinding varType= curr.getType(); if (guessedType != null && varType != null) { if (!isWriteAccess && TypeRules.canAssign(varType, guessedType) || isWriteAccess && TypeRules.canAssign(guessedType, varType)) { relevance += 2; // unresolved variable can be assign to this variable } } if (relevance > 0) { String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changevariable.description", currName); //$NON-NLS-1$ proposals.add(new RenameNodeCompletionProposal(label, cu, node.getStartPosition(), node.getLength(), currName, relevance)); } } } } } public static void getTypeProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException { ICompilationUnit cu= context.getCompilationUnit(); ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot()); if (selectedNode == null) { return; } int kind= SimilarElementsRequestor.ALL_TYPES; ASTNode parent= selectedNode.getParent(); while (parent.getLength() == selectedNode.getLength()) { // get parent of type or variable fragment parent= parent.getParent(); } switch (parent.getNodeType()) { case ASTNode.TYPE_DECLARATION: TypeDeclaration typeDeclaration=(TypeDeclaration) parent; if (typeDeclaration.superInterfaces().contains(selectedNode)) { kind= SimilarElementsRequestor.INTERFACES; } else if (selectedNode.equals(typeDeclaration.getSuperclass())) { kind= SimilarElementsRequestor.CLASSES; } break; case ASTNode.METHOD_DECLARATION: MethodDeclaration methodDeclaration= (MethodDeclaration) parent; if (methodDeclaration.thrownExceptions().contains(selectedNode)) { kind= SimilarElementsRequestor.CLASSES; } else if (selectedNode.equals(methodDeclaration.getReturnType())) { kind= SimilarElementsRequestor.ALL_TYPES | SimilarElementsRequestor.VOIDTYPE; } break; case ASTNode.INSTANCEOF_EXPRESSION: kind= SimilarElementsRequestor.REF_TYPES; break; case ASTNode.THROW_STATEMENT: kind= SimilarElementsRequestor.REF_TYPES; break; case ASTNode.CLASS_INSTANCE_CREATION: if (((ClassInstanceCreation) parent).getAnonymousClassDeclaration() == null) { kind= SimilarElementsRequestor.CLASSES; } else { kind= SimilarElementsRequestor.REF_TYPES; } break; case ASTNode.SINGLE_VARIABLE_DECLARATION: int superParent= parent.getParent().getNodeType(); if (superParent == ASTNode.CATCH_CLAUSE) { kind= SimilarElementsRequestor.CLASSES; } break; case ASTNode.TAG_ELEMENT: kind= SimilarElementsRequestor.REF_TYPES; break; default: } Name node= null; if (selectedNode instanceof SimpleType) { node= ((SimpleType) selectedNode).getName(); } else if (selectedNode instanceof ArrayType) { Type elementType= ((ArrayType) selectedNode).getElementType(); if (elementType.isSimpleType()) { node= ((SimpleType) elementType).getName(); } } else if (selectedNode instanceof Name) { node= (Name) selectedNode; } else { return; } // change to similar type proposals addSimilarTypeProposals(kind, cu, node, 3, proposals); // add type addNewTypeProposals(cu, node, kind, 0, proposals); } private static void addSimilarTypeProposals(int kind, ICompilationUnit cu, Name node, int relevance, Collection proposals) throws CoreException { SimilarElement[] elements= SimilarElementsRequestor.findSimilarElement(cu, node, kind); // try to resolve type in context -> highest severity String resolvedTypeName= null; ITypeBinding binding= ASTResolving.guessBindingForTypeReference(node); if (binding != null) { if (binding.isArray()) { binding= binding.getElementType(); } resolvedTypeName= binding.getQualifiedName(); proposals.add(createTypeRefChangeProposal(cu, resolvedTypeName, node, relevance + 2)); } // add all similar elements for (int i= 0; i < elements.length; i++) { SimilarElement elem= elements[i]; if ((elem.getKind() & SimilarElementsRequestor.ALL_TYPES) != 0) { String fullName= elem.getName(); if (!fullName.equals(resolvedTypeName)) { proposals.add(createTypeRefChangeProposal(cu, fullName, node, relevance)); } } } } private static CUCorrectionProposal createTypeRefChangeProposal(ICompilationUnit cu, String fullName, Name node, int relevance) throws CoreException { ImportRewrite importRewrite= new ImportRewrite(cu); importRewrite.setFindAmbiguosImports(true); String simpleName= importRewrite.addImport(fullName); String packName= Signature.getQualifier(fullName); String[] arg= { simpleName, packName }; CUCorrectionProposal proposal; if (node.isSimpleName() && simpleName.equals(((SimpleName) node).getIdentifier())) { // import only // import only String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.importtype.description", arg); //$NON-NLS-1$ Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_IMPDECL); proposal= new CUCorrectionProposal(label, cu, relevance + 100, image); } else { String label; if (packName.length() == 0) { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changetype.nopack.description", simpleName); //$NON-NLS-1$ } else { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changetype.description", arg); //$NON-NLS-1$ } proposal= new RenameNodeCompletionProposal(label, cu, node.getStartPosition(), node.getLength(), simpleName, relevance); //$NON-NLS-1$ } proposal.setImportRewrite(importRewrite); return proposal; } private static void addNewTypeProposals(ICompilationUnit cu, Name refNode, int kind, int relevance, Collection proposals) throws JavaModelException { Name node= refNode; do { String typeName= ASTResolving.getSimpleName(node); Name qualifier= null; // only propose to create types for qualifiers when the name starts with upper case boolean isPossibleName= Character.isUpperCase(typeName.charAt(0)) || (node == refNode); if (isPossibleName) { IPackageFragment enclosingPackage= null; IType enclosingType= null; if (node.isSimpleName()) { enclosingPackage= (IPackageFragment) cu.getParent(); // don't suggest member type, user can select it in wizard } else { Name qualifierName= ((QualifiedName) node).getQualifier(); // 24347 // IBinding binding= qualifierName.resolveBinding(); // if (binding instanceof ITypeBinding) { // enclosingType= Binding2JavaModel.find((ITypeBinding) binding, cu.getJavaProject()); IJavaElement[] res= cu.codeSelect(qualifierName.getStartPosition(), qualifierName.getLength()); if (res!= null && res.length > 0 && res[0] instanceof IType) { enclosingType= (IType) res[0]; } else { qualifier= qualifierName; enclosingPackage= JavaModelUtil.getPackageFragmentRoot(cu).getPackageFragment(ASTResolving.getFullName(qualifierName)); } } // new top level type if (enclosingPackage != null && !enclosingPackage.getCompilationUnit(typeName + ".java").exists()) { //$NON-NLS-1$ if ((kind & SimilarElementsRequestor.CLASSES) != 0) { proposals.add(new NewCUCompletionUsingWizardProposal(cu, node, true, enclosingPackage, relevance)); } if ((kind & SimilarElementsRequestor.INTERFACES) != 0) { proposals.add(new NewCUCompletionUsingWizardProposal(cu, node, false, enclosingPackage, relevance)); } } // new member type if (enclosingType != null && !enclosingType.isReadOnly() && !enclosingType.getType(typeName).exists()) { if ((kind & SimilarElementsRequestor.CLASSES) != 0) { proposals.add(new NewCUCompletionUsingWizardProposal(cu, node, true, enclosingType, relevance)); } if ((kind & SimilarElementsRequestor.INTERFACES) != 0) { proposals.add(new NewCUCompletionUsingWizardProposal(cu, node, false, enclosingType, relevance)); } } } node= qualifier; } while (node != null); } public static void getMethodProposals(IInvocationContext context, IProblemLocation problem, boolean needsNewName, Collection proposals) throws CoreException { ICompilationUnit cu= context.getCompilationUnit(); CompilationUnit astRoot= context.getASTRoot(); ASTNode selectedNode= problem.getCoveringNode(astRoot); if (!(selectedNode instanceof SimpleName)) { return; } SimpleName nameNode= (SimpleName) selectedNode; List arguments; Expression sender; boolean isSuperInvocation; ASTNode invocationNode= nameNode.getParent(); if (invocationNode instanceof MethodInvocation) { MethodInvocation methodImpl= (MethodInvocation) invocationNode; arguments= methodImpl.arguments(); sender= methodImpl.getExpression(); isSuperInvocation= false; } else if (invocationNode instanceof SuperMethodInvocation) { SuperMethodInvocation methodImpl= (SuperMethodInvocation) invocationNode; arguments= methodImpl.arguments(); sender= methodImpl.getQualifier(); isSuperInvocation= true; } else { return; } String methodName= nameNode.getIdentifier(); int nArguments= arguments.size(); // corrections IBinding[] bindings= (new ScopeAnalyzer(astRoot)).getDeclarationsInScope(nameNode, ScopeAnalyzer.METHODS); ArrayList parameterMismatchs= new ArrayList(); for (int i= 0; i < bindings.length; i++) { IMethodBinding binding= (IMethodBinding) bindings[i]; String curr= binding.getName(); if (curr.equals(methodName) && needsNewName) { parameterMismatchs.add(binding); } else if (binding.getParameterTypes().length == nArguments && NameMatcher.isSimilarName(methodName, curr)) { String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changemethod.description", curr); //$NON-NLS-1$ proposals.add(new RenameNodeCompletionProposal(label, context.getCompilationUnit(), problem.getOffset(), problem.getLength(), curr, 6)); } } addParameterMissmatchProposals(context, problem, parameterMismatchs, invocationNode, arguments, proposals); // new method ITypeBinding binding= null; if (sender != null) { binding= sender.resolveTypeBinding(); } else { binding= Bindings.getBindingOfParentType(invocationNode); if (isSuperInvocation && binding != null) { binding= binding.getSuperclass(); } } if (binding != null && binding.isFromSource()) { ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, binding); if (targetCU != null) { String label; Image image; String sig= getMethodSignature(methodName, arguments); if (cu.equals(targetCU)) { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createmethod.description", sig); //$NON-NLS-1$ image= JavaPluginImages.get(JavaPluginImages.IMG_MISC_PRIVATE); } else { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createmethod.other.description", new Object[] { sig, targetCU.getElementName() } ); //$NON-NLS-1$ image= JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC); } proposals.add(new NewMethodCompletionProposal(label, targetCU, invocationNode, arguments, binding, 5, image)); if (binding.isAnonymous() && cu.equals(targetCU) && sender == null && Bindings.findMethodInHierarchy(binding, methodName, null) == null) { // no covering method ASTNode anonymDecl= astRoot.findDeclaringNode(binding); if (anonymDecl != null) { binding= Bindings.getBindingOfParentType(anonymDecl.getParent()); if (!binding.isAnonymous()) { String[] args= new String[] { sig, binding.getName() }; label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createmethod.other.description", args); //$NON-NLS-1$ image= JavaPluginImages.get(JavaPluginImages.IMG_MISC_PROTECTED); proposals.add(new NewMethodCompletionProposal(label, targetCU, invocationNode, arguments, binding, 5, image)); } } } } } if (!isSuperInvocation) { ASTNode parent= invocationNode.getParent(); while (parent instanceof Expression && parent.getNodeType() != ASTNode.CAST_EXPRESSION) { parent= parent.getParent(); } if (!isSuperInvocation && parent instanceof CastExpression) { addMissingCastParentsProposal(cu, (CastExpression) parent, sender, nameNode, getArgumentTypes(arguments), proposals); } } } private static void addMissingCastParentsProposal(ICompilationUnit cu, CastExpression expression, Expression accessExpression, SimpleName accessSelector, ITypeBinding[] paramTypes, Collection proposals) { ITypeBinding castType= expression.getType().resolveBinding(); if (castType == null) { return; } if (paramTypes != null) { if (Bindings.findMethodInHierarchy(castType, accessSelector.getIdentifier(), paramTypes) == null) { return; } } else if (Bindings.findFieldInHierarchy(castType, accessSelector.getIdentifier()) == null) { return; } ITypeBinding bindingToCast= accessExpression.resolveTypeBinding(); if (bindingToCast != null && !TypeRules.canCast(castType, bindingToCast)) { return; } IMethodBinding res= Bindings.findMethodInHierarchy(castType, accessSelector.getIdentifier(), paramTypes); if (res != null) { AST ast= expression.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); CastExpression newCast= ast.newCastExpression(); newCast.setType((Type) ASTNode.copySubtree(ast, expression.getType())); newCast.setExpression((Expression) rewrite.createCopyTarget(accessExpression)); ParenthesizedExpression parents= ast.newParenthesizedExpression(); parents.setExpression(newCast); ASTNode node= rewrite.createCopyTarget(expression.getExpression()); rewrite.replace(expression, node, null); rewrite.replace(accessExpression, parents, null); String label= CorrectionMessages.getString("UnresolvedElementsSubProcessor.missingcastbrackets.description"); //$NON-NLS-1$ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, 8, image); proposals.add(proposal); } } private static void addParameterMissmatchProposals(IInvocationContext context, IProblemLocation problem, List similarElements, ASTNode invocationNode, List arguments, Collection proposals) throws CoreException { int nSimilarElements= similarElements.size(); ITypeBinding[] argTypes= getArgumentTypes(arguments); if (argTypes == null || nSimilarElements == 0) { return; } for (int i= 0; i < nSimilarElements; i++) { IMethodBinding elem = (IMethodBinding) similarElements.get(i); int diff= elem.getParameterTypes().length - argTypes.length; if (diff == 0) { int nProposals= proposals.size(); doEqualNumberOfParameters(context, invocationNode, problem, arguments, argTypes, elem, proposals); if (nProposals != proposals.size()) { return; // only suggest for one method (avoid duplicated proposals) } } else if (diff > 0) { doMoreParameters(context, problem, invocationNode, arguments, argTypes, elem, proposals); } else { doMoreArguments(context, problem, invocationNode, arguments, argTypes, elem, proposals); } } } private static void doMoreParameters(IInvocationContext context, IProblemLocation problem, ASTNode invocationNode, List arguments, ITypeBinding[] argTypes, IMethodBinding methodBinding, Collection proposals) throws CoreException { ITypeBinding[] paramTypes= methodBinding.getParameterTypes(); int k= 0, nSkipped= 0; int diff= paramTypes.length - argTypes.length; int[] indexSkipped= new int[diff]; for (int i= 0; i < paramTypes.length; i++) { if (k < argTypes.length && TypeRules.canAssign(argTypes[k], paramTypes[i])) { k++; // match } else { if (nSkipped >= diff) { return; // too different } indexSkipped[nSkipped++]= i; } } ITypeBinding declaringType= methodBinding.getDeclaringClass(); ICompilationUnit cu= context.getCompilationUnit(); CompilationUnit astRoot= context.getASTRoot(); // add arguments { String[] arg= new String[] { getMethodSignature(methodBinding, false) }; String label; if (diff == 1) { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addargument.description", arg); //$NON-NLS-1$ } else { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addarguments.description", arg); //$NON-NLS-1$ } AddArgumentCorrectionProposal proposal= new AddArgumentCorrectionProposal(label, context.getCompilationUnit(), invocationNode, indexSkipped, paramTypes, 8); proposal.setImage(JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_ADD)); proposals.add(proposal); } // remove parameters if (!declaringType.isFromSource()) { return; } ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, declaringType); if (targetCU != null) { ChangeDescription[] changeDesc= new ChangeDescription[paramTypes.length]; ITypeBinding[] changedTypes= new ITypeBinding[diff]; for (int i= diff - 1; i >= 0; i--) { int idx= indexSkipped[i]; changeDesc[idx]= new RemoveDescription(); changedTypes[i]= paramTypes[idx]; } String[] arg= new String[] { getMethodSignature(methodBinding, !cu.equals(targetCU)), getTypeNames(changedTypes) }; String label; if (methodBinding.isConstructor()) { if (diff == 1) { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.removeparam.constr.description", arg); //$NON-NLS-1$ } else { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.removeparams.constr.description", arg); //$NON-NLS-1$ } } else { if (diff == 1) { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.removeparam.description", arg); //$NON-NLS-1$ } else { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.removeparams.description", arg); //$NON-NLS-1$ } } Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_REMOVE); ChangeMethodSignatureProposal proposal= new ChangeMethodSignatureProposal(label, targetCU, invocationNode, methodBinding, changeDesc, 5, image); proposals.add(proposal); } } private static String getTypeNames(ITypeBinding[] types) { StringBuffer buf= new StringBuffer(); for (int i= 0; i < types.length; i++) { if (i > 0) { buf.append(", "); //$NON-NLS-1$ } buf.append(types[i].getName()); } return buf.toString(); } private static String getArgumentName(ICompilationUnit cu, List arguments, int index) { String def= String.valueOf(index + 1); ASTNode expr= (ASTNode) arguments.get(index); if (expr.getLength() > 18) { return def; } try { String str= cu.getBuffer().getText(expr.getStartPosition(), expr.getLength()); for (int i= 0; i < str.length(); i++) { if (Strings.isLineDelimiterChar(str.charAt(i))) { return def; } } ASTMatcher matcher= new ASTMatcher(); for (int i= 0; i < arguments.size(); i++) { if (i != index && matcher.safeSubtreeMatch(expr, arguments.get(i))) { return def; } } return '\'' + str + '\''; } catch (JavaModelException e) { JavaPlugin.log(e); } return def; } private static void doMoreArguments(IInvocationContext context, IProblemLocation problem, ASTNode invocationNode, List arguments, ITypeBinding[] argTypes, IMethodBinding methodBinding, Collection proposals) throws CoreException { ITypeBinding[] paramTypes= methodBinding.getParameterTypes(); int k= 0, nSkipped= 0; int diff= argTypes.length - paramTypes.length; int[] indexSkipped= new int[diff]; for (int i= 0; i < argTypes.length; i++) { if (k < paramTypes.length && TypeRules.canAssign(argTypes[i], paramTypes[k])) { k++; // match } else { if (nSkipped >= diff) { return; // too different } indexSkipped[nSkipped++]= i; } } ITypeBinding declaringType= methodBinding.getDeclaringClass(); ICompilationUnit cu= context.getCompilationUnit(); CompilationUnit astRoot= context.getASTRoot(); // remove arguments { ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST()); for (int i= diff - 1; i >= 0; i--) { rewrite.remove((Expression) arguments.get(indexSkipped[i]), null); } String[] arg= new String[] { getMethodSignature(methodBinding, false) }; String label; if (diff == 1) { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.removeargument.description", arg); //$NON-NLS-1$ } else { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.removearguments.description", arg); //$NON-NLS-1$ } Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_REMOVE); ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 8, image); proposals.add(proposal); } // add parameters if (!declaringType.isFromSource()) { return; } ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, declaringType); if (targetCU != null) { boolean isDifferentCU= !cu.equals(targetCU); if (isImplicitConstructor(methodBinding, targetCU)) { return; } ChangeDescription[] changeDesc= new ChangeDescription[argTypes.length]; ITypeBinding[] changeTypes= new ITypeBinding[diff]; for (int i= diff - 1; i >= 0; i--) { int idx= indexSkipped[i]; Expression arg= (Expression) arguments.get(idx); String name= arg instanceof SimpleName ? ((SimpleName) arg).getIdentifier() : null; ITypeBinding newType= Bindings.normalizeTypeBinding(argTypes[idx]); if (newType == null) { newType= astRoot.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } changeDesc[idx]= new InsertDescription(newType, name); changeTypes[i]= newType; } String[] arg= new String[] { getMethodSignature(methodBinding, isDifferentCU), getTypeNames(changeTypes) }; String label; if (methodBinding.isConstructor()) { if (diff == 1) { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addparam.constr.description", arg); //$NON-NLS-1$ } else { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addparams.constr.description", arg); //$NON-NLS-1$ } } else { if (diff == 1) { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addparam.description", arg); //$NON-NLS-1$ } else { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addparams.description", arg); //$NON-NLS-1$ } } Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_ADD); ChangeMethodSignatureProposal proposal= new ChangeMethodSignatureProposal(label, targetCU, invocationNode, methodBinding, changeDesc, 5, image); proposals.add(proposal); } } private static boolean isImplicitConstructor(IMethodBinding meth, ICompilationUnit targetCU) { if (meth.isConstructor() && meth.getParameterTypes().length == 0) { IMethodBinding[] bindings= meth.getDeclaringClass().getDeclaredMethods(); // implicit constructors must be the only constructor for (int i= 0; i < bindings.length; i++) { IMethodBinding curr= bindings[i]; if (curr.isConstructor() && curr != meth) { return false; } } ASTParser parser= ASTParser.newParser(AST.JLS2); parser.setSource(targetCU); parser.setFocalPosition(0); parser.setResolveBindings(true); CompilationUnit unit= (CompilationUnit) parser.createAST(null); return unit.findDeclaringNode(meth.getKey()) == null; } return false; } private static String getMethodSignature(IMethodBinding binding, boolean inOtherCU) { StringBuffer buf= new StringBuffer(); if (inOtherCU && !binding.isConstructor()) { buf.append(binding.getDeclaringClass().getName()).append('.'); } buf.append(binding.getName()); return getMethodSignature(buf.toString(), binding.getParameterTypes()); } private static String getMethodSignature(String name, List args) { ITypeBinding[] params= new ITypeBinding[args.size()]; for (int i= 0; i < args.size(); i++) { Expression expr= (Expression) args.get(i); ITypeBinding curr= Bindings.normalizeTypeBinding(expr.resolveTypeBinding()); if (curr == null) { curr= expr.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } params[i]= curr; } return getMethodSignature(name, params); } private static String getMethodSignature(String name, ITypeBinding[] params) { StringBuffer buf= new StringBuffer(); buf.append(name).append('('); for (int i= 0; i < params.length; i++) { if (i > 0) { buf.append(", "); //$NON-NLS-1$ } buf.append(params[i].getName()); } buf.append(')'); return buf.toString(); } private static void doEqualNumberOfParameters(IInvocationContext context, ASTNode invocationNode, IProblemLocation problem, List arguments, ITypeBinding[] argTypes, IMethodBinding methodBinding, Collection proposals) throws CoreException { ITypeBinding[] paramTypes= methodBinding.getParameterTypes(); int[] indexOfDiff= new int[paramTypes.length]; int nDiffs= 0; for (int n= 0; n < argTypes.length; n++) { if (!TypeRules.canAssign(argTypes[n], paramTypes[n])) { indexOfDiff[nDiffs++]= n; } } ITypeBinding declaringType= methodBinding.getDeclaringClass(); ICompilationUnit cu= context.getCompilationUnit(); CompilationUnit astRoot= context.getASTRoot(); ASTNode nameNode= problem.getCoveringNode(astRoot); if (nameNode == null) { return; } if (nDiffs == 0) { if (nameNode.getParent() instanceof MethodInvocation) { MethodInvocation inv= (MethodInvocation) nameNode.getParent(); if (inv.getExpression() == null) { addQualifierToOuterProposal(context, inv, methodBinding, proposals); } } return; } if (nDiffs == 1) { // one argument mismatching: try to fix int idx= indexOfDiff[0]; Expression nodeToCast= (Expression) arguments.get(idx); ITypeBinding castType= paramTypes[idx]; ITypeBinding binding= nodeToCast.resolveTypeBinding(); if (binding == null || TypeRules.canCast(castType, binding)) { String castTypeName= castType.getQualifiedName(); ASTRewriteCorrectionProposal proposal= TypeMismatchSubProcessor.createCastProposal(context, castTypeName, nodeToCast, 6); String[] arg= new String[] { getArgumentName(cu, arguments, idx), castTypeName}; proposal.setDisplayName(CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.addargumentcast.description", arg)); //$NON-NLS-1$ proposals.add(proposal); } TypeMismatchSubProcessor.addChangeSenderTypeProposals(context, nodeToCast, castType, false, 5, proposals); } if (nDiffs == 2) { // try to swap int idx1= indexOfDiff[0]; int idx2= indexOfDiff[1]; boolean canSwap= TypeRules.canAssign(argTypes[idx1], paramTypes[idx2]) && TypeRules.canAssign(argTypes[idx2], paramTypes[idx1]); if (canSwap) { Expression arg1= (Expression) arguments.get(idx1); Expression arg2= (Expression) arguments.get(idx2); ASTRewrite rewrite= ASTRewrite.create(astRoot.getAST()); rewrite.replace(arg1, rewrite.createCopyTarget(arg2), null); rewrite.replace(arg2, rewrite.createCopyTarget(arg1), null); { String[] arg= new String[] { getArgumentName(cu, arguments, idx1), getArgumentName(cu, arguments, idx2) }; String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.swaparguments.description", arg); //$NON-NLS-1$ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 8, image); proposals.add(proposal); } if (declaringType.isFromSource()) { ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, declaringType); if (targetCU != null) { ChangeDescription[] changeDesc= new ChangeDescription[paramTypes.length]; for (int i= 0; i < nDiffs; i++) { changeDesc[idx1]= new SwapDescription(idx2); } ITypeBinding[] swappedTypes= new ITypeBinding[] { paramTypes[idx1], paramTypes[idx2] }; String[] args= new String[] { getMethodSignature(methodBinding, !targetCU.equals(cu)), getTypeNames(swappedTypes) }; String label; if (methodBinding.isConstructor()) { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.swapparams.constr.description", args); //$NON-NLS-1$ } else { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.swapparams.description", args); //$NON-NLS-1$ } Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); ChangeMethodSignatureProposal proposal= new ChangeMethodSignatureProposal(label, targetCU, invocationNode, methodBinding, changeDesc, 5, image); proposals.add(proposal); } } return; } } if (declaringType.isFromSource()) { ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, declaringType); if (targetCU != null) { ChangeDescription[] changeDesc= new ChangeDescription[paramTypes.length]; for (int i= 0; i < nDiffs; i++) { int diffIndex= indexOfDiff[i]; Expression arg= (Expression) arguments.get(diffIndex); String name= arg instanceof SimpleName ? ((SimpleName) arg).getIdentifier() : null; changeDesc[diffIndex]= new EditDescription(argTypes[diffIndex], name); } String[] args= new String[] { getMethodSignature(methodBinding, !targetCU.equals(cu)), getMethodSignature(methodBinding.getName(), arguments) }; String label; if (methodBinding.isConstructor()) { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changeparamsignature.constr.description", args); //$NON-NLS-1$ } else { label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changeparamsignature.description", args); //$NON-NLS-1$ } Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); ChangeMethodSignatureProposal proposal= new ChangeMethodSignatureProposal(label, targetCU, invocationNode, methodBinding, changeDesc, 7, image); proposals.add(proposal); } } } private static ITypeBinding[] getArgumentTypes(List arguments) { ITypeBinding[] res= new ITypeBinding[arguments.size()]; for (int i= 0; i < res.length; i++) { Expression expression= (Expression) arguments.get(i); ITypeBinding curr= expression.resolveTypeBinding(); if (curr == null) { return null; } curr= Bindings.normalizeTypeBinding(curr); if (curr == null) { curr= expression.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$ } res[i]= curr; } return res; } private static void addQualifierToOuterProposal(IInvocationContext context, MethodInvocation invocationNode, IMethodBinding binding, Collection proposals) throws CoreException { ITypeBinding declaringType= binding.getDeclaringClass(); ITypeBinding parentType= Bindings.getBindingOfParentType(invocationNode); ITypeBinding currType= parentType; boolean isInstanceMethod= !Modifier.isStatic(binding.getModifiers()); while (currType != null && !Bindings.isSuperType(declaringType, currType)) { if (isInstanceMethod && Modifier.isStatic(currType.getModifiers())) { return; } currType= currType.getDeclaringClass(); } if (currType == null || currType == parentType) { return; } ASTRewrite rewrite= ASTRewrite.create(invocationNode.getAST()); ImportRewrite imports= new ImportRewrite(context.getCompilationUnit()); AST ast= invocationNode.getAST(); String qualifier= imports.addImport(currType); Name name= ASTNodeFactory.newName(ast, qualifier); Expression newExpression; if (isInstanceMethod) { ThisExpression expr= ast.newThisExpression(); expr.setQualifier(name); newExpression= expr; } else { newExpression= name; } rewrite.set(invocationNode, MethodInvocation.EXPRESSION_PROPERTY, newExpression, null); String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.changetoouter.description", currType.getName()); //$NON-NLS-1$ Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 8, image); proposal.setImportRewrite(imports); proposals.add(proposal); } public static void getConstructorProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException { ICompilationUnit cu= context.getCompilationUnit(); CompilationUnit astRoot= context.getASTRoot(); ASTNode selectedNode= problem.getCoveringNode(astRoot); if (selectedNode == null) { return; } ITypeBinding targetBinding= null; List arguments= null; IMethodBinding recursiveConstructor= null; int type= selectedNode.getNodeType(); if (type == ASTNode.CLASS_INSTANCE_CREATION) { ClassInstanceCreation creation= (ClassInstanceCreation) selectedNode; IBinding binding= creation.getName().resolveBinding(); if (binding instanceof ITypeBinding) { targetBinding= (ITypeBinding) binding; arguments= creation.arguments(); } } else if (type == ASTNode.SUPER_CONSTRUCTOR_INVOCATION) { ITypeBinding typeBinding= Bindings.getBindingOfParentType(selectedNode); if (typeBinding != null && !typeBinding.isAnonymous()) { targetBinding= typeBinding.getSuperclass(); arguments= ((SuperConstructorInvocation) selectedNode).arguments(); } } else if (type == ASTNode.CONSTRUCTOR_INVOCATION) { ITypeBinding typeBinding= Bindings.getBindingOfParentType(selectedNode); if (typeBinding != null && !typeBinding.isAnonymous()) { targetBinding= typeBinding; arguments= ((ConstructorInvocation) selectedNode).arguments(); recursiveConstructor= ASTResolving.findParentMethodDeclaration(selectedNode).resolveBinding(); } } if (targetBinding == null) { return; } IMethodBinding[] methods= targetBinding.getDeclaredMethods(); ArrayList similarElements= new ArrayList(); for (int i= 0; i < methods.length; i++) { IMethodBinding curr= methods[i]; if (curr.isConstructor() && recursiveConstructor != curr) { similarElements.add(curr); // similar elements can contain a implicit default constructor } } addParameterMissmatchProposals(context, problem, similarElements, selectedNode, arguments, proposals); if (targetBinding.isFromSource()) { ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, astRoot, targetBinding); if (targetCU != null) { String[] args= new String[] { getMethodSignature( targetBinding.getName(), arguments) }; String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.createconstructor.description", args); //$NON-NLS-1$ Image image= JavaPluginImages.get(JavaPluginImages.IMG_MISC_PUBLIC); proposals.add(new NewMethodCompletionProposal(label, targetCU, selectedNode, arguments, targetBinding, 5, image)); } } } public static void getAmbiguosTypeReferenceProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException { final ICompilationUnit cu= context.getCompilationUnit(); int offset= problem.getOffset(); int len= problem.getLength(); IJavaElement[] elements= cu.codeSelect(offset, len); for (int i= 0; i < elements.length; i++) { IJavaElement curr= elements[i]; if (curr instanceof IType && !TypeFilter.isFiltered((IType) curr)) { String qualifiedTypeName= JavaModelUtil.getFullyQualifiedName((IType) curr); ImportRewrite imports= new ImportRewrite(cu); imports.setFindAmbiguosImports(true); imports.addImport(qualifiedTypeName); String label= CorrectionMessages.getFormattedString("UnresolvedElementsSubProcessor.importexplicit.description", qualifiedTypeName); //$NON-NLS-1$ Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_IMPDECL); CUCorrectionProposal proposal= new CUCorrectionProposal(label, cu, 5, image); proposal.setImportRewrite(imports); proposals.add(proposal); } } } }
38,086
Bug 38086 Add suggestion "array.length()" -> array.length [quick fix]
When referring to an array's length, it would be useful if the developer made a mistake of using array.length() to be prompted with a suggestion to change it to array.length instead, as opposed to 'no suggestion' that it currently says at the moment Mac OS X.2.6 with Eclipse 2.1
resolved fixed
a271da5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-07T10:18:30Z
2003-05-24T23:46:40Z
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/UnresolvedMethodsQuickFixTest.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.tests.quickfix; import java.util.ArrayList; import java.util.Hashtable; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.tests.core.ProjectTestSetup; import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal; import org.eclipse.jdt.internal.ui.text.correction.NewMethodCompletionProposal; public class UnresolvedMethodsQuickFixTest extends QuickFixTest { private static final Class THIS= UnresolvedMethodsQuickFixTest.class; private IJavaProject fJProject1; private IPackageFragmentRoot fSourceFolder; public UnresolvedMethodsQuickFixTest(String name) { super(name); } public static Test allTests() { return new ProjectTestSetup(new TestSuite(THIS)); } public static Test suite() { if (false) { return allTests(); } else { TestSuite suite= new TestSuite(); suite.addTest(new UnresolvedMethodsQuickFixTest("testParameterMismatchChangeMethodType")); return new ProjectTestSetup(suite); } } protected void setUp() throws Exception { Hashtable options= JavaCore.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); options.put(JavaCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT, JavaCore.IGNORE); JavaCore.setOptions(options); IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); fJProject1= ProjectTestSetup.getProject(); JavaPlugin.getDefault().getCodeTemplateStore().findTemplate(CodeTemplateContextType.CATCHBLOCK).setPattern(""); JavaPlugin.getDefault().getCodeTemplateStore().findTemplate(CodeTemplateContextType.CONSTRUCTORSTUB).setPattern(""); JavaPlugin.getDefault().getCodeTemplateStore().findTemplate(CodeTemplateContextType.METHODSTUB).setPattern(""); fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src"); } protected void tearDown() throws Exception { JavaProjectHelper.clear(fJProject1, ProjectTestSetup.getDefaultClasspath()); } public void testMethodInSameType() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= goo(vec, true);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); NewMethodCompletionProposal proposal= (NewMethodCompletionProposal) proposals.get(0); String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= goo(vec, true);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private int goo(Vector vec, boolean b) {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } public void testMethodInForInit() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" void foo() {\n"); buf.append(" for (int i= 0, j= goo(3); i < 0; i++) {\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); NewMethodCompletionProposal proposal= (NewMethodCompletionProposal) proposals.get(0); String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" void foo() {\n"); buf.append(" for (int i= 0, j= goo(3); i < 0; i++) {\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private int goo(int i) {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } public void testMethodInInfixExpression1() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" private boolean foo() {\n"); buf.append(" return f(1) || f(2);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot, 2); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); NewMethodCompletionProposal proposal= (NewMethodCompletionProposal) proposals.get(0); String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" private boolean foo() {\n"); buf.append(" return f(1) || f(2);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private boolean f(int i) {\n"); buf.append(" return false;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } public void testMethodInInfixExpression2() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" private boolean foo() {\n"); buf.append(" return f(1) == f(2);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot, 2); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); NewMethodCompletionProposal proposal= (NewMethodCompletionProposal) proposals.get(0); String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" private boolean foo() {\n"); buf.append(" return f(1) == f(2);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private Object f(int i) {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } public void testMethodSpacing0EmptyLines() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append("\n"); buf.append(" void fred() {\n"); buf.append(" }\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= goo(vec, true);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); NewMethodCompletionProposal proposal= (NewMethodCompletionProposal) proposals.get(0); String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append("\n"); buf.append(" void fred() {\n"); buf.append(" }\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= goo(vec, true);\n"); buf.append(" }\n"); buf.append(" private int goo(Vector vec, boolean b) {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } public void testMethodSpacing1EmptyLine() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append("\n"); buf.append(" void fred() {\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= goo(vec, true);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); NewMethodCompletionProposal proposal= (NewMethodCompletionProposal) proposals.get(0); String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append("\n"); buf.append(" void fred() {\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= goo(vec, true);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private int goo(Vector vec, boolean b) {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } public void testMethodSpacing2EmptyLines() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append("\n"); buf.append(" void fred() {\n"); buf.append(" }\n"); buf.append(" \n"); buf.append(" \n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= goo(vec, true);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); NewMethodCompletionProposal proposal= (NewMethodCompletionProposal) proposals.get(0); String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append("\n"); buf.append(" void fred() {\n"); buf.append(" }\n"); buf.append(" \n"); buf.append(" \n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= goo(vec, true);\n"); buf.append(" }\n"); buf.append("\n"); buf.append("\n"); buf.append(" private int goo(Vector vec, boolean b) {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } public void testMethodSpacingComment() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append("\n"); buf.append(" void fred() {\n"); buf.append(" }\n"); buf.append("\n"); buf.append("//comment\n"); buf.append("\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= goo(vec, true);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); NewMethodCompletionProposal proposal= (NewMethodCompletionProposal) proposals.get(0); String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append("\n"); buf.append(" void fred() {\n"); buf.append(" }\n"); buf.append("\n"); buf.append("//comment\n"); buf.append("\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= goo(vec, true);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private int goo(Vector vec, boolean b) {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } public void testMethodSpacingJavadoc() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append("\n"); buf.append(" void fred() {\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" /**\n"); buf.append(" * javadoc\n"); buf.append(" */\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= goo(vec, true);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); NewMethodCompletionProposal proposal= (NewMethodCompletionProposal) proposals.get(0); String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append("\n"); buf.append(" void fred() {\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" /**\n"); buf.append(" * javadoc\n"); buf.append(" */\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= goo(vec, true);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private int goo(Vector vec, boolean b) {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } public void testMethodSpacingNonJavadoc() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append("\n"); buf.append(" void fred() {\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" /*\n"); buf.append(" * non javadoc\n"); buf.append(" */\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= goo(vec, true);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); NewMethodCompletionProposal proposal= (NewMethodCompletionProposal) proposals.get(0); String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append("\n"); buf.append(" void fred() {\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" /*\n"); buf.append(" * non javadoc\n"); buf.append(" */\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= goo(vec, true);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private int goo(Vector vec, boolean b) {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } public void testMethodInSameTypeUsingThis() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= this.goo(vec, true);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); NewMethodCompletionProposal proposal= (NewMethodCompletionProposal) proposals.get(0); String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" int i= this.goo(vec, true);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private int goo(Vector vec, boolean b) {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } public void testMethodInDifferentClass() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" void foo(X x) {\n"); buf.append(" boolean i= x.goo(1, 2.1);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append("}\n"); pack1.createCompilationUnit("X.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); NewMethodCompletionProposal proposal= (NewMethodCompletionProposal) proposals.get(0); String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append("\n"); buf.append(" public boolean goo(int i, double d) {\n"); buf.append(" return false;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } public void testMethodInAnonymous1() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" xoo();\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" xoo();\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private void xoo() {\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" xoo();\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" protected void xoo() {\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" foo();\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testMethodInAnonymous2() throws Exception { IPackageFragment pack0= fSourceFolder.createPackageFragment("other", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package other;\n"); buf.append("public class A {\n"); buf.append("}\n"); pack0.createCompilationUnit("A.java", buf.toString(), false, null); IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import other.A;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" A.xoo();\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package other;\n"); buf.append("public class A {\n"); buf.append("\n"); buf.append(" public static void xoo() {\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); assertEqualString(preview1, expected1); } public void testMethodInAnonymousCovering1() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void run(int i) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" run(1);\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 4); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void run(int i) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" E.this.run(1);\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void run(int i) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" run();\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void run(int i) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run(int i) {\n"); buf.append(" run(1);\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(3); String preview4= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void run(int i) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" run(1);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private void run(int i) {\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected4= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3, preview4 }, new String[] { expected1, expected2, expected3, expected4 }); } public void testMethodInAnonymousCovering2() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public static void run(int i) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" run(1);\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 4); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public static void run(int i) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" E.run(1);\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public static void run(int i) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" run();\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public static void run(int i) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run(int i) {\n"); buf.append(" run(1);\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(3); String preview4= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public static void run(int i) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" run(1);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private void run(int i) {\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected4= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3, preview4 }, new String[] { expected1, expected2, expected3, expected4 }); } public void testMethodInAnonymousCovering3() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void run(int i) {\n"); buf.append(" }\n"); buf.append(" public class Inner {\n"); buf.append(" public void run() {\n"); buf.append(" run(1);\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 4); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void run(int i) {\n"); buf.append(" }\n"); buf.append(" public class Inner {\n"); buf.append(" public void run() {\n"); buf.append(" E.this.run(1);\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void run(int i) {\n"); buf.append(" }\n"); buf.append(" public class Inner {\n"); buf.append(" public void run() {\n"); buf.append(" run();\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void run(int i) {\n"); buf.append(" }\n"); buf.append(" public class Inner {\n"); buf.append(" public void run(int i) {\n"); buf.append(" run(1);\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(3); String preview4= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void run(int i) {\n"); buf.append(" }\n"); buf.append(" public class Inner {\n"); buf.append(" public void run() {\n"); buf.append(" run(1);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private void run(int i) {\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); String expected4= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3, preview4 }, new String[] { expected1, expected2, expected3, expected4 }); } public void testMethodInAnonymousCovering4() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void run(int i) {\n"); buf.append(" }\n"); buf.append(" public static class Inner {\n"); buf.append(" public void run() {\n"); buf.append(" run(1);\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void run(int i) {\n"); buf.append(" }\n"); buf.append(" public static class Inner {\n"); buf.append(" public void run() {\n"); buf.append(" run(1);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private void run(int i) {\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void run(int i) {\n"); buf.append(" }\n"); buf.append(" public static class Inner {\n"); buf.append(" public void run() {\n"); buf.append(" run();\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void run(int i) {\n"); buf.append(" }\n"); buf.append(" public static class Inner {\n"); buf.append(" public void run(int i) {\n"); buf.append(" run(1);\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testMethodInDifferentInterface() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" void foo(X x) {\n"); buf.append(" boolean i= x.goo(getClass());\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public interface X {\n"); buf.append("}\n"); pack1.createCompilationUnit("X.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); NewMethodCompletionProposal proposal= (NewMethodCompletionProposal) proposals.get(0); String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public interface X {\n"); buf.append("\n"); buf.append(" boolean goo(Class class1);\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } public void testParameterMismatchCast() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" long x= 0;\n"); buf.append(" foo(x + 1);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" long x= 0;\n"); buf.append(" foo((int) (x + 1));\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" long x= 0;\n"); buf.append(" foo(x + 1);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private void foo(long l) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(long l) {\n"); buf.append(" long x= 0;\n"); buf.append(" foo(x + 1);\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testParameterMismatchCast2() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" double x= 0.0;\n"); buf.append(" X.xoo((float) x, this);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public static void xoo(int i, Object o) {\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("X.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" double x= 0.0;\n"); buf.append(" X.xoo((int) x, this);\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public static void xoo(int i, Object o) {\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" public static void xoo(float f, E e) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public static void xoo(float f, Object o) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testParameterMismatchChangeVarType() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public void goo(Vector v) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" long x= 0;\n"); buf.append(" goo(x);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public void goo(long x) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" long x= 0;\n"); buf.append(" goo(x);\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public void goo(Vector v) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" long x= 0;\n"); buf.append(" goo(x);\n"); buf.append(" }\n"); buf.append(" private void goo(long x) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public void goo(Vector v) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" Vector x= 0;\n"); buf.append(" goo(x);\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testParameterMismatchChangeFieldType() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" int fCount= 0;\n"); buf.append(" public void goo(Vector v) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" goo(fCount);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" int fCount= 0;\n"); buf.append(" public void goo(int count) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" goo(fCount);\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" int fCount= 0;\n"); buf.append(" public void goo(Vector v) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" goo(fCount);\n"); buf.append(" }\n"); buf.append(" private void goo(int count) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" Vector fCount= 0;\n"); buf.append(" public void goo(Vector v) {\n"); buf.append(" }\n"); buf.append(" public void foo() {\n"); buf.append(" goo(fCount);\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testParameterMismatchChangeMethodType() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public void goo(Vector v) {\n"); buf.append(" }\n"); buf.append(" public int foo() {\n"); buf.append(" goo(this.foo());\n"); buf.append(" return 9;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public void goo(int i) {\n"); buf.append(" }\n"); buf.append(" public int foo() {\n"); buf.append(" goo(this.foo());\n"); buf.append(" return 9;\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public void goo(Vector v) {\n"); buf.append(" }\n"); buf.append(" public int foo() {\n"); buf.append(" goo(this.foo());\n"); buf.append(" return 9;\n"); buf.append(" }\n"); buf.append(" private void goo(int i) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public void goo(Vector v) {\n"); buf.append(" }\n"); buf.append(" public Vector foo() {\n"); buf.append(" goo(this.foo());\n"); buf.append(" return 9;\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testParameterMismatchLessArguments() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(String s, int i, Object o) {\n"); buf.append(" int x= 0;\n"); buf.append(" foo(x);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(String s, int i, Object o) {\n"); buf.append(" int x= 0;\n"); buf.append(" foo(s, x, o);\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(String s, int i, Object o) {\n"); buf.append(" int x= 0;\n"); buf.append(" foo(x);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private void foo(int x) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" int x= 0;\n"); buf.append(" foo(x);\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testParameterMismatchLessArguments2() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" X.xoo(null);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public static void xoo(int i, Object o) {\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("X.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo() {\n"); buf.append(" X.xoo(0, null);\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public static void xoo(int i, Object o) {\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" public static void xoo(Object object) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public static void xoo(Object o) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testSuperConstructorLessArguments() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public X(Object o, int i) {\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("X.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E extends X {\n"); buf.append(" public E() {\n"); buf.append(" super(new Vector());\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E extends X {\n"); buf.append(" public E() {\n"); buf.append(" super(new Vector(), 0);\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("import java.util.Vector;\n"); buf.append("\n"); buf.append("public class X {\n"); buf.append(" public X(Object o, int i) {\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" public X(Vector vector) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public X(Object o) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testConstructorInvocationLessArguments() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public E(Object o, int i) {\n"); buf.append(" }\n"); buf.append(" public E() {\n"); buf.append(" this(new Vector());\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public E(Object o, int i) {\n"); buf.append(" }\n"); buf.append(" public E() {\n"); buf.append(" this(new Vector(), 0);\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public E(Object o) {\n"); buf.append(" }\n"); buf.append(" public E() {\n"); buf.append(" this(new Vector());\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public E(Object o, int i) {\n"); buf.append(" }\n"); buf.append(" public E() {\n"); buf.append(" this(new Vector());\n"); buf.append(" }\n"); buf.append(" public E(Vector vector) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testParameterMismatchMoreArguments() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(X x) {\n"); buf.append(" x.xoo(1, 1, x);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public void xoo(int i, Object o) {\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("X.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(X x) {\n"); buf.append(" x.xoo(1, x);\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public void xoo(int i, int j, Object o) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public void xoo(int i, Object o) {\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" public void xoo(int i, int j, X x) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testParameterMismatchMoreArguments2() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(String s) {\n"); buf.append(" int x= 0;\n"); buf.append(" foo(s, x);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(String s) {\n"); buf.append(" int x= 0;\n"); buf.append(" foo(s);\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(String s) {\n"); buf.append(" int x= 0;\n"); buf.append(" foo(s, x);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private void foo(String s, int x) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(String s, int x2) {\n"); buf.append(" int x= 0;\n"); buf.append(" foo(s, x);\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testParameterMismatchMoreArguments3() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Collections;\n"); buf.append("public class E {\n"); buf.append(" public void foo(X x) {\n"); buf.append(" x.xoo(Collections.EMPTY_SET, 1, 2);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public void xoo(int i) {\n"); buf.append(" int j= 0;\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("X.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Collections;\n"); buf.append("public class E {\n"); buf.append(" public void foo(X x) {\n"); buf.append(" x.xoo(1);\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("import java.util.Set;\n"); buf.append("\n"); buf.append("public class X {\n"); buf.append(" public void xoo(Set set, int i, int k) {\n"); buf.append(" int j= 0;\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("import java.util.Set;\n"); buf.append("\n"); buf.append("public class X {\n"); buf.append(" public void xoo(int i) {\n"); buf.append(" int j= 0;\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" public void xoo(Set set, int i, int j) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testSuperConstructorMoreArguments() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public X() {\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("X.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E extends X {\n"); buf.append(" public E() {\n"); buf.append(" super(new Vector());\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E extends X {\n"); buf.append(" public E() {\n"); buf.append(" super();\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("import java.util.Vector;\n"); buf.append("\n"); buf.append("public class X {\n"); buf.append(" public X() {\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" public X(Vector vector) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("import java.util.Vector;\n"); buf.append("\n"); buf.append("public class X {\n"); buf.append(" public X(Vector vector) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testConstructorInvocationMoreArguments() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public E() {\n"); buf.append(" }\n"); buf.append(" public E(Object o, int i) {\n"); buf.append(" this(new Vector());\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public E() {\n"); buf.append(" }\n"); buf.append(" public E(Object o, int i) {\n"); buf.append(" this();\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public E(Vector vector) {\n"); buf.append(" }\n"); buf.append(" public E(Object o, int i) {\n"); buf.append(" this(new Vector());\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" public E() {\n"); buf.append(" }\n"); buf.append(" public E(Object o, int i) {\n"); buf.append(" this(new Vector());\n"); buf.append(" }\n"); buf.append(" public E(Vector vector) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testParameterMismatchSwap() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i, Object o) {\n"); buf.append(" foo(new Object[] { o }, i - 1);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i, Object o) {\n"); buf.append(" foo(i - 1, new Object[] { o });\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i, Object o) {\n"); buf.append(" foo(new Object[] { o }, i - 1);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" private void foo(Object[] objects, int i) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Object o, int i) {\n"); buf.append(" foo(new Object[] { o }, i - 1);\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testSuperConstructor() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E extends A {\n"); buf.append(" public E(int i) {\n"); buf.append(" super(i);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1=pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class A {\n"); buf.append("}\n"); pack1.createCompilationUnit("A.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class A {\n"); buf.append("\n"); buf.append(" public A(int i) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E extends A {\n"); buf.append(" public E(int i) {\n"); buf.append(" super();\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } public void testClassInstanceCreation() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" A a= new A(i);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1=pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class A {\n"); buf.append("}\n"); pack1.createCompilationUnit("A.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class A {\n"); buf.append("\n"); buf.append(" public A(int i) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" A a= new A();\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } public void testClassInstanceCreation2() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" A a= new A(\"test\");\n"); buf.append(" }\n"); buf.append(" class A {\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1=pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" A a= new A(\"test\");\n"); buf.append(" }\n"); buf.append(" class A {\n"); buf.append("\n"); buf.append(" public A(String string) {\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" A a= new A();\n"); buf.append(" }\n"); buf.append(" class A {\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } public void testClassInstanceCreationMoreArguments() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" A a= new A(i, String.valueOf(i), true);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1=pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class A {\n"); buf.append(" public A(int i) {\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("A.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class A {\n"); buf.append(" public A(int i, String string, boolean b) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" A a= new A(i);\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class A {\n"); buf.append(" public A(int i) {\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" public A(int i, String string, boolean b) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testClassInstanceCreationLessArguments() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" A a= new A();\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1=pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class A {\n"); buf.append(" public A(int i, String s) {\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("A.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class A {\n"); buf.append(" public A() {\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" A a= new A(i, null);\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class A {\n"); buf.append(" public A(int i, String s) {\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" public A() {\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testConstructorInvocation() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public E(int i) {\n"); buf.append(" this(i, true);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1=pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public E(int i) {\n"); buf.append(" this(i, true);\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" public E(int i, boolean b) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); assertEqualString(preview1, expected1); } public void testSuperMethodInvocation() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E extends A {\n"); buf.append(" public void foo(int i) {\n"); buf.append(" super.foo(i);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1=pack1.createCompilationUnit("E.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class A {\n"); buf.append("}\n"); pack1.createCompilationUnit("A.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); NewMethodCompletionProposal proposal= (NewMethodCompletionProposal) proposals.get(0); String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class A {\n"); buf.append("\n"); buf.append(" public void foo(int i) {\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } public void testSuperMethodMoreArguments() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public int foo() {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("X.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E extends X {\n"); buf.append(" public void xoo() {\n"); buf.append(" super.foo(new Vector());\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E extends X {\n"); buf.append(" public void xoo() {\n"); buf.append(" super.foo();\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("import java.util.Vector;\n"); buf.append("\n"); buf.append("public class X {\n"); buf.append(" public int foo(Vector vector) {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("import java.util.Vector;\n"); buf.append("\n"); buf.append("public class X {\n"); buf.append(" public int foo() {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" public void foo(Vector vector) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testSuperMethodLessArguments() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public int foo(Object o, boolean b) {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("}\n"); pack1.createCompilationUnit("X.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E extends X {\n"); buf.append(" public void xoo() {\n"); buf.append(" super.foo(new Vector());\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOfProposals(proposals, 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E extends X {\n"); buf.append(" public void xoo() {\n"); buf.append(" super.foo(new Vector(), false);\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class X {\n"); buf.append(" public int foo(Object o) {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("import java.util.Vector;\n"); buf.append("\n"); buf.append("public class X {\n"); buf.append(" public int foo(Object o, boolean b) {\n"); buf.append(" return 0;\n"); buf.append(" }\n"); buf.append("\n"); buf.append(" public void foo(Vector vector) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testMissingCastParents1() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Object o) {\n"); buf.append(" String x= (String) o.substring(1);\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Object o) {\n"); buf.append(" String x= ((String) o).substring(1);\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); assertEqualString(preview1, expected1); } public void testMissingCastParents2() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Object o) {\n"); buf.append(" String x= (String) o.substring(1).toLowerCase();\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(Object o) {\n"); buf.append(" String x= ((String) o).substring(1).toLowerCase();\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); assertEqualString(preview1, expected1); } public void testMissingCastParents3() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" private static Object obj;\n"); buf.append(" public void foo() {\n"); buf.append(" String x= (String) E.obj.substring(1).toLowerCase();\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOfProposals(proposals, 1); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" private static Object obj;\n"); buf.append(" public void foo() {\n"); buf.append(" String x= ((String) E.obj).substring(1).toLowerCase();\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); assertEqualString(preview1, expected1); } }
38,086
Bug 38086 Add suggestion "array.length()" -> array.length [quick fix]
When referring to an array's length, it would be useful if the developer made a mistake of using array.length() to be prompted with a suggestion to change it to array.length instead, as opposed to 'no suggestion' that it currently says at the moment Mac OS X.2.6 with Eclipse 2.1
resolved fixed
a271da5
JDT
https://github.com/eclipse-jdt/eclipse.jdt.ui
eclipse-jdt/eclipse.jdt.ui
java
null
null
null
2004-05-07T10:18:30Z
2003-05-24T23:46:40Z
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/quickfix/UnresolvedVariablesQuickFixTest.java
/******************************************************************************* * Copyright (c) 2000, 2003 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/cpl-v10.html * * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ package org.eclipse.jdt.ui.tests.quickfix; import java.util.ArrayList; import java.util.Hashtable; import junit.framework.Test; import junit.framework.TestSuite; import org.eclipse.jdt.testplugin.JavaProjectHelper; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jdt.core.ICompilationUnit; import org.eclipse.jdt.core.IJavaProject; import org.eclipse.jdt.core.IPackageFragment; import org.eclipse.jdt.core.IPackageFragmentRoot; import org.eclipse.jdt.core.JavaCore; import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.jdt.core.dom.CompilationUnit; import org.eclipse.jdt.ui.PreferenceConstants; import org.eclipse.jdt.ui.tests.core.ProjectTestSetup; import org.eclipse.jdt.internal.corext.template.java.CodeTemplateContextType; import org.eclipse.jdt.internal.ui.JavaPlugin; import org.eclipse.jdt.internal.ui.text.correction.CUCorrectionProposal; import org.eclipse.jdt.internal.ui.text.correction.NewCUCompletionUsingWizardProposal; import org.eclipse.jdt.internal.ui.text.correction.NewVariableCompletionProposal; import org.eclipse.jdt.internal.ui.text.correction.RenameNodeCompletionProposal; public class UnresolvedVariablesQuickFixTest extends QuickFixTest { private static final Class THIS= UnresolvedVariablesQuickFixTest.class; private IJavaProject fJProject1; private IPackageFragmentRoot fSourceFolder; public UnresolvedVariablesQuickFixTest(String name) { super(name); } public static Test allTests() { return new ProjectTestSetup(new TestSuite(THIS)); } public static Test suite() { if (true) { return allTests(); } else { TestSuite suite= new TestSuite(); suite.addTest(new UnresolvedVariablesQuickFixTest("testVarInAnonymous")); return new ProjectTestSetup(suite); } } protected void setUp() throws Exception { Hashtable options= JavaCore.getDefaultOptions(); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR, JavaCore.SPACE); options.put(DefaultCodeFormatterConstants.FORMATTER_NUMBER_OF_EMPTY_LINES_TO_PRESERVE, "1"); options.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, "4"); options.put(JavaCore.COMPILER_PB_UNUSED_IMPORT, JavaCore.IGNORE); JavaCore.setOptions(options); IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); store.setValue(PreferenceConstants.CODEGEN_ADD_COMMENTS, false); fJProject1= ProjectTestSetup.getProject(); JavaPlugin.getDefault().getCodeTemplateStore().findTemplate(CodeTemplateContextType.NEWTYPE).setPattern(""); JavaPlugin.getDefault().getCodeTemplateStore().findTemplate(CodeTemplateContextType.TYPECOMMENT).setPattern(""); fSourceFolder= JavaProjectHelper.addSourceContainer(fJProject1, "src"); } protected void tearDown() throws Exception { JavaProjectHelper.clear(fJProject1, ProjectTestSetup.getDefaultClasspath()); } public void testVarInAssignment() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" iter= vec.iterator();\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOf("proposals", proposals.size(), 4); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Iterator;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" private Iterator iter;\n"); buf.append("\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" iter= vec.iterator();\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Iterator;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" Iterator iter = vec.iterator();\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Iterator;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" void foo(Vector vec, Iterator iter) {\n"); buf.append(" iter= vec.iterator();\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(3); String preview4= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.util.Vector;\n"); buf.append("public class E {\n"); buf.append(" void foo(Vector vec) {\n"); buf.append(" }\n"); buf.append("}\n"); String expected4= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3, preview4 }, new String[] { expected1, expected2, expected3, expected4 }); } public void testVarInForInitializer() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" void foo() {\n"); buf.append(" for (i= 0;;) {\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOf("proposals", proposals.size(), 3); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" private int i;\n"); buf.append("\n"); buf.append(" void foo() {\n"); buf.append(" for (i= 0;;) {\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" void foo() {\n"); buf.append(" for (int i = 0;;) {\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" void foo(int i) {\n"); buf.append(" for (i= 0;;) {\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3 }, new String[] { expected1, expected2, expected3 }); } public void testVarInInitializer() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" private int i= k;\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); assertNumberOf("proposals", proposals.size(), 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" private int k;\n"); buf.append(" private int i= k;\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" private static final int k = 0;\n"); buf.append(" private int i= k;\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } public void testVarInOtherType() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class F {\n"); buf.append(" void foo(E e) {\n"); buf.append(" e.var2= 2;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("F.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" protected int var1;\n"); buf.append("}\n"); pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOf("proposals", proposals.size(), 2); assertCorrectLabels(proposals); boolean doNew= true, doChange= true; for (int i= 0; i < proposals.size(); i++) { Object curr= proposals.get(i); if (curr instanceof NewVariableCompletionProposal) { assertTrue("2 new proposals", doNew); doNew= false; NewVariableCompletionProposal proposal= (NewVariableCompletionProposal) curr; String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" protected int var1;\n"); buf.append(" public int var2;\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } else if (curr instanceof CUCorrectionProposal) { assertTrue("2 replace proposals", doChange); doChange= false; CUCorrectionProposal proposal= (CUCorrectionProposal) curr; String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class F {\n"); buf.append(" void foo(E e) {\n"); buf.append(" e.var1= 2;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } } } public void testVarInSuperFieldAccess() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class F extends E {\n"); buf.append(" void foo() {\n"); buf.append(" super.var2= 2;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("F.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" protected int var1;\n"); buf.append("}\n"); pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOf("proposals", proposals.size(), 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class F extends E {\n"); buf.append(" void foo() {\n"); buf.append(" super.var1= 2;\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" protected int var1;\n"); buf.append(" public int var2;\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } public void testVarInSuper() throws Exception { StringBuffer buf= new StringBuffer(); IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import test3.E;\n"); buf.append("public class F extends E {\n"); buf.append(" void foo() {\n"); buf.append(" this.color= baz();\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("F.java", buf.toString(), false, null); IPackageFragment pack2= fSourceFolder.createPackageFragment("test2", false, null); buf= new StringBuffer(); buf.append("package test2;\n"); buf.append("public class E {\n"); buf.append("}\n"); pack2.createCompilationUnit("E.java", buf.toString(), false, null); IPackageFragment pack3= fSourceFolder.createPackageFragment("test3", false, null); buf= new StringBuffer(); buf.append("package test3;\n"); buf.append("public class E {\n"); buf.append(" protected Object olor;\n"); buf.append(" public test2.E baz() {\n"); buf.append(" return null;\n"); buf.append(" }\n"); buf.append("}\n"); pack3.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOf("proposals", proposals.size(), 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import test3.E;\n"); buf.append("public class F extends E {\n"); buf.append(" void foo() {\n"); buf.append(" this.olor= baz();\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import test3.E;\n"); buf.append("public class F extends E {\n"); buf.append(" private test2.E color;\n"); buf.append("\n"); buf.append(" void foo() {\n"); buf.append(" this.color= baz();\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } public void testVarInAnonymous() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int fcount) {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" fCount= 7;\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOf("proposals", proposals.size(), 6); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int fcount) {\n"); buf.append(" new Runnable() {\n"); buf.append(" private int fCount;\n"); buf.append("\n"); buf.append(" public void run() {\n"); buf.append(" fCount= 7;\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" protected int fCount;\n"); buf.append("\n"); buf.append(" public void foo(int fcount) {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" fCount= 7;\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(2); String preview3= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int fcount) {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" int fCount = 7;\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected3= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(3); String preview4= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int fcount) {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run(int fCount) {\n"); buf.append(" fCount= 7;\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected4= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(4); String preview5= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int fcount) {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" fcount= 7;\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected5= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(5); String preview6= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public void foo(int fcount) {\n"); buf.append(" new Runnable() {\n"); buf.append(" public void run() {\n"); buf.append(" }\n"); buf.append(" };\n"); buf.append(" }\n"); buf.append("}\n"); String expected6= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2, preview3, preview4, preview5, preview6 }, new String[] { expected1, expected2, expected3, expected4, expected5, expected6 }); } public void testLongVarRef() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class F {\n"); buf.append(" public int mash;\n"); buf.append(" void foo(E e) {\n"); buf.append(" e.var.hash= 2;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("F.java", buf.toString(), false, null); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" public F var;\n"); buf.append("}\n"); pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOf("proposals", proposals.size(), 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class F {\n"); buf.append(" public int mash;\n"); buf.append(" private int hash;\n"); buf.append(" void foo(E e) {\n"); buf.append(" e.var.hash= 2;\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class F {\n"); buf.append(" public int mash;\n"); buf.append(" void foo(E e) {\n"); buf.append(" e.var.mash= 2;\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2}, new String[] { expected1, expected2}); } public void testVarAndTypeRef() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.io.File;\n"); buf.append("public class F {\n"); buf.append(" void foo() {\n"); buf.append(" char ch= Fixe.pathSeparatorChar;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu1= pack1.createCompilationUnit("F.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu1); ArrayList proposals= collectCorrections(cu1, astRoot); assertNumberOf("proposals", proposals.size(), 7); assertCorrectLabels(proposals); boolean doField= true, doParam= true, doLocal= true, doConst= true, doInterface= true, doClass= true, doChange= true; for (int i= 0; i < proposals.size(); i++) { Object curr= proposals.get(i); if (curr instanceof NewVariableCompletionProposal) { NewVariableCompletionProposal proposal= (NewVariableCompletionProposal) proposals.get(i); String preview= getPreviewContent(proposal); if (proposal.getVariableKind() == NewVariableCompletionProposal.FIELD) { assertTrue("2 field proposals", doField); doField= false; buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.io.File;\n"); buf.append("public class F {\n"); buf.append(" private Object Fixe;\n"); buf.append("\n"); buf.append(" void foo() {\n"); buf.append(" char ch= Fixe.pathSeparatorChar;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } else if (proposal.getVariableKind() == NewVariableCompletionProposal.LOCAL) { assertTrue("2 local proposals", doLocal); doLocal= false; buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.io.File;\n"); buf.append("public class F {\n"); buf.append(" void foo() {\n"); buf.append(" Object Fixe;\n"); buf.append(" char ch= Fixe.pathSeparatorChar;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } else if (proposal.getVariableKind() == NewVariableCompletionProposal.PARAM) { assertTrue("2 param proposals", doParam); doParam= false; buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.io.File;\n"); buf.append("public class F {\n"); buf.append(" void foo(Object Fixe) {\n"); buf.append(" char ch= Fixe.pathSeparatorChar;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } else if (proposal.getVariableKind() == NewVariableCompletionProposal.CONST_FIELD) { assertTrue("2 const proposals", doConst); doConst= false; buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.io.File;\n"); buf.append("public class F {\n"); buf.append(" private static final String Fixe = null;\n"); buf.append("\n"); buf.append(" void foo() {\n"); buf.append(" char ch= Fixe.pathSeparatorChar;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } else { assertTrue("unknown type", false); } } else if (curr instanceof NewCUCompletionUsingWizardProposal) { NewCUCompletionUsingWizardProposal proposal= (NewCUCompletionUsingWizardProposal) curr; proposal.setShowDialog(false); proposal.apply(null); ICompilationUnit newCU= pack1.getCompilationUnit("Fixe.java"); assertTrue("Nothing created", newCU.exists()); if (proposal.isClass()) { assertTrue("2 class proposals", doClass); doClass= false; buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("public class Fixe {\n"); buf.append("\n"); buf.append("}\n"); assertEqualStringIgnoreDelim(newCU.getSource(), buf.toString()); JavaProjectHelper.performDummySearch(); newCU.delete(true, null); } else { assertTrue("2 interface proposals", doInterface); doInterface= false; buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("\n"); buf.append("public interface Fixe {\n"); buf.append("\n"); buf.append("}\n"); assertEqualStringIgnoreDelim(newCU.getSource(), buf.toString()); JavaProjectHelper.performDummySearch(); newCU.delete(true, null); } } else { assertTrue("2 replace proposals", doChange); doChange= false; CUCorrectionProposal proposal= (CUCorrectionProposal) curr; String preview= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("import java.io.File;\n"); buf.append("public class F {\n"); buf.append(" void foo() {\n"); buf.append(" char ch= File.pathSeparatorChar;\n"); buf.append(" }\n"); buf.append("}\n"); assertEqualString(preview, buf.toString()); } } } public void testSimilarVariableNames1() throws Exception { StringBuffer buf= new StringBuffer(); IPackageFragment pack1= fSourceFolder.createPackageFragment("test3", false, null); buf= new StringBuffer(); buf.append("package test3;\n"); buf.append("public class E {\n"); buf.append(" private static final short CON1= 1;\n"); buf.append(" private static final float CON2= 1.0f;\n"); buf.append(" private String bla;\n"); buf.append(" private String cout;\n"); buf.append(" public int foo() {\n"); buf.append(" return count;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); for (int i= proposals.size() - 1; i >= 0; i--) { Object curr= proposals.get(i); if (!(curr instanceof RenameNodeCompletionProposal)) { proposals.remove(i); } } assertNumberOf("proposals", proposals.size(), 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test3;\n"); buf.append("public class E {\n"); buf.append(" private static final short CON1= 1;\n"); buf.append(" private static final float CON2= 1.0f;\n"); buf.append(" private String bla;\n"); buf.append(" private String cout;\n"); buf.append(" public int foo() {\n"); buf.append(" return CON1;\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test3;\n"); buf.append("public class E {\n"); buf.append(" private static final short CON1= 1;\n"); buf.append(" private static final float CON2= 1.0f;\n"); buf.append(" private String bla;\n"); buf.append(" private String cout;\n"); buf.append(" public int foo() {\n"); buf.append(" return cout;\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } public void testSimilarVariableNames2() throws Exception { StringBuffer buf= new StringBuffer(); IPackageFragment pack1= fSourceFolder.createPackageFragment("test3", false, null); buf= new StringBuffer(); buf.append("package test3;\n"); buf.append("public class E {\n"); buf.append(" private static final short CON1= 1;\n"); buf.append(" private static final float CON2= 1.0f;\n"); buf.append(" private static short var1= 1;\n"); buf.append(" private static float var2= 1.0f;\n"); buf.append(" private String bla;\n"); buf.append(" private String cout;\n"); buf.append(" public void foo(int x) {\n"); buf.append(" count= x;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot); for (int i= proposals.size() - 1; i >= 0; i--) { Object curr= proposals.get(i); if (!(curr instanceof RenameNodeCompletionProposal)) { proposals.remove(i); } } assertNumberOf("proposals", proposals.size(), 2); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test3;\n"); buf.append("public class E {\n"); buf.append(" private static final short CON1= 1;\n"); buf.append(" private static final float CON2= 1.0f;\n"); buf.append(" private static short var1= 1;\n"); buf.append(" private static float var2= 1.0f;\n"); buf.append(" private String bla;\n"); buf.append(" private String cout;\n"); buf.append(" public void foo(int x) {\n"); buf.append(" var2= x;\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); proposal= (CUCorrectionProposal) proposals.get(1); String preview2= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test3;\n"); buf.append("public class E {\n"); buf.append(" private static final short CON1= 1;\n"); buf.append(" private static final float CON2= 1.0f;\n"); buf.append(" private static short var1= 1;\n"); buf.append(" private static float var2= 1.0f;\n"); buf.append(" private String bla;\n"); buf.append(" private String cout;\n"); buf.append(" public void foo(int x) {\n"); buf.append(" cout= x;\n"); buf.append(" }\n"); buf.append("}\n"); String expected2= buf.toString(); assertEqualStringsIgnoreOrder(new String[] { preview1, preview2 }, new String[] { expected1, expected2 }); } public void testSimilarVariableNamesMultipleOcc() throws Exception { StringBuffer buf= new StringBuffer(); IPackageFragment pack1= fSourceFolder.createPackageFragment("test3", false, null); buf= new StringBuffer(); buf.append("package test3;\n"); buf.append("public class E {\n"); buf.append(" private int cout;\n"); buf.append(" public void setCount(int x) {\n"); buf.append(" count= x;\n"); buf.append(" count++;\n"); buf.append(" }\n"); buf.append(" public int getCount() {\n"); buf.append(" return count;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot, 3); for (int i= proposals.size() - 1; i >= 0; i--) { Object curr= proposals.get(i); if (!(curr instanceof RenameNodeCompletionProposal)) { proposals.remove(i); } } assertNumberOf("proposals", proposals.size(), 1); assertCorrectLabels(proposals); CUCorrectionProposal proposal= (CUCorrectionProposal) proposals.get(0); String preview1= getPreviewContent(proposal); buf= new StringBuffer(); buf.append("package test3;\n"); buf.append("public class E {\n"); buf.append(" private int cout;\n"); buf.append(" public void setCount(int x) {\n"); buf.append(" cout= x;\n"); buf.append(" cout++;\n"); buf.append(" }\n"); buf.append(" public int getCount() {\n"); buf.append(" return cout;\n"); buf.append(" }\n"); buf.append("}\n"); String expected1= buf.toString(); assertEqualString( preview1, expected1); } public void testVarMultipleOccurances1() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" void foo() {\n"); buf.append(" for (i= 0; i > 9; i++) {\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot, 3); assertNumberOf("proposals", proposals.size(), 3); assertCorrectLabels(proposals); CUCorrectionProposal localProposal= null; for (int i = 0; i < proposals.size(); i++) { Object curr= proposals.get(i); if (curr instanceof NewVariableCompletionProposal && ((NewVariableCompletionProposal) curr).getVariableKind() == NewVariableCompletionProposal.LOCAL) { localProposal= (CUCorrectionProposal) curr; } } assertNotNull(localProposal); String preview= getPreviewContent(localProposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" void foo() {\n"); buf.append(" for (int i = 0; i > 9; i++) {\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); String expected= buf.toString(); assertEqualString(preview, expected); } public void testVarMultipleOccurances2() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" void foo() {\n"); buf.append(" for (i= 0; i > 9;) {\n"); buf.append(" i++;\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot, 3); assertNumberOf("proposals", proposals.size(), 3); assertCorrectLabels(proposals); CUCorrectionProposal localProposal= null; for (int i = 0; i < proposals.size(); i++) { Object curr= proposals.get(i); if (curr instanceof NewVariableCompletionProposal && ((NewVariableCompletionProposal) curr).getVariableKind() == NewVariableCompletionProposal.LOCAL) { localProposal= (CUCorrectionProposal) curr; } } assertNotNull(localProposal); String preview= getPreviewContent(localProposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" void foo() {\n"); buf.append(" for (int i = 0; i > 9;) {\n"); buf.append(" i++;\n"); buf.append(" }\n"); buf.append(" }\n"); buf.append("}\n"); String expected= buf.toString(); assertEqualString(preview, expected); } public void testVarMultipleOccurances3() throws Exception { IPackageFragment pack1= fSourceFolder.createPackageFragment("test1", false, null); StringBuffer buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" void foo() {\n"); buf.append(" for (i = 0; i > 9;) {\n"); buf.append(" }\n"); buf.append(" i= 9;\n"); buf.append(" }\n"); buf.append("}\n"); ICompilationUnit cu= pack1.createCompilationUnit("E.java", buf.toString(), false, null); CompilationUnit astRoot= getASTRoot(cu); ArrayList proposals= collectCorrections(cu, astRoot, 3); assertNumberOf("proposals", proposals.size(), 3); assertCorrectLabels(proposals); CUCorrectionProposal localProposal= null; for (int i = 0; i < proposals.size(); i++) { Object curr= proposals.get(i); if (curr instanceof NewVariableCompletionProposal && ((NewVariableCompletionProposal) curr).getVariableKind() == NewVariableCompletionProposal.LOCAL) { localProposal= (CUCorrectionProposal) curr; } } assertNotNull(localProposal); String preview= getPreviewContent(localProposal); buf= new StringBuffer(); buf.append("package test1;\n"); buf.append("public class E {\n"); buf.append(" void foo() {\n"); buf.append(" int i;\n"); buf.append(" for (i = 0; i > 9;) {\n"); buf.append(" }\n"); buf.append(" i= 9;\n"); buf.append(" }\n"); buf.append("}\n"); String expected= buf.toString(); assertEqualString(preview, expected); } }