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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
49,826 |
Bug 49826 Type filter ignores some filters
| null |
resolved fixed
|
11a869d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-05T21:17:11Z | 2004-01-11T19:40:00Z |
org.eclipse.jdt.ui/core
| |
49,826 |
Bug 49826 Type filter ignores some filters
| null |
resolved fixed
|
11a869d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-05T21:17:11Z | 2004-01-11T19:40:00Z |
extension/org/eclipse/jdt/internal/corext/util/TypeFilter.java
| |
49,826 |
Bug 49826 Type filter ignores some filters
| null |
resolved fixed
|
11a869d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-05T21:17:11Z | 2004-01-11T19:40:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/TypeFilterInputDialog.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.util.List;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.util.Assert;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.core.JavaConventions;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.internal.core.PackageFragment;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.dialogs.PackageSelectionDialog;
import org.eclipse.jdt.internal.ui.dialogs.StatusDialog;
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IStringButtonAdapter;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.StringButtonDialogField;
/**
* Dialog to enter a new entry in the type filter preference page.
*/
public class TypeFilterInputDialog extends StatusDialog {
private class ImportOrganizeInputAdapter implements IDialogFieldListener, IStringButtonAdapter {
/*
* @see IDialogFieldListener#dialogFieldChanged(DialogField)
*/
public void dialogFieldChanged(DialogField field) {
doValidation();
}
/*
* @see IStringButtonAdapter#changeControlPressed(DialogField)
*/
public void changeControlPressed(DialogField field) {
doButtonPressed();
}
}
private StringButtonDialogField fNameDialogField;
private List fExistingEntries;
public TypeFilterInputDialog(Shell parent, List existingEntries) {
super(parent);
fExistingEntries= existingEntries;
setTitle(PreferencesMessages.getString("TypeFilterInputDialog.title")); //$NON-NLS-1$
ImportOrganizeInputAdapter adapter= new ImportOrganizeInputAdapter();
fNameDialogField= new StringButtonDialogField(adapter);
fNameDialogField.setLabelText(PreferencesMessages.getString("TypeFilterInputDialog.message")); //$NON-NLS-1$
fNameDialogField.setButtonLabel(PreferencesMessages.getString("TypeFilterInputDialog.browse.button")); //$NON-NLS-1$
fNameDialogField.setDialogFieldListener(adapter);
fNameDialogField.setText(""); //$NON-NLS-1$
}
public void setInitialString(String input) {
Assert.isNotNull(input);
fNameDialogField.setText(input);
}
public Object getResult() {
return fNameDialogField.getText();
}
protected Control createDialogArea(Composite parent) {
Composite composite= (Composite) super.createDialogArea(parent);
Composite inner= new Composite(composite, SWT.NONE);
LayoutUtil.doDefaultLayout(inner, new DialogField[] { fNameDialogField }, true, 0, 0);
int fieldWidthHint= convertWidthInCharsToPixels(60);
LayoutUtil.setWidthHint(fNameDialogField.getTextControl(null), fieldWidthHint);
LayoutUtil.setHorizontalGrabbing(fNameDialogField.getTextControl(null));
fNameDialogField.postSetFocusOnDialogField(parent.getDisplay());
applyDialogFont(composite);
return composite;
}
private void doButtonPressed() {
IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
BusyIndicatorRunnableContext context= new BusyIndicatorRunnableContext();
int flags= PackageSelectionDialog.F_SHOW_PARENTS | PackageSelectionDialog.F_HIDE_DEFAULT_PACKAGE | PackageSelectionDialog.F_REMOVE_DUPLICATES;
PackageSelectionDialog dialog = new PackageSelectionDialog(getShell(), context, flags , scope);
dialog.setTitle(PreferencesMessages.getString("TypeFilterInputDialog.choosepackage.label")); //$NON-NLS-1$
dialog.setMessage(PreferencesMessages.getString("TypeFilterInputDialog.choosepackage.description")); //$NON-NLS-1$
dialog.setMultipleSelection(false);
dialog.setFilter(fNameDialogField.getText());
if (dialog.open() == IDialogConstants.OK_ID) {
PackageFragment res= (PackageFragment) dialog.getFirstResult();
fNameDialogField.setText(res.getElementName() + ".*"); //$NON-NLS-1$
}
}
private void doValidation() {
StatusInfo status= new StatusInfo();
String newText= fNameDialogField.getText();
if (newText.length() == 0) {
status.setError(PreferencesMessages.getString("TypeFilterInputDialog.error.enterName")); //$NON-NLS-1$
} else {
newText= newText.replace('*', 'X').replace('?', 'Y');
IStatus val= JavaConventions.validatePackageName(newText);
if (val.matches(IStatus.ERROR)) {
status.setError(PreferencesMessages.getFormattedString("TypeFilterInputDialog.error.invalidName", val.getMessage())); //$NON-NLS-1$
} else {
if (fExistingEntries.contains(newText)) {
status.setError(PreferencesMessages.getString("TypeFilterInputDialog.error.entryExists")); //$NON-NLS-1$
}
}
}
updateStatus(status);
}
/*
* @see org.eclipse.jface.window.Window#configureShell(Shell)
*/
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
WorkbenchHelp.setHelp(newShell, IJavaHelpContextIds.IMPORT_ORGANIZE_INPUT_DIALOG);
}
}
|
49,826 |
Bug 49826 Type filter ignores some filters
| null |
resolved fixed
|
11a869d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-05T21:17:11Z | 2004-01-11T19:40:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/TypeFilterPreferencePage.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.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.ViewerSorter;
import org.eclipse.jface.window.Window;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.internal.core.PackageFragment;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.dialogs.PackageSelectionDialog;
import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.CheckedListDialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.IListAdapter;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.LayoutUtil;
import org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField;
/*
* The page for setting the type filters
*/
public class TypeFilterPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
private static final String PREF_FILTER_ENABLED= PreferenceConstants.TYPEFILTER_ENABLED;
private static final String PREF_FILTER_DISABLED= PreferenceConstants.TYPEFILTER_DISABLED;
private static String[] unpackOrderList(String str) {
StringTokenizer tok= new StringTokenizer(str, ";"); //$NON-NLS-1$
int nTokens= tok.countTokens();
String[] res= new String[nTokens];
for (int i= 0; i < nTokens; i++) {
res[i]= tok.nextToken();
}
return res;
}
private static String packOrderList(List orderList) {
StringBuffer buf= new StringBuffer();
for (int i= 0; i < orderList.size(); i++) {
buf.append((String) orderList.get(i));
buf.append(';');
}
return buf.toString();
}
private class TypeFilterAdapter implements IListAdapter, IDialogFieldListener {
private boolean canEdit(ListDialogField field) {
return field.getSelectedElements().size() == 1;
}
public void customButtonPressed(ListDialogField field, int index) {
doButtonPressed(index);
}
public void selectionChanged(ListDialogField field) {
fFilterListField.enableButton(IDX_EDIT, canEdit(field));
}
public void dialogFieldChanged(DialogField field) {
}
public void doubleClicked(ListDialogField field) {
if (canEdit(field)) {
doButtonPressed(IDX_EDIT);
}
}
}
private static final int IDX_ADD= 0;
private static final int IDX_ADD_PACKAGE= 1;
private static final int IDX_EDIT= 2;
private static final int IDX_REMOVE= 3;
private static final int IDX_SELECT= 5;
private static final int IDX_DESELECT= 6;
private CheckedListDialogField fFilterListField;
public TypeFilterPreferencePage() {
super();
setPreferenceStore(JavaPlugin.getDefault().getPreferenceStore());
setDescription(PreferencesMessages.getString("TypeFilterPreferencePage.description")); //$NON-NLS-1$
String[] buttonLabels= new String[] {
/* 0 */ PreferencesMessages.getString("TypeFilterPreferencePage.add.button"), //$NON-NLS-1$
/* 1 */ PreferencesMessages.getString("TypeFilterPreferencePage.addpackage.button"), //$NON-NLS-1$
/* 2 */ PreferencesMessages.getString("TypeFilterPreferencePage.edit.button"), //$NON-NLS-1$
/* 3 */ PreferencesMessages.getString("TypeFilterPreferencePage.remove.button"), //$NON-NLS-1$
/* 4 */ null,
/* 5 */ PreferencesMessages.getString("TypeFilterPreferencePage.selectall.button"), //$NON-NLS-1$
/* 6 */ PreferencesMessages.getString("TypeFilterPreferencePage.deselectall.button"), //$NON-NLS-1$
};
TypeFilterAdapter adapter= new TypeFilterAdapter();
fFilterListField= new CheckedListDialogField(adapter, buttonLabels, new LabelProvider());
fFilterListField.setDialogFieldListener(adapter);
fFilterListField.setLabelText(PreferencesMessages.getString("TypeFilterPreferencePage.list.label")); //$NON-NLS-1$
fFilterListField.setCheckAllButtonIndex(IDX_SELECT);
fFilterListField.setUncheckAllButtonIndex(IDX_DESELECT);
fFilterListField.setRemoveButtonIndex(IDX_REMOVE);
fFilterListField.enableButton(IDX_EDIT, false);
initialize(false);
}
/*
* @see PreferencePage#createControl(org.eclipse.swt.widgets.Composite)
*/
public void createControl(Composite parent) {
super.createControl(parent);
//WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.TYPE_FILTER_PREFERENCE_PAGE);
}
protected Control createContents(Composite parent) {
initializeDialogUnits(parent);
Composite composite= new Composite(parent, SWT.NONE);
GridLayout layout= new GridLayout();
layout.numColumns= 2;
layout.marginWidth= 0;
layout.marginHeight= 0;
composite.setLayout(layout);
fFilterListField.doFillIntoGrid(composite, 3);
LayoutUtil.setHorizontalSpan(fFilterListField.getLabelControl(null), 2);
LayoutUtil.setWidthHint(fFilterListField.getLabelControl(null), convertWidthInCharsToPixels(40));
LayoutUtil.setHorizontalGrabbing(fFilterListField.getListControl(null));
fFilterListField.getTableViewer().setSorter(new ViewerSorter() {});
Dialog.applyDialogFont(composite);
return composite;
}
private void initialize(boolean fromDefault) {
IPreferenceStore store= getPreferenceStore();
String enabled= fromDefault ? store.getDefaultString(PREF_FILTER_ENABLED) : store.getString(PREF_FILTER_ENABLED);
String disabled= fromDefault ? store.getDefaultString(PREF_FILTER_DISABLED) : store.getString(PREF_FILTER_DISABLED);
ArrayList res= new ArrayList();
String[] enabledEntries= unpackOrderList(enabled);
for (int i= 0; i < enabledEntries.length; i++) {
res.add(enabledEntries[i]);
}
String[] disabledEntries= unpackOrderList(disabled);
for (int i= 0; i < disabledEntries.length; i++) {
res.add(disabledEntries[i]);
}
fFilterListField.setElements(res);
fFilterListField.setCheckedElements(Arrays.asList(enabledEntries));
}
private void doButtonPressed(int index) {
if (index == IDX_ADD) { // add new
List existing= fFilterListField.getElements();
TypeFilterInputDialog dialog= new TypeFilterInputDialog(getShell(), existing);
if (dialog.open() == Window.OK) {
Object res= dialog.getResult();
fFilterListField.addElement(res);
fFilterListField.setChecked(res, true);
}
} else if (index == IDX_ADD_PACKAGE) { // add packages
String[] res= choosePackage();
if (res != null) {
fFilterListField.addElements(Arrays.asList(res));
for (int i= 0; i < res.length; i++) {
fFilterListField.setChecked(res[i], true);
}
}
} else if (index == IDX_EDIT) { // edit
List selected= fFilterListField.getSelectedElements();
if (selected.isEmpty()) {
return;
}
String editedEntry= (String) selected.get(0);
List existing= fFilterListField.getElements();
existing.remove(editedEntry);
TypeFilterInputDialog dialog= new TypeFilterInputDialog(getShell(), existing);
dialog.setInitialString(editedEntry);
if (dialog.open() == Window.OK) {
fFilterListField.replaceElement(editedEntry, dialog.getResult());
}
}
}
private String[] choosePackage() {
IJavaSearchScope scope= SearchEngine.createWorkspaceScope();
BusyIndicatorRunnableContext context= new BusyIndicatorRunnableContext();
int flags= PackageSelectionDialog.F_SHOW_PARENTS | PackageSelectionDialog.F_HIDE_DEFAULT_PACKAGE | PackageSelectionDialog.F_REMOVE_DUPLICATES;
PackageSelectionDialog dialog = new PackageSelectionDialog(getShell(), context, flags , scope);
dialog.setTitle(PreferencesMessages.getString("TypeFilterPreferencePage.choosepackage.label")); //$NON-NLS-1$
dialog.setMessage(PreferencesMessages.getString("TypeFilterPreferencePage.choosepackage.description")); //$NON-NLS-1$
dialog.setMultipleSelection(true);
if (dialog.open() == IDialogConstants.OK_ID) {
Object[] fragments= dialog.getResult();
String[] res= new String[fragments.length];
for (int i= 0; i < res.length; i++) {
res[i]= ((PackageFragment) fragments[i]).getElementName() + ".*"; //$NON-NLS-1$
}
return res;
}
return null;
}
public void init(IWorkbench workbench) {
}
/*
* @see PreferencePage#performDefaults()
*/
protected void performDefaults() {
initialize(true);
super.performDefaults();
}
/*
* @see org.eclipse.jface.preference.IPreferencePage#performOk()
*/
public boolean performOk() {
IPreferenceStore prefs= JavaPlugin.getDefault().getPreferenceStore();
List checked= fFilterListField.getCheckedElements();
List unchecked= fFilterListField.getElements();
unchecked.removeAll(checked);
prefs.setValue(PREF_FILTER_ENABLED, packOrderList(checked));
prefs.setValue(PREF_FILTER_DISABLED, packOrderList(unchecked));
JavaPlugin.getDefault().savePluginPreferences();
return true;
}
}
|
50,892 |
Bug 50892 Search empty using Search perspective
|
Build 20040129 Here is my setup: - I have my own Search perspective defined. - I set the preference to use this perspective to report matches. - I'm NOT using the new search view. - I have one window per perspective. When I search for references to a method from the Java perspective, it briefly switches to the Search perspective, then come back to the Java perspctive, continue progress reporting (saying that matches are found), but at the end no result is shown in the Search perspective.
|
resolved fixed
|
55e5e63
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-06T17:29:30Z | 2004-01-29T18:13:20Z |
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.resources.IMarker;
import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search.ui.SearchUI;
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.jdt.ui.JavaElementLabelProvider;
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.EditorUtility;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.preferences.WorkInProgressPreferencePage;
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.JavaSearchResult;
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;
/**
* 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);
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) {
}
public void run(IJavaElement element) {
if (!ActionUtil.isProcessable(getShell(), element))
return;
Shell shell= JavaPlugin.getActiveWorkbenchShell();
if (JavaPlugin.getDefault().getPreferenceStore().getBoolean(WorkInProgressPreferencePage.PREF_BGSEARCH)) {
try {
performNewSearch(element);
} 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$
}
} else {
SearchUI.activateSearchResultView();
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 {
new ProgressMonitorDialog(shell).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 job= createJob(element);
JavaSearchResult result= new JavaSearchResult(job);
NewSearchUI.activateSearchResultView();
NewSearchUI.runSearchInBackground(job, result);
}
protected JavaSearchQuery createJob(IJavaElement element) throws JavaModelException {
IType type= getType(element);
return new JavaSearchQuery(element, getLimitTo(), getScope(type), getScopeDescription(type));
}
protected Object createSearchDescription(IJavaElement element) {
IType type= getType(element);
return new JavaSearchDescription(getLimitTo(), element, null, getScopeDescription(type));
}
JavaSearchOperation makeOperation(IJavaElement element) throws JavaModelException {
IType type= getType(element);
return new JavaSearchOperation(JavaPlugin.getWorkspace(), element, getLimitTo(), getScope(type), getScopeDescription(type), getCollector());
}
abstract int getLimitTo();
IJavaSearchScope getScope(IType element) throws JavaModelException {
return SearchEngine.createWorkspaceScope();
}
JavaSearchResultCollector getCollector() {
return new JavaSearchResultCollector();
}
String getScopeDescription(IType type) {
return SearchMessages.getString("WorkspaceScope"); //$NON-NLS-1$
}
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) {
try {
if (input instanceof ICompilationUnit)
return EditorUtility.getWorkingCopy((ICompilationUnit)input);
else
return EditorUtility.getWorkingCopy(input, true);
} catch (JavaModelException ex) {
}
return null;
}
}
|
51,160 |
Bug 51160 IllegalArgumentException inlining method
|
Build 20040203 Got the following IllegalArgumentException attempting to show the preview of an inline method refactoring: Caused by: java.lang.IllegalArgumentException at org.eclipse.jdt.core.dom.ASTNode.checkNewChild(ASTNode.java:1101) at org.eclipse.jdt.core.dom.ASTNode$NodeList.add(ASTNode.java:828) at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.addNewLocals (CallInliner.java:518) at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.perform (CallInliner.java:448) at org.eclipse.jdt.internal.corext.refactoring.code.InlineMethodRefactoring.checkIn put(InlineMethodRefactoring.java:229) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:64) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:99) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101) Apparently, the child that is being added already has a parent.
|
verified fixed
|
226dbe4
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T04:32:45Z | 2004-02-04T15:53:20Z |
org.eclipse.jdt.ui/core
| |
51,160 |
Bug 51160 IllegalArgumentException inlining method
|
Build 20040203 Got the following IllegalArgumentException attempting to show the preview of an inline method refactoring: Caused by: java.lang.IllegalArgumentException at org.eclipse.jdt.core.dom.ASTNode.checkNewChild(ASTNode.java:1101) at org.eclipse.jdt.core.dom.ASTNode$NodeList.add(ASTNode.java:828) at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.addNewLocals (CallInliner.java:518) at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.perform (CallInliner.java:448) at org.eclipse.jdt.internal.corext.refactoring.code.InlineMethodRefactoring.checkIn put(InlineMethodRefactoring.java:229) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:64) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:99) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101) Apparently, the child that is being added already has a parent.
|
verified fixed
|
226dbe4
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T04:32:45Z | 2004-02-04T15:53:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/CallInliner.java
| |
48,968 |
Bug 48968 "Focus on" in typehierarchy doesn't show name for anonymous inners [type hiearchy]
|
I2003-12-16-20:00 1) Import Junit 2) Create a Java working set containing junit.framework 3) open a type hierarchy on junit.framework.Protectable. 4) In the type hierarchy, select the working set created in step 2). 5) Observe: Protectable has an anonymous inner subclass 6) open the context menu on the anonymous class 7) observe: the menu contains an entry like this: "Focus on ''". I.e. there is no label for the anonymous inner class.
|
resolved fixed
|
4739f58
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T04:33:22Z | 2003-12-17T11:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/typehierarchy/FocusOnSelectionAction.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.typehierarchy;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.util.SelectionUtil;
/**
* Refocuses the type hierarchy on the currently selection type.
*/
public class FocusOnSelectionAction extends Action {
private TypeHierarchyViewPart fViewPart;
public FocusOnSelectionAction(TypeHierarchyViewPart part) {
super(TypeHierarchyMessages.getString("FocusOnSelectionAction.label")); //$NON-NLS-1$
setDescription(TypeHierarchyMessages.getString("FocusOnSelectionAction.description")); //$NON-NLS-1$
setToolTipText(TypeHierarchyMessages.getString("FocusOnSelectionAction.tooltip")); //$NON-NLS-1$
fViewPart= part;
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.FOCUS_ON_SELECTION_ACTION);
}
private ISelection getSelection() {
ISelectionProvider provider= fViewPart.getSite().getSelectionProvider();
if (provider != null) {
return provider.getSelection();
}
return null;
}
/*
* @see Action#run
*/
public void run() {
Object element= SelectionUtil.getSingleElement(getSelection());
if (element instanceof IType) {
fViewPart.setInputElement((IType)element);
}
}
public boolean canActionBeAdded() {
Object element= SelectionUtil.getSingleElement(getSelection());
if (element instanceof IType) {
setText(TypeHierarchyMessages.getFormattedString("FocusOnSelectionAction.label", ((IType)element).getElementName())); //$NON-NLS-1$
return true;
}
return false;
}
}
|
48,831 |
Bug 48831 Introduce Factory: doesn't generate needed imports
|
I20031216 + patch Example code: package p1; public class A { public A() { } } package p2; public class B { void foo() { } } Create a factory method for A() in B. B is missing the import to A.
|
resolved fixed
|
d873746
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T04:34:20Z | 2003-12-16T10:20:00Z |
org.eclipse.jdt.ui/core
| |
48,831 |
Bug 48831 Introduce Factory: doesn't generate needed imports
|
I20031216 + patch Example code: package p1; public class A { public A() { } } package p2; public class B { void foo() { } } Create a factory method for A() in B. B is missing the import to A.
|
resolved fixed
|
d873746
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T04:34:20Z | 2003-12-16T10:20:00Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/IntroduceFactoryRefactoring.java
| |
38,200 |
Bug 38200 quick fix: make method abstract [quick fix]
|
20030527 abstract class A{ String getText();//error here } it's likely that i want to make getText() abstract but there's no qf for it
|
resolved fixed
|
bca6140
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T13:03:31Z | 2003-05-28T16:40:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LocalCorrectionsSubProcessor.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 <[email protected]> - Access to static proposal
******************************************************************************/
package org.eclipse.jdt.internal.ui.text.correction;
import java.util.Collection;
import java.util.List;
import org.eclipse.text.edits.TextEdit;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.graphics.Image;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.dom.*;
import org.eclipse.jdt.core.dom.PrimitiveType.Code;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.text.java.IInvocationContext;
import org.eclipse.jdt.ui.text.java.IProblemLocation;
import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
import org.eclipse.jdt.internal.corext.codemanipulation.ImportRewrite;
import org.eclipse.jdt.internal.corext.codemanipulation.StubUtility;
import org.eclipse.jdt.internal.corext.dom.ASTNodeConstants;
import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory;
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.dom.ASTRewrite;
import org.eclipse.jdt.internal.corext.dom.Bindings;
import org.eclipse.jdt.internal.corext.dom.ListRewriter;
import org.eclipse.jdt.internal.corext.dom.NewASTRewrite;
import org.eclipse.jdt.internal.corext.dom.Selection;
import org.eclipse.jdt.internal.corext.refactoring.changes.CompilationUnitChange;
import org.eclipse.jdt.internal.corext.refactoring.nls.NLSRefactoring;
import org.eclipse.jdt.internal.corext.refactoring.nls.NLSUtil;
import org.eclipse.jdt.internal.corext.refactoring.surround.ExceptionAnalyzer;
import org.eclipse.jdt.internal.corext.refactoring.surround.SurroundWithTryCatchRefactoring;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
import org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter;
import org.eclipse.jdt.internal.ui.refactoring.nls.ExternalizeWizard;
/**
*/
public class LocalCorrectionsSubProcessor {
public static void addCastProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException {
String[] args= problem.getProblemArguments();
if (args.length != 2) {
return;
}
ICompilationUnit cu= context.getCompilationUnit();
String castType= args[1];
CompilationUnit astRoot= context.getASTRoot();
ASTNode selectedNode= problem.getCoveredNode(astRoot);
if (!(selectedNode instanceof Expression)) {
return;
}
Expression nodeToCast= (Expression) selectedNode;
int parentNodeType= selectedNode.getParent().getNodeType();
if (parentNodeType == ASTNode.ASSIGNMENT) {
Assignment assign= (Assignment) selectedNode.getParent();
if (selectedNode.equals(assign.getLeftHandSide())) {
nodeToCast= assign.getRightHandSide();
}
} else if (parentNodeType == ASTNode.VARIABLE_DECLARATION_FRAGMENT) {
VariableDeclarationFragment frag= (VariableDeclarationFragment) selectedNode.getParent();
if (selectedNode.equals(frag.getName())) {
nodeToCast= frag.getInitializer();
}
}
ITypeBinding binding= nodeToCast.resolveTypeBinding();
if (binding == null || canCast(castType, binding)) {
proposals.add(createCastProposal(context, castType, 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= new ASTRewrite(methodDeclaration);
ImportRewrite imports= new ImportRewrite(cu);
String returnTypeName= imports.addImport(currBinding);
Type newReturnType= ASTNodeFactory.newType(astRoot.getAST(), returnTypeName);
rewrite.markAsReplaced(methodDeclaration.getReturnType(), newReturnType);
String label= CorrectionMessages.getFormattedString("LocalCorrectionsSubProcessor.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.markAsLinked(rewrite, newReturnType, true, returnKey);
ITypeBinding[] typeSuggestions= ASTResolving.getRelaxingTypes(astRoot.getAST(), currBinding);
for (int i= 0; i < typeSuggestions.length; i++) {
proposal.addLinkedModeProposal(returnKey, typeSuggestions[i]);
}
proposal.ensureNoModifications();
proposals.add(proposal);
}
}
if (parentNodeType == ASTNode.VARIABLE_DECLARATION_FRAGMENT) {
VariableDeclarationFragment fragment= (VariableDeclarationFragment) selectedNode.getParent();
ASTNode parent= fragment.getParent();
Type typeNode= null;
if (parent instanceof VariableDeclarationStatement) {
VariableDeclarationStatement stmt= (VariableDeclarationStatement) parent;
if (stmt.fragments().size() == 1) {
typeNode= stmt.getType();
}
} else if (parent instanceof FieldDeclaration) {
FieldDeclaration decl= (FieldDeclaration) parent;
if (decl.fragments().size() == 1) {
typeNode= decl.getType();
}
}
if (typeNode != null) {
currBinding= Bindings.normalizeTypeBinding(currBinding);
if (currBinding == null) {
currBinding= astRoot.getAST().resolveWellKnownType("java.lang.Object"); //$NON-NLS-1$
}
ImportRewrite importRewrite= new ImportRewrite(cu);
String typeName= importRewrite.addImport(currBinding);
String label= CorrectionMessages.getFormattedString("LocalCorrectionsSubProcessor.changevartype.description", typeName); //$NON-NLS-1$
ReplaceCorrectionProposal varProposal= new ReplaceCorrectionProposal(label, cu, typeNode.getStartPosition(), typeNode.getLength(), typeName, 5);
varProposal.setImportRewrite(importRewrite);
proposals.add(varProposal);
}
}
}
private static boolean canCast(String castTarget, ITypeBinding 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= new ASTRewrite(nodeToCast.getParent());
ImportRewrite imports= new ImportRewrite(cu);
String label;
String simpleCastType= imports.addImport(castType);
if (nodeToCast.getNodeType() == ASTNode.CAST_EXPRESSION) {
label= CorrectionMessages.getFormattedString("LocalCorrectionsSubProcessor.changecast.description", castType); //$NON-NLS-1$
CastExpression expression= (CastExpression) nodeToCast;
rewrite.markAsReplaced(expression.getType(), rewrite.createPlaceholder(simpleCastType, NewASTRewrite.TYPE));
} else {
label= CorrectionMessages.getFormattedString("LocalCorrectionsSubProcessor.addcast.description", castType); //$NON-NLS-1$
Expression expressionCopy= (Expression) rewrite.createCopy(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.createPlaceholder(simpleCastType, NewASTRewrite.TYPE);
CastExpression castExpression= astRoot.getAST().newCastExpression();
castExpression.setExpression(expressionCopy);
castExpression.setType(typeCopy);
rewrite.markAsReplaced(nodeToCast, castExpression);
}
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, relevance, image); //$NON-NLS-1$
proposal.setImportRewrite(imports);
proposal.ensureNoModifications();
return proposal;
}
public static void addUncaughtExceptionProposals(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;
}
while (selectedNode != null && !(selectedNode instanceof Statement)) {
selectedNode= selectedNode.getParent();
}
if (selectedNode == null) {
return;
}
CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings();
SurroundWithTryCatchRefactoring refactoring= SurroundWithTryCatchRefactoring.create(cu, selectedNode.getStartPosition(), selectedNode.getLength(), settings, null);
if (refactoring == null)
return;
refactoring.setLeaveDirty(true);
if (refactoring.checkActivationBasics(astRoot, null).isOK()) {
String label= CorrectionMessages.getString("LocalCorrectionsSubProcessor.surroundwith.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
CUCorrectionProposal proposal= new CUCorrectionProposal(label, (CompilationUnitChange) refactoring.createChange(null), 4, image);
proposals.add(proposal);
}
BodyDeclaration decl= ASTResolving.findParentBodyDeclaration(selectedNode);
if (decl == null) {
return;
}
ITypeBinding[] uncaughtExceptions= ExceptionAnalyzer.perform(decl, Selection.createFromStartLength(selectedNode.getStartPosition(), selectedNode.getLength()));
if (uncaughtExceptions.length == 0) {
return;
}
TryStatement surroundingTry= ASTResolving.findParentTryStatement(selectedNode);
if (surroundingTry != null && ASTNodes.isParent(selectedNode, surroundingTry.getBody())) {
ASTRewrite rewrite= new ASTRewrite(surroundingTry);
ImportRewrite imports= new ImportRewrite(cu);
String label= CorrectionMessages.getString("LocalCorrectionsSubProcessor.addadditionalcatch.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, 5, image);
proposal.setImportRewrite(imports);
AST ast= astRoot.getAST();
ListRewriter clausesRewrite= rewrite.getListRewrite(surroundingTry, ASTNodeConstants.CATCH_CLAUSES);
for (int i= 0; i < uncaughtExceptions.length; i++) {
ITypeBinding excBinding= uncaughtExceptions[i];
String varName= PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.CODEGEN_EXCEPTION_VAR_NAME);
String imp= imports.addImport(excBinding);
Name name= ASTNodeFactory.newName(ast, imp);
SingleVariableDeclaration var= ast.newSingleVariableDeclaration();
var.setName(ast.newSimpleName(varName));
var.setType(ast.newSimpleType(name));
CatchClause newClause= ast.newCatchClause();
newClause.setException(var);
String catchBody = StubUtility.getCatchBodyContent(cu, excBinding.getName(), varName, String.valueOf('\n'));
if (catchBody != null) {
ASTNode node= rewrite.createPlaceholder(catchBody, NewASTRewrite.STATEMENT);
newClause.getBody().statements().add(node);
}
clausesRewrite.insertLast(newClause, null);
String typeKey= "type" + i; //$NON-NLS-1$
String nameKey= "name" + i; //$NON-NLS-1$
proposal.markAsLinked(rewrite, var.getType(), false, typeKey); //$NON-NLS-1$
proposal.markAsLinked(rewrite, var.getName(), false, nameKey); //$NON-NLS-1$
addExceptionTypeLinkProposals(proposal, excBinding, typeKey);
}
proposal.ensureNoModifications();
proposals.add(proposal);
}
if (decl instanceof MethodDeclaration) {
ASTRewrite rewrite= new ASTRewrite(astRoot);
ImportRewrite imports= new ImportRewrite(cu);
String label= CorrectionMessages.getString("LocalCorrectionsSubProcessor.addthrows.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, 6, image);
proposal.setImportRewrite(imports);
AST ast= astRoot.getAST();
MethodDeclaration methodDecl= (MethodDeclaration) decl;
List exceptions= methodDecl.thrownExceptions();
ListRewriter listRewrite= rewrite.getListRewrite(methodDecl, ASTNodeConstants.THROWN_EXCEPTIONS);
for (int i= 0; i < uncaughtExceptions.length; i++) {
String imp= imports.addImport(uncaughtExceptions[i]);
Name name= ASTNodeFactory.newName(ast, imp);
listRewrite.insertLast(name, null);
String typeKey= "type" + i; //$NON-NLS-1$
proposal.markAsLinked(rewrite, name, false, typeKey); //$NON-NLS-1$
addExceptionTypeLinkProposals(proposal, uncaughtExceptions[i], typeKey);
}
for (int i= 0; i < exceptions.size(); i++) {
Name elem= (Name) exceptions.get(i);
if (canRemoveException(elem.resolveTypeBinding(), uncaughtExceptions)) {
rewrite.markAsRemoved(elem);
}
}
proposal.ensureNoModifications();
proposals.add(proposal);
}
}
private static void addExceptionTypeLinkProposals(LinkedCorrectionProposal proposal, ITypeBinding exc, String key) {
// all superclasses except Object
while (exc != null && !"java.lang.Object".equals(exc.getQualifiedName())) { //$NON-NLS-1$
proposal.addLinkedModeProposal(key, exc);
exc= exc.getSuperclass();
}
}
private static boolean canRemoveException(ITypeBinding curr, ITypeBinding[] addedExceptions) {
while (curr != null) {
for (int i= 0; i < addedExceptions.length; i++) {
if (curr == addedExceptions[i]) {
return true;
}
}
curr= curr.getSuperclass();
}
return false;
}
public static void addUnreachableCatchProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException {
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
if (selectedNode == null) {
return;
}
QuickAssistProcessor.getCatchClauseToThrowsProposals(context, selectedNode, proposals);
}
public static void addNLSProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException {
final ICompilationUnit cu= context.getCompilationUnit();
if (! NLSRefactoring.isAvailable(cu)){
return;
}
String name= CorrectionMessages.getString("LocalCorrectionsSubProcessor.externalizestrings.description"); //$NON-NLS-1$
ChangeCorrectionProposal proposal= new ChangeCorrectionProposal(name, null, 5) {
public void apply(IDocument document) {
try {
NLSRefactoring refactoring= NLSRefactoring.create(cu, JavaPreferencesSettings.getCodeGenerationSettings());
if (refactoring == null)
return;
ExternalizeWizard wizard= new ExternalizeWizard(refactoring);
String dialogTitle= CorrectionMessages.getString("LocalCorrectionsSubProcessor.externalizestrings.dialog.title"); //$NON-NLS-1$
new RefactoringStarter().activate(refactoring, wizard, JavaPlugin.getActiveWorkbenchShell(), dialogTitle, true);
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
}
};
proposals.add(proposal);
TextEdit edit= NLSUtil.createNLSEdit(cu, problem.getOffset());
if (edit != null) {
String label= CorrectionMessages.getString("LocalCorrectionsSubProcessor.addnon-nls.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_NLS_NEVER_TRANSLATE);
CUCorrectionProposal nlsProposal= new CUCorrectionProposal(label, cu, 6, image);
nlsProposal.getRootTextEdit().addChild(edit);
proposals.add(nlsProposal);
}
}
/**
* Fix instance accesses and indirect (static) accesses to static fields/methods
*/
public static void addCorrectAccessToStaticProposals(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;
}
// fix for 32022
String[] args= problem.getProblemArguments();
if (selectedNode instanceof QualifiedName && args.length == 2) {
String field= args[1];
QualifiedName qualified= (QualifiedName) selectedNode;
while (!field.equals(qualified.getName().getIdentifier()) && qualified.getQualifier() instanceof QualifiedName) {
qualified= (QualifiedName) qualified.getQualifier();
}
selectedNode= qualified;
problem= new ProblemLocation(qualified.getStartPosition(), qualified.getLength(), problem.getProblemId(), args);
}
Expression qualifier= null;
IBinding accessBinding= null;
if (selectedNode instanceof QualifiedName) {
QualifiedName name= (QualifiedName) selectedNode;
qualifier= name.getQualifier();
accessBinding= name.resolveBinding();
} else if (selectedNode instanceof SimpleName) {
ASTNode parent= selectedNode.getParent();
if (parent instanceof FieldAccess) {
FieldAccess fieldAccess= (FieldAccess) parent;
qualifier= fieldAccess.getExpression();
accessBinding= fieldAccess.getName().resolveBinding();
}
} else if (selectedNode instanceof MethodInvocation) {
MethodInvocation methodInvocation= (MethodInvocation) selectedNode;
qualifier= methodInvocation.getExpression();
accessBinding= methodInvocation.getName().resolveBinding();
} else if (selectedNode instanceof FieldAccess) {
FieldAccess fieldAccess= (FieldAccess) selectedNode;
qualifier= fieldAccess.getExpression();
accessBinding= fieldAccess.getName().resolveBinding();
}
if (problem.getProblemId() == IProblem.IndirectAccessToStaticField || problem.getProblemId() == IProblem.IndirectAccessToStaticMethod) {
// indirectAccessToStaticProposal
if (accessBinding != null) {
ITypeBinding declaringTypeBinding= getDeclaringTypeBinding(accessBinding);
if (declaringTypeBinding != null) {
ASTRewrite rewrite= new ASTRewrite(selectedNode.getParent());
ImportRewrite imports= new ImportRewrite(cu);
String typeName= imports.addImport(declaringTypeBinding);
rewrite.markAsReplaced(qualifier, ASTNodeFactory.newName(astRoot.getAST(), typeName));
String label= CorrectionMessages.getFormattedString("LocalCorrectionsSubProcessor.indirectaccesstostatic.description", declaringTypeBinding.getName()); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, 6, image);
proposal.setImportRewrite(imports);
proposal.ensureNoModifications();
proposals.add(proposal);
}
}
return;
}
ITypeBinding declaringTypeBinding= null;
if (accessBinding != null) {
declaringTypeBinding= getDeclaringTypeBinding(accessBinding);
if (declaringTypeBinding != null) {
ASTRewrite rewrite= new ASTRewrite(selectedNode.getParent());
ImportRewrite imports= new ImportRewrite(cu);
String label= CorrectionMessages.getFormattedString("LocalCorrectionsSubProcessor.changeaccesstostaticdefining.description", declaringTypeBinding.getName()); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, 6, image);
proposal.setImportRewrite(imports);
String typeName= imports.addImport(declaringTypeBinding);
rewrite.markAsReplaced(qualifier, ASTNodeFactory.newName(astRoot.getAST(), typeName));
proposal.ensureNoModifications();
proposals.add(proposal);
}
}
if (qualifier != null) {
ITypeBinding instanceTypeBinding= Bindings.normalizeTypeBinding(qualifier.resolveTypeBinding());
if (instanceTypeBinding != null && instanceTypeBinding != declaringTypeBinding) {
ASTRewrite rewrite= new ASTRewrite(selectedNode.getParent());
ImportRewrite imports= new ImportRewrite(cu);
String label= CorrectionMessages.getFormattedString("LocalCorrectionsSubProcessor.changeaccesstostatic.description", instanceTypeBinding.getName()); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, 5, image);
proposal.setImportRewrite(imports);
String typeName= imports.addImport(instanceTypeBinding);
rewrite.markAsReplaced(qualifier, ASTNodeFactory.newName(astRoot.getAST(), typeName));
proposal.ensureNoModifications();
proposals.add(proposal);
}
}
ModifierCorrectionSubProcessor.addNonAccessibleMemberProposal(context, problem, proposals, ModifierCorrectionSubProcessor.TO_NON_STATIC, 4);
}
private static ITypeBinding getDeclaringTypeBinding(IBinding accessBinding) {
if (accessBinding instanceof IMethodBinding) {
return ((IMethodBinding) accessBinding).getDeclaringClass();
} else if (accessBinding instanceof IVariableBinding) {
return ((IVariableBinding) accessBinding).getDeclaringClass();
}
return null;
}
public static void addUnimplementedMethodsProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException {
ICompilationUnit cu= context.getCompilationUnit();
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
if (selectedNode == null) {
return;
}
ASTNode typeNode= null;
if (selectedNode.getNodeType() == ASTNode.SIMPLE_NAME && selectedNode.getParent().getNodeType() == ASTNode.TYPE_DECLARATION) {
typeNode= selectedNode.getParent();
} else if (selectedNode.getNodeType() == ASTNode.CLASS_INSTANCE_CREATION) {
ClassInstanceCreation creation= (ClassInstanceCreation) selectedNode;
typeNode= creation.getAnonymousClassDeclaration();
}
if (typeNode != null) {
UnimplementedMethodsCompletionProposal proposal= new UnimplementedMethodsCompletionProposal(cu, typeNode, 10);
proposals.add(proposal);
}
if (typeNode instanceof TypeDeclaration) {
TypeDeclaration typeDeclaration= (TypeDeclaration) typeNode;
ASTRewriteCorrectionProposal proposal= ModifierCorrectionSubProcessor.getMakeTypeStaticProposal(cu, typeDeclaration, 5);
proposals.add(proposal);
}
}
public static void addUninitializedLocalVariableProposal(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException {
ICompilationUnit cu= context.getCompilationUnit();
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
if (!(selectedNode instanceof Name)) {
return;
}
Name name= (Name) selectedNode;
IBinding binding= name.resolveBinding();
if (!(binding instanceof IVariableBinding)) {
return;
}
IVariableBinding varBinding= (IVariableBinding) binding;
CompilationUnit astRoot= context.getASTRoot();
ASTNode node= astRoot.findDeclaringNode(binding);
if (node instanceof VariableDeclarationFragment) {
ASTRewrite rewrite= new ASTRewrite(node.getParent());
VariableDeclarationFragment fragment= (VariableDeclarationFragment) node;
if (fragment.getInitializer() != null) {
return;
}
Expression expression= ASTNodeFactory.newDefaultExpression(astRoot.getAST(), varBinding.getType());
if (expression == null) {
return;
}
rewrite.markAsInsert(fragment, ASTNodeConstants.INITIALIZER, expression, null);
String label= CorrectionMessages.getString("LocalCorrectionsSubProcessor.uninitializedvariable.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, 6, image);
proposal.markAsLinked(rewrite, expression, false, "initializer"); //$NON-NLS-1$
proposal.ensureNoModifications();
proposals.add(proposal);
}
}
public static void addConstructorFromSuperclassProposal(IInvocationContext context, IProblemLocation problem, Collection proposals) {
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
if (!(selectedNode instanceof Name && selectedNode.getParent() instanceof TypeDeclaration)) {
return;
}
TypeDeclaration typeDeclaration= (TypeDeclaration) selectedNode.getParent();
ITypeBinding binding= typeDeclaration.resolveBinding();
if (binding == null || binding.getSuperclass() == null) {
return;
}
ICompilationUnit cu= context.getCompilationUnit();
IMethodBinding[] methods= binding.getSuperclass().getDeclaredMethods();
for (int i= 0; i < methods.length; i++) {
IMethodBinding curr= methods[i];
if (curr.isConstructor() && !Modifier.isPrivate(curr.getModifiers())) {
proposals.add(new ConstructorFromSuperclassProposal(cu, typeDeclaration, curr, 5));
}
}
}
public static void addUnusedMemberProposal(IInvocationContext context, IProblemLocation problem, Collection proposals) {
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
SimpleName name= null;
if (selectedNode instanceof MethodDeclaration) {
name= ((MethodDeclaration) selectedNode).getName();
} else if (selectedNode instanceof SimpleName) {
name= (SimpleName) selectedNode;
}
if (name != null) {
IBinding binding= name.resolveBinding();
if (binding != null) {
proposals.add(new RemoveDeclarationCorrectionProposal(context.getCompilationUnit(), name, 5));
}
}
}
public static void addSuperfluousSemicolonProposal(IInvocationContext context, IProblemLocation problem, Collection proposals) {
String label= CorrectionMessages.getString("LocalCorrectionsSubProcessor.removesemicolon.description"); //$NON-NLS-1$
ReplaceCorrectionProposal proposal= new ReplaceCorrectionProposal(label, context.getCompilationUnit(), problem.getOffset(), problem.getLength(), "", 6); //$NON-NLS-1$
proposals.add(proposal);
}
public static void addUnnecessaryCastProposal(IInvocationContext context, IProblemLocation problem, Collection proposals) {
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
ASTNode curr= selectedNode;
while (curr instanceof ParenthesizedExpression) {
curr= ((ParenthesizedExpression) curr).getExpression();
}
if (curr instanceof CastExpression) {
ASTRewrite rewrite= new ASTRewrite(selectedNode.getParent());
CastExpression cast= (CastExpression) curr;
Expression expression= cast.getExpression();
ASTNode placeholder= rewrite.createCopy(expression);
if (ASTNodes.needsParentheses(expression)) {
rewrite.markAsReplaced(curr, placeholder);
} else {
rewrite.markAsReplaced(selectedNode, placeholder);
}
String label= CorrectionMessages.getString("LocalCorrectionsSubProcessor.unnecessarycast.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 5, image);
proposals.add(proposal);
}
}
public static void addUnnecessaryInstanceofProposal(IInvocationContext context, IProblemLocation problem, Collection proposals) {
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
ASTNode curr= selectedNode;
while (curr instanceof ParenthesizedExpression) {
curr= ((ParenthesizedExpression) curr).getExpression();
}
if (curr instanceof InstanceofExpression) {
ASTRewrite rewrite= new ASTRewrite(curr.getParent());
InstanceofExpression inst= (InstanceofExpression) curr;
AST ast= inst.getAST();
InfixExpression expression= ast.newInfixExpression();
expression.setLeftOperand((Expression) rewrite.createCopy(inst.getLeftOperand()));
expression.setOperator(InfixExpression.Operator.NOT_EQUALS);
expression.setRightOperand(ast.newNullLiteral());
if (false/*ASTNodes.needsParentheses(expression)*/) {
ParenthesizedExpression parents= ast.newParenthesizedExpression();
parents.setExpression(expression);
rewrite.markAsReplaced(inst, parents);
} else {
rewrite.markAsReplaced(inst, expression);
}
String label= CorrectionMessages.getString("LocalCorrectionsSubProcessor.unnecessaryinstanceof.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 5, image);
proposals.add(proposal);
}
}
public static void addUnnecessaryThrownExceptionProposal(IInvocationContext context, IProblemLocation problem, Collection proposals) {
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
if (selectedNode == null) {
return;
}
if (selectedNode.getParent() instanceof MethodDeclaration) {
MethodDeclaration decl= (MethodDeclaration) selectedNode.getParent();
List thrownExceptions= decl.thrownExceptions();
if (!thrownExceptions.contains(selectedNode)) {
return;
}
ASTRewrite rewrite= new ASTRewrite(decl);
rewrite.markAsRemoved(selectedNode);
Javadoc javadoc= decl.getJavadoc();
if (javadoc != null) {
IBinding binding= ((Name) selectedNode).resolveBinding();
if (binding != null) {
TagElement tagElement= findThrowsTag(javadoc, binding);
if (tagElement != null) {
rewrite.markAsRemoved(tagElement);
}
}
}
String label= CorrectionMessages.getString("LocalCorrectionsSubProcessor.unnecessarythrow.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_OBJS_EXCEPTION);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 5, image);
proposals.add(proposal);
}
}
private static TagElement findThrowsTag(Javadoc javadoc, IBinding binding) {
List tags= javadoc.tags();
for (int i= tags.size() - 1; i >= 0; i--) {
TagElement curr= (TagElement) tags.get(i);
String currName= curr.getTagName();
if ("@throws".equals(currName) || "@exception".equals(currName)) { //$NON-NLS-1$//$NON-NLS-2$
List fragments= curr.fragments();
if (!fragments.isEmpty() && fragments.get(0) instanceof Name) {
Name name= (Name) fragments.get(0);
if (name.resolveBinding() == binding) {
return curr;
}
}
}
}
return null;
}
public static void addUnqualifiedFieldAccessProposal(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException {
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
while (selectedNode instanceof QualifiedName) {
selectedNode= ((QualifiedName) selectedNode).getQualifier();
}
if (!(selectedNode instanceof SimpleName)) {
return;
}
SimpleName name = (SimpleName) selectedNode;
IBinding binding= name.resolveBinding();
if (binding.getKind() != IBinding.VARIABLE) {
return;
}
ASTRewrite rewrite= new ASTRewrite(name.getParent());
ImportRewrite imports= new ImportRewrite(context.getCompilationUnit());
ITypeBinding declaringClass= ((IVariableBinding) binding).getDeclaringClass();
String qualifier;
if (Modifier.isStatic(binding.getModifiers())) {
qualifier= imports.addImport(declaringClass);
} else {
ITypeBinding currType= Bindings.getBindingOfParentType(name);
if (Bindings.isSuperType(currType, declaringClass)) {
qualifier= "this"; //$NON-NLS-1$
} else {
String outer= imports.addImport(declaringClass);
qualifier= outer + ".this"; //$NON-NLS-1$
}
}
String replacement= qualifier + '.' + name.getIdentifier();
rewrite.markAsReplaced(name, rewrite.createPlaceholder(replacement, NewASTRewrite.NAME));
String label= CorrectionMessages.getFormattedString("LocalCorrectionsSubProcessor.unqualifiedfieldaccess.description", qualifier); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, 5, image); //$NON-NLS-1$
proposal.setImportRewrite(imports);
proposals.add(proposal);
}
}
|
38,200 |
Bug 38200 quick fix: make method abstract [quick fix]
|
20030527 abstract class A{ String getText();//error here } it's likely that i want to make getText() abstract but there's no qf for it
|
resolved fixed
|
bca6140
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T13:03:31Z | 2003-05-28T16:40:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/ModifierCorrectionSubProcessor.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.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.compiler.IProblem;
import org.eclipse.jdt.core.dom.*;
import org.eclipse.jdt.ui.text.java.*;
import org.eclipse.jdt.internal.corext.dom.ASTNodeConstants;
import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory;
import org.eclipse.jdt.internal.corext.dom.ASTRewrite;
import org.eclipse.jdt.internal.corext.dom.Bindings;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
/**
*/
public class ModifierCorrectionSubProcessor {
public static final int TO_STATIC= 1;
public static final int TO_VISIBLE= 2;
public static final int TO_NON_PRIVATE= 3;
public static final int TO_NON_STATIC= 4;
public static void addNonAccessibleMemberProposal(IInvocationContext context, IProblemLocation problem, Collection proposals, int kind, int relevance) throws JavaModelException {
ICompilationUnit cu= context.getCompilationUnit();
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
if (selectedNode == null) {
return;
}
IBinding binding=null;
switch (selectedNode.getNodeType()) {
case ASTNode.SIMPLE_NAME:
binding= ((SimpleName) selectedNode).resolveBinding();
break;
case ASTNode.QUALIFIED_NAME:
binding= ((QualifiedName) selectedNode).resolveBinding();
break;
case ASTNode.SIMPLE_TYPE:
binding= ((SimpleType) selectedNode).resolveBinding();
break;
case ASTNode.METHOD_INVOCATION:
binding= ((MethodInvocation) selectedNode).getName().resolveBinding();
break;
case ASTNode.SUPER_METHOD_INVOCATION:
binding= ((SuperMethodInvocation) selectedNode).getName().resolveBinding();
break;
case ASTNode.FIELD_ACCESS:
binding= ((FieldAccess) selectedNode).getName().resolveBinding();
break;
case ASTNode.SUPER_FIELD_ACCESS:
binding= ((SuperFieldAccess) selectedNode).getName().resolveBinding();
break;
case ASTNode.CLASS_INSTANCE_CREATION:
binding= ((ClassInstanceCreation) selectedNode).resolveConstructorBinding();
break;
case ASTNode.SUPER_CONSTRUCTOR_INVOCATION:
binding= ((SuperConstructorInvocation) selectedNode).resolveConstructorBinding();
break;
default:
return;
}
ITypeBinding typeBinding= null;
String name;
if (binding instanceof IMethodBinding) {
typeBinding= ((IMethodBinding) binding).getDeclaringClass();
name= binding.getName() + "()"; //$NON-NLS-1$
} else if (binding instanceof IVariableBinding) {
typeBinding= ((IVariableBinding) binding).getDeclaringClass();
name= binding.getName();
} else if (binding instanceof ITypeBinding) {
typeBinding= (ITypeBinding) binding;
name= binding.getName();
} else {
return;
}
if (typeBinding != null && typeBinding.isFromSource()) {
int includedModifiers= 0;
int excludedModifiers= 0;
String label;
if (kind == TO_VISIBLE) {
excludedModifiers= Modifier.PRIVATE | Modifier.PROTECTED | Modifier.PUBLIC;
includedModifiers= getNeededVisibility(selectedNode, typeBinding);
label= CorrectionMessages.getFormattedString("ModifierCorrectionSubProcessor.changevisibility.description", new String[] { name, getVisibilityString(includedModifiers) }); //$NON-NLS-1$
} else if (kind == TO_STATIC) {
label= CorrectionMessages.getFormattedString("ModifierCorrectionSubProcessor.changemodifiertostatic.description", name); //$NON-NLS-1$
includedModifiers= Modifier.STATIC;
} else if (kind == TO_NON_STATIC) {
label= CorrectionMessages.getFormattedString("ModifierCorrectionSubProcessor.changemodifiertononstatic.description", name); //$NON-NLS-1$
excludedModifiers= Modifier.STATIC;
} else if (kind == TO_NON_PRIVATE) {
label= CorrectionMessages.getFormattedString("ModifierCorrectionSubProcessor.changemodifiertodefault.description", name); //$NON-NLS-1$
excludedModifiers= Modifier.PRIVATE;
} else {
return;
}
ICompilationUnit targetCU= ASTResolving.findCompilationUnitForBinding(cu, context.getASTRoot(), typeBinding);
if (targetCU != null) {
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
proposals.add(new ModifierChangeCompletionProposal(label, targetCU, binding, selectedNode, includedModifiers, excludedModifiers, relevance, image));
}
}
}
public static void addNonFinalLocalProposal(IInvocationContext context, IProblemLocation problem, Collection proposals) {
ICompilationUnit cu= context.getCompilationUnit();
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
if (!(selectedNode instanceof SimpleName)) {
return;
}
IBinding binding= ((SimpleName) selectedNode).resolveBinding();
if (binding instanceof IVariableBinding) {
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
String label= CorrectionMessages.getFormattedString("ModifierCorrectionSubProcessor.changemodifiertofinal.description", binding.getName()); //$NON-NLS-1$
proposals.add(new ModifierChangeCompletionProposal(label, cu, binding, selectedNode, Modifier.FINAL, 0, 5, image));
}
}
private static String getVisibilityString(int code) {
if (Modifier.isPublic(code)) {
return "public"; //$NON-NLS-1$
}else if (Modifier.isProtected(code)) {
return "protected"; //$NON-NLS-1$
}
return "default"; //$NON-NLS-1$
}
private static int getNeededVisibility(ASTNode currNode, ITypeBinding targetType) {
ITypeBinding currNodeBinding= Bindings.getBindingOfParentType(currNode);
if (currNodeBinding == null) { // import
return Modifier.PUBLIC;
}
if (Bindings.isSuperType(targetType, currNodeBinding)) {
return Modifier.PROTECTED;
}
if (currNodeBinding.getPackage().getKey().equals(targetType.getPackage().getKey())) {
return 0;
}
return Modifier.PUBLIC;
}
public static void addAbstractMethodProposals(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;
}
MethodDeclaration decl;
if (selectedNode instanceof SimpleName) {
decl= (MethodDeclaration) selectedNode.getParent();
} else if (selectedNode instanceof MethodDeclaration) {
decl= (MethodDeclaration) selectedNode;
} else {
return;
}
ASTNode parentType= ASTResolving.findParentType(decl);
TypeDeclaration parentTypeDecl= null;
boolean parentIsAbstractClass= false;
if (parentType instanceof TypeDeclaration) {
parentTypeDecl= (TypeDeclaration) parentType;
parentIsAbstractClass= !parentTypeDecl.isInterface() && Modifier.isAbstract(parentTypeDecl.getModifiers());
}
boolean hasNoBody= (decl.getBody() == null);
if (problem.getProblemId() == IProblem.AbstractMethodInAbstractClass || parentIsAbstractClass) {
ASTRewrite rewrite= new ASTRewrite(decl.getParent());
AST ast= astRoot.getAST();
int newModifiers= decl.getModifiers() & ~Modifier.ABSTRACT;
rewrite.markAsReplaced(decl, ASTNodeConstants.MODIFIERS, new Integer(newModifiers), null);
if (hasNoBody) {
Block newBody= ast.newBlock();
rewrite.markAsInsert(decl, ASTNodeConstants.BODY, newBody, null);
Expression expr= ASTNodeFactory.newDefaultExpression(ast, decl.getReturnType(), decl.getExtraDimensions());
if (expr != null) {
ReturnStatement returnStatement= ast.newReturnStatement();
returnStatement.setExpression(expr);
newBody.statements().add(returnStatement);
}
}
String label= CorrectionMessages.getString("ModifierCorrectionSubProcessor.removeabstract.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, 6, image);
proposal.ensureNoModifications();
proposals.add(proposal);
}
if (!hasNoBody && problem.getProblemId() == IProblem.BodyForAbstractMethod) {
ASTRewrite rewrite= new ASTRewrite(decl.getParent());
rewrite.markAsRemoved(decl.getBody());
String label= CorrectionMessages.getString("ModifierCorrectionSubProcessor.removebody.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal2= new ASTRewriteCorrectionProposal(label, cu, rewrite, 5, image);
proposal2.ensureNoModifications();
proposals.add(proposal2);
}
if (problem.getProblemId() == IProblem.AbstractMethodInAbstractClass && (parentTypeDecl != null)) {
ASTRewriteCorrectionProposal proposal= getMakeTypeStaticProposal(cu, parentTypeDecl, 5);
proposals.add(proposal);
}
}
public static void addNativeMethodProposals(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;
}
MethodDeclaration decl;
if (selectedNode instanceof SimpleName) {
decl= (MethodDeclaration) selectedNode.getParent();
} else if (selectedNode instanceof MethodDeclaration) {
decl= (MethodDeclaration) selectedNode;
} else {
return;
}
{
ASTRewrite rewrite= new ASTRewrite(decl.getParent());
AST ast= astRoot.getAST();
int newModifiers= decl.getModifiers() & ~Modifier.NATIVE;
rewrite.markAsReplaced(decl, ASTNodeConstants.MODIFIERS, new Integer(newModifiers), null);
Block newBody= ast.newBlock();
rewrite.markAsInsert(decl, ASTNodeConstants.BODY, newBody, null);
Expression expr= ASTNodeFactory.newDefaultExpression(ast, decl.getReturnType(), decl.getExtraDimensions());
if (expr != null) {
ReturnStatement returnStatement= ast.newReturnStatement();
returnStatement.setExpression(expr);
newBody.statements().add(returnStatement);
}
String label= CorrectionMessages.getString("ModifierCorrectionSubProcessor.removenative.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, 6, image);
proposal.ensureNoModifications();
proposals.add(proposal);
}
if (decl.getBody() != null) {
ASTRewrite rewrite= new ASTRewrite(decl.getParent());
rewrite.markAsRemoved(decl.getBody());
String label= CorrectionMessages.getString("ModifierCorrectionSubProcessor.removebody.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal2= new ASTRewriteCorrectionProposal(label, cu, rewrite, 5, image);
proposal2.ensureNoModifications();
proposals.add(proposal2);
}
}
public static ASTRewriteCorrectionProposal getMakeTypeStaticProposal(ICompilationUnit cu, TypeDeclaration typeDeclaration, int relevance) throws CoreException {
ASTRewrite rewrite= new ASTRewrite(typeDeclaration.getParent());
int newModifiers= typeDeclaration.getModifiers() | Modifier.ABSTRACT;
rewrite.markAsReplaced(typeDeclaration, ASTNodeConstants.MODIFIERS, new Integer(newModifiers), null);
String label= CorrectionMessages.getFormattedString("ModifierCorrectionSubProcessor.addabstract.description", typeDeclaration.getName().getIdentifier()); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, relevance, image);
proposal.ensureNoModifications();
return proposal;
}
public static void addMethodRequiresBodyProposals(IInvocationContext context, IProblemLocation problem, Collection proposals) throws CoreException {
ICompilationUnit cu= context.getCompilationUnit();
AST ast= context.getASTRoot().getAST();
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
if (!(selectedNode instanceof MethodDeclaration)) {
return;
}
MethodDeclaration decl= (MethodDeclaration) selectedNode;
ASTRewrite rewrite= new ASTRewrite(decl);
int newModifiers= decl.getModifiers() & ~Modifier.ABSTRACT;
rewrite.markAsReplaced(decl, ASTNodeConstants.MODIFIERS, new Integer(newModifiers), null);
Block body= ast.newBlock();
rewrite.markAsInsert(decl, ASTNodeConstants.BODY, body, null);
Type returnType= decl.getReturnType();
if (!decl.isConstructor()) {
Expression expression= ASTNodeFactory.newDefaultExpression(ast, returnType, decl.getExtraDimensions());
if (expression != null) {
ReturnStatement returnStatement= ast.newReturnStatement();
returnStatement.setExpression(expression);
body.statements().add(returnStatement);
}
}
String label= CorrectionMessages.getString("ModifierCorrectionSubProcessor.addmissingbody.description"); //$NON-NLS-1$
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
ASTRewriteCorrectionProposal proposal= new ASTRewriteCorrectionProposal(label, cu, rewrite, 5, image);
proposal.ensureNoModifications();
proposals.add(proposal);
}
public static void addNeedToEmulateProposal(IInvocationContext context, IProblemLocation problem, Collection proposals) {
ICompilationUnit cu= context.getCompilationUnit();
ASTNode selectedNode= problem.getCoveringNode(context.getASTRoot());
if (!(selectedNode instanceof SimpleName)) {
return;
}
IBinding binding= ((SimpleName) selectedNode).resolveBinding();
if (binding instanceof IVariableBinding) {
Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
String label= CorrectionMessages.getFormattedString("ModifierCorrectionSubProcessor.changemodifiertofinal.description", binding.getName()); //$NON-NLS-1$
proposals.add(new ModifierChangeCompletionProposal(label, cu, binding, selectedNode, Modifier.FINAL, 0, 5, image));
}
}
}
|
50,574 |
Bug 50574 quick fix for removing local variable that is never read changes side effects
|
You'll need to set the "Local variable is never read" option in Window>Preferences>Java>Compiler>Unused Code to something other than "Ignore" to reproduce this. The quick fix "Remove variable <variable name> and assignments without possible side effects" that is offered if a local variable is never read makes two types of mistakes: 1. Some side effects are not recognized, e.g. "fixing" int k = 3; int n; n = k++; System.out.println (k); yields int k = 3; System.out.println (k); 2. The variable definition is removed even if it has side effects, e.g. int n = System.in.read (); is removed, whereas if a later assignment has side effects, it is left unchanged, including the now undefined reference to the local variable, e.g. int n; n = System.in.read (); becomes n = System.in.read (); What I think *should* happen is that the initializing assignment and later assignments should be treated alike; the left-hand side referring to the local variable should *always* be removed, and the right-hand side should be removed if and only if it has no side effects. This may result in invalid code if the right-hand side expression has side effects but does not form a statement; a deluxe version might extract the parts that have side effects and insert them as statements in the correct order, but even without this there would be a significant improvement over the current behaviour, which changes side effects and leaves references to undefined variables around.
|
resolved fixed
|
e47f476
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T14:21:06Z | 2004-01-25T19:46:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/RemoveDeclarationCorrectionProposal.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.ui.ISharedImages;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.dom.*;
import org.eclipse.jdt.internal.corext.dom.ASTRewrite;
import org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder;
import org.eclipse.jdt.internal.corext.dom.NodeFinder;
import org.eclipse.jdt.internal.ui.JavaPlugin;
public class RemoveDeclarationCorrectionProposal extends ASTRewriteCorrectionProposal {
private static class SideEffectFinder extends ASTVisitor {
private ArrayList fSideEffectNodes;
public SideEffectFinder(ArrayList res) {
fSideEffectNodes= res;
}
public boolean visit(Assignment node) {
fSideEffectNodes.add(node);
return false;
}
public boolean visit(MethodInvocation node) {
fSideEffectNodes.add(node);
return false;
}
public boolean visit(ClassInstanceCreation node) {
fSideEffectNodes.add(node);
return false;
}
public boolean visit(SuperMethodInvocation node) {
fSideEffectNodes.add(node);
return false;
}
}
private SimpleName fName;
public RemoveDeclarationCorrectionProposal(ICompilationUnit cu, SimpleName name, int relevance) {
super("", cu, null, relevance, JavaPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_DELETE)); //$NON-NLS-1$
fName= name;
}
public String getDisplayString() {
IBinding binding= fName.resolveBinding();
String name= fName.getIdentifier();
switch (binding.getKind()) {
case IBinding.TYPE:
return CorrectionMessages.getFormattedString("RemoveDeclarationCorrectionProposal.removeunusedtype.description", name); //$NON-NLS-1$
case IBinding.METHOD:
if (((IMethodBinding) binding).isConstructor()) {
return CorrectionMessages.getFormattedString("RemoveDeclarationCorrectionProposal.removeunusedconstructor.description", name); //$NON-NLS-1$
} else {
return CorrectionMessages.getFormattedString("RemoveDeclarationCorrectionProposal.removeunusedmethod.description", name); //$NON-NLS-1$
}
case IBinding.VARIABLE:
if (((IVariableBinding) binding).isField()) {
return CorrectionMessages.getFormattedString("RemoveDeclarationCorrectionProposal.removeunusedfield.description", name); //$NON-NLS-1$
} else {
return CorrectionMessages.getFormattedString("RemoveDeclarationCorrectionProposal.removeunusedvar.description", name); //$NON-NLS-1$
}
default:
return super.getDisplayString();
}
}
/*(non-Javadoc)
* @see org.eclipse.jdt.internal.ui.text.correction.ASTRewriteCorrectionProposal#getRewrite()
*/
protected ASTRewrite getRewrite() {
IBinding binding= fName.resolveBinding();
CompilationUnit root= (CompilationUnit) fName.getRoot();
ASTRewrite rewrite;
if (binding.getKind() != IBinding.VARIABLE) {
ASTNode declaration= root.findDeclaringNode(binding);
rewrite= new ASTRewrite(declaration.getParent());
rewrite.markAsRemoved(declaration);
} else { // variable
// needs full AST
CompilationUnit completeRoot= AST.parseCompilationUnit(getCompilationUnit(), true, null, null);
SimpleName nameNode= (SimpleName) NodeFinder.perform(completeRoot, fName.getStartPosition(), fName.getLength());
rewrite= new ASTRewrite(completeRoot);
SimpleName[] references= LinkedNodeFinder.findByBinding(completeRoot, nameNode.resolveBinding());
for (int i= 0; i < references.length; i++) {
removeVariableReferences(rewrite, references[i]);
}
ASTNode declaringNode= completeRoot.findDeclaringNode(nameNode.resolveBinding());
if (declaringNode instanceof SingleVariableDeclaration) {
if (declaringNode.getParent() instanceof MethodDeclaration) {
Javadoc javadoc= ((MethodDeclaration) declaringNode.getParent()).getJavadoc();
if (javadoc != null) {
TagElement tagElement= findThrowsTag(javadoc, nameNode.resolveBinding());
if (tagElement != null) {
rewrite.markAsRemoved(tagElement);
}
}
}
}
}
return rewrite;
}
private static TagElement findThrowsTag(Javadoc javadoc, IBinding binding) {
List tags= javadoc.tags();
for (int i= tags.size() - 1; i >= 0; i--) {
TagElement curr= (TagElement) tags.get(i);
String currName= curr.getTagName();
if ("@param".equals(currName)) { //$NON-NLS-1$
List fragments= curr.fragments();
if (!fragments.isEmpty() && fragments.get(0) instanceof Name) {
Name name= (Name) fragments.get(0);
if (name.resolveBinding() == binding) {
return curr;
}
}
}
}
return null;
}
/**
* Remove the field or variable declaration including the initializer.
*
*/
private void removeVariableReferences(ASTRewrite rewrite, SimpleName reference) {
int nameParentType= reference.getParent().getNodeType();
if (nameParentType == ASTNode.ASSIGNMENT) {
Assignment assignment= (Assignment) reference.getParent();
Expression rightHand= assignment.getRightHandSide();
ASTNode parent= assignment.getParent();
if (parent.getNodeType() == ASTNode.EXPRESSION_STATEMENT && rightHand.getNodeType() != ASTNode.ASSIGNMENT) {
removeVariableWithInitializer(rewrite, rightHand, parent);
} else {
rewrite.markAsReplaced(assignment, rewrite.createCopy(rightHand));
}
} else if (nameParentType == ASTNode.SINGLE_VARIABLE_DECLARATION) {
rewrite.markAsRemoved(reference.getParent());
} else if (nameParentType == ASTNode.VARIABLE_DECLARATION_FRAGMENT) {
VariableDeclarationFragment frag= (VariableDeclarationFragment) reference.getParent();
ASTNode varDecl= frag.getParent();
List fragments;
if (varDecl instanceof VariableDeclarationExpression) {
fragments= ((VariableDeclarationExpression) varDecl).fragments();
} else if (varDecl instanceof FieldDeclaration) {
fragments= ((FieldDeclaration) varDecl).fragments();
} else {
fragments= ((VariableDeclarationStatement) varDecl).fragments();
}
if (fragments.size() == 1) {
rewrite.markAsRemoved(varDecl);
} else {
rewrite.markAsRemoved(frag); // don't try to preserve
}
}
}
private void removeVariableWithInitializer(ASTRewrite rewrite, ASTNode initializerNode, ASTNode statementNode) {
ArrayList sideEffectNodes= new ArrayList();
initializerNode.accept(new SideEffectFinder(sideEffectNodes));
int nSideEffects= sideEffectNodes.size();
if (nSideEffects == 0) {
rewrite.markAsRemoved(statementNode);
} else {
// do nothing yet
}
}
}
|
50,911 |
Bug 50911 New search: can't search for a search result
|
I20040128 (5pm) -> New search view turned on The "search" context menu doesn't appear on selections in the search results view. I use this frequently for back-tracing when browsing code. Search for references to a method, and then search for references to the referencing method, etc. Ctrl+Shift+G to search on a selection in the search results view also used to work.
|
resolved fixed
|
21d44a0
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T16:02:34Z | 2004-01-29T21:00:00Z |
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/AutomatedSuite.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;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.jdt.ui.tests.astrewrite.ASTRewritingTest;
import org.eclipse.jdt.ui.tests.browsing.PackagesViewContentProviderTests;
import org.eclipse.jdt.ui.tests.browsing.PackagesViewDeltaTests;
import org.eclipse.jdt.ui.tests.callhierarchy.CallHierarchyContentProviderTest;
import org.eclipse.jdt.ui.tests.core.CoreTests;
import org.eclipse.jdt.ui.tests.packageview.ContentProviderTests1;
import org.eclipse.jdt.ui.tests.packageview.ContentProviderTests2;
import org.eclipse.jdt.ui.tests.packageview.ContentProviderTests3;
import org.eclipse.jdt.ui.tests.packageview.ContentProviderTests4;
import org.eclipse.jdt.ui.tests.quickfix.QuickFixTest;
import org.eclipse.jdt.ui.tests.text.HTML2TextReaderTester;
import org.eclipse.jdt.ui.tests.text.JavaDoc2HTMLTextReaderTester;
import org.eclipse.jdt.ui.tests.text.JavaHeuristicScannerTest;
import org.eclipse.jdt.ui.tests.text.SmartSemicolonAutoEditStrategyTest;
import org.eclipse.jdt.ui.tests.wizardapi.NewJavaProjectWizardTest;
/**
* Test all areas of the UI.
*/
public class AutomatedSuite extends TestSuite {
/**
* Returns the suite. This is required to
* use the JUnit Launcher.
*/
public static Test suite() {
return new AutomatedSuite();
}
/**
* Construct the test suite.
*/
public AutomatedSuite() {
addTest(CoreTests.suite());
addTest(ASTRewritingTest.suite());
addTest(QuickFixTest.suite());
addTest(NewJavaProjectWizardTest.suite());
addTest(JavaDoc2HTMLTextReaderTester.suite());
addTest(HTML2TextReaderTester.suite());
addTest(ContentProviderTests1.suite());
addTest(ContentProviderTests2.suite());
addTest(ContentProviderTests3.suite());
addTest(ContentProviderTests4.suite());
addTest(PackagesViewContentProviderTests.suite());
addTest(PackagesViewDeltaTests.suite());
addTest(CallHierarchyContentProviderTest.suite());
addTest(JavaHeuristicScannerTest.suite());
addTest(SmartSemicolonAutoEditStrategyTest.suite());
}
}
|
50,911 |
Bug 50911 New search: can't search for a search result
|
I20040128 (5pm) -> New search view turned on The "search" context menu doesn't appear on selections in the search results view. I use this frequently for back-tracing when browsing code. Search for references to a method, and then search for references to the referencing method, etc. Ctrl+Shift+G to search on a selection in the search results view also used to work.
|
resolved fixed
|
21d44a0
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T16:02:34Z | 2004-01-29T21:00:00Z |
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/SearchTest.java
| |
50,911 |
Bug 50911 New search: can't search for a search result
|
I20040128 (5pm) -> New search view turned on The "search" context menu doesn't appear on selections in the search results view. I use this frequently for back-tracing when browsing code. Search for references to a method, and then search for references to the referencing method, etc. Ctrl+Shift+G to search on a selection in the search results view also used to work.
|
resolved fixed
|
21d44a0
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T16:02:34Z | 2004-01-29T21:00:00Z |
org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/search/WorkspaceScopeTest.java
| |
50,911 |
Bug 50911 New search: can't search for a search result
|
I20040128 (5pm) -> New search view turned on The "search" context menu doesn't appear on selections in the search results view. I use this frequently for back-tracing when browsing code. Search for references to a method, and then search for references to the referencing method, etc. Ctrl+Shift+G to search on a selection in the search results view also used to work.
|
resolved fixed
|
21d44a0
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T16:02:34Z | 2004-01-29T21:00:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/JavaSearchResultPage.java
| |
50,911 |
Bug 50911 New search: can't search for a search result
|
I20040128 (5pm) -> New search view turned on The "search" context menu doesn't appear on selections in the search results view. I use this frequently for back-tracing when browsing code. Search for references to a method, and then search for references to the referencing method, etc. Ctrl+Shift+G to search on a selection in the search results view also used to work.
|
resolved fixed
|
21d44a0
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T16:02:34Z | 2004-01-29T21:00:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/ReferenceScopeFactory.java
| |
50,911 |
Bug 50911 New search: can't search for a search result
|
I20040128 (5pm) -> New search view turned on The "search" context menu doesn't appear on selections in the search results view. I use this frequently for back-tracing when browsing code. Search for references to a method, and then search for references to the referencing method, etc. Ctrl+Shift+G to search on a selection in the search results view also used to work.
|
resolved fixed
|
21d44a0
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T16:02:34Z | 2004-01-29T21:00:00Z |
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.resources.IMarker;
import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search.ui.SearchUI;
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.jdt.ui.JavaElementLabelProvider;
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.EditorUtility;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.preferences.WorkInProgressPreferencePage;
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.JavaSearchResult;
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;
/**
* 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);
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) {
}
public void run(IJavaElement element) {
if (!ActionUtil.isProcessable(getShell(), element))
return;
if (JavaPlugin.getDefault().getPreferenceStore().getBoolean(WorkInProgressPreferencePage.PREF_BGSEARCH)) {
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 {
new ProgressMonitorDialog(shell).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 job= createJob(element);
JavaSearchResult result= new JavaSearchResult(job);
NewSearchUI.activateSearchResultView();
NewSearchUI.runSearchInBackground(job, result);
}
protected JavaSearchQuery createJob(IJavaElement element) throws JavaModelException {
IType type= getType(element);
return new JavaSearchQuery(element, getLimitTo(), getScope(type), getScopeDescription(type));
}
protected Object createSearchDescription(IJavaElement element) {
IType type= getType(element);
return new JavaSearchDescription(getLimitTo(), element, null, getScopeDescription(type));
}
JavaSearchOperation makeOperation(IJavaElement element) throws JavaModelException {
IType type= getType(element);
return new JavaSearchOperation(JavaPlugin.getWorkspace(), element, getLimitTo(), getScope(type), getScopeDescription(type), getCollector());
}
abstract int getLimitTo();
IJavaSearchScope getScope(IType element) throws JavaModelException {
return SearchEngine.createWorkspaceScope();
}
JavaSearchResultCollector getCollector() {
return new JavaSearchResultCollector();
}
String getScopeDescription(IType type) {
return SearchMessages.getString("WorkspaceScope"); //$NON-NLS-1$
}
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) {
try {
if (input instanceof ICompilationUnit)
return EditorUtility.getWorkingCopy((ICompilationUnit)input);
else
return EditorUtility.getWorkingCopy(input, true);
} catch (JavaModelException ex) {
}
return null;
}
}
|
50,911 |
Bug 50911 New search: can't search for a search result
|
I20040128 (5pm) -> New search view turned on The "search" context menu doesn't appear on selections in the search results view. I use this frequently for back-tracing when browsing code. Search for references to a method, and then search for references to the referencing method, etc. Ctrl+Shift+G to search on a selection in the search results view also used to work.
|
resolved fixed
|
21d44a0
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T16:02:34Z | 2004-01-29T21:00:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindDeclarationsInHierarchyAction.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 org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.ILocalVariable;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.search.SearchMessages;
/**
* Finds declarations of the selected element in its hierarchy.
* The action is applicable to selections representing a Java element.
*
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
* @since 2.0
*/
public class FindDeclarationsInHierarchyAction extends FindDeclarationsAction {
/**
* Creates a new <code>FindDeclarationsInHierarchyAction</code>. The action
* requires that the selection provided by the site's selection provider is of type
* <code>IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public FindDeclarationsInHierarchyAction(IWorkbenchSite site) {
super(site, SearchMessages.getString("Search.FindHierarchyDeclarationsAction.label"), new Class[] {IField.class, IMethod.class, ILocalVariable.class } ); //$NON-NLS-1$
setToolTipText(SearchMessages.getString("Search.FindHierarchyDeclarationsAction.tooltip")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.FIND_DECLARATIONS_IN_HIERARCHY_ACTION);
}
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
*/
public FindDeclarationsInHierarchyAction(JavaEditor editor) {
super(editor, SearchMessages.getString("Search.FindHierarchyDeclarationsAction.label"), new Class[] {IField.class, IMethod.class, ILocalVariable.class} ); //$NON-NLS-1$
setToolTipText(SearchMessages.getString("Search.FindHierarchyDeclarationsAction.tooltip")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.FIND_DECLARATIONS_IN_HIERARCHY_ACTION);
}
IJavaSearchScope getScope(IType type) throws JavaModelException {
if (type != null)
return SearchEngine.createHierarchyScope(type);
else
return super.getScope(type);
}
String getScopeDescription(IType type) {
String typeName= ""; //$NON-NLS-1$
if (type != null)
typeName= type.getElementName();
return SearchMessages.getFormattedString("HierarchyScope", new String[] {typeName}); //$NON-NLS-1$
}
}
|
50,911 |
Bug 50911 New search: can't search for a search result
|
I20040128 (5pm) -> New search view turned on The "search" context menu doesn't appear on selections in the search results view. I use this frequently for back-tracing when browsing code. Search for references to a method, and then search for references to the referencing method, etc. Ctrl+Shift+G to search on a selection in the search results view also used to work.
|
resolved fixed
|
21d44a0
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T16:02:34Z | 2004-01-29T21:00:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReadReferencesInProjectAction.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 org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.search.JavaSearchScopeFactory;
import org.eclipse.jdt.internal.ui.search.SearchMessages;
import org.eclipse.jdt.internal.ui.search.SearchUtil;
/**
* Finds field read accesses of the selected element in the enclosing project.
* The action is applicable to selections representing a Java field.
*
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
* @since 3.0
*/
public class FindReadReferencesInProjectAction extends FindReadReferencesAction {
/**
* Creates a new <code>FindReadReferencesInProjectAction</code>. The action
* requires that the selection provided by the site's selection provider is of type
* <code>IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public FindReadReferencesInProjectAction(IWorkbenchSite site) {
super(site);
init();
}
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
*/
public FindReadReferencesInProjectAction(JavaEditor editor) {
super(editor);
init();
}
private void init() {
setText(SearchMessages.getString("Search.FindReadReferencesInProjectAction.label")); //$NON-NLS-1$
setToolTipText(SearchMessages.getString("Search.FindReadReferencesInProjectAction.tooltip")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.FIND_READ_REFERENCES_IN_PROJECT_ACTION);
}
IJavaSearchScope getScope(IType element) throws JavaModelException {
return JavaSearchScopeFactory.getInstance().createJavaProjectSearchScope(element);
}
String getScopeDescription(IType type) {
return SearchUtil.getProjectScopeDescription(type);
}
}
|
50,911 |
Bug 50911 New search: can't search for a search result
|
I20040128 (5pm) -> New search view turned on The "search" context menu doesn't appear on selections in the search results view. I use this frequently for back-tracing when browsing code. Search for references to a method, and then search for references to the referencing method, etc. Ctrl+Shift+G to search on a selection in the search results view also used to work.
|
resolved fixed
|
21d44a0
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T16:02:34Z | 2004-01-29T21:00:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesAction.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 org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.help.WorkbenchHelp;
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.ILocalVariable;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IPackageDeclaration;
import org.eclipse.jdt.core.IPackageFragment;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.search.SearchMessages;
import org.eclipse.jdt.internal.ui.search.SearchUtil;
/**
* Finds references of the selected element in the workspace.
* The action is applicable to selections representing a Java element.
*
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
* @since 2.0
*/
public class FindReferencesAction extends FindAction {
/**
* Creates a new <code>FindReferencesAction</code>. The action
* requires that the selection provided by the site's selection provider is of type
* <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public FindReferencesAction(IWorkbenchSite site) {
this(site, SearchMessages.getString("Search.FindReferencesAction.label"), new Class[] {ICompilationUnit.class, IType.class, IMethod.class, IField.class, IPackageDeclaration.class, IImportDeclaration.class, IPackageFragment.class, ILocalVariable.class }); //$NON-NLS-1$
setToolTipText(SearchMessages.getString("Search.FindReferencesAction.tooltip")); //$NON-NLS-1$
}
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
*/
public FindReferencesAction(JavaEditor editor) {
this(editor, SearchMessages.getString("Search.FindReferencesAction.label"), new Class[] {ICompilationUnit.class, IType.class, IMethod.class, IField.class, IPackageDeclaration.class, IImportDeclaration.class, IPackageFragment.class, ILocalVariable.class }); //$NON-NLS-1$
setToolTipText(SearchMessages.getString("Search.FindReferencesAction.tooltip")); //$NON-NLS-1$
}
FindReferencesAction(IWorkbenchSite site, String label, Class[] validTypes) {
super(site, label, validTypes);
setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_REF);
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.FIND_REFERENCES_IN_WORKSPACE_ACTION);
}
FindReferencesAction(JavaEditor editor, String label, Class[] validTypes) {
super(editor, label, validTypes);
setImageDescriptor(JavaPluginImages.DESC_OBJS_SEARCH_REF);
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.FIND_REFERENCES_IN_WORKSPACE_ACTION);
}
int getLimitTo() {
return IJavaSearchConstants.REFERENCES;
}
public void run(IJavaElement element) {
SearchUtil.warnIfBinaryConstant(element, getShell());
super.run(element);
}
}
|
50,911 |
Bug 50911 New search: can't search for a search result
|
I20040128 (5pm) -> New search view turned on The "search" context menu doesn't appear on selections in the search results view. I use this frequently for back-tracing when browsing code. Search for references to a method, and then search for references to the referencing method, etc. Ctrl+Shift+G to search on a selection in the search results view also used to work.
|
resolved fixed
|
21d44a0
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T16:02:34Z | 2004-01-29T21:00:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/FindReferencesInHierarchyAction.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 org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.ILocalVariable;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.search.SearchMessages;
/**
* Finds references of the selected element in its hierarchy.
* The action is applicable to selections representing a Java element.
*
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
* @since 2.0
*/
public class FindReferencesInHierarchyAction extends FindReferencesAction {
/**
* Creates a new <code>FindReferencesInHierarchyAction</code>. The action
* requires that the selection provided by the site's selection provider is of type
* <code>org.eclipse.jface.viewers.IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public FindReferencesInHierarchyAction(IWorkbenchSite site) {
super(site, SearchMessages.getString("Search.FindHierarchyReferencesAction.label"), new Class[] {ICompilationUnit.class, IType.class, IMethod.class, IField.class, ILocalVariable.class }); //$NON-NLS-1$
setToolTipText(SearchMessages.getString("Search.FindHierarchyReferencesAction.tooltip")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.FIND_REFERENCES_IN_HIERARCHY_ACTION);
}
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
*/
public FindReferencesInHierarchyAction(JavaEditor editor) {
super(editor, SearchMessages.getString("Search.FindHierarchyReferencesAction.label"), new Class[] {ICompilationUnit.class, IType.class, IMethod.class, IField.class, ILocalVariable.class }); //$NON-NLS-1$
setToolTipText(SearchMessages.getString("Search.FindHierarchyReferencesAction.tooltip")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.FIND_REFERENCES_IN_HIERARCHY_ACTION);
}
FindReferencesInHierarchyAction(IWorkbenchSite site, String label, Class[] validTypes) {
super(site, label, validTypes);
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.FIND_REFERENCES_IN_HIERARCHY_ACTION);
}
FindReferencesInHierarchyAction(JavaEditor editor, String label, Class[] validTypes) {
super(editor, label, validTypes);
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.FIND_REFERENCES_IN_HIERARCHY_ACTION);
}
IJavaSearchScope getScope(IType type) throws JavaModelException {
if (type == null)
return super.getScope(type);
return SearchEngine.createHierarchyScope(type);
}
String getScopeDescription(IType type) {
String typeName= ""; //$NON-NLS-1$
if (type != null)
typeName= type.getElementName();
return SearchMessages.getFormattedString("HierarchyScope", new String[] {typeName}); //$NON-NLS-1$
}
}
|
51,001 |
Bug 51001 prefix parameter [code manipulation]
|
When implementing a methode or overriding a methode the prefixes of the parametersnames are wrongly changed. In the preferences I put an,a,some as prefix for parameters interface: public interface iTestInterFace { public void foo( String aParameter, Integer anInteger ) ; } when I implement this interface I get ( auto generated ): public class TestImplementation implements iTestInterFace { /* (non-Javadoc) * @see iTestInterFace#doStuff(java.lang.String, java.lang.Integer) */ public void foo( String someParameter, Integer someAnInteger ) { ^^^^ ^^^^^^ // TODO Auto-generated method stub } } When I extend this class and use override/implent methode from the source menu I get : public class TestExtender extends TestImplementation { /* (non-Javadoc) * @see iTestInterFace#foo(java.lang.String, java.lang.Integer) */ public void foo( String someSomeParameter, Integer someSomeAnInteger ) { ^^^^^^^^ ^^^^^^^^^^ // TODO Auto-generated method stub super.foo( someSomeParameter, someSomeAnInteger ); } } I would like that if the parameter starts with one of the prefixes that it is not changed. I use Eclipse Version: 3.0.0 Build id: 200401290841
|
resolved fixed
|
0649db2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T18:00:19Z | 2004-01-30T22:00:00Z |
org.eclipse.jdt.ui/core
| |
51,001 |
Bug 51001 prefix parameter [code manipulation]
|
When implementing a methode or overriding a methode the prefixes of the parametersnames are wrongly changed. In the preferences I put an,a,some as prefix for parameters interface: public interface iTestInterFace { public void foo( String aParameter, Integer anInteger ) ; } when I implement this interface I get ( auto generated ): public class TestImplementation implements iTestInterFace { /* (non-Javadoc) * @see iTestInterFace#doStuff(java.lang.String, java.lang.Integer) */ public void foo( String someParameter, Integer someAnInteger ) { ^^^^ ^^^^^^ // TODO Auto-generated method stub } } When I extend this class and use override/implent methode from the source menu I get : public class TestExtender extends TestImplementation { /* (non-Javadoc) * @see iTestInterFace#foo(java.lang.String, java.lang.Integer) */ public void foo( String someSomeParameter, Integer someSomeAnInteger ) { ^^^^^^^^ ^^^^^^^^^^ // TODO Auto-generated method stub super.foo( someSomeParameter, someSomeAnInteger ); } } I would like that if the parameter starts with one of the prefixes that it is not changed. I use Eclipse Version: 3.0.0 Build id: 200401290841
|
resolved fixed
|
0649db2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T18:00:19Z | 2004-01-30T22:00:00Z |
extension/org/eclipse/jdt/internal/corext/codemanipulation/StubUtility.java
| |
47,785 |
Bug 47785 Exception in Extract Interface refactoring [refactoring]
|
Eclipse M5 1) Import JUnit 3.8.1 (as per Smoke test) 2) In the package explorer, select junit.runner.BaseTestRunner 3) From the context menu, select Refactor->Extract Interface 4) Input a name for the interface, select all methods 5) press the preview button 6) observe: you get an exception: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:271) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:377) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:297) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:293) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.getNextPage(UserInputWizardPage.java:79) at org.eclipse.jdt.internal.ui.refactoring.ExtractInterfaceWizard$ExtractInterfaceInputPage.getNextPage(ExtractInterfaceWizard.java:278) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.previewPressed(RefactoringWizardDialog2.java:418) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.access$3(RefactoringWizardDialog2.java:416) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2$1.widgetSelected(RefactoringWizardDialog2.java:547) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.jface.window.Window.runEventLoop(Window.java:586) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:56) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.startRefactoring(ExtractInterfaceAction.java:173) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.run(ExtractInterfaceAction.java:105) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:194) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:172) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:542) at org.eclipse.jface.action.ActionContributionItem.access$4(ActionContributionItem.java:494) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:466) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1405) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1381) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:237) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) 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:299) at org.eclipse.core.launcher.Main.run(Main.java:767) at org.eclipse.core.launcher.Main.main(Main.java:601) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -4 at java.lang.String.<init>(String.java:192) at org.eclipse.jdt.internal.core.Buffer.getText(Buffer.java:168) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMethodDeclarationsSource(ExtractInterfaceRefactoring.java:568) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:545) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:519) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceSource(ExtractInterfaceRefactoring.java:501) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createExtractedInterfaceCUSource(ExtractInterfaceRefactoring.java:477) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createChangeManager(ExtractInterfaceRefactoring.java:309) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.checkInput(ExtractInterfaceRefactoring.java:215) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:100) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
|
verified fixed
|
395246d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T18:08:10Z | 2003-12-01T12:00:00Z |
org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/in/A.java
| |
47,785 |
Bug 47785 Exception in Extract Interface refactoring [refactoring]
|
Eclipse M5 1) Import JUnit 3.8.1 (as per Smoke test) 2) In the package explorer, select junit.runner.BaseTestRunner 3) From the context menu, select Refactor->Extract Interface 4) Input a name for the interface, select all methods 5) press the preview button 6) observe: you get an exception: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:271) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:377) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:297) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:293) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.getNextPage(UserInputWizardPage.java:79) at org.eclipse.jdt.internal.ui.refactoring.ExtractInterfaceWizard$ExtractInterfaceInputPage.getNextPage(ExtractInterfaceWizard.java:278) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.previewPressed(RefactoringWizardDialog2.java:418) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.access$3(RefactoringWizardDialog2.java:416) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2$1.widgetSelected(RefactoringWizardDialog2.java:547) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.jface.window.Window.runEventLoop(Window.java:586) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:56) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.startRefactoring(ExtractInterfaceAction.java:173) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.run(ExtractInterfaceAction.java:105) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:194) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:172) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:542) at org.eclipse.jface.action.ActionContributionItem.access$4(ActionContributionItem.java:494) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:466) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1405) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1381) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:237) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) 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:299) at org.eclipse.core.launcher.Main.run(Main.java:767) at org.eclipse.core.launcher.Main.main(Main.java:601) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -4 at java.lang.String.<init>(String.java:192) at org.eclipse.jdt.internal.core.Buffer.getText(Buffer.java:168) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMethodDeclarationsSource(ExtractInterfaceRefactoring.java:568) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:545) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:519) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceSource(ExtractInterfaceRefactoring.java:501) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createExtractedInterfaceCUSource(ExtractInterfaceRefactoring.java:477) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createChangeManager(ExtractInterfaceRefactoring.java:309) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.checkInput(ExtractInterfaceRefactoring.java:215) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:100) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
|
verified fixed
|
395246d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T18:08:10Z | 2003-12-01T12:00:00Z |
org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/out/A.java
| |
47,785 |
Bug 47785 Exception in Extract Interface refactoring [refactoring]
|
Eclipse M5 1) Import JUnit 3.8.1 (as per Smoke test) 2) In the package explorer, select junit.runner.BaseTestRunner 3) From the context menu, select Refactor->Extract Interface 4) Input a name for the interface, select all methods 5) press the preview button 6) observe: you get an exception: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:271) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:377) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:297) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:293) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.getNextPage(UserInputWizardPage.java:79) at org.eclipse.jdt.internal.ui.refactoring.ExtractInterfaceWizard$ExtractInterfaceInputPage.getNextPage(ExtractInterfaceWizard.java:278) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.previewPressed(RefactoringWizardDialog2.java:418) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.access$3(RefactoringWizardDialog2.java:416) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2$1.widgetSelected(RefactoringWizardDialog2.java:547) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.jface.window.Window.runEventLoop(Window.java:586) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:56) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.startRefactoring(ExtractInterfaceAction.java:173) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.run(ExtractInterfaceAction.java:105) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:194) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:172) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:542) at org.eclipse.jface.action.ActionContributionItem.access$4(ActionContributionItem.java:494) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:466) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1405) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1381) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:237) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) 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:299) at org.eclipse.core.launcher.Main.run(Main.java:767) at org.eclipse.core.launcher.Main.main(Main.java:601) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -4 at java.lang.String.<init>(String.java:192) at org.eclipse.jdt.internal.core.Buffer.getText(Buffer.java:168) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMethodDeclarationsSource(ExtractInterfaceRefactoring.java:568) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:545) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:519) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceSource(ExtractInterfaceRefactoring.java:501) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createExtractedInterfaceCUSource(ExtractInterfaceRefactoring.java:477) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createChangeManager(ExtractInterfaceRefactoring.java:309) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.checkInput(ExtractInterfaceRefactoring.java:215) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:100) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
|
verified fixed
|
395246d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T18:08:10Z | 2003-12-01T12:00:00Z |
org.eclipse.jdt.ui.tests.refactoring/resources/ExtractInterface/test100/out/I.java
| |
47,785 |
Bug 47785 Exception in Extract Interface refactoring [refactoring]
|
Eclipse M5 1) Import JUnit 3.8.1 (as per Smoke test) 2) In the package explorer, select junit.runner.BaseTestRunner 3) From the context menu, select Refactor->Extract Interface 4) Input a name for the interface, select all methods 5) press the preview button 6) observe: you get an exception: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:271) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:377) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:297) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:293) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.getNextPage(UserInputWizardPage.java:79) at org.eclipse.jdt.internal.ui.refactoring.ExtractInterfaceWizard$ExtractInterfaceInputPage.getNextPage(ExtractInterfaceWizard.java:278) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.previewPressed(RefactoringWizardDialog2.java:418) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.access$3(RefactoringWizardDialog2.java:416) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2$1.widgetSelected(RefactoringWizardDialog2.java:547) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.jface.window.Window.runEventLoop(Window.java:586) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:56) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.startRefactoring(ExtractInterfaceAction.java:173) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.run(ExtractInterfaceAction.java:105) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:194) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:172) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:542) at org.eclipse.jface.action.ActionContributionItem.access$4(ActionContributionItem.java:494) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:466) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1405) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1381) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:237) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) 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:299) at org.eclipse.core.launcher.Main.run(Main.java:767) at org.eclipse.core.launcher.Main.main(Main.java:601) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -4 at java.lang.String.<init>(String.java:192) at org.eclipse.jdt.internal.core.Buffer.getText(Buffer.java:168) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMethodDeclarationsSource(ExtractInterfaceRefactoring.java:568) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:545) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:519) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceSource(ExtractInterfaceRefactoring.java:501) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createExtractedInterfaceCUSource(ExtractInterfaceRefactoring.java:477) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createChangeManager(ExtractInterfaceRefactoring.java:309) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.checkInput(ExtractInterfaceRefactoring.java:215) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:100) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
|
verified fixed
|
395246d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T18:08:10Z | 2003-12-01T12:00:00Z |
org.eclipse.jdt.ui.tests.refactoring/test
| |
47,785 |
Bug 47785 Exception in Extract Interface refactoring [refactoring]
|
Eclipse M5 1) Import JUnit 3.8.1 (as per Smoke test) 2) In the package explorer, select junit.runner.BaseTestRunner 3) From the context menu, select Refactor->Extract Interface 4) Input a name for the interface, select all methods 5) press the preview button 6) observe: you get an exception: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:271) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:377) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:297) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:293) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.getNextPage(UserInputWizardPage.java:79) at org.eclipse.jdt.internal.ui.refactoring.ExtractInterfaceWizard$ExtractInterfaceInputPage.getNextPage(ExtractInterfaceWizard.java:278) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.previewPressed(RefactoringWizardDialog2.java:418) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.access$3(RefactoringWizardDialog2.java:416) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2$1.widgetSelected(RefactoringWizardDialog2.java:547) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.jface.window.Window.runEventLoop(Window.java:586) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:56) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.startRefactoring(ExtractInterfaceAction.java:173) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.run(ExtractInterfaceAction.java:105) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:194) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:172) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:542) at org.eclipse.jface.action.ActionContributionItem.access$4(ActionContributionItem.java:494) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:466) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1405) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1381) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:237) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) 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:299) at org.eclipse.core.launcher.Main.run(Main.java:767) at org.eclipse.core.launcher.Main.main(Main.java:601) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -4 at java.lang.String.<init>(String.java:192) at org.eclipse.jdt.internal.core.Buffer.getText(Buffer.java:168) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMethodDeclarationsSource(ExtractInterfaceRefactoring.java:568) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:545) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:519) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceSource(ExtractInterfaceRefactoring.java:501) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createExtractedInterfaceCUSource(ExtractInterfaceRefactoring.java:477) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createChangeManager(ExtractInterfaceRefactoring.java:309) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.checkInput(ExtractInterfaceRefactoring.java:215) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:100) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
|
verified fixed
|
395246d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T18:08:10Z | 2003-12-01T12:00:00Z |
cases/org/eclipse/jdt/ui/tests/refactoring/ExtractInterfaceTests.java
| |
47,785 |
Bug 47785 Exception in Extract Interface refactoring [refactoring]
|
Eclipse M5 1) Import JUnit 3.8.1 (as per Smoke test) 2) In the package explorer, select junit.runner.BaseTestRunner 3) From the context menu, select Refactor->Extract Interface 4) Input a name for the interface, select all methods 5) press the preview button 6) observe: you get an exception: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:271) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:377) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:297) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:293) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.getNextPage(UserInputWizardPage.java:79) at org.eclipse.jdt.internal.ui.refactoring.ExtractInterfaceWizard$ExtractInterfaceInputPage.getNextPage(ExtractInterfaceWizard.java:278) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.previewPressed(RefactoringWizardDialog2.java:418) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.access$3(RefactoringWizardDialog2.java:416) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2$1.widgetSelected(RefactoringWizardDialog2.java:547) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.jface.window.Window.runEventLoop(Window.java:586) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:56) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.startRefactoring(ExtractInterfaceAction.java:173) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.run(ExtractInterfaceAction.java:105) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:194) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:172) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:542) at org.eclipse.jface.action.ActionContributionItem.access$4(ActionContributionItem.java:494) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:466) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1405) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1381) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:237) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) 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:299) at org.eclipse.core.launcher.Main.run(Main.java:767) at org.eclipse.core.launcher.Main.main(Main.java:601) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -4 at java.lang.String.<init>(String.java:192) at org.eclipse.jdt.internal.core.Buffer.getText(Buffer.java:168) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMethodDeclarationsSource(ExtractInterfaceRefactoring.java:568) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:545) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:519) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceSource(ExtractInterfaceRefactoring.java:501) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createExtractedInterfaceCUSource(ExtractInterfaceRefactoring.java:477) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createChangeManager(ExtractInterfaceRefactoring.java:309) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.checkInput(ExtractInterfaceRefactoring.java:215) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:100) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
|
verified fixed
|
395246d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T18:08:10Z | 2003-12-01T12:00:00Z |
org.eclipse.jdt.ui/core
| |
47,785 |
Bug 47785 Exception in Extract Interface refactoring [refactoring]
|
Eclipse M5 1) Import JUnit 3.8.1 (as per Smoke test) 2) In the package explorer, select junit.runner.BaseTestRunner 3) From the context menu, select Refactor->Extract Interface 4) Input a name for the interface, select all methods 5) press the preview button 6) observe: you get an exception: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run(RefactoringWizardDialog2.java:271) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.createChange(RefactoringWizard.java:377) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:297) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.computeUserInputSuccessorPage(RefactoringWizard.java:293) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.getNextPage(UserInputWizardPage.java:79) at org.eclipse.jdt.internal.ui.refactoring.ExtractInterfaceWizard$ExtractInterfaceInputPage.getNextPage(ExtractInterfaceWizard.java:278) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.previewPressed(RefactoringWizardDialog2.java:418) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.access$3(RefactoringWizardDialog2.java:416) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2$1.widgetSelected(RefactoringWizardDialog2.java:547) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.jface.window.Window.runEventLoop(Window.java:586) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:56) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.startRefactoring(ExtractInterfaceAction.java:173) at org.eclipse.jdt.ui.actions.ExtractInterfaceAction.run(ExtractInterfaceAction.java:105) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:194) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:172) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:542) at org.eclipse.jface.action.ActionContributionItem.access$4(ActionContributionItem.java:494) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent(ActionContributionItem.java:466) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2187) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1877) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1405) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1381) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:237) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.boot.InternalBootLoader.run(InternalBootLoader.java:858) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) 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:299) at org.eclipse.core.launcher.Main.run(Main.java:767) at org.eclipse.core.launcher.Main.main(Main.java:601) Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: -4 at java.lang.String.<init>(String.java:192) at org.eclipse.jdt.internal.core.Buffer.getText(Buffer.java:168) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMethodDeclarationsSource(ExtractInterfaceRefactoring.java:568) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:545) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceMemberDeclarationsSource(ExtractInterfaceRefactoring.java:519) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createInterfaceSource(ExtractInterfaceRefactoring.java:501) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createExtractedInterfaceCUSource(ExtractInterfaceRefactoring.java:477) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.createChangeManager(ExtractInterfaceRefactoring.java:309) at org.eclipse.jdt.internal.corext.refactoring.structure.ExtractInterfaceRefactoring.checkInput(ExtractInterfaceRefactoring.java:215) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run(CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run(CreateChangeOperation.java:100) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:101)
|
verified fixed
|
395246d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T18:08:10Z | 2003-12-01T12:00:00Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ExtractInterfaceRefactoring.java
| |
51,076 |
Bug 51076 Quick fix misses and presents wrong name for target field class
|
Observe this example: public class Test { class Foo { void foo() { x = 4; } } void foo() { bar(new Runnable() { public void run() { x = 5; } }); } void bar(Runnable runner) { } } Quick-fix markers are activated for "x = 4" and "x = 5". For "x = 4", there is no suggestion to add a field to 'Test'. For "x = 5", there is a suggestion to add a field to ''. This should be 'Test'
|
resolved fixed
|
e0b6656
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T18:59:36Z | 2004-02-02T19:26:40Z |
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 <[email protected]> - 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.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.ASTNodeConstants;
import org.eclipse.jdt.internal.corext.dom.ASTNodeFactory;
import org.eclipse.jdt.internal.corext.dom.ASTRewrite;
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) throws CoreException {
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= new ASTRewrite(statement.getParent());
rewrite.markAsRemoved(statement);
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);
proposal.ensureNoModifications();
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, senderBinding.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);
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
}
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 variablefragment
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 simlar 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 + 20, 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 sugest 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) throws CoreException {
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= new ASTRewrite(expression.getParent());
CastExpression newCast= ast.newCastExpression();
newCast.setType((Type) ASTNode.copySubtree(ast, expression.getType()));
newCast.setExpression((Expression) rewrite.createCopy(accessExpression));
ParenthesizedExpression parents= ast.newParenthesizedExpression();
parents.setExpression(newCast);
ASTNode node= rewrite.createCopy(expression.getExpression());
rewrite.markAsReplaced(expression, node);
rewrite.markAsReplaced(accessExpression, parents);
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);
proposal.ensureNoModifications();
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));
proposal.ensureNoModifications();
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
{
ASTNode selectedNode= problem.getCoveringNode(astRoot);
ASTRewrite rewrite= new ASTRewrite(selectedNode.getParent());
for (int i= diff - 1; i >= 0; i--) {
rewrite.markAsRemoved((Expression) arguments.get(indexSkipped[i]));
}
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);
proposal.ensureNoModifications();
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 (isDifferentCU && 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;
}
}
CompilationUnit unit= AST.parsePartialCompilationUnit(targetCU, 0, true);
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 missmatching: 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= LocalCorrectionsSubProcessor.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$
proposal.ensureNoModifications();
proposals.add(proposal);
}
}
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= new ASTRewrite(arg1.getParent());
rewrite.markAsReplaced(arg1, rewrite.createCopy(arg2));
rewrite.markAsReplaced(arg2, rewrite.createCopy(arg1));
{
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);
proposal.ensureNoModifications();
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= new ASTRewrite(invocationNode.getParent());
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.markAsInsert(invocationNode, ASTNodeConstants.EXPRESSION, 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);
proposal.ensureNoModifications();
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);
}
}
}
}
|
49,242 |
Bug 49242 NPE when canceling a reference search for a Java Type in the workspace [search]
|
When performing a reference search for an ambiguous Type (such as "List") using the context menu of the java editor and you cancel the dialog box, a NullPointerException is thrown. This happens on both M5 and M6. Steps to replicate: 1. Create a new class file 2. Type in "List" 3. Right click on List 4. Select References->Workspace 5. A dialog box should pop up asking you to qualify the type 6. Press Cancel 7. Dialog will pop up indicating an error has occured and to check the log It looks like the problem is that SelectionConverter.codeResolve will return null if cancel is selected. ActionUtil.isProcessable does not check that the object being checked is null, so the operation continues instead of cancelling. I added a null check in the run method in FindAction#run(ITextSelection) and it seemed to fix the problem. here is the stacktrace, if it helps: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.jface.dialogs.ProgressMonitorDialog.run (ProgressMonitorDialog.java:394) at org.eclipse.jdt.ui.actions.FindAction.run(FindAction.java:293) at org.eclipse.jdt.ui.actions.FindReferencesAction.run (FindReferencesAction.java:84) at org.eclipse.jdt.ui.actions.FindAction.run(FindAction.java:239) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:216) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:188) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:509) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:461) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent (ActionContributionItem.java:408) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:847) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2311) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1992) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1482) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:246) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:226) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:85) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.eclipse.core.launcher.Main.basicRun(Main.java:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581) Caused by: java.lang.NullPointerException at org.eclipse.jdt.core.search.SearchEngine.createSearchPattern (SearchEngine.java:381) at org.eclipse.jdt.internal.ui.search.JavaSearchOperation.execute (JavaSearchOperation.java:99) at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run (WorkspaceModifyOperation.java:91) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1555) at org.eclipse.ui.actions.WorkspaceModifyOperation.run (WorkspaceModifyOperation.java:105) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101)
|
resolved fixed
|
e9a7b2b
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-09T19:49:14Z | 2003-12-21T01:26: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.resources.IMarker;
import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.eclipse.search.ui.NewSearchUI;
import org.eclipse.search.ui.SearchUI;
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.jdt.ui.JavaElementLabelProvider;
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.EditorUtility;
import org.eclipse.jdt.internal.ui.javaeditor.JavaEditor;
import org.eclipse.jdt.internal.ui.preferences.WorkInProgressPreferencePage;
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.JavaSearchResult;
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;
/**
* 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);
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) {
}
public void run(IJavaElement element) {
if (!ActionUtil.isProcessable(getShell(), element))
return;
if (JavaPlugin.getDefault().getPreferenceStore().getBoolean(WorkInProgressPreferencePage.PREF_BGSEARCH)) {
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 {
new ProgressMonitorDialog(shell).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 job= createJob(element);
JavaSearchResult result= new JavaSearchResult(job);
NewSearchUI.activateSearchResultView();
NewSearchUI.runSearchInBackground(job, result);
}
protected JavaSearchQuery createJob(IJavaElement element) throws JavaModelException {
return new JavaSearchQuery(element, getLimitTo(), getScope(element), getScopeDescription(element));
}
protected 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) {
try {
if (input instanceof ICompilationUnit)
return EditorUtility.getWorkingCopy((ICompilationUnit)input);
else
return EditorUtility.getWorkingCopy(input, true);
} catch (JavaModelException ex) {
}
return null;
}
}
|
51,541 |
Bug 51541 NPE restoring scrapbook editor
|
build I20040210-0800 plus latest UI and Text from HEAD When running my target eclipse, I got an error restoring a scrapbook editor that had been saved during the previous session. The log has the following. The line in question is: StyledText styledText= fSourceViewer.getTextWidget(); *** int caret= widgetOffset2ModelOffset(fSourceViewer, styledText.getCaretOffset()); !ENTRY org.eclipse.core.runtime 4 2 Feb 10, 2004 15:49:26.780 !MESSAGE Problems occurred when invoking code from plug- in: "org.eclipse.core.runtime". !STACK 0 java.lang.NullPointerException at org.eclipse.ui.texteditor.AbstractTextEditor.getCursorPosition (AbstractTextEditor.java:4399) at org.eclipse.ui.texteditor.AbstractTextEditor.updateStatusField (AbstractTextEditor.java:4357) at org.eclipse.ui.texteditor.AbstractTextEditor.setStatusField (AbstractTextEditor.java:4104) at org.eclipse.ui.texteditor.BasicTextEditorActionContributor.doSetActiveEditor (BasicTextEditorActionContributor.java:215) at org.eclipse.ui.texteditor.BasicTextEditorActionContributor.setActiveEditor (BasicTextEditorActionContributor.java:229) at org.eclipse.jdt.internal.ui.javaeditor.BasicJavaEditorActionContributor.setActiv eEditor(BasicJavaEditorActionContributor.java:187) at org.eclipse.jdt.internal.ui.javaeditor.BasicEditorActionContributor.setActiveEdi tor(BasicEditorActionContributor.java:83) at org.eclipse.jdt.internal.debug.ui.snippeteditor.SnippetEditorActionContributor.s etActiveEditor(SnippetEditorActionContributor.java:74) at org.eclipse.ui.internal.EditorActionBars.partChanged (EditorActionBars.java:291) at org.eclipse.ui.internal.WorkbenchPage$2.run(WorkbenchPage.java:474) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:819) at org.eclipse.core.runtime.Platform.run(Platform.java:493) at org.eclipse.ui.internal.WorkbenchPage.activatePart (WorkbenchPage.java:466) at org.eclipse.ui.internal.WorkbenchPage.onActivate (WorkbenchPage.java:1953) at org.eclipse.ui.internal.WorkbenchWindow$6.run (WorkbenchWindow.java:1824) at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:84) at org.eclipse.ui.internal.WorkbenchWindow.setActivePage (WorkbenchWindow.java:1811) at org.eclipse.ui.internal.WorkbenchWindow.restoreState (WorkbenchWindow.java:1406) at org.eclipse.ui.internal.Workbench.restoreState(Workbench.java:1369) at org.eclipse.ui.internal.Workbench.access$8(Workbench.java:1337) at org.eclipse.ui.internal.Workbench$11.run(Workbench.java:1259) at org.eclipse.core.internal.runtime.InternalPlatform.run (InternalPlatform.java:819) at org.eclipse.core.runtime.Platform.run(Platform.java:493) at org.eclipse.ui.internal.Workbench.openPreviousWorkbenchState (Workbench.java:1215) at org.eclipse.ui.internal.Workbench.init(Workbench.java:894) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1503) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:257) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:108) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
verified fixed
|
1a81c08
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-10T23:27:51Z | 2004-02-10T21:53:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/SpellReconcileStrategy.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.spelling;
import java.text.MessageFormat;
import java.util.Locale;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.jface.text.reconciler.DirtyRegion;
import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.jdt.core.IProblemRequestor;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellCheckEngine;
import org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellCheckPreferenceKeys;
import org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellChecker;
import org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent;
import org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEventListener;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
/**
* Reconcile strategy to spell-check comments.
*
* @since 3.0
*/
public class SpellReconcileStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension, ISpellEventListener {
/**
* Spelling problem to be accepted by problem requestors.
*/
public class SpellProblem implements IProblem {
/** The id of the problem */
public static final int Spelling= 0x80000000;
/** The end offset of the problem */
private int fEnd= 0;
/** The line number of the problem */
private int fLine= 1;
/** Was the word found in the dictionary? */
private boolean fMatch;
/** Does the word start a new sentence? */
private boolean fSentence= false;
/** The start offset of the problem */
private int fStart= 0;
/** The word which caused the problem */
private final String fWord;
/**
* Creates a new spelling problem
*
* @param word
* The word which caused the problem
*/
protected SpellProblem(final String word) {
fWord= word;
}
/*
* @see org.eclipse.jdt.core.compiler.IProblem#getArguments()
*/
public String[] getArguments() {
String prefix= ""; //$NON-NLS-1$
String postfix= ""; //$NON-NLS-1$
try {
final IRegion line= fDocument.getLineInformationOfOffset(fStart);
prefix= fDocument.get(line.getOffset(), fStart - line.getOffset());
postfix= fDocument.get(fEnd + 1, line.getOffset() + line.getLength() - fEnd);
} catch (BadLocationException exception) {
// Do nothing
}
return new String[] { fWord, prefix, postfix, fSentence ? Boolean.toString(true) : Boolean.toString(false), fMatch ? Boolean.toString(true) : Boolean.toString(false)};
}
/*
* @see org.eclipse.jdt.core.compiler.IProblem#getID()
*/
public int getID() {
return Spelling;
}
/*
* @see org.eclipse.jdt.core.compiler.IProblem#getMessage()
*/
public String getMessage() {
if (fSentence && fMatch)
return MessageFormat.format(JavaUIMessages.getString("Spelling.error.case.label"), new String[] { fWord }); //$NON-NLS-1$
return MessageFormat.format(JavaUIMessages.getString("Spelling.error.label"), new String[] { fWord }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
/*
* @see org.eclipse.jdt.core.compiler.IProblem#getOriginatingFileName()
*/
public char[] getOriginatingFileName() {
return fEditor.getEditorInput().getName().toCharArray();
}
/*
* @see org.eclipse.jdt.core.compiler.IProblem#getSourceEnd()
*/
public final int getSourceEnd() {
return fEnd;
}
/*
* @see org.eclipse.jdt.core.compiler.IProblem#getSourceLineNumber()
*/
public final int getSourceLineNumber() {
return fLine;
}
/*
* @see org.eclipse.jdt.core.compiler.IProblem#getSourceStart()
*/
public final int getSourceStart() {
return fStart;
}
/**
* Was the problem word found in the dictionary?
*
* @return <code>true</code> iff the word was found, <code>false</code>
* otherwise
*/
public final boolean isDictionaryMatch() {
return fMatch;
}
/*
* @see org.eclipse.jdt.core.compiler.IProblem#isError()
*/
public final boolean isError() {
return false;
}
/**
* Does the problem word start a new sentence?
*
* @return <code>true</code> iff it starts a new sentence, <code>false</code>
* otherwise
*/
public final boolean isSentenceStart() {
return fSentence;
}
/*
* @see org.eclipse.jdt.core.compiler.IProblem#isWarning()
*/
public final boolean isWarning() {
return true;
}
/**
* Sets whether the problem word was found in the dictionary.
*
* @param match
* <code>true</code> iff the word was found, <code>false</code>
* otherwise
*/
public final void setDictionaryMatch(final boolean match) {
fMatch= match;
}
/**
* Sets whether the problem word starts a new sentence.
*
* @param sentence
* <code>true</code> iff the word starts a new sentence,
* <code>false</code> otherwise.
*/
public final void setSentenceStart(final boolean sentence) {
fSentence= sentence;
}
/*
* @see org.eclipse.jdt.core.compiler.IProblem#setSourceEnd(int)
*/
public final void setSourceEnd(final int end) {
fEnd= end;
}
/*
* @see org.eclipse.jdt.core.compiler.IProblem#setSourceLineNumber(int)
*/
public final void setSourceLineNumber(final int line) {
fLine= line;
}
/*
* @see org.eclipse.jdt.core.compiler.IProblem#setSourceStart(int)
*/
public final void setSourceStart(final int start) {
fStart= start;
}
}
/** The document to operate on */
private IDocument fDocument= null;
/** The text editor to operate on */
private final ITextEditor fEditor;
/** The current locale */
private Locale fLocale= SpellCheckEngine.getDefaultLocale();
/** The partitioning of the document */
private final String fPartitioning;
/** The preference store to use */
private final IPreferenceStore fPreferences;
/** The problem requestor */
private final IProblemRequestor fRequestor;
/**
* Creates a new comment reconcile strategy.
*
* @param editor
* The text editor to operate on
* @param partitioning
* The partitioning of the document
* @param store
* The preference store to get the preferences from
*/
public SpellReconcileStrategy(final ITextEditor editor, final String partitioning, final IPreferenceStore store) {
fEditor= editor;
fPartitioning= partitioning;
fPreferences= store;
final IAnnotationModel model= editor.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
Assert.isLegal(model instanceof IProblemRequestor);
fRequestor= (IProblemRequestor)model;
}
/**
* Returns the current locale of the spell checking preferences.
*
* @return The current locale of the spell checking preferences
*/
public Locale getLocale() {
final String locale= fPreferences.getString(ISpellCheckPreferenceKeys.SPELLING_LOCALE);
if (locale.equals(fLocale.toString()))
return fLocale;
if (locale.length() >= 5)
return new Locale(locale.substring(0, 2), locale.substring(3, 5));
return SpellCheckEngine.getDefaultLocale();
}
/*
* @see org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEventListener#handle(org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellEvent)
*/
public void handle(final ISpellEvent event) {
final SpellProblem problem= new SpellProblem(event.getWord());
problem.setSourceStart(event.getBegin());
problem.setSourceEnd(event.getEnd());
problem.setSentenceStart(event.isStart());
problem.setDictionaryMatch(event.isMatch());
try {
problem.setSourceLineNumber(fDocument.getLineOfOffset(event.getBegin()) + 1);
} catch (BadLocationException exception) {
// Do nothing
}
fRequestor.acceptProblem(problem);
}
/*
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile()
*/
public void initialReconcile() {
final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
final ISpellChecker checker= engine.createSpellChecker(getLocale(), fPreferences);
if (checker != null)
checker.addListener(this);
}
/*
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion,org.eclipse.jface.text.IRegion)
*/
public void reconcile(final DirtyRegion dirtyRegion, final IRegion subRegion) {
reconcile(subRegion);
}
/*
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
*/
public void reconcile(final IRegion region) {
if (fPreferences.getBoolean(ISpellCheckPreferenceKeys.SPELLING_CHECK_SPELLING)) {
try {
fRequestor.beginReporting();
ITypedRegion partition= null;
final ITypedRegion[] partitions= TextUtilities.computePartitioning(fDocument, fPartitioning, 0, fDocument.getLength());
final Locale locale= getLocale();
final ISpellCheckEngine engine= SpellCheckEngine.getInstance();
final ISpellChecker checker= engine.createSpellChecker(locale, fPreferences);
if (checker != null) {
for (int index= 0; index < partitions.length; index++) {
partition= partitions[index];
if (!partition.getType().equals(IDocument.DEFAULT_CONTENT_TYPE))
checker.execute(new SpellCheckIterator(fDocument, partition, locale));
}
}
} catch (BadLocationException exception) {
// Do nothing
} finally {
fRequestor.endReporting();
}
}
}
/*
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
*/
public final void setDocument(final IDocument document) {
fDocument= document;
}
/*
* @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
*/
public final void setProgressMonitor(final IProgressMonitor monitor) {
// Do nothing
}
}
|
51,453 |
Bug 51453 Find Occurrences in File: Can't jump to location in class file
|
I20040209-1020: - select a java field in the java editor - Search > Occurrences in File - (Old) Search view appears with correct results - Doubleclicking a result or choosing 'Open File' from the context menu doesn't work.
|
verified fixed
|
bc1fe45
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T14:44:23Z | 2004-02-10T13:33:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/FindOccurrencesEngine.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.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.ISourceReference;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.search.ui.ISearchResultView;
import org.eclipse.search.ui.SearchUI;
import org.eclipse.jdt.internal.corext.util.WorkingCopyUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.ui.JavaUI;
public abstract class FindOccurrencesEngine {
private IOccurrencesFinder fFinder;
private static class FindOccurencesClassFileEngine extends FindOccurrencesEngine {
private IClassFile fClassFile;
public FindOccurencesClassFileEngine(IClassFile file, IOccurrencesFinder finder) {
super(finder);
fClassFile= file;
}
protected CompilationUnit createAST() {
return AST.parseCompilationUnit(fClassFile, true);
}
protected IJavaElement getInput() {
return fClassFile;
}
protected IResource getMarkerOwner() {
return fClassFile.getJavaProject().getProject();
}
protected void addSpecialAttributes(Map attributes) throws JavaModelException {
attributes.put(IWorkbenchPage.EDITOR_ID_ATTR, JavaUI.ID_CF_EDITOR);
JavaCore.addJavaElementMarkerAttributes(attributes, fClassFile.getType());
attributes.put(IJavaSearchUIConstants.ATT_JE_HANDLE_ID, fClassFile.getType().getHandleIdentifier());
}
protected ISourceReference getSourceReference() {
return fClassFile;
}
}
private static class FindOccurencesCUEngine extends FindOccurrencesEngine {
private ICompilationUnit fCUnit;
public FindOccurencesCUEngine(ICompilationUnit unit, IOccurrencesFinder finder) {
super(finder);
fCUnit= unit;
}
protected CompilationUnit createAST() {
return AST.parseCompilationUnit(fCUnit, true);
}
protected IJavaElement getInput() {
return fCUnit;
}
protected IResource getMarkerOwner() throws JavaModelException {
ICompilationUnit original= WorkingCopyUtil.getOriginal(fCUnit);
return original.getUnderlyingResource();
}
protected void addSpecialAttributes(Map attributes) {
// do nothing
}
protected ISourceReference getSourceReference() {
return fCUnit;
}
}
protected FindOccurrencesEngine(IOccurrencesFinder finder) {
fFinder= finder;
}
public static FindOccurrencesEngine create(IJavaElement root, IOccurrencesFinder finder) {
if (root == null || finder == null)
return null;
ICompilationUnit unit= (ICompilationUnit)root.getAncestor(IJavaElement.COMPILATION_UNIT);
if (unit != null)
return new FindOccurencesCUEngine(unit, finder);
IClassFile cf= (IClassFile)root.getAncestor(IJavaElement.CLASS_FILE);
if (cf != null)
return new FindOccurencesClassFileEngine(cf, finder);
return null;
}
protected abstract CompilationUnit createAST();
protected abstract IJavaElement getInput();
protected abstract ISourceReference getSourceReference();
protected abstract IResource getMarkerOwner() throws JavaModelException;
protected abstract void addSpecialAttributes(Map attributes) throws JavaModelException;
public String run(int offset, int length) throws JavaModelException {
ISourceReference sr= getSourceReference();
if (sr.getSourceRange() == null) {
return SearchMessages.getString("FindOccurrencesEngine.noSource.text"); //$NON-NLS-1$
}
final CompilationUnit root= createAST();
if (root == null) {
return SearchMessages.getString("FindOccurrencesEngine.cannotParse.text"); //$NON-NLS-1$
}
String message= fFinder.initialize(root, offset, length);
if (message != null)
return message;
final IDocument document= new Document(getSourceReference().getSource());
final IWorkspaceRunnable runnable= new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
ISearchResultView view= startSearch();
fFinder.perform();
IResource file= getMarkerOwner();
IMarker[] markers= fFinder.createMarkers(file, document);
for (int i = 0; i < markers.length; i++) {
IMarker marker= markers[i];
addSpecialAttributes(marker.getAttributes());
addMatch(view, file, marker);
}
searchFinished(view);
}
};
run(runnable);
return null;
}
private ISearchResultView startSearch() {
SearchUI.activateSearchResultView();
ISearchResultView view= SearchUI.getSearchResultView();
IJavaElement element= getInput();
if (view != null) {
fFinder.searchStarted(view, element.getElementName());
}
return view;
}
private void addMatch(final ISearchResultView view, IResource file, IMarker marker) {
if (view != null)
view.addMatch("", getGroupByKey(marker), file, marker); //$NON-NLS-1$
}
private void searchFinished(final ISearchResultView view) {
if (view != null)
view.searchFinished();
}
private Object getGroupByKey(IMarker marker) {
try {
return marker.getAttribute(IMarker.LINE_NUMBER);
} catch (CoreException e) {
}
return marker;
}
private void run(final IWorkspaceRunnable runnable) {
BusyIndicator.showWhile(null,
new Runnable() {
public void run() {
try {
JavaCore.run(runnable, null);
} catch (CoreException e) {
JavaPlugin.log(e);
}
}
}
);
}
}
|
51,612 |
Bug 51612 [preferences] Indent new annotation style combo
|
I200402102000 The combo for text styles on the annotation preference page depends on the above check box. This should be shown by indenting the combo. Nice to have for M7 since it is in N&NW.
|
verified fixed
|
d3561a7
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T15:26:34Z | 2004-02-11T11:46:40Z |
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.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.ExtendedTextEditorPreferenceConstants;
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.IJavaPartitions;
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$
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.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"), ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR}, //$NON-NLS-1$
{PreferencesMessages.getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"), PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR}, //$NON-NLS-1$
{PreferencesMessages.getString("JavaEditorPreferencePage.currentLineHighlighColor"), ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR}, //$NON-NLS-1$
{PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColor2"), ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR}, //$NON-NLS-1$
{PreferencesMessages.getString("JavaEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR}, //$NON-NLS-1$
{PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_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.SQUIGGLIES"), AnnotationPreference.STYLE_SQUIGGLIES}, //$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 JavaTextTools fJavaTextTools;
private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
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 ColorEditor fAnnotationForegroundColorEditor;
private ColorEditor fContentAssistColorEditor;
private ColorEditor fBackgroundColorEditor;
private Button fBackgroundDefaultRadioButton;
private Button fBackgroundCustomRadioButton;
private Button fBackgroundColorButton;
private Button fBoldCheckBox;
private Button fAddJavaDocTagsButton;
private Button fEscapeStringsButton;
private Button fGuessMethodArgumentsButton;
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;
private Button fStickyOccurrencesButton;
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.INT, PreferenceConstants.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_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, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OCCURRENCES));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
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, ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.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.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_SHOW_TEXT_HOVER_AFFORDANCE));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
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));
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);
}
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 squigglies 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) {
Preferences coreStore= createTemporaryCorePreferenceStore();
fJavaTextTools= new JavaTextTools(fOverlayStore, coreStore, false);
fPreviewViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
fPreviewViewer.configure(new JavaSourceViewerConfiguration(fJavaTextTools, null, IJavaPartitions.JAVA_PARTITIONING));
Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
fPreviewViewer.getTextWidget().setFont(font);
new JavaSourcePreviewerUpdater(fPreviewViewer, fJavaTextTools);
fPreviewViewer.setEditable(false);
String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
IDocument document= new Document(content);
fJavaTextTools.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, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
label= PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
addTextField(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
label= PreferencesMessages.getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
label= PreferencesMessages.getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.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, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
label= PreferencesMessages.getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
label= PreferencesMessages.getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
Button master= addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
label= PreferencesMessages.getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
fStickyOccurrencesButton= addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
createDependency(master, fStickyOccurrencesButton);
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);
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;
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() {
/**
* {@inheritdoc}
*/
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
/**
* {@inheritdoc}
*/
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();
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 button= addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 1);
label= PreferencesMessages.getString("JavaEditorPreferencePage.escapeStrings"); //$NON-NLS-1$
fEscapeStringsButton= addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS, 1);
createDependency(button, fEscapeStringsButton);
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$
button= addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
label= PreferencesMessages.getString("JavaEditorPreferencePage.addJavaDocTags"); //$NON-NLS-1$
fAddJavaDocTagsButton= addCheckBox(group, label, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
createDependency(button, fAddJavaDocTagsButton);
// 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 static void createDependency(final Button master, final Control slave) {
indent(slave);
master.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
slave.setEnabled(master.getSelection());
}
public void widgetDefaultSelected(SelectionEvent e) {}
});
}
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.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 button= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, 0);
label= PreferencesMessages.getString("JavaEditorPreferencePage.guessArgumentNamesOnMethodCompletion"); //$NON-NLS-1$
fGuessMethodArgumentsButton= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, 0);
createDependency(button, fGuessMethodArgumentsButton);
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();
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$
fJavaEditorHoverConfigurationBlock= new JavaEditorHoverConfigurationBlock(this, fOverlayStore);
item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title")); //$NON-NLS-1$
item.setControl(createNavigationPage(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();
}
}
});
}
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 closeJavaDocs= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
fEscapeStringsButton.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS));
boolean fillMethodArguments= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
boolean completionInserts= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
fCompletionInsertsRadioButton.setSelection(completionInserts);
fCompletionOverwritesRadioButton.setSelection(! completionInserts);
fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection());
boolean markOccurrences= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
fStickyOccurrencesButton.setEnabled(markOccurrences);
updateAutoactivationControls();
}
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);
}
}
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();
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();
super.performDefaults();
fPreviewViewer.invalidateTextPresentation();
}
/*
* @see DialogPage#dispose()
*/
public void dispose() {
if (fJavaTextTools != null) {
fJavaTextTools.dispose();
fJavaTextTools= null;
}
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.
*/
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 (!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(fJavaEditorHoverConfigurationBlock.getStatus(), status);
status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(), status);
setValid(!status.matches(IStatus.ERROR));
StatusUtil.applyToStatusLine(this, status);
}
}
|
50,988 |
Bug 50988 3.0M6 - Refactor rename for class members ignore non java files, and java files which are not in the same source folder.
| null |
verified fixed
|
66f82e9
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T15:57:03Z | 2004-01-30T19:13:20Z |
org.eclipse.jdt.ui/core
| |
50,988 |
Bug 50988 3.0M6 - Refactor rename for class members ignore non java files, and java files which are not in the same source folder.
| null |
verified fixed
|
66f82e9
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T15:57:03Z | 2004-01-30T19:13:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/rename/RefactoringScopeFactory.java
| |
50,904 |
Bug 50904 IllegalArgumentException during refactoring
|
build i0129, winxp, j9sc20031212 - create package /org.eclipse.core.runtime.compatibility/src-runtime/org.eclipse.core.runtime - in packages explorer, select org.eclipse.core.runtime.Preferences - Refactor -> move - destination is new package - Preview In the Preview, there were a lot (maybe 12?) classes selected but there wasn't any differences in the compare. I expanded one class and it had "updated imports". I selected that line (not sure if it was the line or the checkbox) and I got the following error in my log file. !ENTRY org.eclipse.core.runtime 4 2 Jan 29, 2004 14:50:25.641 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.runtime". !STACK 0 java.lang.IllegalArgumentException: at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java) at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java) at org.eclipse.core.runtime.Status.setMessage(Status.java:156) at org.eclipse.core.runtime.Status.<init>(Status.java:75) at org.eclipse.jdt.internal.corext.refactoring.changes.Changes.asCoreException(Changes.java:25) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getContent(TextChange.java:655) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getCurrentContent(TextChange.java:402) at org.eclipse.jdt.internal.ui.refactoring.TextChangePreviewViewer.setInput(TextChangePreviewViewer.java:155) at org.eclipse.jdt.internal.ui.refactoring.TextEditChangeElement.feedInput(TextEditChangeElement.java:68) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.showPreview(PreviewWizardPage.java:387) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.access$2(PreviewWizardPage.java:366) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage$2.selectionChanged(PreviewWizardPage.java:357) at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java) at org.eclipse.core.runtime.Platform.run(Platform.java) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java) at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:1310) at org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredViewer.java:666) at org.eclipse.jface.viewers.CheckboxTreeViewer.handleSelect(CheckboxTreeViewer.java:261) at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(StructuredViewer.java:690) at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenStrategy.java:178) at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.java) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java) 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.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:56) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.startRefactoring(ReorgMoveAction.java:135) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.run(ReorgMoveAction.java:119) 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.jdt.ui.actions.MoveAction.run(MoveAction.java:123) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java) 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:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
6019623
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T16:02:44Z | 2004-01-29T21:00:00Z |
org.eclipse.jdt.ui/core
| |
50,904 |
Bug 50904 IllegalArgumentException during refactoring
|
build i0129, winxp, j9sc20031212 - create package /org.eclipse.core.runtime.compatibility/src-runtime/org.eclipse.core.runtime - in packages explorer, select org.eclipse.core.runtime.Preferences - Refactor -> move - destination is new package - Preview In the Preview, there were a lot (maybe 12?) classes selected but there wasn't any differences in the compare. I expanded one class and it had "updated imports". I selected that line (not sure if it was the line or the checkbox) and I got the following error in my log file. !ENTRY org.eclipse.core.runtime 4 2 Jan 29, 2004 14:50:25.641 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.runtime". !STACK 0 java.lang.IllegalArgumentException: at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java) at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java) at org.eclipse.core.runtime.Status.setMessage(Status.java:156) at org.eclipse.core.runtime.Status.<init>(Status.java:75) at org.eclipse.jdt.internal.corext.refactoring.changes.Changes.asCoreException(Changes.java:25) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getContent(TextChange.java:655) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getCurrentContent(TextChange.java:402) at org.eclipse.jdt.internal.ui.refactoring.TextChangePreviewViewer.setInput(TextChangePreviewViewer.java:155) at org.eclipse.jdt.internal.ui.refactoring.TextEditChangeElement.feedInput(TextEditChangeElement.java:68) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.showPreview(PreviewWizardPage.java:387) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.access$2(PreviewWizardPage.java:366) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage$2.selectionChanged(PreviewWizardPage.java:357) at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java) at org.eclipse.core.runtime.Platform.run(Platform.java) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java) at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:1310) at org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredViewer.java:666) at org.eclipse.jface.viewers.CheckboxTreeViewer.handleSelect(CheckboxTreeViewer.java:261) at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(StructuredViewer.java:690) at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenStrategy.java:178) at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.java) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java) 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.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:56) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.startRefactoring(ReorgMoveAction.java:135) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.run(ReorgMoveAction.java:119) 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.jdt.ui.actions.MoveAction.run(MoveAction.java:123) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java) 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:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
6019623
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T16:02:44Z | 2004-01-29T21:00:00Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/Changes.java
| |
50,904 |
Bug 50904 IllegalArgumentException during refactoring
|
build i0129, winxp, j9sc20031212 - create package /org.eclipse.core.runtime.compatibility/src-runtime/org.eclipse.core.runtime - in packages explorer, select org.eclipse.core.runtime.Preferences - Refactor -> move - destination is new package - Preview In the Preview, there were a lot (maybe 12?) classes selected but there wasn't any differences in the compare. I expanded one class and it had "updated imports". I selected that line (not sure if it was the line or the checkbox) and I got the following error in my log file. !ENTRY org.eclipse.core.runtime 4 2 Jan 29, 2004 14:50:25.641 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.runtime". !STACK 0 java.lang.IllegalArgumentException: at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java) at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java) at org.eclipse.core.runtime.Status.setMessage(Status.java:156) at org.eclipse.core.runtime.Status.<init>(Status.java:75) at org.eclipse.jdt.internal.corext.refactoring.changes.Changes.asCoreException(Changes.java:25) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getContent(TextChange.java:655) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getCurrentContent(TextChange.java:402) at org.eclipse.jdt.internal.ui.refactoring.TextChangePreviewViewer.setInput(TextChangePreviewViewer.java:155) at org.eclipse.jdt.internal.ui.refactoring.TextEditChangeElement.feedInput(TextEditChangeElement.java:68) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.showPreview(PreviewWizardPage.java:387) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.access$2(PreviewWizardPage.java:366) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage$2.selectionChanged(PreviewWizardPage.java:357) at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java) at org.eclipse.core.runtime.Platform.run(Platform.java) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java) at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:1310) at org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredViewer.java:666) at org.eclipse.jface.viewers.CheckboxTreeViewer.handleSelect(CheckboxTreeViewer.java:261) at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(StructuredViewer.java:690) at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenStrategy.java:178) at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.java) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java) 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.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:56) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.startRefactoring(ReorgMoveAction.java:135) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.run(ReorgMoveAction.java:119) 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.jdt.ui.actions.MoveAction.run(MoveAction.java:123) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java) 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:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
6019623
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T16:02:44Z | 2004-01-29T21:00:00Z |
org.eclipse.jdt.ui/core
| |
50,904 |
Bug 50904 IllegalArgumentException during refactoring
|
build i0129, winxp, j9sc20031212 - create package /org.eclipse.core.runtime.compatibility/src-runtime/org.eclipse.core.runtime - in packages explorer, select org.eclipse.core.runtime.Preferences - Refactor -> move - destination is new package - Preview In the Preview, there were a lot (maybe 12?) classes selected but there wasn't any differences in the compare. I expanded one class and it had "updated imports". I selected that line (not sure if it was the line or the checkbox) and I got the following error in my log file. !ENTRY org.eclipse.core.runtime 4 2 Jan 29, 2004 14:50:25.641 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.runtime". !STACK 0 java.lang.IllegalArgumentException: at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java) at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java) at org.eclipse.core.runtime.Status.setMessage(Status.java:156) at org.eclipse.core.runtime.Status.<init>(Status.java:75) at org.eclipse.jdt.internal.corext.refactoring.changes.Changes.asCoreException(Changes.java:25) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getContent(TextChange.java:655) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getCurrentContent(TextChange.java:402) at org.eclipse.jdt.internal.ui.refactoring.TextChangePreviewViewer.setInput(TextChangePreviewViewer.java:155) at org.eclipse.jdt.internal.ui.refactoring.TextEditChangeElement.feedInput(TextEditChangeElement.java:68) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.showPreview(PreviewWizardPage.java:387) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.access$2(PreviewWizardPage.java:366) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage$2.selectionChanged(PreviewWizardPage.java:357) at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java) at org.eclipse.core.runtime.Platform.run(Platform.java) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java) at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:1310) at org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredViewer.java:666) at org.eclipse.jface.viewers.CheckboxTreeViewer.handleSelect(CheckboxTreeViewer.java:261) at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(StructuredViewer.java:690) at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenStrategy.java:178) at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.java) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java) 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.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:56) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.startRefactoring(ReorgMoveAction.java:135) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.run(ReorgMoveAction.java:119) 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.jdt.ui.actions.MoveAction.run(MoveAction.java:123) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java) 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:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
6019623
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T16:02:44Z | 2004-01-29T21:00:00Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/TextChange.java
| |
50,904 |
Bug 50904 IllegalArgumentException during refactoring
|
build i0129, winxp, j9sc20031212 - create package /org.eclipse.core.runtime.compatibility/src-runtime/org.eclipse.core.runtime - in packages explorer, select org.eclipse.core.runtime.Preferences - Refactor -> move - destination is new package - Preview In the Preview, there were a lot (maybe 12?) classes selected but there wasn't any differences in the compare. I expanded one class and it had "updated imports". I selected that line (not sure if it was the line or the checkbox) and I got the following error in my log file. !ENTRY org.eclipse.core.runtime 4 2 Jan 29, 2004 14:50:25.641 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.runtime". !STACK 0 java.lang.IllegalArgumentException: at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java) at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java) at org.eclipse.core.runtime.Status.setMessage(Status.java:156) at org.eclipse.core.runtime.Status.<init>(Status.java:75) at org.eclipse.jdt.internal.corext.refactoring.changes.Changes.asCoreException(Changes.java:25) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getContent(TextChange.java:655) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getCurrentContent(TextChange.java:402) at org.eclipse.jdt.internal.ui.refactoring.TextChangePreviewViewer.setInput(TextChangePreviewViewer.java:155) at org.eclipse.jdt.internal.ui.refactoring.TextEditChangeElement.feedInput(TextEditChangeElement.java:68) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.showPreview(PreviewWizardPage.java:387) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.access$2(PreviewWizardPage.java:366) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage$2.selectionChanged(PreviewWizardPage.java:357) at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java) at org.eclipse.core.runtime.Platform.run(Platform.java) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java) at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:1310) at org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredViewer.java:666) at org.eclipse.jface.viewers.CheckboxTreeViewer.handleSelect(CheckboxTreeViewer.java:261) at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(StructuredViewer.java:690) at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenStrategy.java:178) at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.java) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java) 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.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:56) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.startRefactoring(ReorgMoveAction.java:135) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.run(ReorgMoveAction.java:119) 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.jdt.ui.actions.MoveAction.run(MoveAction.java:123) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java) 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:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
6019623
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T16:02:44Z | 2004-01-29T21:00:00Z |
org.eclipse.jdt.ui/ui
| |
50,904 |
Bug 50904 IllegalArgumentException during refactoring
|
build i0129, winxp, j9sc20031212 - create package /org.eclipse.core.runtime.compatibility/src-runtime/org.eclipse.core.runtime - in packages explorer, select org.eclipse.core.runtime.Preferences - Refactor -> move - destination is new package - Preview In the Preview, there were a lot (maybe 12?) classes selected but there wasn't any differences in the compare. I expanded one class and it had "updated imports". I selected that line (not sure if it was the line or the checkbox) and I got the following error in my log file. !ENTRY org.eclipse.core.runtime 4 2 Jan 29, 2004 14:50:25.641 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.core.runtime". !STACK 0 java.lang.IllegalArgumentException: at java.lang.Throwable.<init>(Throwable.java) at java.lang.Throwable.<init>(Throwable.java) at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java) at org.eclipse.core.internal.runtime.Assert.isLegal(Assert.java) at org.eclipse.core.runtime.Status.setMessage(Status.java:156) at org.eclipse.core.runtime.Status.<init>(Status.java:75) at org.eclipse.jdt.internal.corext.refactoring.changes.Changes.asCoreException(Changes.java:25) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getContent(TextChange.java:655) at org.eclipse.jdt.internal.corext.refactoring.changes.TextChange.getCurrentContent(TextChange.java:402) at org.eclipse.jdt.internal.ui.refactoring.TextChangePreviewViewer.setInput(TextChangePreviewViewer.java:155) at org.eclipse.jdt.internal.ui.refactoring.TextEditChangeElement.feedInput(TextEditChangeElement.java:68) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.showPreview(PreviewWizardPage.java:387) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage.access$2(PreviewWizardPage.java:366) at org.eclipse.jdt.internal.ui.refactoring.PreviewWizardPage$2.selectionChanged(PreviewWizardPage.java:357) at org.eclipse.jface.viewers.Viewer$2.run(Viewer.java) at org.eclipse.core.internal.runtime.InternalPlatform.run(InternalPlatform.java) at org.eclipse.core.runtime.Platform.run(Platform.java) at org.eclipse.jface.viewers.Viewer.fireSelectionChanged(Viewer.java) at org.eclipse.jface.viewers.StructuredViewer.updateSelection(StructuredViewer.java:1310) at org.eclipse.jface.viewers.StructuredViewer.handleSelect(StructuredViewer.java:666) at org.eclipse.jface.viewers.CheckboxTreeViewer.handleSelect(CheckboxTreeViewer.java:261) at org.eclipse.jface.viewers.StructuredViewer$4.widgetSelected(StructuredViewer.java:690) at org.eclipse.jface.util.OpenStrategy.fireSelectionEvent(OpenStrategy.java:178) at org.eclipse.jface.util.OpenStrategy.access$3(OpenStrategy.java) at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java) 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.jface.window.Window.runEventLoop(Window.java) at org.eclipse.jface.window.Window.open(Window.java:566) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate(RefactoringStarter.java:56) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.startRefactoring(ReorgMoveAction.java:135) at org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgMoveAction.run(ReorgMoveAction.java:119) 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.jdt.ui.actions.MoveAction.run(MoveAction.java:123) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java) 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:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
6019623
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T16:02:44Z | 2004-01-29T21:00:00Z |
refactoring/org/eclipse/jdt/internal/ui/refactoring/PreviewWizardPage.java
| |
51,619 |
Bug 51619 Vertical ruler Roll-Overs should only appear for vertical ruler annotations
|
I200402102000 Roll-over shows all annotations also those which I explicitly disabled to show up in the vertical ruler. M7 candidate.
|
verified fixed
|
b013f6d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T16:23:35Z | 2004-02-11T11:46:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/JavaExpandHover.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.java.hover;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;
import org.eclipse.swt.widgets.Display;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IInformationControlExtension2;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationAccess;
import org.eclipse.jface.text.source.IAnnotationAccessExtension;
import org.eclipse.jface.text.source.IAnnotationListener;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IAnnotationPresentation;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRulerInfo;
import org.eclipse.ui.internal.texteditor.AnnotationExpandHover;
import org.eclipse.ui.internal.texteditor.AnnotationExpansionControl;
import org.eclipse.ui.internal.texteditor.AnnotationExpansionControl.AnnotationHoverInput;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.javaeditor.IJavaAnnotation;
import org.eclipse.jdt.internal.ui.javaeditor.JavaMarkerAnnotation;
/**
*
*
* @since 3.0
*/
public class JavaExpandHover extends AnnotationExpandHover {
public static final String NO_BREAKPOINT_ANNOTATION= "org.eclipse.jdt.internal.ui.NoBreakpointAnnotation"; //$NON-NLS-1$
private static class NoBreakpointAnnotation extends Annotation implements IAnnotationPresentation {
NoBreakpointAnnotation() {
super(NO_BREAKPOINT_ANNOTATION, false, "Double click to add a breakpoint"); //$NON-NLS-1$
}
/*
* @see org.eclipse.jface.text.source.Annotation#paint(org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Canvas, org.eclipse.swt.graphics.Rectangle)
*/
public void paint(GC gc, Canvas canvas, Rectangle bounds) {
// draw affordance so the user know she can click here to get a breakpoint
Image fImage= JavaPluginImages.get(JavaPluginImages.IMG_FIELD_PUBLIC);
drawImage(fImage, gc, canvas, bounds, SWT.CENTER);
}
}
/**
* @param ruler
* @param listener
*/
public JavaExpandHover(IVerticalRulerInfo ruler, IAnnotationListener listener, IDoubleClickListener doubleClickListener, IAnnotationAccess access) {
super(ruler, listener, doubleClickListener, access);
}
/**
* @param ruler
* @param access
*/
public JavaExpandHover(IVerticalRulerInfo ruler, IAnnotationAccess access) {
super(ruler, access);
}
/*
* @see org.eclipse.ui.internal.texteditor.AnnotationExpandHover#getHoverInfo2(org.eclipse.jface.text.source.ISourceViewer, int)
*/
public Object getHoverInfo2(final ISourceViewer viewer, final int line) {
IAnnotationModel model= viewer.getAnnotationModel();
IDocument document= viewer.getDocument();
if (model == null)
return null;
List exact= new ArrayList();
HashMap messagesAtPosition= new HashMap();
StyledText text= viewer.getTextWidget();
Display display;
if (text != null && !text.isDisposed())
display= text.getDisplay();
else
display= null;
Iterator e= model.getAnnotationIterator();
while (e.hasNext()) {
Annotation annotation= (Annotation) e.next();
// don't prune deleted ones as we don't get many errors this way
// if (annotation.isMarkedDeleted())
// continue;
if (fAnnotationAccess instanceof IAnnotationAccessExtension)
if (!((IAnnotationAccessExtension)fAnnotationAccess).isPaintable(annotation))
continue;
if (annotation instanceof IJavaAnnotation && annotation instanceof IAnnotationPresentation)
if (((IJavaAnnotation) annotation).getImage(display) == null)
continue;
Position position= model.getPosition(annotation);
if (position == null)
continue;
if (compareRulerLine(position, document, line) == 1) {
if (isDuplicateMessage(messagesAtPosition, position, annotation.getText()))
continue;
exact.add(annotation);
}
}
sort(exact, model);
if (exact.size() > 0)
setLastRulerMouseLocation(viewer, line);
if (exact.size() > 0) {
Annotation first= (Annotation) exact.get(0);
if (!isBreakpointAnnotation(first))
exact.add(0, new NoBreakpointAnnotation());
}
if (exact.size() <= 1)
// if (exact.size() < 1)
return null;
AnnotationHoverInput input= new AnnotationHoverInput();
input.fAnnotations= (Annotation[]) exact.toArray(new Annotation[0]);
input.fViewer= viewer;
input.fRulerInfo= fVerticalRulerInfo;
input.fAnnotationListener= fAnnotationListener;
input.fDoubleClickListener= fDblClickListener;
input.redoAction= new AnnotationExpansionControl.ICallback() {
public void run(IInformationControlExtension2 control) {
control.setInput(getHoverInfo2(viewer, line));
}
};
input.model= model;
return input;
}
/*
* @see org.eclipse.ui.internal.texteditor.AnnotationExpandHover#getOrder(org.eclipse.jface.text.source.Annotation)
*/
protected int getOrder(Annotation annotation) {
if (isBreakpointAnnotation(annotation)) //$NON-NLS-1$
return 1000;
else
return super.getOrder(annotation);
}
private boolean isBreakpointAnnotation(Annotation a) {
if (a instanceof JavaMarkerAnnotation) {
JavaMarkerAnnotation jma= (JavaMarkerAnnotation) a;
// HACK to get breakpoints to show up first
return jma.getType().equals("org.eclipse.debug.core.breakpoint"); //$NON-NLS-1$
}
return false;
}
}
|
51,608 |
Bug 51608 project creation wizard: add folder button lets one add existing folder the first time
|
M7 test pass, I200402102000 1. Create a new java project 2. configure using src and bin folders 3. on the second page, press "add folder" 4. enter "src" as the folder name into the mask -> there is no complaint about the added folder, although it already existed -> when pressing "add folder" a second time, a different dialog comes up, allowing to specify where to add a new folder. Entering an existing folder name here gets flagged as an error. -> it seems that although there is an entry for the preconfigured "src" folder, it does not yet exist really.
|
verified fixed
|
9263607
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T18:37:54Z | 2004-02-11T11:46:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizardSecondPage.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.wizards;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.wizards.JavaCapabilityConfigurationPage;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
/**
* As addition to the JavaCapabilityConfigurationPage, the wizard does an
* early project creation (so that linked folders can be defined) and, if an
* existing external location was specified, offers to do a classpath detection
*/
public class JavaProjectWizardSecondPage extends JavaCapabilityConfigurationPage {
private final JavaProjectWizardFirstPage fFirstPage;
protected IPath fCurrProjectLocation;
protected IProject fCurrProject;
protected boolean fCanRemoveContent;
/**
* Constructor for NewProjectCreationWizardPage.
*/
public JavaProjectWizardSecondPage(JavaProjectWizardFirstPage mainPage) {
super();
fFirstPage= mainPage;
fCurrProjectLocation= null;
fCurrProject= null;
fCanRemoveContent= false;
}
/* (non-Javadoc)
* @see org.eclipse.jface.dialogs.IDialogPage#setVisible(boolean)
*/
public void setVisible(boolean visible) {
if (visible) {
changeToNewProject();
} else {
removeProject();
}
super.setVisible(visible);
}
private void changeToNewProject() {
final IProject newProjectHandle= fFirstPage.getProjectHandle();
final IPath newProjectLocation= fFirstPage.getLocationPath();
fCanRemoveContent= !fFirstPage.getDetect();
final boolean initialize= !(newProjectHandle.equals(fCurrProject) && newProjectLocation.equals(fCurrProjectLocation));
final IRunnableWithProgress op= new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
updateProject(initialize, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
};
try {
getContainer().run(false, true, op);
} catch (InvocationTargetException e) {
final String title= NewWizardMessages.getString("JavaProjectWizardSecondPage.error.title"); //$NON-NLS-1$
final String message= NewWizardMessages.getString("JavaProjectWizardSecondPage.error.message"); //$NON-NLS-1$
ExceptionHandler.handle(e, getShell(), title, message);
} catch (InterruptedException e) {
// cancel pressed
}
}
protected void updateProject(boolean initialize, IProgressMonitor monitor) throws CoreException {
fCurrProject= fFirstPage.getProjectHandle();
fCurrProjectLocation= fFirstPage.getLocationPath();
final boolean noProgressMonitor= !initialize && !fFirstPage.getDetect();
if (monitor == null || noProgressMonitor ) {
monitor= new NullProgressMonitor();
}
try {
monitor.beginTask(NewWizardMessages.getString("JavaProjectWizardSecondPage.operation.initialize"), 2); //$NON-NLS-1$
createProject(fCurrProject, fCurrProjectLocation, new SubProgressMonitor(monitor, 1));
if (initialize) {
IClasspathEntry[] entries= null;
IPath outputLocation= null;
if (fFirstPage.getDetect()) {
if (!fCurrProject.getFile(".classpath").exists()) { //$NON-NLS-1$
final ClassPathDetector detector= new ClassPathDetector(fCurrProject);
entries= detector.getClasspath();
outputLocation= detector.getOutputLocation();
}
} else if (fFirstPage.isSrcBin()) {
String srcName= PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.SRCBIN_SRCNAME);
String binName= PreferenceConstants.getPreferenceStore().getString(PreferenceConstants.SRCBIN_BINNAME);
final IPath projectPath= fCurrProject.getFullPath();
// configure the classpath entries, including the default jre library.
final List cpEntries= new ArrayList();
cpEntries.add(JavaCore.newSourceEntry(projectPath.append(srcName)));
cpEntries.addAll(Arrays.asList(PreferenceConstants.getDefaultJRELibrary()));
entries= new IClasspathEntry[cpEntries.size()];
cpEntries.toArray(entries);
// configure the output location
outputLocation= projectPath.append(binName);
}
init(JavaCore.create(fCurrProject), outputLocation, entries, false);
}
monitor.worked(1);
} finally {
monitor.done();
}
}
/**
* Called from the wizard on finish.
*/
public void performFinish(IProgressMonitor monitor) throws CoreException, InterruptedException {
try {
monitor.beginTask(NewWizardMessages.getString("JavaProjectWizardSecondPage.operation.create"), 3); //$NON-NLS-1$
if (fCurrProject == null) {
updateProject(true, new SubProgressMonitor(monitor, 1));
}
configureJavaProject(new SubProgressMonitor(monitor, 2));
} finally {
monitor.done();
fCurrProject= null;
}
}
private void removeProject() {
if (fCurrProject == null || !fCurrProject.exists()) {
return;
}
IRunnableWithProgress op= new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
final boolean noProgressMonitor= Platform.getInstanceLocation().equals(fCurrProjectLocation);
if (monitor == null || noProgressMonitor) {
monitor= new NullProgressMonitor();
}
monitor.beginTask(NewWizardMessages.getString("JavaProjectWizardSecondPage.operation.remove"), 3); //$NON-NLS-1$
try {
fCurrProject.delete(fCanRemoveContent, false, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
fCurrProject= null;
fCanRemoveContent= false;
}
}
};
try {
getContainer().run(false, true, op);
} catch (InvocationTargetException e) {
final String title= NewWizardMessages.getString("JavaProjectWizardSecondPage.error.remove.title"); //$NON-NLS-1$
final String message= NewWizardMessages.getString("JavaProjectWizardSecondPage.error.remove.message"); //$NON-NLS-1$
ExceptionHandler.handle(e, getShell(), title, message);
} catch (InterruptedException e) {
// cancel pressed
}
}
/**
* Called from the wizard on cancel.
*/
public void performCancel() {
removeProject();
}
}
|
51,607 |
Bug 51607 project creation wizard: too tall [build path]
|
M7 test pass, I200402102000 1. Ctrl+N, choose Java Project -> The first page is too tall, filling out almost the entire screen although the space is not used.
|
verified fixed
|
56aab35
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T19:28:17Z | 2004-02-11T11:46:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizardFirstPage.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.wizards;
import java.io.File;
import java.util.Observable;
import java.util.Observer;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
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.graphics.Font;
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.DirectoryDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.jdt.internal.ui.JavaPlugin;
/**
* The first page of the <code>SimpleProjectWizard</code>.
*/
public class JavaProjectWizardFirstPage extends WizardPage {
/**
* Request a project name. Fires an event whenever the text field is
* changed, regardless of its content.
*/
private final class NameGroup extends Observable {
protected final Text fNameField;
public NameGroup(Composite composite) {
final Composite nameComposite= new Composite(composite, SWT.NONE);
nameComposite.setFont(composite.getFont());
nameComposite.setLayout(initGridLayout(new GridLayout(2, false), false));
nameComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
// label "Project name:"
final Label nameLabel= new Label(nameComposite, SWT.NONE);
nameLabel.setText(NewWizardMessages.getString("JavaProjectWizardFirstPage.NameGroup.label.text")); //$NON-NLS-1$
nameLabel.setFont(composite.getFont());
// text field for project name
fNameField= new Text(nameComposite, SWT.BORDER);
fNameField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fNameField.setFont(composite.getFont());
fNameField.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
fNameField.setSelection(0, fNameField.getText().length());
}
});
fNameField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
fireEvent();
}
});
setChanged();
}
protected void fireEvent() {
setChanged();
notifyObservers();
}
public String getName() {
return fNameField.getText().trim();
}
public void setFocus() {
fNameField.setFocus();
}
}
/**
* Request a location. Fires an event whenever the checkbox or the location
* field is changed, regardless of whether the change originates from the
* user or has been invoked programmatically.
*/
private final class LocationGroup extends Observable implements Observer {
protected final Button fWorkspaceCheckbox;
protected final Label fLocationLabel;
protected final Text fLocationField;
protected final Button fLocationButton;
protected String fExternalLocation;
public LocationGroup(Composite composite) {
final Font font= composite.getFont();
final int numColumns= 3;
fExternalLocation= ""; //$NON-NLS-1$
final Group group= new Group(composite, SWT.NONE);
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
group.setLayout(initGridLayout(new GridLayout(numColumns, false), true));
group.setFont(font);
group.setText(NewWizardMessages.getString("JavaProjectWizardFirstPage.LocationGroup.title")); //$NON-NLS-1$
fWorkspaceCheckbox= new Button(group, SWT.CHECK | SWT.RIGHT);
fWorkspaceCheckbox.setText(NewWizardMessages.getString("JavaProjectWizardFirstPage.LocationGroup.checkbox.desc")); //$NON-NLS-1$
fWorkspaceCheckbox.setSelection(true);
fWorkspaceCheckbox.setFont(font);
final GridData gd= new GridData();
gd.horizontalSpan= numColumns;
fWorkspaceCheckbox.setLayoutData(gd);
fLocationLabel= new Label(group, SWT.NONE);
fLocationLabel.setText(NewWizardMessages.getString("JavaProjectWizardFirstPage.LocationGroup.locationLabel.desc")); //$NON-NLS-1$
fLocationLabel.setEnabled(false);
fLocationLabel.setFont(font);
fLocationLabel.setLayoutData(new GridData());
fLocationField= new Text(group, SWT.BORDER);
fLocationField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fLocationField.setEnabled(false);
fLocationField.setFont(font);
fLocationField.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
if (fLocationField.getEnabled()) {
fExternalLocation= fLocationField.getText();
fireEvent();
}
}
});
fLocationField.addFocusListener(new FocusAdapter() {
public void focusGained(FocusEvent e) {
fLocationField.setSelection(0, fLocationField.getText().length());
}
});
fLocationButton= new Button(group, SWT.PUSH);
setButtonLayoutData(fLocationButton);
fLocationButton.setText(NewWizardMessages.getString("JavaProjectWizardFirstPage.LocationGroup.browseButton.desc")); //$NON-NLS-1$
fLocationButton.setEnabled(false);
fLocationButton.setFont(font);
fLocationButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
final DirectoryDialog dialog= new DirectoryDialog(fLocationField.getShell());
dialog.setMessage(NewWizardMessages.getString("JavaProjectWizardFirstPage.directory.message")); //$NON-NLS-1$
final String directoryName = fLocationField.getText().trim();
if (directoryName.length() > 0) {
final File path = new File(directoryName);
if (path.exists())
dialog.setFilterPath(new Path(directoryName).toOSString());
}
final String selectedDirectory = dialog.open();
if (selectedDirectory != null) {
fExternalLocation= selectedDirectory;
fLocationField.setText(fExternalLocation);
fireEvent();
}
}
});
fWorkspaceCheckbox.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
final boolean checked= fWorkspaceCheckbox.getSelection();
fLocationLabel.setEnabled(!checked);
fLocationField.setEnabled(!checked);
fLocationButton.setEnabled(!checked);
if (checked) {
fLocationField.setText(getDefaultPath(fNameGroup.getName()));
} else {
fLocationField.setText(fExternalLocation);
}
fireEvent();
}
});
}
protected void fireEvent() {
setChanged();
notifyObservers();
}
protected String getDefaultPath(String name) {
final IPath path= Platform.getInstanceLocation().append(name);
return path.toOSString();
}
/*
* (non-Javadoc)
*
* @see java.util.Observer#update(java.util.Observable,
* java.lang.Object)
*/
public void update(Observable o, Object arg) {
if (fWorkspaceCheckbox.getSelection()) {
fLocationField.setText(getDefaultPath(fNameGroup.getName()));
}
fireEvent();
}
public IPath getLocation() {
if (isInWorkspace()) {
return Platform.getInstanceLocation();
}
return new Path(fLocationField.getText().trim());
}
public boolean isInWorkspace() {
return fWorkspaceCheckbox.getSelection();
}
}
/**
* Request a project layout.
*/
private final class LayoutGroup implements Observer {
protected final Button fStdRadio, fSrcBinRadio;
protected final Group fGroup;
public LayoutGroup(Composite composite) {
fGroup= new Group(composite, SWT.NONE);
fGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
fGroup.setLayout(initGridLayout(new GridLayout(), true));
fGroup.setText(NewWizardMessages.getString("JavaProjectWizardFirstPage.LayoutGroup.title")); //$NON-NLS-1$
fGroup.setFont(composite.getFont());
fSrcBinRadio= new Button(fGroup, SWT.RADIO);
fSrcBinRadio.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
fSrcBinRadio.setText(NewWizardMessages.getString("JavaProjectWizardFirstPage.LayoutGroup.option.separateFolders")); //$NON-NLS-1$
fSrcBinRadio.setFont(composite.getFont());
fStdRadio= new Button(fGroup, SWT.RADIO);
fStdRadio.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
fStdRadio.setText(NewWizardMessages.getString("JavaProjectWizardFirstPage.LayoutGroup.option.oneFolder")); //$NON-NLS-1$
fStdRadio.setFont(composite.getFont());
fSrcBinRadio.setSelection(true);
}
public void update(Observable o, Object arg) {
final boolean detect= fDetectGroup.mustDetect();
fStdRadio.setEnabled(!detect);
fSrcBinRadio.setEnabled(!detect);
fGroup.setEnabled(!detect);
}
public boolean isSrcBin() {
return fSrcBinRadio.getSelection();
}
}
/**
* Show a warning when the project location contains files.
*/
private final class DetectGroup extends Observable implements Observer {
private final Text fText;
private boolean fDetect;
public DetectGroup(Composite composite) {
fText= new Text(composite, SWT.MULTI | SWT.READ_ONLY | SWT.WRAP);
final GridData gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
gd.widthHint= 0;
fText.setLayoutData(gd);
fText.setFont(composite.getFont());
fText.setText(NewWizardMessages.getString("JavaProjectWizardFirstPage.DetectGroup.message1") //$NON-NLS-1$
+ NewWizardMessages.getString("JavaProjectWizardFirstPage.DetectGroup.message2") + //$NON-NLS-1$
NewWizardMessages.getString("JavaProjectWizardFirstPage.DetectGroup.message3")); //$NON-NLS-1$
fText.setVisible(false);
}
public void update(Observable o, Object arg) {
if (fLocationGroup.isInWorkspace()) {
String name= getProjectName();
if (name.length() == 0 || JavaPlugin.getWorkspace().getRoot().findMember(name) != null) {
fDetect= false;
} else {
final File directory= fLocationGroup.getLocation().append(getProjectName()).toFile();
fDetect= directory.isDirectory();
}
} else {
final File directory= fLocationGroup.getLocation().toFile();
fDetect= directory.isDirectory();
}
fText.setVisible(fDetect);
setChanged();
notifyObservers();
}
public boolean mustDetect() {
return fDetect;
}
}
/**
* Validate this page and show appropriate warnings and error NewWizardMessages.
*/
private final class Validator implements Observer {
public void update(Observable o, Object arg) {
final IWorkspace workspace= JavaPlugin.getWorkspace();
final String name= fNameGroup.getName();
// check wether the project name field is empty
if (name.length() == 0) { //$NON-NLS-1$
setErrorMessage(null);
setMessage(NewWizardMessages.getString("JavaProjectWizardFirstPage.Message.enterProjectName")); //$NON-NLS-1$
setPageComplete(false);
return;
}
// check whether the project name is valid
final IStatus nameStatus= workspace.validateName(name, IResource.PROJECT);
if (!nameStatus.isOK()) {
setErrorMessage(nameStatus.getMessage());
setPageComplete(false);
return;
}
// check whether project already exists
final IProject handle= getProjectHandle();
if (handle.exists()) {
setErrorMessage(NewWizardMessages.getString("JavaProjectWizardFirstPage.Message.projectAlreadyExists")); //$NON-NLS-1$
setPageComplete(false);
return;
}
final String location= fLocationGroup.getLocation().toOSString();
// check whether location is empty
if (location.length() == 0) {
setErrorMessage(null);
setMessage(NewWizardMessages.getString("JavaProjectWizardFirstPage.Message.enterLocation")); //$NON-NLS-1$
setPageComplete(false);
return;
}
// check whether the location is a syntactically correct path
if (!Path.EMPTY.isValidPath(location)) { //$NON-NLS-1$
setErrorMessage(NewWizardMessages.getString("JavaProjectWizardFirstPage.Message.invalidDirectory")); //$NON-NLS-1$
setPageComplete(false);
return;
}
// check whether the location has the workspace as prefix
IPath projectPath= new Path(location);
if (!fLocationGroup.isInWorkspace() && Platform.getInstanceLocation().isPrefixOf(projectPath)) {
setErrorMessage(NewWizardMessages.getString("JavaProjectWizardFirstPage.Message.cannotCreateInWorkspace")); //$NON-NLS-1$
setPageComplete(false);
return;
}
// If we do not place the contents in the workspace validate the
// location.
if (!fLocationGroup.isInWorkspace()) {
final IStatus locationStatus= workspace.validateProjectLocation(handle, projectPath);
if (!locationStatus.isOK()) {
setErrorMessage(locationStatus.getMessage());
setPageComplete(false);
return;
}
}
setPageComplete(true);
setErrorMessage(null);
setMessage(null);
}
}
protected NameGroup fNameGroup;
protected LocationGroup fLocationGroup;
protected LayoutGroup fLayoutGroup;
protected DetectGroup fDetectGroup;
protected Validator fValidator;
private static final String PAGE_NAME= NewWizardMessages.getString("JavaProjectWizardFirstPage.page.pageName"); //$NON-NLS-1$
/**
* Create a new <code>SimpleProjectFirstPage</code>.
*/
public JavaProjectWizardFirstPage() {
super(PAGE_NAME);
setPageComplete(false);
setTitle(NewWizardMessages.getString("JavaProjectWizardFirstPage.page.title")); //$NON-NLS-1$
setDescription(NewWizardMessages.getString("JavaProjectWizardFirstPage.page.description")); //$NON-NLS-1$
}
public void createControl(Composite parent) {
initializeDialogUnits(parent);
final Composite composite= new Composite(parent, SWT.NULL);
composite.setFont(parent.getFont());
composite.setLayout(initGridLayout(new GridLayout(1, false), true));
composite.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
// create UI elements
fNameGroup= new NameGroup(composite);
fLocationGroup= new LocationGroup(composite);
fLayoutGroup= new LayoutGroup(composite);
fDetectGroup= new DetectGroup(composite);
// establish connections
fNameGroup.addObserver(fLocationGroup);
fDetectGroup.addObserver(fLayoutGroup);
fLocationGroup.addObserver(fDetectGroup);
// initialize all elements
fNameGroup.notifyObservers();
// create and connect validator
fValidator= new Validator();
fNameGroup.addObserver(fValidator);
fLocationGroup.addObserver(fValidator);
setControl(composite);
}
/**
* Returns the current project location path as entered by the user, or its
* anticipated initial value. Note that if the default has been returned
* the path in a project description used to create a project should not be
* set.
*
* @return the project location path or its anticipated initial value.
*/
public IPath getLocationPath() {
return fLocationGroup.getLocation();
}
/**
* Creates a project resource handle for the current project name field
* value.
* <p>
* This method does not create the project resource; this is the
* responsibility of <code>IProject::create</code> invoked by the new
* project resource wizard.
* </p>
*
* @return the new project resource handle
*/
public IProject getProjectHandle() {
return ResourcesPlugin.getWorkspace().getRoot().getProject(fNameGroup.getName());
}
public boolean isInWorkspace() {
return fLocationGroup.isInWorkspace();
}
public String getProjectName() {
return fNameGroup.getName();
}
public boolean getDetect() {
return fDetectGroup.mustDetect();
}
public boolean isSrcBin() {
return fLayoutGroup.isSrcBin();
}
/*
* see @DialogPage.setVisible(boolean)
*/
public void setVisible(boolean visible) {
super.setVisible(visible);
if (visible) fNameGroup.setFocus();
}
/**
* Initialize a grid layout with the default Dialog settings.
*/
protected GridLayout initGridLayout(GridLayout layout, boolean margins) {
layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
if (margins) {
layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.marginHeight= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
} else {
layout.marginWidth= 0;
layout.marginHeight= 0;
}
return layout;
}
/**
* Set the layout data for a button.
*/
protected GridData setButtonLayoutData(Button button) {
return super.setButtonLayoutData(button);
}
}
|
51,573 |
Bug 51573 [formatter] built-in profile; OK button enablement
|
Please disable the OK button on the "Show Profile ... [built-in]" dialog for the built-in profiles. This should be in addition to the warning. It's easy to read over a message, but a disabled OK button is a clear message that one cannot save changes.
|
verified fixed
|
c9b175e
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T20:14:37Z | 2004-02-11T03:26:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/ModifyDialog.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.preferences.formatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.dialogs.StatusDialog;
import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.BuiltInProfile;
import org.eclipse.jdt.internal.ui.preferences.formatter.ProfileManager.Profile;
public class ModifyDialog extends StatusDialog {
/**
* The keys to retrieve the preferred area from the dialog settings.
*/
private static final String DS_KEY_PREFERRED_WIDTH= JavaUI.ID_PLUGIN + "formatter_page.modify_dialog.preferred_width"; //$NON-NLS-1$
private static final String DS_KEY_PREFERRED_HEIGHT= JavaUI.ID_PLUGIN + "formatter_page.modify_dialog.preferred_height"; //$NON-NLS-1$
private static final String DS_KEY_PREFERRED_X= JavaUI.ID_PLUGIN + "formatter_page.modify_dialog.preferred_x"; //$NON-NLS-1$
private static final String DS_KEY_PREFERRED_Y= JavaUI.ID_PLUGIN + "formatter_page.modify_dialog.preferred_y"; //$NON-NLS-1$
/**
* The key to store the number (beginning at 0) of the tab page which had the
* focus last time.
*/
private static final String DS_KEY_LAST_FOCUS= JavaUI.ID_PLUGIN + "formatter_page.modify_dialog.last_focus"; //$NON-NLS-1$
private final String fTitle;
private final boolean fNewProfile;
private final Profile fProfile;
private final Map fWorkingValues;
private final IStatus fStandardStatus;
protected final List fTabPages;
final IDialogSettings fDialogSettings;
private TabFolder fTabFolder;
protected ModifyDialog(Shell parentShell, Profile profile, boolean newProfile) {
super(parentShell);
fNewProfile= newProfile;
setShellStyle(getShellStyle() | SWT.RESIZE | SWT.MAX );
fProfile= profile;
if (fProfile instanceof BuiltInProfile) {
fStandardStatus= new Status(IStatus.WARNING, JavaPlugin.getPluginId(), IStatus.OK, FormatterMessages.getString("ModifyDialog.dialog.show.warning.builtin"), null); //$NON-NLS-1$
fTitle= FormatterMessages.getFormattedString("ModifyDialog.dialog.show.title", profile.getName()); //$NON-NLS-1$
} else {
fStandardStatus= new Status(IStatus.OK, JavaPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
fTitle= FormatterMessages.getFormattedString("ModifyDialog.dialog.title", profile.getName()); //$NON-NLS-1$
}
fWorkingValues= new HashMap(fProfile.getSettings());
updateStatus(fStandardStatus);
setStatusLineAboveButtons(false);
fTabPages= new ArrayList();
fDialogSettings= JavaPlugin.getDefault().getDialogSettings();
}
public void create() {
super.create();
int lastFocusNr= 0;
try {
lastFocusNr= fDialogSettings.getInt(DS_KEY_LAST_FOCUS);
if (lastFocusNr < 0) lastFocusNr= 0;
if (lastFocusNr > fTabPages.size() - 1) lastFocusNr= fTabPages.size() - 1;
} catch (NumberFormatException x) {
lastFocusNr= 0;
}
if (!fNewProfile) {
fTabFolder.setSelection(lastFocusNr);
((ModifyDialogTabPage)fTabFolder.getSelection()[0].getData()).setInitialFocus();
}
}
protected void configureShell(Shell shell) {
super.configureShell(shell);
shell.setText(fTitle);
}
protected Control createDialogArea(Composite parent) {
final Composite composite= (Composite)super.createDialogArea(parent);
fTabFolder = new TabFolder(composite, SWT.NONE);
fTabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
addTabPage(fTabFolder, FormatterMessages.getString("ModifyDialog.tabpage.indentation.title"), new IndentationTabPage(this, fWorkingValues)); //$NON-NLS-1$
addTabPage(fTabFolder, FormatterMessages.getString("ModifyDialog.tabpage.braces.title"), new BracesTabPage(this, fWorkingValues)); //$NON-NLS-1$
addTabPage(fTabFolder, FormatterMessages.getString("ModifyDialog.tabpage.whitespace.title"), new WhiteSpaceTabPage(this, fWorkingValues)); //$NON-NLS-1$
addTabPage(fTabFolder, FormatterMessages.getString("ModifyDialog.tabpage.blank_lines.title"), new BlankLinesTabPage(this, fWorkingValues)); //$NON-NLS-1$
addTabPage(fTabFolder, FormatterMessages.getString("ModifyDialog.tabpage.new_lines.title"), new NewLinesTabPage(this, fWorkingValues)); //$NON-NLS-1$
addTabPage(fTabFolder, FormatterMessages.getString("ModifyDialog.tabpage.control_statements.title"), new ControlStatementsTabPage(this, fWorkingValues)); //$NON-NLS-1$
addTabPage(fTabFolder, FormatterMessages.getString("ModifyDialog.tabpage.line_wrapping.title"), new LineWrappingTabPage(this, fWorkingValues)); //$NON-NLS-1$
addTabPage(fTabFolder, FormatterMessages.getString("ModifyDialog.tabpage.comments.title"), new CommentsTabPage(this, fWorkingValues)); //$NON-NLS-1$
applyDialogFont(composite);
fTabFolder.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {}
public void widgetSelected(SelectionEvent e) {
final TabItem tabItem= (TabItem)e.item;
final ModifyDialogTabPage page= (ModifyDialogTabPage)tabItem.getData();
// page.fSashForm.setWeights();
fDialogSettings.put(DS_KEY_LAST_FOCUS, fTabPages.indexOf(page));
page.makeVisible();
}
});
return composite;
}
public void updateStatus(IStatus status) {
super.updateStatus(status != null ? status : fStandardStatus);
}
protected void constrainShellSize() {
final Shell shell= getShell();
try {
final int x= fDialogSettings.getInt(DS_KEY_PREFERRED_X);
final int y= fDialogSettings.getInt(DS_KEY_PREFERRED_Y);
final int width= fDialogSettings.getInt(DS_KEY_PREFERRED_WIDTH);
final int height= fDialogSettings.getInt(DS_KEY_PREFERRED_HEIGHT);
shell.setLocation(x, y);
shell.setSize(width, height);
} catch (NumberFormatException ex) {
// there are no values saved, so just leave the defaults
}
// make sure we're on the display:
super.constrainShellSize();
}
public boolean close()
{
fProfile.setSettings(fWorkingValues);
final Rectangle shell= getShell().getBounds();
fDialogSettings.put(DS_KEY_PREFERRED_WIDTH, shell.width);
fDialogSettings.put(DS_KEY_PREFERRED_HEIGHT, shell.height);
fDialogSettings.put(DS_KEY_PREFERRED_X, shell.x);
fDialogSettings.put(DS_KEY_PREFERRED_Y, shell.y);
return super.close();
}
private final void addTabPage(TabFolder tabFolder, String title, ModifyDialogTabPage tabPage) {
final TabItem tabItem= new TabItem(tabFolder, SWT.NONE);
applyDialogFont(tabItem.getControl());
tabItem.setText(title);
tabItem.setData(tabPage);
tabItem.setControl(tabPage.createContents(tabFolder));
fTabPages.add(tabPage);
}
}
|
51,448 |
Bug 51448 Creating java project doesn't switch to java perspective [build path]
|
Smoke test for 2004-01-10 08:00 1) Create a java project in a new workspace 2) observe: you're not asked to switch to the java perspective.
|
verified fixed
|
e2c1594
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-11T20:44:38Z | 2004-02-10T10:46:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/JavaProjectWizard.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.wizards;
import java.lang.reflect.InvocationTargetException;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.wizards.newresource.BasicNewProjectResourceWizard;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
public class JavaProjectWizard extends NewElementWizard {
private JavaProjectWizardFirstPage fFirstPage;
private JavaProjectWizardSecondPage fSecondPage;
private IConfigurationElement fConfigElement;
public JavaProjectWizard() {
setDefaultPageImageDescriptor(JavaPluginImages.DESC_WIZBAN_NEWJPRJ);
setDialogSettings(JavaPlugin.getDefault().getDialogSettings());
setWindowTitle(NewWizardMessages.getString("JavaProjectWizard.title")); //$NON-NLS-1$
}
/*
* @see Wizard#addPages
*/
public void addPages() {
super.addPages();
fFirstPage= new JavaProjectWizardFirstPage();
addPage(fFirstPage);
fSecondPage= new JavaProjectWizardSecondPage(fFirstPage);
addPage(fSecondPage);
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.wizards.NewElementWizard#finishPage(org.eclipse.core.runtime.IProgressMonitor)
*/
protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
fSecondPage.performFinish(monitor); // use the full progress monitor
BasicNewProjectResourceWizard.updatePerspective(fConfigElement);
selectAndReveal(fSecondPage.getJavaProject().getProject());
}
protected void handleFinishException(Shell shell, InvocationTargetException e) {
String title= NewWizardMessages.getString("JavaProjectWizard.op_error.title"); //$NON-NLS-1$
String message= NewWizardMessages.getString("JavaProjectWizard.op_error_create.message"); //$NON-NLS-1$
ExceptionHandler.handle(e, getShell(), title, message);
}
/*
* Stores the configuration element for the wizard. The config element will be used
* in <code>performFinish</code> to set the result perspective.
*/
public void setInitializationData(IConfigurationElement cfig, String propertyName, Object data) {
fConfigElement= cfig;
}
/* (non-Javadoc)
* @see IWizard#performCancel()
*/
public boolean performCancel() {
fSecondPage.performCancel();
return super.performCancel();
}
/* (non-Javadoc)
* @see org.eclipse.jface.wizard.IWizard#canFinish()
*/
public boolean canFinish() {
return super.canFinish();
}
}
|
51,811 |
Bug 51811 NPE attempting to search NLS
|
I200402102000 With the RefactoringMessages.properties from org.eclipse.jdt.internal.debug.core.refactoring (renamed from RefractoringMessages.properties) selected in the PackageExplorer, I clicked on the Search toolbar button. From the NLS keys page, I clicked search. Related to the fact that there is another RefactoringMessages class? java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.search.internal.ui.util.ExtendedDialogWindow.run (ExtendedDialogWindow.java:180) at org.eclipse.jdt.internal.ui.refactoring.nls.search.NLSSearchPage.performAction (NLSSearchPage.java:199) at org.eclipse.search.internal.ui.SearchDialog.performAction (SearchDialog.java:363) at org.eclipse.search.internal.ui.util.ExtendedDialogWindow.buttonPressed (ExtendedDialogWindow.java:147) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:402) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2029) at org.eclipse.jface.window.Window.runEventLoop(Window.java:647) at org.eclipse.jface.window.Window.open(Window.java:627) at org.eclipse.search.internal.ui.OpenSearchDialogAction.run (OpenSearchDialogAction.java:60) at org.eclipse.search.internal.ui.OpenSearchDialogAction.run (OpenSearchDialogAction.java:46) at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:273) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent (WWinPluginAction.java:207) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:536) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:460) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2029) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1550) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1526) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:257) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:104) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581) Caused by: java.lang.NullPointerException at org.eclipse.jdt.internal.ui.refactoring.nls.search.NLSSearchResultCollector.fin dKey(NLSSearchResultCollector.java:199) at org.eclipse.jdt.internal.ui.refactoring.nls.search.NLSSearchResultCollector.acc ept(NLSSearchResultCollector.java:108) at org.eclipse.jdt.core.search.SearchEngine$ResultCollectorAdapter.acceptSearchMat ch(SearchEngine.java:58) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.report (MatchLocator.java:967) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.report (MatchLocator.java:948) at org.eclipse.jdt.internal.core.search.matching.PatternLocator.matchReportReferen ce(PatternLocator.java:228) at org.eclipse.jdt.internal.core.search.matching.TypeReferenceLocator.matchReportR eference(TypeReferenceLocator.java:168) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching (MatchLocator.java:1136) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching (MatchLocator.java:1337) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching (MatchLocator.java:1348) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching (MatchLocator.java:1201) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process (MatchLocator.java:887) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches (MatchLocator.java:619) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches (MatchLocator.java:653) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches (MatchLocator.java:744) at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches (JavaSearchParticipant.java:157) at org.eclipse.jdt.internal.core.search.pattern.InternalSearchPattern.findMatches (InternalSearchPattern.java:190) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:716) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:684) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:665) at org.eclipse.jdt.internal.ui.refactoring.nls.search.NLSSearchOperation.execute (NLSSearchOperation.java:84) at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run (WorkspaceModifyOperation.java:91) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1567) at org.eclipse.ui.actions.WorkspaceModifyOperation.run (WorkspaceModifyOperation.java:105) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101)
|
resolved fixed
|
70db708
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T08:54:13Z | 2004-02-12T04:26:40Z |
org.eclipse.jdt.ui/ui
| |
51,811 |
Bug 51811 NPE attempting to search NLS
|
I200402102000 With the RefactoringMessages.properties from org.eclipse.jdt.internal.debug.core.refactoring (renamed from RefractoringMessages.properties) selected in the PackageExplorer, I clicked on the Search toolbar button. From the NLS keys page, I clicked search. Related to the fact that there is another RefactoringMessages class? java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:283) at org.eclipse.search.internal.ui.util.ExtendedDialogWindow.run (ExtendedDialogWindow.java:180) at org.eclipse.jdt.internal.ui.refactoring.nls.search.NLSSearchPage.performAction (NLSSearchPage.java:199) at org.eclipse.search.internal.ui.SearchDialog.performAction (SearchDialog.java:363) at org.eclipse.search.internal.ui.util.ExtendedDialogWindow.buttonPressed (ExtendedDialogWindow.java:147) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:402) at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2029) at org.eclipse.jface.window.Window.runEventLoop(Window.java:647) at org.eclipse.jface.window.Window.open(Window.java:627) at org.eclipse.search.internal.ui.OpenSearchDialogAction.run (OpenSearchDialogAction.java:60) at org.eclipse.search.internal.ui.OpenSearchDialogAction.run (OpenSearchDialogAction.java:46) at org.eclipse.ui.internal.PluginAction.runWithEvent(PluginAction.java:273) at org.eclipse.ui.internal.WWinPluginAction.runWithEvent (WWinPluginAction.java:207) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:536) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$6.handleEvent (ActionContributionItem.java:460) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2029) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1550) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1526) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:257) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:104) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581) Caused by: java.lang.NullPointerException at org.eclipse.jdt.internal.ui.refactoring.nls.search.NLSSearchResultCollector.fin dKey(NLSSearchResultCollector.java:199) at org.eclipse.jdt.internal.ui.refactoring.nls.search.NLSSearchResultCollector.acc ept(NLSSearchResultCollector.java:108) at org.eclipse.jdt.core.search.SearchEngine$ResultCollectorAdapter.acceptSearchMat ch(SearchEngine.java:58) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.report (MatchLocator.java:967) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.report (MatchLocator.java:948) at org.eclipse.jdt.internal.core.search.matching.PatternLocator.matchReportReferen ce(PatternLocator.java:228) at org.eclipse.jdt.internal.core.search.matching.TypeReferenceLocator.matchReportR eference(TypeReferenceLocator.java:168) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching (MatchLocator.java:1136) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching (MatchLocator.java:1337) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching (MatchLocator.java:1348) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.reportMatching (MatchLocator.java:1201) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process (MatchLocator.java:887) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches (MatchLocator.java:619) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches (MatchLocator.java:653) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches (MatchLocator.java:744) at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches (JavaSearchParticipant.java:157) at org.eclipse.jdt.internal.core.search.pattern.InternalSearchPattern.findMatches (InternalSearchPattern.java:190) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:716) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:684) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:665) at org.eclipse.jdt.internal.ui.refactoring.nls.search.NLSSearchOperation.execute (NLSSearchOperation.java:84) at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run (WorkspaceModifyOperation.java:91) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1567) at org.eclipse.ui.actions.WorkspaceModifyOperation.run (WorkspaceModifyOperation.java:105) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101)
|
resolved fixed
|
70db708
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T08:54:13Z | 2004-02-12T04:26:40Z |
refactoring/org/eclipse/jdt/internal/ui/refactoring/nls/search/NLSSearchResultCollector.java
| |
51,704 |
Bug 51704 multiple beginCompoundChange in LinkedUIKeyListener
|
build used: eclipse-SDK-I20040210-win32 I noticed some strange undo/redo behavior in the JDT Editor. I don't have a simple testcase to demonstrate the problem in the JDT Editor. But, I noticed if I set a breakpoint at the implementation of IRewriteTarget.beginCompoundChange, it's called multiple times while I'm in the linked edit mode of Local Rename (one time for each keystroke). But, endCompoundChange was only called one time at the end. I traced and noticed the origin of the multiple beginCompoundChange calls came from the LinkedUIKeyListener#controlUndoBehavior(int, int). LinkedUIKeyListener is an inner class in LinkedUIControl. I understand org.eclipse.jdt.internal.ui.text.link is an internal package. But, I hope the developer may agree that it's a simple problem to fix. That may avoid some hard- to-explain problems in the future because of this unmatching beginCompoundChange/endCompoundChange calls. Here is a copy of LinkedUIKeyListener#controlUndoBehavior(int, int). You may notice that target.beginCompoundChange() is called everytime position is not null. private boolean controlUndoBehavior(int offset, int length) { LinkedPosition position= fEnvironment.findPosition(new LinkedPosition( fCurrentTarget.getViewer().getDocument(), offset, length, LinkedPositionGroup.NO_STOP)); if (position != null) { ITextViewerExtension extension= (ITextViewerExtension) fCurrentTarget.getViewer(); IRewriteTarget target= extension.getRewriteTarget(); if (fPreviousPosition != null && !fPreviousPosition.equals(position)) target.endCompoundChange(); target.beginCompoundChange(); } fPreviousPosition= position; return fPreviousPosition != null; }
|
closed fixed
|
ac783da
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T11:09:57Z | 2004-02-11T17:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/link/LinkedUIControl.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.link;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.events.ShellListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.events.VerifyListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.viewers.IPostSelectionProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.DefaultPositionUpdater;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IPositionUpdater;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.IRewriteTarget;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITextViewerExtension;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IAnnotationModelExtension;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.IJavaPartitions;
import org.eclipse.jdt.internal.ui.text.link.contentassist.ContentAssistant2;
/**
* The UI for linked mode. Detects events that influence behaviour of the
* linked position UI and acts upon them.
*
* @since 3.0
*/
public class LinkedUIControl {
/* cycle constants */
/**
* Constant indicating that this UI should never cycle from the last
* position to the first and vice versa.
*/
public static final int CYCLE_NEVER= 0;
/**
* Constant indicating that this UI should always cycle from the last
* position to the first and vice versa.
*/
public static final int CYCLE_ALWAYS= 1;
/**
* Constant indicating that this UI should cycle from the last position to
* the first and vice versa if its environment is not nested.
*/
public static final int CYCLE_WHEN_NO_PARENT= 2;
/**
* Listens on a styled text for events before (Verify) and after (Modify)
* modifications. Used to update the caret after linked changes.
*/
private final class CaretListener implements ModifyListener, VerifyListener {
/*
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
*/
public void modifyText(ModifyEvent e) {
updateSelection(e);
}
/*
* @see org.eclipse.swt.events.VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
*/
public void verifyText(VerifyEvent e) {
rememberSelection(e);
}
}
/**
* A link target consists of a viewer and gets notified if the linked UI on
* it is being shown.
*
* @since 3.0
*/
public static abstract class LinkedUITarget {
/**
* Returns the viewer represented by this target, never <code>null</code>.
*
* @return the viewer associated with this target.
*/
abstract ITextViewer getViewer();
/**
* Called by the linked UI when this target is being shown. An
* implementation could for example ensure that the corresponding
* editor is showing.
*/
abstract void enter();
/**
* The viewer's text widget is initialized when the UI first connects
* to the viewer and never changed thereafter. This is to keep the
* reference of the widget that we have registered our listeners with,
* as the viewer, when it gets disposed, does not remember it, resulting
* in a situation where we cannot uninstall the listeners and a memory leak.
*/
StyledText fWidget;
/** The cached shell - same reason as fWidget. */
Shell fShell;
/** The registered listener, or <code>null</code>. */
LinkedUIKeyListener fKeyListener;
/** The cached custom annotation model. */
LinkedPositionAnnotations fAnnotationModel;
}
private static final class EmptyTarget extends LinkedUITarget {
private ITextViewer fTextViewer;
/**
* @param viewer the viewer
*/
public EmptyTarget(ITextViewer viewer) {
Assert.isNotNull(viewer);
fTextViewer= viewer;
}
/*
* @see org.eclipse.jdt.internal.ui.text.link2.LinkedUIControl.ILinkedUITarget#getViewer()
*/
public ITextViewer getViewer() {
return fTextViewer;
}
/*
* @see org.eclipse.jdt.internal.ui.text.link2.LinkedUIControl.ILinkedUITarget#enter()
*/
public void enter() {
}
}
/**
* An <code>ILinkedUITarget</code> with an associated editor, which is
* brought to the top when a linked position in its viewer is jumped to.
*
* @since 3.0
*/
public static class EditorTarget extends LinkedUITarget {
/** The text viewer. */
protected final ITextViewer fTextViewer;
/** The editor displaying the viewer. */
protected final ITextEditor fTextEditor;
/**
* Creates a new instance.
*
* @param viewer the viewer
* @param editor the editor displaying <code>viewer</code>, or <code>null</code>
*/
public EditorTarget(ITextViewer viewer, ITextEditor editor) {
Assert.isNotNull(viewer);
fTextViewer= viewer;
fTextEditor= editor;
}
/*
* @see org.eclipse.jdt.internal.ui.text.link2.LinkedUIControl.ILinkedUITarget#getViewer()
*/
public ITextViewer getViewer() {
return fTextViewer;
}
/*
* @see org.eclipse.jdt.internal.ui.text.link2.LinkedUIControl.ILinkedUITarget#enter()
*/
public void enter() {
if (fTextEditor != null)
return;
IWorkbenchPage page= fTextEditor.getEditorSite().getPage();
if (page != null) {
page.bringToTop(fTextEditor);
}
fTextEditor.setFocus();
}
}
/**
* Listens for state changes in the model.
*/
private final class ExitListener implements ILinkedListener {
/*
* @see org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment.ILinkedListener#left(org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment, int)
*/
public void left(LinkedEnvironment environment, int flags) {
leave(ILinkedListener.EXIT_ALL | flags);
}
/*
* @see org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment.ILinkedListener#suspend(org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment)
*/
public void suspend(LinkedEnvironment environment) {
disconnect();
redraw();
}
/*
* @see org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment.ILinkedListener#resume(org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment)
*/
public void resume(LinkedEnvironment environment, int flags) {
if ((flags & ILinkedListener.EXIT_ALL) != 0) {
leave(flags);
} else {
connect();
if ((flags & ILinkedListener.SELECT) != 0)
select();
redraw();
}
}
}
/**
* Exit flags returned if a custom exit policy wants to exit linked mode.
*/
public static class ExitFlags {
/** The flags to return in the <code>leave</code> method. */
public int flags;
/** The doit flag of the checked <code>VerifyKeyEvent</code>. */
public boolean doit;
/**
* Creates a new instance.
*
* @param flags the exit flags
* @param doit the doit flag for the verify event
*/
public ExitFlags(int flags, boolean doit) {
this.flags= flags;
this.doit= doit;
}
}
/**
* An exit policy can be registered by a caller to get custom exit
* behaviour.
*/
public interface IExitPolicy {
/**
* Checks whether the linked mode should be left after receiving the
* given <code>VerifyEvent</code> and selection. Note that the event
* carries widget coordinates as opposed to <code>offset</code> and
* <code>length</code> which are document coordinates.
*
* @param environment the linked environment
* @param event the verify event
* @param offset the offset of the current selection
* @param length the length of the current selection
* @return valid exit flags or <code>null</code> if no special action
* should be taken
*/
ExitFlags doExit(LinkedEnvironment environment, VerifyEvent event, int offset, int length);
}
/**
* A NullObject implementation of <code>IExitPolicy</code>.
*/
private static class NullExitPolicy implements IExitPolicy {
/*
* @see org.eclipse.jdt.internal.ui.text.link2.LinkedUIControl.IExitPolicy#doExit(org.eclipse.swt.events.VerifyEvent, int, int)
*/
public ExitFlags doExit(LinkedEnvironment environment, VerifyEvent event, int offset, int length) {
return null;
}
}
/**
* Listens for shell events and acts upon them.
*/
private class LinkedUICloser implements ShellListener {
public void shellActivated(ShellEvent e) {
}
public void shellClosed(ShellEvent e) {
leave(ILinkedListener.EXIT_ALL);
}
public void shellDeactivated(ShellEvent e) {
// T ODO reenable after debugging
// if (true) return;
// from LinkedPositionUI:
// don't deactivate on focus lost, since the proposal popups may take focus
// plus: it doesn't hurt if you can check with another window without losing linked mode
// since there is no intrusive popup sticking out.
// need to check first what happens on reentering based on an open action
// Seems to be no problem
// Better:
// Check with content assistant and only leave if its not the proposal shell that took the
// focus away.
StyledText text;
Display display;
if (fAssistant == null || fCurrentTarget == null || (text= fCurrentTarget.fWidget) == null
|| text.isDisposed() || (display= text.getDisplay()) == null || display.isDisposed()) {
leave(ILinkedListener.EXIT_ALL);
} else {
// Post in UI thread since the assistant popup will only get the focus after we lose it.
display.asyncExec(new Runnable() {
public void run() {
if (fIsActive && (fAssistant == null || !fAssistant.hasFocus())) {
leave(ILinkedListener.EXIT_ALL);
}
}
});
}
}
public void shellDeiconified(ShellEvent e) {
}
public void shellIconified(ShellEvent e) {
leave(ILinkedListener.EXIT_ALL);
}
}
/**
* Listens for key events, checks the exit policy for custom exit
* strategies but defaults to handling Tab, Enter, and Escape.
*/
private class LinkedUIKeyListener implements VerifyKeyListener {
private boolean fIsEnabled= true;
public void verifyKey(VerifyEvent event) {
if (!event.doit || !fIsEnabled)
return;
Point selection= fCurrentTarget.getViewer().getSelectedRange();
int offset= selection.x;
int length= selection.y;
// if the custom exit policy returns anything, use that
ExitFlags exitFlags= fExitPolicy.doExit(fEnvironment, event, offset, length);
if (exitFlags != null) {
leave(exitFlags.flags);
event.doit= exitFlags.doit;
return;
}
// standard behaviour:
// (Shift+)Tab: jumps from position to position, depending on cycle mode
// Enter: accepts all entries and leaves all (possibly stacked) environments, the last sets the caret
// Esc: accepts all entries and leaves all (possibly stacked) environments, the caret stays
// ? what do we do to leave one level of a cycling environment that is stacked?
// -> This is only the case if the level was set up with forced cycling (CYCLE_ALWAYS), in which case
// the caller is sure that one does not need by-level exiting.
switch (event.character) {
// [SHIFT-]TAB = hop between edit boxes
case 0x09:
if (!(fExitPosition != null && fExitPosition.includes(offset)) && !fEnvironment.anyPositionContains(offset)) {
// outside any edit box -> leave (all? TODO should only leave the affected, level and forward to the next upper)
leave(ILinkedListener.EXIT_ALL);
break;
} else {
if (event.stateMask == SWT.SHIFT)
previous();
else
next();
}
event.doit= false;
break;
// ENTER
case 0x0A:
// Ctrl+Enter on WinXP
case 0x0D:
if (fAssistant != null && fAssistant.wasProposalChosen()) {
// don't exit as it was really just the proposal that was chosen
next();
event.doit= false;
break;
} else if ((fExitPosition != null && fExitPosition.includes(offset)) || !fEnvironment.anyPositionContains(offset)) {
// outside any edit box or on exit position -> leave (all? TODO should only leave the affected, level and forward to the next upper)
leave(ILinkedListener.EXIT_ALL);
break;
} else {
// normal case: exit entire stack and put caret to final position
leave(ILinkedListener.EXIT_ALL | ILinkedListener.UPDATE_CARET);
event.doit= false;
break;
}
// ESC
case 0x1B:
// exit entire stack and leave caret
leave(ILinkedListener.EXIT_ALL);
event.doit= false;
break;
default:
if (event.character != 0) {
if (!controlUndoBehavior(offset, length)) {
leave(ILinkedListener.EXIT_ALL);
break;
}
}
}
}
private boolean controlUndoBehavior(int offset, int length) {
LinkedPosition position= fEnvironment.findPosition(new LinkedPosition(fCurrentTarget.getViewer().getDocument(), offset, length, LinkedPositionGroup.NO_STOP));
if (position != null) {
ITextViewerExtension extension= (ITextViewerExtension) fCurrentTarget.getViewer();
IRewriteTarget target= extension.getRewriteTarget();
if (fPreviousPosition != null && !fPreviousPosition.equals(position))
target.endCompoundChange();
target.beginCompoundChange();
}
fPreviousPosition= position;
return fPreviousPosition != null;
}
/**
* @param enabled the new enabled state
*/
public void setEnabled(boolean enabled) {
fIsEnabled= enabled;
}
}
/**
* Installed as post selection listener on the watched viewer. Updates the
* linked position after cursor movement, even to positions not in the
* iteration list.
*/
private class MySelectionListener implements ISelectionChangedListener {
/*
* @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
*/
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection= event.getSelection();
if (selection instanceof ITextSelection) {
ITextSelection textsel= (ITextSelection) selection;
if (event.getSelectionProvider() instanceof ITextViewer) {
IDocument doc= ((ITextViewer) event.getSelectionProvider()).getDocument();
if (doc != null) {
int offset= textsel.getOffset();
int length= textsel.getLength();
if (offset >= 0 && length >= 0) {
LinkedPosition find= new LinkedPosition(doc, offset, length, LinkedPositionGroup.NO_STOP);
LinkedPosition pos= fEnvironment.findPosition(find);
if (pos == null && fExitPosition != null && fExitPosition.includes(find))
pos= fExitPosition;
if (pos != null)
switchPosition(pos, false, false);
}
}
}
}
}
}
/** The current viewer. */
private LinkedUITarget fCurrentTarget;
/** The manager of the linked positions we provide a UI for. */
private LinkedEnvironment fEnvironment;
/** The set of viewers we manage. */
private LinkedUITarget[] fTargets;
/** The iterator over the tab stop positions. */
private TabStopIterator fIterator;
/* Our team of event listeners */
/** The shell listener. */
private LinkedUICloser fCloser= new LinkedUICloser();
/** The linked listener. */
private ILinkedListener fLinkedListener= new ExitListener();
/** The selection listener. */
private MySelectionListener fSelectionListener= new MySelectionListener();
/** The styled text listener. */
private CaretListener fCaretListener= new CaretListener();
/** The last caret position, used by fCaretListener. */
private final Position fCaretPosition= new Position(0, 0);
/** The exit policy to control custom exit behaviour */
private IExitPolicy fExitPolicy= new NullExitPolicy();
/** The current frame position shown in the UI, or <code>null</code>. */
private LinkedPosition fFramePosition;
/** The last visisted position, used for undo / redo. */
private LinkedPosition fPreviousPosition;
/** The content assistant used to show proposals. */
private ContentAssistant2 fAssistant;
/** The exit position. */
private LinkedPosition fExitPosition;
/** State indicator to prevent multiple invocation of leave. */
private boolean fIsActive= false;
private IPositionUpdater fPositionUpdater= new DefaultPositionUpdater(getCategory());
private boolean fDoContextInfo= false;
/**
* Creates a new UI on the given model (environment) and the set of
* viewers. The environment must provide a tab stop sequence with a
* non-empty list of tab stops.
*
* @param environment the linked position model
* @param targets the non-empty list of targets upon which the linked ui
* should act
*/
public LinkedUIControl(LinkedEnvironment environment, LinkedUITarget[] targets) {
constructor(environment, targets);
}
/**
* Conveniance ctor for just one viewer.
*
* @param environment the linked position model
* @param viewer the viewer upon which the linked ui
* should act
*/
public LinkedUIControl(LinkedEnvironment environment, ITextViewer viewer) {
constructor(environment, new LinkedUITarget[]{new EmptyTarget(viewer)});
}
/**
* Conveniance ctor for multiple viewers.
*
* @param environment the linked position model
* @param viewers the non-empty list of viewers upon which the linked ui
* should act
*/
public LinkedUIControl(LinkedEnvironment environment, ITextViewer[] viewers) {
LinkedUITarget[] array= new LinkedUITarget[viewers.length];
for (int i= 0; i < array.length; i++) {
array[i]= new EmptyTarget(viewers[i]);
}
constructor(environment, array);
}
/**
* Conveniance ctor for one target.
*
* @param environment the linked position model
* @param target the target upon which the linked ui
* should act
*/
public LinkedUIControl(LinkedEnvironment environment, LinkedUITarget target) {
constructor(environment, new LinkedUITarget[]{target});
}
/**
* This does the actual constructor work.
*
* @param environment the linked position model
* @param targets the non-empty array of targets upon which the linked ui
* should act
*/
private void constructor(LinkedEnvironment environment, LinkedUITarget[] targets) {
Assert.isNotNull(environment);
Assert.isNotNull(targets);
Assert.isTrue(targets.length > 0);
Assert.isTrue(environment.getTabStopSequence().size() > 0);
fEnvironment= environment;
fTargets= targets;
fCurrentTarget= targets[0];
fIterator= new TabStopIterator(fEnvironment.getTabStopSequence());
fIterator.setCycling(!fEnvironment.isNested());
fEnvironment.addLinkedListener(fLinkedListener);
fAssistant= new ContentAssistant2();
fAssistant.setDocumentPartitioning(IJavaPartitions.JAVA_PARTITIONING);
fCaretPosition.delete();
}
/**
* Starts this UI on the first position.
*/
public void enter() {
fIsActive= true;
connect();
next();
}
/**
* Sets an <code>IExitPolicy</code> to customize the exit behaviour of
* this linked UI.
*
* @param policy the exit policy to use.
*/
public void setExitPolicy(IExitPolicy policy) {
fExitPolicy= policy;
}
/**
* Sets the exit position to move the caret to when linked mode is exited.
*
* @param target the target where the exit position is located
* @param offset the offset of the exit position
* @param length the length of the exit position (in case there should be a
* selection)
* @param sequence set to the tab stop position of the exit position, or
* <code>LinkedPositionGroup.NO_STOP</code> if there should be no tab stop.
* @throws BadLocationException if the position is not valid in the
* viewer's document
*/
public void setExitPosition(LinkedUITarget target, int offset, int length, int sequence) throws BadLocationException {
// remove any existing exit position
if (fExitPosition != null) {
fExitPosition.getDocument().removePosition(fExitPosition);
fIterator.removePosition(fExitPosition);
fExitPosition= null;
}
IDocument doc= target.getViewer().getDocument();
if (doc == null)
return;
fExitPosition= new LinkedPosition(doc, offset, length, sequence);
doc.addPosition(fExitPosition); // gets removed in leave()
if (sequence != LinkedPositionGroup.NO_STOP)
fIterator.addPosition(fExitPosition);
}
/**
* Sets the exit position to move the caret to when linked mode is exited.
*
* @param viewer the viewer where the exit position is located
* @param offset the offset of the exit position
* @param length the length of the exit position (in case there should be a
* selection)
* @param sequence set to the tab stop position of the exit position, or
* <code>LinkedPositionGroup.NO_STOP</code> if there should be no tab stop.
* @throws BadLocationException if the position is not valid in the
* viewer's document
*/
public void setExitPosition(ITextViewer viewer, int offset, int length, int sequence) throws BadLocationException {
setExitPosition(new EditorTarget(viewer, null), offset, length, sequence);
}
/**
* Sets the cycling mode to either of <code>CYCLING_ALWAYS</code>,
* <code>CYCLING_NEVER</code>, or <code>CYCLING_WHEN_NO_PARENT</code>,
* which is the default.
*
* @param mode the new cycling mode.
*/
public void setCyclingMode(int mode) {
if (mode == CYCLE_ALWAYS || mode == CYCLE_WHEN_NO_PARENT && !fEnvironment.isNested())
fIterator.setCycling(true);
else
fIterator.setCycling(false);
}
void next() {
if (fIterator.hasNext(fFramePosition)) {
switchPosition(fIterator.next(fFramePosition), true, true);
return;
} else
leave(ILinkedListener.UPDATE_CARET);
}
void previous() {
if (fIterator.hasPrevious(fFramePosition)) {
switchPosition(fIterator.previous(fFramePosition), true, true);
} else
// dont't update caret, but rather select the current frame
leave(ILinkedListener.SELECT);
}
private void triggerContextInfo() {
ITextOperationTarget target= fCurrentTarget.getViewer().getTextOperationTarget();
if (target != null) {
if (target.canDoOperation(ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION))
target.doOperation(ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION);
}
}
/** Trigger content assist on choice positions */
private void triggerContentAssist() {
if (fFramePosition instanceof ProposalPosition) {
ProposalPosition pp= (ProposalPosition) fFramePosition;
fAssistant.setCompletions(pp.getChoices());
fAssistant.showPossibleCompletions();
} else {
fAssistant.setCompletions(new ICompletionProposal[0]);
fAssistant.hidePossibleCompletions();
}
}
private void switchPosition(LinkedPosition pos, boolean select, boolean showProposals) {
Assert.isNotNull(pos);
if (pos.equals(fFramePosition))
return;
// mark navigation history
JavaPlugin.getActivePage().getNavigationHistory().markLocation(JavaPlugin.getActivePage().getActiveEditor());
// undo
ITextViewerExtension extension= (ITextViewerExtension) fCurrentTarget.getViewer();
IRewriteTarget target= extension.getRewriteTarget();
if (fFramePosition != null && fFramePosition != fExitPosition)
target.endCompoundChange();
redraw();
IDocument oldDoc= fFramePosition == null ? null : fFramePosition.getDocument();
IDocument newDoc= pos.getDocument();
if (fCurrentTarget.fAnnotationModel != null)
fCurrentTarget.fAnnotationModel.switchToPosition(fEnvironment, pos);
switchViewer(oldDoc, newDoc);
fFramePosition= pos;
if (fFramePosition != null && fFramePosition != fExitPosition)
target.beginCompoundChange();
if (select)
select();
if (fFramePosition == fExitPosition && !fIterator.isCycling())
leave(ILinkedListener.NONE);
else {
redraw();
}
if (showProposals)
triggerContentAssist();
if (fFramePosition != fExitPosition && fDoContextInfo)
triggerContextInfo();
}
private void switchViewer(IDocument oldDoc, IDocument newDoc) {
if (oldDoc != newDoc) {
LinkedUITarget target= null;
for (int i= 0; i < fTargets.length; i++) {
if (fTargets[i].getViewer().getDocument() == newDoc) {
target= fTargets[i];
break;
}
}
if (target != fCurrentTarget) {
disconnect();
fCurrentTarget= target;
target.enter();
connect();
}
}
}
private void select() {
ITextViewer viewer= fCurrentTarget.getViewer();
if (!viewer.overlapsWithVisibleRegion(fFramePosition.offset, fFramePosition.length))
viewer.resetVisibleRegion();
viewer.revealRange(fFramePosition.offset, fFramePosition.length);
viewer.setSelectedRange(fFramePosition.offset, fFramePosition.length);
}
private void redraw() {
if (fCurrentTarget.fAnnotationModel != null)
fCurrentTarget.fAnnotationModel.switchToPosition(fEnvironment, fFramePosition);
}
private void connect() {
Assert.isNotNull(fCurrentTarget);
ITextViewer viewer= fCurrentTarget.getViewer();
Assert.isNotNull(viewer);
fCurrentTarget.fWidget= viewer.getTextWidget();
if (fCurrentTarget.fWidget == null)
leave(ILinkedListener.EXIT_ALL);
if (fCurrentTarget.fKeyListener == null) {
fCurrentTarget.fKeyListener= new LinkedUIKeyListener();
((ITextViewerExtension) viewer).prependVerifyKeyListener(fCurrentTarget.fKeyListener);
} else
fCurrentTarget.fKeyListener.setEnabled(true);
((IPostSelectionProvider) viewer).addPostSelectionChangedListener(fSelectionListener);
if (viewer instanceof ISourceViewer) {
ISourceViewer sv= (ISourceViewer) viewer;
IAnnotationModel model= sv.getAnnotationModel();
if (model instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ext= (IAnnotationModelExtension) model;
IAnnotationModel ourModel= ext.getAnnotationModel(getUniqueKey());
if (ourModel == null) {
LinkedPositionAnnotations lpa= new LinkedPositionAnnotations();
lpa.setTargets(fIterator.getPositions());
lpa.setExitTarget(fExitPosition);
ext.addAnnotationModel(getUniqueKey(), lpa);
fCurrentTarget.fAnnotationModel= lpa;
}
}
}
fCurrentTarget.fWidget.showSelection();
fCurrentTarget.fWidget.addVerifyListener(fCaretListener);
fCurrentTarget.fWidget.addModifyListener(fCaretListener);
fCurrentTarget.fShell= fCurrentTarget.fWidget.getShell();
if (fCurrentTarget.fShell == null)
leave(ILinkedListener.EXIT_ALL);
fCurrentTarget.fShell.addShellListener(fCloser);
fAssistant.install(viewer);
}
private String getUniqueKey() {
return "linked.annotationmodelkey."+toString(); //$NON-NLS-1$
}
private void disconnect() {
Assert.isNotNull(fCurrentTarget);
ITextViewer viewer= fCurrentTarget.getViewer();
Assert.isNotNull(viewer);
fAssistant.uninstall();
StyledText text= fCurrentTarget.fWidget;
fCurrentTarget.fWidget= null;
Shell shell= fCurrentTarget.fShell;
fCurrentTarget.fShell= null;
if (shell != null && !shell.isDisposed())
shell.removeShellListener(fCloser);
if (text != null && !text.isDisposed()) {
text.removeModifyListener(fCaretListener);
text.removeVerifyListener(fCaretListener);
}
// don't remove the verify key listener to let it keep its position
// in the listener queue
fCurrentTarget.fKeyListener.setEnabled(false);
fCurrentTarget.fAnnotationModel.removeAllAnnotations();
if (viewer instanceof ISourceViewer) {
ISourceViewer sv= (ISourceViewer) viewer;
IAnnotationModel model= sv.getAnnotationModel();
if (model instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ext= (IAnnotationModelExtension) model;
ext.removeAnnotationModel(getUniqueKey());
}
}
((IPostSelectionProvider) viewer).removePostSelectionChangedListener(fSelectionListener);
redraw();
}
void leave(int flags) {
if (!fIsActive)
return;
fIsActive= false;
ITextViewerExtension extension= (ITextViewerExtension) fCurrentTarget.getViewer();
IRewriteTarget target= extension.getRewriteTarget();
target.endCompoundChange();
// // debug trace
// JavaPlugin.log(new Status(IStatus.INFO, JavaPlugin.getPluginId(), IStatus.OK, "leaving linked mode", null));
disconnect();
redraw();
for (int i= 0; i < fTargets.length; i++) {
if (fCurrentTarget.fKeyListener != null) {
((ITextViewerExtension) fTargets[i].getViewer()).removeVerifyKeyListener(fCurrentTarget.fKeyListener);
fCurrentTarget.fKeyListener= null;
}
}
for (int i= 0; i < fTargets.length; i++) {
if (fTargets[i].fAnnotationModel != null) {
fTargets[i].fAnnotationModel.removeAllAnnotations();
fTargets[i].fAnnotationModel= null;
}
ITextViewer vi= fTargets[i].getViewer();
if (vi instanceof ISourceViewer) {
ISourceViewer sv= (ISourceViewer) vi;
IAnnotationModel model= sv.getAnnotationModel();
if (model instanceof IAnnotationModelExtension) {
IAnnotationModelExtension ext= (IAnnotationModelExtension) model;
ext.removeAnnotationModel(getUniqueKey());
}
}
}
if (fExitPosition != null)
fExitPosition.getDocument().removePosition(fExitPosition);
if ((flags & ILinkedListener.UPDATE_CARET) != 0 && fExitPosition != null && fFramePosition != fExitPosition && !fExitPosition.isDeleted())
switchPosition(fExitPosition, true, false);
for (int i= 0; i < fTargets.length; i++) {
IDocument doc= fTargets[i].getViewer().getDocument();
if (doc != null) {
doc.removePositionUpdater(fPositionUpdater);
boolean uninstallCat= false;
String[] cats= doc.getPositionCategories();
for (int j= 0; j < cats.length; j++) {
if (getCategory().equals(cats[j])) {
uninstallCat= true;
break;
}
}
if (uninstallCat)
try {
doc.removePositionCategory(getCategory());
} catch (BadPositionCategoryException e) {
// ignore
}
}
}
fEnvironment.exit(flags);
}
/**
* Returns the currently selected region or <code>null</code>.
*
* @return the currently selected region or <code>null</code>
*/
public IRegion getSelectedRegion() {
if (fFramePosition == null)
if (fExitPosition != null)
return new Region(fExitPosition.getOffset(), fExitPosition.getLength());
else
return null;
else
return new Region(fFramePosition.getOffset(), fFramePosition.getLength());
}
private void rememberSelection(VerifyEvent event) {
// don't update other editor's carets
if (event.getSource() != fCurrentTarget.fWidget)
return;
Point selection= fCurrentTarget.getViewer().getSelectedRange();
fCaretPosition.offset= selection.x + selection.y;
fCaretPosition.length= 0;
fCaretPosition.isDeleted= false;
try {
IDocument document= fCurrentTarget.getViewer().getDocument();
boolean installCat= true;
String[] cats= document.getPositionCategories();
for (int i= 0; i < cats.length; i++) {
if (getCategory().equals(cats[i]))
installCat= false;
}
if (installCat) {
document.addPositionCategory(getCategory());
document.addPositionUpdater(fPositionUpdater);
}
if (document.getPositions(getCategory()).length != 0)
document.removePosition(getCategory(), fCaretPosition);
document.addPosition(getCategory(), fCaretPosition);
} catch (BadLocationException e) {
// will not happen
Assert.isTrue(false);
} catch (BadPositionCategoryException e) {
// will not happen
Assert.isTrue(false);
}
}
private void updateSelection(ModifyEvent event) {
// don't set the caret if we've left already (we're still called as the listener
// has just been removed) or the event does not happen on our current viewer
if (!fIsActive || event.getSource() != fCurrentTarget.fWidget)
return;
if (!fCaretPosition.isDeleted())
fCurrentTarget.getViewer().setSelectedRange(fCaretPosition.getOffset(), 0);
fCaretPosition.isDeleted= true;
}
private String getCategory() {
return toString();
}
/**
* Sets the context info property. If set to <code>true</code>, context
* info will be invoked on the current target's viewer whenever a position
* is switched.
*
* @param doContextInfo The doContextInfo to set.
*/
public void setDoContextInfo(boolean doContextInfo) {
fDoContextInfo= doContextInfo;
}
}
|
51,763 |
Bug 51763 Source -> Override methods fails in inner classes [code manipulation]
|
In Version: 3.0.0 Build id: 200312182000 Type the following in the Java editor, in the header of a class : private MouseTrackAdapter mouseTrackListener = new MouseTrackAdapter() { XXX }; right mouse click where the XXX in the above line is and choose Source -> Override/Implement methods. You get the correct methods in the pop up. choose some, and say ok. You get an error and the methods are not generated.
|
verified fixed
|
45461e2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T11:10:18Z | 2004-02-11T20:06:40Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/actions/OverrideMethodsAction.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 java.util.ArrayList;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.operation.IRunnableContext;
import org.eclipse.jface.text.IRewriteTarget;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.window.Window;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.core.ICompilationUnit;
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.internal.corext.codemanipulation.AddUnimplementedMethodsOperation;
import org.eclipse.jdt.internal.corext.codemanipulation.CodeGenerationSettings;
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.ActionMessages;
import org.eclipse.jdt.internal.ui.actions.ActionUtil;
import org.eclipse.jdt.internal.ui.actions.SelectionConverter;
import org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter;
import org.eclipse.jdt.internal.ui.dialogs.OverrideMethodDialog;
import org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor;
import org.eclipse.jdt.internal.ui.javaeditor.EditorUtility;
import org.eclipse.jdt.internal.ui.preferences.JavaPreferencesSettings;
import org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext;
import org.eclipse.jdt.internal.ui.util.ElementValidator;
import org.eclipse.jdt.internal.ui.util.ExceptionHandler;
/**
* Adds unimplemented methods of a type. Action opens a dialog from
* which the user can chosse the methods to be added.
* <p>
* Will open the parent compilation unit in a Java editor. The result is
* unsaved, so the user can decide if the changes are acceptable.
* <p>
* The action is applicable to structured selections containing elements
* of type <code>IType</code>.
*
* <p>
* This class may be instantiated; it is not intended to be subclassed.
* </p>
*
* @since 2.0
*/
public class OverrideMethodsAction extends SelectionDispatchAction {
private CompilationUnitEditor fEditor;
private static final String DIALOG_TITLE= ActionMessages.getString("OverrideMethodsAction.error.title"); //$NON-NLS-1$
/**
* Creates a new <code>OverrideMethodsAction</code>. The action requires
* that the selection provided by the site's selection provider is of type <code>
* org.eclipse.jface.viewers.IStructuredSelection</code>.
*
* @param site the site providing context information for this action
*/
public OverrideMethodsAction(IWorkbenchSite site) {
super(site);
setText(ActionMessages.getString("OverrideMethodsAction.label")); //$NON-NLS-1$
setDescription(ActionMessages.getString("OverrideMethodsAction.description")); //$NON-NLS-1$
setToolTipText(ActionMessages.getString("OverrideMethodsAction.tooltip")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.ADD_UNIMPLEMENTED_METHODS_ACTION);
}
/**
* Note: This constructor is for internal use only. Clients should not call this constructor.
*/
public OverrideMethodsAction(CompilationUnitEditor editor) {
this(editor.getEditorSite());
fEditor= editor;
setEnabled(checkEnabledEditor());
}
//---- Structured Viewer -----------------------------------------------------------
/* (non-Javadoc)
* Method declared on SelectionDispatchAction
*/
public void selectionChanged(IStructuredSelection selection) {
try {
setEnabled(canEnable(selection));
} catch (JavaModelException e) {
// http://bugs.eclipse.org/bugs/show_bug.cgi?id=19253
if (JavaModelUtil.filterNotPresentException(e))
JavaPlugin.log(e);
setEnabled(false);
}
}
private boolean canEnable(IStructuredSelection selection) throws JavaModelException {
if ((selection.size() == 1) && (selection.getFirstElement() instanceof IType)) {
IType type= (IType) selection.getFirstElement();
// look if class: not cheap but done by all source generation actions
// disable anonymous until create method is supported by jdt.core (bug 44395)
return type.getCompilationUnit() != null && type.isClass() && !type.isAnonymous();
}
if ((selection.size() == 1) && (selection.getFirstElement() instanceof ICompilationUnit))
return true;
return false;
}
/* (non-Javadoc)
* Method declared on SelectionDispatchAction
*/
public void run(IStructuredSelection selection) {
Shell shell= getShell();
try {
IType type= getSelectedType(selection);
if (type == null) {
MessageDialog.openInformation(shell, getDialogTitle(), ActionMessages.getString("OverrideMethodsAction.not_applicable")); //$NON-NLS-1$
return;
}
if (!ElementValidator.check(type, getShell(), getDialogTitle(), false) || !ActionUtil.isProcessable(getShell(), type)) {
return;
}
if (type == null) {
MessageDialog.openError(shell, getDialogTitle(), ActionMessages.getString("OverrideMethodsAction.error.type_removed_in_editor")); //$NON-NLS-1$
return;
}
run(shell, type);
} catch (CoreException e) {
ExceptionHandler.handle(e, shell, getDialogTitle(), ActionMessages.getString("OverrideMethodsAction.error.actionfailed")); //$NON-NLS-1$
}
}
//---- Java Editior --------------------------------------------------------------
/* (non-Javadoc)
* Method declared on SelectionDispatchAction
*/
public void selectionChanged(ITextSelection selection) {
}
private boolean checkEnabledEditor() {
return fEditor != null && SelectionConverter.canOperateOn(fEditor);
}
/* (non-Javadoc)
* Method declared on SelectionDispatchAction
*/
public void run(ITextSelection selection) {
Shell shell= getShell();
try {
IType type= SelectionConverter.getTypeAtOffset(fEditor);
if (type != null) {
if (!ElementValidator.check(type, shell, getDialogTitle(), false) || !ActionUtil.isProcessable(shell, type) || type.isInterface()) {
MessageDialog.openInformation(shell, getDialogTitle(), ActionMessages.getString("OverrideMethodsAction.not_applicable")); //$NON-NLS-1$
return;
}
run(shell, type);
} else {
MessageDialog.openInformation(shell, getDialogTitle(), ActionMessages.getString("OverrideMethodsAction.not_applicable")); //$NON-NLS-1$
}
} catch (JavaModelException e) {
ExceptionHandler.handle(e, getShell(), getDialogTitle(), null);
} catch (CoreException e) {
ExceptionHandler.handle(e, getShell(), getDialogTitle(), ActionMessages.getString("OverrideMethodsAction.error.actionfailed")); //$NON-NLS-1$
}
}
//---- Helpers -------------------------------------------------------------------
private void run(Shell shell, IType type) throws JavaModelException, CoreException {
OverrideMethodDialog dialog= new OverrideMethodDialog(shell, fEditor, type, false);
IMethod[] selected= null;
if (!dialog.hasMethodsToOverride()) {
MessageDialog.openInformation(shell, getDialogTitle(), ActionMessages.getString("OverrideMethodsAction.error.nothing_found")); //$NON-NLS-1$
return;
}
int dialogResult= dialog.open();
if (dialogResult == Window.OK) {
Object[] checkedElements= dialog.getResult();
if (checkedElements == null)
return;
ArrayList result= new ArrayList(checkedElements.length);
for (int i= 0; i < checkedElements.length; i++) {
Object curr= checkedElements[i];
if (curr instanceof IMethod) {
result.add(curr);
}
}
selected= (IMethod[]) result.toArray(new IMethod[result.size()]);
CodeGenerationSettings settings= JavaPreferencesSettings.getCodeGenerationSettings();
settings.createComments= dialog.getGenerateComment();
IEditorPart editor= EditorUtility.openInEditor(type.getCompilationUnit());
type= (IType) JavaModelUtil.toWorkingCopy(type);
IRewriteTarget target= editor != null ? (IRewriteTarget) editor.getAdapter(IRewriteTarget.class) : null;
if (target != null) {
target.beginCompoundChange();
}
try {
IJavaElement elementPosition= dialog.getElementPosition();
if (elementPosition != null)
elementPosition= JavaModelUtil.toWorkingCopy(elementPosition);
AddUnimplementedMethodsOperation op= new AddUnimplementedMethodsOperation(type, settings, selected, false, elementPosition);
IRunnableContext context= JavaPlugin.getActiveWorkbenchWindow();
if (context == null) {
context= new BusyIndicatorRunnableContext();
}
context.run(false, true, new WorkbenchRunnableAdapter(op));
IMethod[] res= op.getCreatedMethods();
if (res == null || res.length == 0) {
MessageDialog.openInformation(shell, getDialogTitle(), ActionMessages.getString("OverrideMethodsAction.error.nothing_found")); //$NON-NLS-1$
} else if (editor != null) {
EditorUtility.revealInEditor(editor, res[0]);
}
} catch (InvocationTargetException e) {
ExceptionHandler.handle(e, shell, getDialogTitle(), null);
} catch (InterruptedException e) {
// Do nothing. Operation has been canceled by user.
} finally {
if (target != null) {
target.endCompoundChange();
}
}
}
}
private IType getSelectedType(IStructuredSelection selection) throws JavaModelException {
Object[] elements= selection.toArray();
if (elements.length == 1 && (elements[0] instanceof IType)) {
IType type= (IType) elements[0];
if (type.getCompilationUnit() != null && type.isClass()) {
return type;
}
}
else if (elements[0] instanceof ICompilationUnit) {
ICompilationUnit cu= (ICompilationUnit) elements[0];
IType type= cu.findPrimaryType();
if (!type.isInterface())
return type;
}
return null;
}
private String getDialogTitle() {
return DIALOG_TITLE;
}
}
|
51,622 |
Bug 51622 Organize import misses type references in javadoc
|
20040211 - organize import the following coe - IClassFile and ICompilationUnit go away import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; /** * Implemented by {@link IClassFile} and {@link ICompilationUnit} */ public interface IOpenable { }
|
verified fixed
|
1aed45f
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T11:23:46Z | 2004-02-11T14:33:20Z |
org.eclipse.jdt.ui/core
| |
51,622 |
Bug 51622 Organize import misses type references in javadoc
|
20040211 - organize import the following coe - IClassFile and ICompilationUnit go away import org.eclipse.jdt.core.IClassFile; import org.eclipse.jdt.core.ICompilationUnit; /** * Implemented by {@link IClassFile} and {@link ICompilationUnit} */ public interface IOpenable { }
|
verified fixed
|
1aed45f
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T11:23:46Z | 2004-02-11T14:33:20Z |
extension/org/eclipse/jdt/internal/corext/codemanipulation/OrganizeImportsOperation.java
| |
51,451 |
Bug 51451 [formatting] unstable comment formatting
|
- open TestCase - in the editor set the carret in a method declaration's name (e.g., ru|n()) - press CTRL-SHIFT-F multiple times -> the formatting changes in each `format'
|
resolved fixed
|
d354501
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T15:43:44Z | 2004-02-10T13:33:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaFormattingStrategy.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.java;
import java.util.LinkedList;
import java.util.Map;
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.jface.text.TypedPosition;
import org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy;
import org.eclipse.jface.text.formatter.FormattingContext;
import org.eclipse.jface.text.formatter.FormattingContextProperties;
import org.eclipse.jface.text.formatter.IFormattingContext;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jdt.core.formatter.CodeFormatter;
import org.eclipse.jdt.internal.corext.util.CodeFormatterUtil;
import org.eclipse.jdt.internal.ui.JavaPlugin;
/**
* Formatting strategy for java source code.
* <p>
* This strategy implements <code>IFormattingStrategyExtension</code>. It must be
* registered with a content formatter implementing <code>IContentFormatterExtension2<code>
* to take effect.
*
* @since 3.0
*/
public class JavaFormattingStrategy extends ContextBasedFormattingStrategy {
/** Indentations to use by this strategy */
private final LinkedList fIndentations= new LinkedList();
/** Partitions to be formatted by this strategy */
private final LinkedList fPartitions= new LinkedList();
/** The position sets to keep track of during formatting */
private final LinkedList fPositions= new LinkedList();
/**
* Creates a new java formatting strategy.
*
* @param viewer ISourceViewer to operate on
*/
public JavaFormattingStrategy(final ISourceViewer viewer) {
super(viewer);
}
/*
* @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#format()
*/
public void format() {
super.format();
Assert.isLegal(fIndentations.size() > 0);
Assert.isLegal(fPartitions.size() > 0);
Assert.isLegal(fPositions.size() > 0);
final int[] positions= (int[])fPositions.removeFirst();
final TypedPosition partition= (TypedPosition)fPartitions.removeFirst();
final Map preferences= getPreferences();
final IDocument document= getViewer().getDocument();
int indent= 0;
// not needed with the new API, but still in discussion..
//final String indentation= (String)fIndentations.removeFirst();
//if (indentation != null) {
// indent= Strings.computeIndent(indentation, CodeFormatterUtil.getTabWidth());
//}
try {
//TODO rewrite using the edit API (CodeFormatterUtil.format2)
// reshape the partition to get around some peculiarities of the formatter
Position toFormat= new Position(partition.offset, partition.length);
stripLeadingWS(document, toFormat);
stripTrailingWS(document, toFormat, partition);
IDocument formattedDoc= new Document(CodeFormatterUtil.format(CodeFormatter.K_COMPILATION_UNIT, document.get(), toFormat.offset, toFormat.length, indent, positions, TextUtilities.getDefaultLineDelimiter(document), preferences));
int leadingEmptyLines= document.getNumberOfLines(partition.offset, toFormat.offset - partition.offset) - 1; // getNumberOfLines is one-based
int trailingEmptyLines= document.getNumberOfLines(toFormat.offset + toFormat.length, partition.offset + partition.length - (toFormat.offset + toFormat.length)) - 1;
int from= getLeadingWSOffset(leadingEmptyLines, formattedDoc);
int to= getTrailingWSOffset(trailingEmptyLines, formattedDoc);
String formatted= formattedDoc.get(from, to - from);
final String raw= document.get(partition.getOffset(), partition.getLength());
if (formatted != null && !formatted.equals(raw))
document.replace(partition.getOffset(), partition.getLength(), formatted);
} catch (BadLocationException exception) {
// Can only happen on concurrent document modification - log and bail out
JavaPlugin.log(exception);
}
}
/**
* Strips leading white space off the region described by <code>toFormat</code>
*
* @param document the doc
* @param toFormat the position
* @throws BadLocationException
*/
private void stripLeadingWS(final IDocument document, final Position toFormat) throws BadLocationException {
// get rid of leading white space:
// partition is an entire line selection (from start of a line)
// the formatter, however, expects an offset that points to the first
// non-ws of the line.
int offset= toFormat.getOffset();
int length= toFormat.getLength();
for (int i= 0; i < length; i++) {
if (!Character.isWhitespace(document.getChar(offset + i)))
break;
toFormat.offset++;
toFormat.length--;
}
}
/**
* Strips any trailing white space off the region described by <code>toFormat</code>.
* If the number of lines is reduced, <code>partition</code> is also trimmed off its last
* (emtpy) line.
*
* @param document the document to format
* @param toFormat the position describing the range to be formatted
* @param partition the position describing the original range
* @throws BadLocationException
*/
private void stripTrailingWS(final IDocument document, Position toFormat, Position partition) throws BadLocationException {
// strip an empty selected line end so we don't get additional lines
int offset= toFormat.getOffset();
int length= toFormat.getLength();
int line= document.getLineOfOffset(offset + length);
for (int i= length; i > 0; i--) {
if (!Character.isWhitespace(document.getChar(offset + i - 1)))
break;
toFormat.length--;
}
if (document.getLineOfOffset(toFormat.length + toFormat.offset) != line) {
IRegion region= document.getLineInformation(line - 1);
int endOfLine= region.getOffset() + region.getLength();
partition.setLength(endOfLine - partition.offset);
}
}
/**
* Returns the offset of the line in <code>document</code> that is the
* <code>leadingEmptyLine</code>th empty line before any non-WS comes in
* <code>document</code>.
*
* @param leadingEmptyLines the number of empty lines to leave
* @param document the document
* @return the index such that if the document is cut up to the offset, it will have <code>leadingEmptyLines</code> empty lines upfront
* @throws BadLocationException
*/
private int getLeadingWSOffset(int leadingEmptyLines, IDocument document) throws BadLocationException {
// discard all leading ws except leadingEmtyLines lines
int nLines= document.getNumberOfLines();
int line= 0;
for (; line < nLines; line++) {
IRegion region= document.getLineInformation(line);
if (document.get(region.getOffset(), region.getLength()).trim().length() != 0)
break;
}
int wsLine= Math.max(line - leadingEmptyLines, 0);
return document.getLineOffset(wsLine);
}
/**
* Returns the offset of the end of the line in <code>document</code> that is the
* <code>trailingEmptyLine</code>th empty line after the last non-WS character in
* <code>document</code>.
*
* @param trailingEmptyLine the number of empty lines to leave
* @param document the document
* @return the index such that if the document is cut from the offset, it will have <code>trailingEmptyLine</code> empty lines at the end
* @throws BadLocationException
*/
private int getTrailingWSOffset(int trailingEmptyLines, IDocument document) throws BadLocationException {
// discard all trailing ws
int numberOfLines= document.getNumberOfLines();
int line = numberOfLines - 1;
for (; line >= 0; line--) {
IRegion region= document.getLineInformation(line);
if (document.get(region.getOffset(), region.getLength()).trim().length() != 0)
break;
}
int wsLine= Math.min(line + trailingEmptyLines, numberOfLines);
IRegion region= document.getLineInformation(wsLine);
return region.getOffset() + region.getLength();
}
/*
* @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStarts(org.eclipse.jface.text.formatter.IFormattingContext)
*/
public void formatterStarts(IFormattingContext context) {
super.formatterStarts(context);
final FormattingContext current= (FormattingContext)context;
fIndentations.addLast(current.getProperty(FormattingContextProperties.CONTEXT_INDENTATION));
fPartitions.addLast(current.getProperty(FormattingContextProperties.CONTEXT_PARTITION));
fPositions.addLast(current.getProperty(FormattingContextProperties.CONTEXT_POSITIONS));
}
/*
* @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStops()
*/
public void formatterStops() {
super.formatterStops();
fIndentations.clear();
fPartitions.clear();
fPositions.clear();
}
}
|
51,853 |
Bug 51853 Support new compiler option PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING
|
20040212 Add the new setting to the compiler preference page
|
verified fixed
|
2573160
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T16:10:05Z | 2004-02-12T15:33:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CompilerConfigurationBlock.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.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
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.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.jdt.internal.ui.dialogs.StatusUtil;
import org.eclipse.jdt.internal.ui.util.PixelConverter;
import org.eclipse.jdt.internal.ui.util.TabFolderLayout;
import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
/**
*/
public class CompilerConfigurationBlock extends OptionsConfigurationBlock {
// Preference store keys, see JavaCore.getOptions
private static final String PREF_LOCAL_VARIABLE_ATTR= JavaCore.COMPILER_LOCAL_VARIABLE_ATTR;
private static final String PREF_LINE_NUMBER_ATTR= JavaCore.COMPILER_LINE_NUMBER_ATTR;
private static final String PREF_SOURCE_FILE_ATTR= JavaCore.COMPILER_SOURCE_FILE_ATTR;
private static final String PREF_CODEGEN_UNUSED_LOCAL= JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL;
private static final String PREF_CODEGEN_TARGET_PLATFORM= JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM;
//private static final String PREF_PB_UNREACHABLE_CODE= JavaCore.COMPILER_PB_UNREACHABLE_CODE;
//private static final String PREF_PB_INVALID_IMPORT= JavaCore.COMPILER_PB_INVALID_IMPORT;
private static final String PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD= JavaCore.COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD;
private static final String PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME= JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME;
private static final String PREF_PB_DEPRECATION= JavaCore.COMPILER_PB_DEPRECATION;
private static final String PREF_PB_DEPRECATION_WHEN_OVERRIDING= JavaCore.COMPILER_PB_DEPRECATION_WHEN_OVERRIDING_DEPRECATED_METHOD;
private static final String PREF_PB_HIDDEN_CATCH_BLOCK= JavaCore.COMPILER_PB_HIDDEN_CATCH_BLOCK;
private static final String PREF_PB_UNUSED_LOCAL= JavaCore.COMPILER_PB_UNUSED_LOCAL;
private static final String PREF_PB_UNUSED_PARAMETER= JavaCore.COMPILER_PB_UNUSED_PARAMETER;
private static final String PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING= JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE;
private static final String PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT= JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT;
private static final String PREF_PB_SYNTHETIC_ACCESS_EMULATION= JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION;
private static final String PREF_PB_NON_EXTERNALIZED_STRINGS= JavaCore.COMPILER_PB_NON_NLS_STRING_LITERAL;
private static final String PREF_PB_ASSERT_AS_IDENTIFIER= JavaCore.COMPILER_PB_ASSERT_IDENTIFIER;
private static final String PREF_PB_MAX_PER_UNIT= JavaCore.COMPILER_PB_MAX_PER_UNIT;
private static final String PREF_PB_UNUSED_IMPORT= JavaCore.COMPILER_PB_UNUSED_IMPORT;
private static final String PREF_PB_UNUSED_PRIVATE= JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER;
private static final String PREF_PB_STATIC_ACCESS_RECEIVER= JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER;
private static final String PREF_PB_NO_EFFECT_ASSIGNMENT= JavaCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT;
private static final String PREF_PB_CHAR_ARRAY_IN_CONCAT= JavaCore.COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION;
private static final String PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT= JavaCore.COMPILER_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT;
private static final String PREF_PB_LOCAL_VARIABLE_HIDING= JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING;
private static final String PREF_PB_FIELD_HIDING= JavaCore.COMPILER_PB_FIELD_HIDING;
private static final String PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD= JavaCore.COMPILER_PB_SPECIAL_PARAMETER_HIDING_FIELD;
private static final String PREF_PB_INDIRECT_STATIC_ACCESS= JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS;
private static final String PREF_PB_SUPERFLUOUS_SEMICOLON= JavaCore.COMPILER_PB_SUPERFLUOUS_SEMICOLON;
private static final String PREF_PB_UNNECESSARY_TYPE_CHECK= JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK;
private static final String PREF_PB_INVALID_JAVADOC= JavaCore.COMPILER_PB_INVALID_JAVADOC;
private static final String PREF_PB_INVALID_JAVADOC_TAGS= JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS;
private static final String PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY= JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY;
private static final String PREF_PB_MISSING_JAVADOC_TAGS= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS;
private static final String PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY;
private static final String PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING;
private static final String PREF_PB_MISSING_JAVADOC_COMMENTS= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS;
private static final String PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY;
private static final String PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING;
private static final String PREF_SOURCE_COMPATIBILITY= JavaCore.COMPILER_SOURCE;
private static final String PREF_COMPLIANCE= JavaCore.COMPILER_COMPLIANCE;
private static final String PREF_RESOURCE_FILTER= JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER;
private static final String PREF_BUILD_INVALID_CLASSPATH= JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH;
private static final String PREF_BUILD_CLEAN_OUTPUT_FOLDER= JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER;
private static final String PREF_ENABLE_EXCLUSION_PATTERNS= JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS;
private static final String PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS= JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS;
private static final String PREF_PB_INCOMPLETE_BUILDPATH= JavaCore.CORE_INCOMPLETE_CLASSPATH;
private static final String PREF_PB_CIRCULAR_BUILDPATH= JavaCore.CORE_CIRCULAR_CLASSPATH;
private static final String PREF_PB_INCOMPATIBLE_JDK_LEVEL= JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL;
private static final String PREF_PB_DEPRECATION_IN_DEPRECATED_CODE= JavaCore.COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE;
private static final String PREF_PB_DUPLICATE_RESOURCE= JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE;
private static final String PREF_PB_INCOMPATIBLE_INTERFACE_METHOD= JavaCore.COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD;
private static final String PREF_PB_UNDOCUMENTED_EMPTY_BLOCK= JavaCore.COMPILER_PB_UNDOCUMENTED_EMPTY_BLOCK;
private static final String PREF_PB_FINALLY_BLOCK_NOT_COMPLETING= JavaCore.COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING;
private static final String PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION= JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION;
private static final String PREF_PB_UNQUALIFIED_FIELD_ACCESS= JavaCore.COMPILER_PB_UNQUALIFIED_FIELD_ACCESS;
private static final String INTR_DEFAULT_COMPLIANCE= "internal.default.compliance"; //$NON-NLS-1$
// values
private static final String GENERATE= JavaCore.GENERATE;
private static final String DO_NOT_GENERATE= JavaCore.DO_NOT_GENERATE;
private static final String PRESERVE= JavaCore.PRESERVE;
private static final String OPTIMIZE_OUT= JavaCore.OPTIMIZE_OUT;
private static final String VERSION_1_1= JavaCore.VERSION_1_1;
private static final String VERSION_1_2= JavaCore.VERSION_1_2;
private static final String VERSION_1_3= JavaCore.VERSION_1_3;
private static final String VERSION_1_4= JavaCore.VERSION_1_4;
private static final String ERROR= JavaCore.ERROR;
private static final String WARNING= JavaCore.WARNING;
private static final String IGNORE= JavaCore.IGNORE;
private static final String ABORT= JavaCore.ABORT;
private static final String CLEAN= JavaCore.CLEAN;
private static final String ENABLED= JavaCore.ENABLED;
private static final String DISABLED= JavaCore.DISABLED;
private static final String PUBLIC= JavaCore.PUBLIC;
private static final String PROTECTED= JavaCore.PROTECTED;
private static final String DEFAULT= JavaCore.DEFAULT;
private static final String PRIVATE= JavaCore.PRIVATE;
private static final String DEFAULT_CONF= "default"; //$NON-NLS-1$
private static final String USER_CONF= "user"; //$NON-NLS-1$
private ArrayList fComplianceControls;
private PixelConverter fPixelConverter;
private IStatus fComplianceStatus, fMaxNumberProblemsStatus, fResourceFilterStatus;
public CompilerConfigurationBlock(IStatusChangeListener context, IJavaProject project) {
super(context, project);
fComplianceControls= new ArrayList();
fComplianceStatus= new StatusInfo();
fMaxNumberProblemsStatus= new StatusInfo();
fResourceFilterStatus= new StatusInfo();
}
private final String[] KEYS= new String[] {
PREF_LOCAL_VARIABLE_ATTR, PREF_LINE_NUMBER_ATTR, PREF_SOURCE_FILE_ATTR, PREF_CODEGEN_UNUSED_LOCAL,
PREF_CODEGEN_TARGET_PLATFORM, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,
PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, PREF_PB_DEPRECATION, PREF_PB_HIDDEN_CATCH_BLOCK, PREF_PB_UNUSED_LOCAL,
PREF_PB_UNUSED_PARAMETER, PREF_PB_SYNTHETIC_ACCESS_EMULATION, PREF_PB_NON_EXTERNALIZED_STRINGS,
PREF_PB_ASSERT_AS_IDENTIFIER, PREF_PB_UNUSED_IMPORT, PREF_PB_MAX_PER_UNIT, PREF_SOURCE_COMPATIBILITY, PREF_COMPLIANCE,
PREF_RESOURCE_FILTER, PREF_BUILD_INVALID_CLASSPATH, PREF_PB_STATIC_ACCESS_RECEIVER, PREF_PB_INCOMPLETE_BUILDPATH,
PREF_PB_CIRCULAR_BUILDPATH, PREF_PB_DEPRECATION_IN_DEPRECATED_CODE, PREF_BUILD_CLEAN_OUTPUT_FOLDER,
PREF_PB_DUPLICATE_RESOURCE, PREF_PB_NO_EFFECT_ASSIGNMENT, PREF_PB_INCOMPATIBLE_INTERFACE_METHOD,
PREF_PB_UNUSED_PRIVATE, PREF_PB_CHAR_ARRAY_IN_CONCAT, PREF_ENABLE_EXCLUSION_PATTERNS, PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS,
PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, PREF_PB_LOCAL_VARIABLE_HIDING, PREF_PB_FIELD_HIDING,
PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD, PREF_PB_INCOMPATIBLE_JDK_LEVEL, PREF_PB_INDIRECT_STATIC_ACCESS,
PREF_PB_SUPERFLUOUS_SEMICOLON, PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT,
PREF_PB_UNNECESSARY_TYPE_CHECK, PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION, PREF_PB_UNQUALIFIED_FIELD_ACCESS,
PREF_PB_UNDOCUMENTED_EMPTY_BLOCK, PREF_PB_FINALLY_BLOCK_NOT_COMPLETING, PREF_PB_DEPRECATION_WHEN_OVERRIDING,
PREF_PB_INVALID_JAVADOC, PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY,
PREF_PB_MISSING_JAVADOC_TAGS, PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING,
PREF_PB_MISSING_JAVADOC_COMMENTS, PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING
};
protected String[] getAllKeys() {
return KEYS;
}
protected final Map getOptions(boolean inheritJavaCoreOptions) {
Map map= super.getOptions(inheritJavaCoreOptions);
map.put(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance(map));
return map;
}
protected final Map getDefaultOptions() {
Map map= super.getDefaultOptions();
map.put(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance(map));
return map;
}
/*
* @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
*/
protected Control createContents(Composite parent) {
fPixelConverter= new PixelConverter(parent);
setShell(parent.getShell());
TabFolder folder= new TabFolder(parent, SWT.NONE);
folder.setLayout(new TabFolderLayout());
folder.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite commonComposite= createStyleTabContent(folder);
Composite unusedComposite= createUnusedCodeTabContent(folder);
Composite advancedComposite= createAdvancedTabContent(folder);
Composite javadocComposite= createJavadocTabContent(folder);
Composite complianceComposite= createComplianceTabContent(folder);
Composite othersComposite= createBuildPathTabContent(folder);
TabItem item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.common.tabtitle")); //$NON-NLS-1$
item.setControl(commonComposite);
item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.advanced.tabtitle")); //$NON-NLS-1$
item.setControl(advancedComposite);
item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.unused.tabtitle")); //$NON-NLS-1$
item.setControl(unusedComposite);
item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.javadoc.tabtitle")); //$NON-NLS-1$
item.setControl(javadocComposite);
item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.compliance.tabtitle")); //$NON-NLS-1$
item.setControl(complianceComposite);
item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.others.tabtitle")); //$NON-NLS-1$
item.setControl(othersComposite);
validateSettings(null, null);
return folder;
}
private Composite createStyleTabContent(Composite folder) {
String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
String[] errorWarningIgnoreLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
};
int nColumns= 3;
GridLayout layout= new GridLayout();
layout.numColumns= nColumns;
Composite composite= new Composite(folder, SWT.NULL);
composite.setLayout(layout);
Label description= new Label(composite, SWT.WRAP);
description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.common.description")); //$NON-NLS-1$
GridData gd= new GridData();
gd.horizontalSpan= nColumns;
gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50);
description.setLayoutData(gd);
String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_overriding_pkg_dflt.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_method_naming.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_hidden_catchblock.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_HIDDEN_CATCH_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_static_access_receiver.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_STATIC_ACCESS_RECEIVER, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_no_effect_assignment.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_NO_EFFECT_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_indirect_access_to_static.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_INDIRECT_STATIC_ACCESS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_accidential_assignement.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_finally_block_not_completing.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_FINALLY_BLOCK_NOT_COMPLETING, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_undocumented_empty_block.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNDOCUMENTED_EMPTY_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, 0);
return composite;
}
private Composite createAdvancedTabContent(TabFolder folder) {
String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
String[] errorWarningIgnoreLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
};
String[] enabledDisabled= new String[] { ENABLED, DISABLED };
int nColumns= 3;
GridLayout layout= new GridLayout();
layout.numColumns= nColumns;
Composite composite= new Composite(folder, SWT.NULL);
composite.setLayout(layout);
Label description= new Label(composite, SWT.WRAP);
description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.advanced.description")); //$NON-NLS-1$
GridData gd= new GridData();
gd.horizontalSpan= nColumns;
gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50);
description.setLayoutData(gd);
String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_synth_access_emul.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_SYNTHETIC_ACCESS_EMULATION, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_local_variable_hiding.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_LOCAL_VARIABLE_HIDING, errorWarningIgnore, errorWarningIgnoreLabels, 0);
int indent= fPixelConverter.convertWidthInCharsToPixels(2);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_special_param_hiding.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD, enabledDisabled, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_field_hiding.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_FIELD_HIDING, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_non_externalized_strings.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_NON_EXTERNALIZED_STRINGS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_incompatible_interface_method.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_INCOMPATIBLE_INTERFACE_METHOD, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_char_array_in_concat.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_CHAR_ARRAY_IN_CONCAT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unqualified_field_access.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNQUALIFIED_FIELD_ACCESS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
gd= new GridData();
gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(6);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_max_per_unit.label"); //$NON-NLS-1$
Text text= addTextField(composite, label, PREF_PB_MAX_PER_UNIT, 0, 0);
text.setTextLimit(6);
text.setLayoutData(gd);
return composite;
}
private Composite createUnusedCodeTabContent(TabFolder folder) {
String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
String[] errorWarningIgnoreLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
};
String[] enabledDisabled= new String[] { ENABLED, DISABLED };
int nColumns= 3;
GridLayout layout= new GridLayout();
layout.numColumns= nColumns;
Composite composite= new Composite(folder, SWT.NULL);
composite.setLayout(layout);
Label description= new Label(composite, SWT.WRAP);
description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.unused.description")); //$NON-NLS-1$
GridData gd= new GridData();
gd.horizontalSpan= nColumns;
gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50);
description.setLayoutData(gd);
String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_local.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNUSED_LOCAL, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_parameter.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNUSED_PARAMETER, errorWarningIgnore, errorWarningIgnoreLabels, 0);
int indent= fPixelConverter.convertWidthInCharsToPixels(2);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_signal_param_in_overriding.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, enabledDisabled, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_signal_param_in_abstract.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT, enabledDisabled, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_imports.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNUSED_IMPORT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_private.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNUSED_PRIVATE, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_deprecation.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_DEPRECATION, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_deprecation_in_deprecation.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_DEPRECATION_IN_DEPRECATED_CODE, enabledDisabled, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_deprecation_when_overriding.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_DEPRECATION_WHEN_OVERRIDING, enabledDisabled, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_superfluous_semicolon.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_SUPERFLUOUS_SEMICOLON, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unnecessary_type_check.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNNECESSARY_TYPE_CHECK, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_throwing_exception.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION, errorWarningIgnore, errorWarningIgnoreLabels, 0);
return composite;
}
private Composite createJavadocTabContent(TabFolder folder) {
String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
String[] errorWarningIgnoreLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
};
String[] enabledDisabled= new String[] { ENABLED, DISABLED };
String[] visibilities= new String[] { PUBLIC, PROTECTED, DEFAULT, PRIVATE };
String[] visibilitiesLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.public"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.protected"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.default"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.private") //$NON-NLS-1$
};
int nColumns= 3;
/*
* COMPILER_PB_INVALID_JAVADOC: "ignore", "warning", "error"
COMPILER_PB_INVALID_JAVADOC_TAGS: "enabled", "disabled"
COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY: "public", "protected", "default", "private"
COMPILER_PB_MISSING_JAVADOC_TAGS: "ignore", "warning", "error"
COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY: "public", "protected", "default", "private"
COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING: "enabled", "disabled"
COMPILER_PB_MISSING_JAVADOC_COMMENTS: "ignore", "warning", "error"
COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY: "public", "protected", "default", "private"
COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING: "enabled", "disabled"
*/
// GridLayout layout = new GridLayout();
// layout.numColumns= nColumns;
//
// Composite composite= new Composite(folder, SWT.NULL);
// composite.setLayout(layout);
//
// Label description= new Label(composite, SWT.WRAP);
// description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.javadoc.description")); //$NON-NLS-1$
// GridData gd= new GridData();
// gd.horizontalSpan= nColumns;
// gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50);
// description.setLayoutData(gd);
GridLayout layout = new GridLayout();
layout.numColumns= nColumns;
Composite composite= new Composite(folder, SWT.NULL);
composite.setLayout(layout);
Label description= new Label(composite, SWT.WRAP);
description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.javadoc.description")); //$NON-NLS-1$
GridData gd= new GridData();
gd.horizontalSpan= nColumns;
gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50);
description.setLayoutData(gd);
int indent= fPixelConverter.convertWidthInCharsToPixels(2);
String label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_comments.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_COMMENTS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_comments_visibility.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, visibilities, visibilitiesLabels, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_comments_overriding.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING, enabledDisabled, indent);
Label separator= new Label(composite, SWT.HORIZONTAL);
gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan= nColumns;
separator.setLayoutData(gd);
label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_javadoc.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_TAGS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_javadoc_tags_visibility.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, visibilities, visibilitiesLabels, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_javadoc_tags_overriding.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING, enabledDisabled, indent);
separator= new Label(composite, SWT.HORIZONTAL);
gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan= nColumns;
separator.setLayoutData(gd);
label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_invalid_javadoc.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_INVALID_JAVADOC, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_invalid_javadoc_tags_visibility.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, visibilities, visibilitiesLabels, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_invalid_javadoc_tags.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_INVALID_JAVADOC_TAGS, enabledDisabled, indent);
return composite;
}
private Composite createBuildPathTabContent(TabFolder folder) {
String[] abortIgnoreValues= new String[] { ABORT, IGNORE };
String[] cleanIgnoreValues= new String[] { CLEAN, IGNORE };
String[] enableDisableValues= new String[] { ENABLED, DISABLED };
String[] errorWarning= new String[] { ERROR, WARNING };
String[] errorWarningLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.warning") //$NON-NLS-1$
};
int nColumns= 3;
GridLayout layout= new GridLayout();
layout.numColumns= nColumns;
Composite othersComposite= new Composite(folder, SWT.NULL);
othersComposite.setLayout(layout);
Label description= new Label(othersComposite, SWT.WRAP);
description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.build_warnings.description")); //$NON-NLS-1$
GridData gd= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
gd.horizontalSpan= nColumns;
description.setLayoutData(gd);
String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_incomplete_build_path.label"); //$NON-NLS-1$
addComboBox(othersComposite, label, PREF_PB_INCOMPLETE_BUILDPATH, errorWarning, errorWarningLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_build_path_cycles.label"); //$NON-NLS-1$
addComboBox(othersComposite, label, PREF_PB_CIRCULAR_BUILDPATH, errorWarning, errorWarningLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_duplicate_resources.label"); //$NON-NLS-1$
addComboBox(othersComposite, label, PREF_PB_DUPLICATE_RESOURCE, errorWarning, errorWarningLabels, 0);
String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
String[] errorWarningIgnoreLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
};
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_check_prereq_binary_level.label"); //$NON-NLS-1$
addComboBox(othersComposite, label, PREF_PB_INCOMPATIBLE_JDK_LEVEL, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.build_invalid_classpath.label"); //$NON-NLS-1$
addCheckBox(othersComposite, label, PREF_BUILD_INVALID_CLASSPATH, abortIgnoreValues, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.build_clean_outputfolder.label"); //$NON-NLS-1$
addCheckBox(othersComposite, label, PREF_BUILD_CLEAN_OUTPUT_FOLDER, cleanIgnoreValues, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.enable_exclusion_patterns.label"); //$NON-NLS-1$
addCheckBox(othersComposite, label, PREF_ENABLE_EXCLUSION_PATTERNS, enableDisableValues, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.enable_multiple_outputlocations.label"); //$NON-NLS-1$
addCheckBox(othersComposite, label, PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS, enableDisableValues, 0);
description= new Label(othersComposite, SWT.WRAP);
description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.resource_filter.description")); //$NON-NLS-1$
gd= new GridData(GridData.FILL);
gd.horizontalSpan= nColumns;
gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(60);
description.setLayoutData(gd);
label= PreferencesMessages.getString("CompilerConfigurationBlock.resource_filter.label"); //$NON-NLS-1$
Text text= addTextField(othersComposite, label, PREF_RESOURCE_FILTER, 0, 0);
gd= (GridData) text.getLayoutData();
gd.grabExcessHorizontalSpace= true;
gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(10);
return othersComposite;
}
private Composite createComplianceTabContent(Composite folder) {
GridLayout layout= new GridLayout();
layout.numColumns= 1;
String[] values34= new String[] { VERSION_1_3, VERSION_1_4 };
String[] values34Labels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.version13"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.version14") //$NON-NLS-1$
};
Composite compComposite= new Composite(folder, SWT.NULL);
compComposite.setLayout(layout);
int nColumns= 3;
layout= new GridLayout();
layout.numColumns= nColumns;
Group group= new Group(compComposite, SWT.NONE);
group.setText(PreferencesMessages.getString("CompilerConfigurationBlock.compliance.group.label")); //$NON-NLS-1$
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
group.setLayout(layout);
String label= PreferencesMessages.getString("CompilerConfigurationBlock.compiler_compliance.label"); //$NON-NLS-1$
addComboBox(group, label, PREF_COMPLIANCE, values34, values34Labels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.default_settings.label"); //$NON-NLS-1$
addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, new String[] { DEFAULT_CONF, USER_CONF }, 0);
int indent= fPixelConverter.convertWidthInCharsToPixels(2);
Control[] otherChildren= group.getChildren();
String[] values14= new String[] { VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4 };
String[] values14Labels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.version11"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.version12"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.version13"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.version14") //$NON-NLS-1$
};
label= PreferencesMessages.getString("CompilerConfigurationBlock.codegen_targetplatform.label"); //$NON-NLS-1$
addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, values14, values14Labels, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.source_compatibility.label"); //$NON-NLS-1$
addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, values34, values34Labels, indent);
String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
String[] errorWarningIgnoreLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
};
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_assert_as_identifier.label"); //$NON-NLS-1$
addComboBox(group, label, PREF_PB_ASSERT_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent);
Control[] allChildren= group.getChildren();
fComplianceControls.addAll(Arrays.asList(allChildren));
fComplianceControls.removeAll(Arrays.asList(otherChildren));
layout= new GridLayout();
layout.numColumns= nColumns;
group= new Group(compComposite, SWT.NONE);
group.setText(PreferencesMessages.getString("CompilerConfigurationBlock.classfiles.group.label")); //$NON-NLS-1$
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
group.setLayout(layout);
String[] generateValues= new String[] { GENERATE, DO_NOT_GENERATE };
label= PreferencesMessages.getString("CompilerConfigurationBlock.variable_attr.label"); //$NON-NLS-1$
addCheckBox(group, label, PREF_LOCAL_VARIABLE_ATTR, generateValues, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.line_number_attr.label"); //$NON-NLS-1$
addCheckBox(group, label, PREF_LINE_NUMBER_ATTR, generateValues, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.source_file_attr.label"); //$NON-NLS-1$
addCheckBox(group, label, PREF_SOURCE_FILE_ATTR, generateValues, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.codegen_unused_local.label"); //$NON-NLS-1$
addCheckBox(group, label, PREF_CODEGEN_UNUSED_LOCAL, new String[] { PRESERVE, OPTIMIZE_OUT }, 0);
return compComposite;
}
/* (non-javadoc)
* Update fields and validate.
* @param changedKey Key that changed, or null, if all changed.
*/
protected void validateSettings(String changedKey, String newValue) {
if (changedKey != null) {
if (INTR_DEFAULT_COMPLIANCE.equals(changedKey)) {
updateComplianceEnableState();
if (DEFAULT_CONF.equals(newValue)) {
updateComplianceDefaultSettings();
}
fComplianceStatus= validateCompliance();
} else if (PREF_COMPLIANCE.equals(changedKey)) {
if (checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF)) {
updateComplianceDefaultSettings();
}
fComplianceStatus= validateCompliance();
} else if (PREF_SOURCE_COMPATIBILITY.equals(changedKey) ||
PREF_CODEGEN_TARGET_PLATFORM.equals(changedKey) ||
PREF_PB_ASSERT_AS_IDENTIFIER.equals(changedKey)) {
fComplianceStatus= validateCompliance();
} else if (PREF_PB_MAX_PER_UNIT.equals(changedKey)) {
fMaxNumberProblemsStatus= validateMaxNumberProblems();
} else if (PREF_RESOURCE_FILTER.equals(changedKey)) {
fResourceFilterStatus= validateResourceFilters();
} else if (PREF_PB_UNUSED_PARAMETER.equals(changedKey) ||
PREF_PB_DEPRECATION.equals(changedKey) ||
PREF_PB_INVALID_JAVADOC.equals(changedKey) ||
PREF_PB_MISSING_JAVADOC_TAGS.equals(changedKey) ||
PREF_PB_MISSING_JAVADOC_COMMENTS.equals(changedKey) ||
PREF_PB_LOCAL_VARIABLE_HIDING.equals(changedKey)) {
updateEnableStates();
} else {
return;
}
} else {
updateEnableStates();
updateComplianceEnableState();
fComplianceStatus= validateCompliance();
fMaxNumberProblemsStatus= validateMaxNumberProblems();
fResourceFilterStatus= validateResourceFilters();
}
IStatus status= StatusUtil.getMostSevere(new IStatus[] { fComplianceStatus, fMaxNumberProblemsStatus, fResourceFilterStatus });
fContext.statusChanged(status);
}
private void updateEnableStates() {
boolean enableUnusedParams= !checkValue(PREF_PB_UNUSED_PARAMETER, IGNORE);
getCheckBox(PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING).setEnabled(enableUnusedParams);
getCheckBox(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT).setEnabled(enableUnusedParams);
boolean enableDeprecation= !checkValue(PREF_PB_DEPRECATION, IGNORE);
getCheckBox(PREF_PB_DEPRECATION_IN_DEPRECATED_CODE).setEnabled(enableDeprecation);
getCheckBox(PREF_PB_DEPRECATION_WHEN_OVERRIDING).setEnabled(enableDeprecation);
boolean enableHiding= !checkValue(PREF_PB_LOCAL_VARIABLE_HIDING, IGNORE);
getCheckBox(PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD).setEnabled(enableHiding);
boolean enableInvalidTagsErrors= !checkValue(PREF_PB_INVALID_JAVADOC, IGNORE);
getCheckBox(PREF_PB_INVALID_JAVADOC_TAGS).setEnabled(enableInvalidTagsErrors);
setComboEnabled(PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, enableInvalidTagsErrors);
boolean enableMissingTagsErrors= !checkValue(PREF_PB_MISSING_JAVADOC_TAGS, IGNORE);
getCheckBox(PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING).setEnabled(enableMissingTagsErrors);
setComboEnabled(PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, enableMissingTagsErrors);
boolean enableMissingCommentsErrors= !checkValue(PREF_PB_MISSING_JAVADOC_COMMENTS, IGNORE);
getCheckBox(PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING).setEnabled(enableMissingCommentsErrors);
setComboEnabled(PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, enableMissingCommentsErrors);
}
private IStatus validateCompliance() {
StatusInfo status= new StatusInfo();
if (checkValue(PREF_COMPLIANCE, VERSION_1_3)) {
if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) {
status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl13src14.error")); //$NON-NLS-1$
return status;
} else if (checkValue(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_4)) {
status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl13trg14.error")); //$NON-NLS-1$
return status;
}
}
if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) {
if (!checkValue(PREF_PB_ASSERT_AS_IDENTIFIER, ERROR)) {
status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.src14asrterr.error")); //$NON-NLS-1$
return status;
}
}
if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) {
if (!checkValue(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_4)) {
status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.src14tgt14.error")); //$NON-NLS-1$
return status;
}
}
return status;
}
private IStatus validateMaxNumberProblems() {
String number= (String) fWorkingValues.get(PREF_PB_MAX_PER_UNIT);
StatusInfo status= new StatusInfo();
if (number.length() == 0) {
status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.empty_input")); //$NON-NLS-1$
} else {
try {
int value= Integer.parseInt(number);
if (value <= 0) {
status.setError(PreferencesMessages.getFormattedString("CompilerConfigurationBlock.invalid_input", number)); //$NON-NLS-1$
}
} catch (NumberFormatException e) {
status.setError(PreferencesMessages.getFormattedString("CompilerConfigurationBlock.invalid_input", number)); //$NON-NLS-1$
}
}
return status;
}
private IStatus validateResourceFilters() {
String text= (String) fWorkingValues.get(PREF_RESOURCE_FILTER);
IWorkspace workspace= ResourcesPlugin.getWorkspace();
String[] filters= getTokens(text, ","); //$NON-NLS-1$
for (int i= 0; i < filters.length; i++) {
String fileName= filters[i].replace('*', 'x');
int resourceType= IResource.FILE;
int lastCharacter= fileName.length() - 1;
if (lastCharacter >= 0 && fileName.charAt(lastCharacter) == '/') {
fileName= fileName.substring(0, lastCharacter);
resourceType= IResource.FOLDER;
}
IStatus status= workspace.validateName(fileName, resourceType);
if (status.matches(IStatus.ERROR)) {
String message= PreferencesMessages.getFormattedString("CompilerConfigurationBlock.filter.invalidsegment.error", status.getMessage()); //$NON-NLS-1$
return new StatusInfo(IStatus.ERROR, message);
}
}
return new StatusInfo();
}
/*
* Update the compliance controls' enable state
*/
private void updateComplianceEnableState() {
boolean enabled= checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF);
for (int i= fComplianceControls.size() - 1; i >= 0; i--) {
Control curr= (Control) fComplianceControls.get(i);
curr.setEnabled(enabled);
}
}
/*
* Set the default compliance values derived from the chosen level
*/
private void updateComplianceDefaultSettings() {
Object complianceLevel= fWorkingValues.get(PREF_COMPLIANCE);
if (VERSION_1_3.equals(complianceLevel)) {
fWorkingValues.put(PREF_PB_ASSERT_AS_IDENTIFIER, IGNORE);
fWorkingValues.put(PREF_SOURCE_COMPATIBILITY, VERSION_1_3);
fWorkingValues.put(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
} else if (VERSION_1_4.equals(complianceLevel)) {
fWorkingValues.put(PREF_PB_ASSERT_AS_IDENTIFIER, WARNING);
fWorkingValues.put(PREF_SOURCE_COMPATIBILITY, VERSION_1_3);
fWorkingValues.put(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_2);
}
updateControls();
}
/*
* Evaluate if the current compliance setting correspond to a default setting
*/
private static String getCurrentCompliance(Map map) {
Object complianceLevel= map.get(PREF_COMPLIANCE);
if ((VERSION_1_3.equals(complianceLevel)
&& IGNORE.equals(map.get(PREF_PB_ASSERT_AS_IDENTIFIER))
&& VERSION_1_3.equals(map.get(PREF_SOURCE_COMPATIBILITY))
&& VERSION_1_1.equals(map.get(PREF_CODEGEN_TARGET_PLATFORM)))
|| (VERSION_1_4.equals(complianceLevel)
&& WARNING.equals(map.get(PREF_PB_ASSERT_AS_IDENTIFIER))
&& VERSION_1_3.equals(map.get(PREF_SOURCE_COMPATIBILITY))
&& VERSION_1_2.equals(map.get(PREF_CODEGEN_TARGET_PLATFORM)))) {
return DEFAULT_CONF;
}
return USER_CONF;
}
protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
String title= PreferencesMessages.getString("CompilerConfigurationBlock.needsbuild.title"); //$NON-NLS-1$
String message;
if (workspaceSettings) {
message= PreferencesMessages.getString("CompilerConfigurationBlock.needsfullbuild.message"); //$NON-NLS-1$
} else {
message= PreferencesMessages.getString("CompilerConfigurationBlock.needsprojectbuild.message"); //$NON-NLS-1$
}
return new String[] { title, message };
}
}
|
51,637 |
Bug 51637 Quick Fix compilation unit rename throws CoreException
|
Test case: - create class Foo - manually rename class from Foo to Bar - use Quick Fix to "Rename compilation unit to 'Bar.java'" -> CoreException: !SESSION Feb 11, 2004 15:32:14.486 --------------------------------------------- java.version=1.4.2 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -dev bin -os win32 -ws win32 -arch x86 -nl en_US !ENTRY org.eclipse.jdt.ui 4 10001 Feb 11, 2004 15:32:14.486 !MESSAGE Internal Error !STACK 1 org.eclipse.core.runtime.CoreException: /IAE/src/x/Foo.java is unsaved at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.apply(ChangeCorrectionProposal.java:69) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:375) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposalWithMask(CompletionProposalPopup.java:339) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:639) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:622) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:378) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:650) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5321) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5066) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1716) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1712) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3037) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2940) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2865) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1371) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2019) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581) !ENTRY org.eclipse.jdt.ui 4 4 Feb 11, 2004 15:32:14.486 !MESSAGE /IAE/src/x/Foo.java is unsaved
|
verified fixed
|
b705204
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T18:39:36Z | 2004-02-11T14:33:20Z |
org.eclipse.jdt.ui/core
| |
51,637 |
Bug 51637 Quick Fix compilation unit rename throws CoreException
|
Test case: - create class Foo - manually rename class from Foo to Bar - use Quick Fix to "Rename compilation unit to 'Bar.java'" -> CoreException: !SESSION Feb 11, 2004 15:32:14.486 --------------------------------------------- java.version=1.4.2 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -dev bin -os win32 -ws win32 -arch x86 -nl en_US !ENTRY org.eclipse.jdt.ui 4 10001 Feb 11, 2004 15:32:14.486 !MESSAGE Internal Error !STACK 1 org.eclipse.core.runtime.CoreException: /IAE/src/x/Foo.java is unsaved at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.apply(ChangeCorrectionProposal.java:69) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:375) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposalWithMask(CompletionProposalPopup.java:339) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:639) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:622) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:378) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:650) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5321) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5066) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1716) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1712) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3037) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2940) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2865) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1371) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2019) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581) !ENTRY org.eclipse.jdt.ui 4 4 Feb 11, 2004 15:32:14.486 !MESSAGE /IAE/src/x/Foo.java is unsaved
|
verified fixed
|
b705204
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T18:39:36Z | 2004-02-11T14:33:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/AbstractJavaElementRenameChange.java
| |
51,637 |
Bug 51637 Quick Fix compilation unit rename throws CoreException
|
Test case: - create class Foo - manually rename class from Foo to Bar - use Quick Fix to "Rename compilation unit to 'Bar.java'" -> CoreException: !SESSION Feb 11, 2004 15:32:14.486 --------------------------------------------- java.version=1.4.2 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -dev bin -os win32 -ws win32 -arch x86 -nl en_US !ENTRY org.eclipse.jdt.ui 4 10001 Feb 11, 2004 15:32:14.486 !MESSAGE Internal Error !STACK 1 org.eclipse.core.runtime.CoreException: /IAE/src/x/Foo.java is unsaved at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.apply(ChangeCorrectionProposal.java:69) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:375) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposalWithMask(CompletionProposalPopup.java:339) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:639) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:622) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:378) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:650) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5321) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5066) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1716) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1712) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3037) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2940) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2865) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1371) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2019) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581) !ENTRY org.eclipse.jdt.ui 4 4 Feb 11, 2004 15:32:14.486 !MESSAGE /IAE/src/x/Foo.java is unsaved
|
verified fixed
|
b705204
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T18:39:36Z | 2004-02-11T14:33:20Z |
org.eclipse.jdt.ui/core
| |
51,637 |
Bug 51637 Quick Fix compilation unit rename throws CoreException
|
Test case: - create class Foo - manually rename class from Foo to Bar - use Quick Fix to "Rename compilation unit to 'Bar.java'" -> CoreException: !SESSION Feb 11, 2004 15:32:14.486 --------------------------------------------- java.version=1.4.2 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -dev bin -os win32 -ws win32 -arch x86 -nl en_US !ENTRY org.eclipse.jdt.ui 4 10001 Feb 11, 2004 15:32:14.486 !MESSAGE Internal Error !STACK 1 org.eclipse.core.runtime.CoreException: /IAE/src/x/Foo.java is unsaved at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.apply(ChangeCorrectionProposal.java:69) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:375) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposalWithMask(CompletionProposalPopup.java:339) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:639) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:622) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:378) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:650) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5321) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5066) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1716) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1712) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3037) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2940) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2865) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1371) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2019) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581) !ENTRY org.eclipse.jdt.ui 4 4 Feb 11, 2004 15:32:14.486 !MESSAGE /IAE/src/x/Foo.java is unsaved
|
verified fixed
|
b705204
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T18:39:36Z | 2004-02-11T14:33:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/base/JDTChange.java
| |
51,637 |
Bug 51637 Quick Fix compilation unit rename throws CoreException
|
Test case: - create class Foo - manually rename class from Foo to Bar - use Quick Fix to "Rename compilation unit to 'Bar.java'" -> CoreException: !SESSION Feb 11, 2004 15:32:14.486 --------------------------------------------- java.version=1.4.2 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -dev bin -os win32 -ws win32 -arch x86 -nl en_US !ENTRY org.eclipse.jdt.ui 4 10001 Feb 11, 2004 15:32:14.486 !MESSAGE Internal Error !STACK 1 org.eclipse.core.runtime.CoreException: /IAE/src/x/Foo.java is unsaved at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.apply(ChangeCorrectionProposal.java:69) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:375) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposalWithMask(CompletionProposalPopup.java:339) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:639) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:622) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:378) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:650) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5321) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5066) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1716) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1712) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3037) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2940) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2865) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1371) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2019) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581) !ENTRY org.eclipse.jdt.ui 4 4 Feb 11, 2004 15:32:14.486 !MESSAGE /IAE/src/x/Foo.java is unsaved
|
verified fixed
|
b705204
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T18:39:36Z | 2004-02-11T14:33:20Z |
org.eclipse.jdt.ui/core
| |
51,637 |
Bug 51637 Quick Fix compilation unit rename throws CoreException
|
Test case: - create class Foo - manually rename class from Foo to Bar - use Quick Fix to "Rename compilation unit to 'Bar.java'" -> CoreException: !SESSION Feb 11, 2004 15:32:14.486 --------------------------------------------- java.version=1.4.2 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -dev bin -os win32 -ws win32 -arch x86 -nl en_US !ENTRY org.eclipse.jdt.ui 4 10001 Feb 11, 2004 15:32:14.486 !MESSAGE Internal Error !STACK 1 org.eclipse.core.runtime.CoreException: /IAE/src/x/Foo.java is unsaved at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.apply(ChangeCorrectionProposal.java:69) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:375) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposalWithMask(CompletionProposalPopup.java:339) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:639) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:622) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:378) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:650) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5321) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5066) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1716) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1712) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3037) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2940) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2865) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1371) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2019) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581) !ENTRY org.eclipse.jdt.ui 4 4 Feb 11, 2004 15:32:14.486 !MESSAGE /IAE/src/x/Foo.java is unsaved
|
verified fixed
|
b705204
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T18:39:36Z | 2004-02-11T14:33:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/RenameCompilationUnitChange.java
| |
51,637 |
Bug 51637 Quick Fix compilation unit rename throws CoreException
|
Test case: - create class Foo - manually rename class from Foo to Bar - use Quick Fix to "Rename compilation unit to 'Bar.java'" -> CoreException: !SESSION Feb 11, 2004 15:32:14.486 --------------------------------------------- java.version=1.4.2 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -dev bin -os win32 -ws win32 -arch x86 -nl en_US !ENTRY org.eclipse.jdt.ui 4 10001 Feb 11, 2004 15:32:14.486 !MESSAGE Internal Error !STACK 1 org.eclipse.core.runtime.CoreException: /IAE/src/x/Foo.java is unsaved at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.apply(ChangeCorrectionProposal.java:69) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:375) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposalWithMask(CompletionProposalPopup.java:339) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:639) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:622) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:378) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:650) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5321) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5066) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1716) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1712) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3037) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2940) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2865) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1371) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2019) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581) !ENTRY org.eclipse.jdt.ui 4 4 Feb 11, 2004 15:32:14.486 !MESSAGE /IAE/src/x/Foo.java is unsaved
|
verified fixed
|
b705204
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T18:39:36Z | 2004-02-11T14:33:20Z |
org.eclipse.jdt.ui/core
| |
51,637 |
Bug 51637 Quick Fix compilation unit rename throws CoreException
|
Test case: - create class Foo - manually rename class from Foo to Bar - use Quick Fix to "Rename compilation unit to 'Bar.java'" -> CoreException: !SESSION Feb 11, 2004 15:32:14.486 --------------------------------------------- java.version=1.4.2 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -dev bin -os win32 -ws win32 -arch x86 -nl en_US !ENTRY org.eclipse.jdt.ui 4 10001 Feb 11, 2004 15:32:14.486 !MESSAGE Internal Error !STACK 1 org.eclipse.core.runtime.CoreException: /IAE/src/x/Foo.java is unsaved at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.apply(ChangeCorrectionProposal.java:69) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:375) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposalWithMask(CompletionProposalPopup.java:339) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:639) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:622) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:378) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:650) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5321) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5066) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1716) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1712) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3037) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2940) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2865) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1371) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2019) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581) !ENTRY org.eclipse.jdt.ui 4 4 Feb 11, 2004 15:32:14.486 !MESSAGE /IAE/src/x/Foo.java is unsaved
|
verified fixed
|
b705204
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T18:39:36Z | 2004-02-11T14:33:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/RenamePackageChange.java
| |
51,637 |
Bug 51637 Quick Fix compilation unit rename throws CoreException
|
Test case: - create class Foo - manually rename class from Foo to Bar - use Quick Fix to "Rename compilation unit to 'Bar.java'" -> CoreException: !SESSION Feb 11, 2004 15:32:14.486 --------------------------------------------- java.version=1.4.2 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -dev bin -os win32 -ws win32 -arch x86 -nl en_US !ENTRY org.eclipse.jdt.ui 4 10001 Feb 11, 2004 15:32:14.486 !MESSAGE Internal Error !STACK 1 org.eclipse.core.runtime.CoreException: /IAE/src/x/Foo.java is unsaved at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.apply(ChangeCorrectionProposal.java:69) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:375) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposalWithMask(CompletionProposalPopup.java:339) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:639) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:622) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:378) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:650) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5321) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5066) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1716) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1712) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3037) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2940) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2865) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1371) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2019) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581) !ENTRY org.eclipse.jdt.ui 4 4 Feb 11, 2004 15:32:14.486 !MESSAGE /IAE/src/x/Foo.java is unsaved
|
verified fixed
|
b705204
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T18:39:36Z | 2004-02-11T14:33:20Z |
org.eclipse.jdt.ui/core
| |
51,637 |
Bug 51637 Quick Fix compilation unit rename throws CoreException
|
Test case: - create class Foo - manually rename class from Foo to Bar - use Quick Fix to "Rename compilation unit to 'Bar.java'" -> CoreException: !SESSION Feb 11, 2004 15:32:14.486 --------------------------------------------- java.version=1.4.2 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=en_US Command-line arguments: -dev bin -os win32 -ws win32 -arch x86 -nl en_US !ENTRY org.eclipse.jdt.ui 4 10001 Feb 11, 2004 15:32:14.486 !MESSAGE Internal Error !STACK 1 org.eclipse.core.runtime.CoreException: /IAE/src/x/Foo.java is unsaved at org.eclipse.jdt.internal.ui.text.correction.ChangeCorrectionProposal.apply(ChangeCorrectionProposal.java:69) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.insertProposal(CompletionProposalPopup.java:375) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.selectProposalWithMask(CompletionProposalPopup.java:339) at org.eclipse.jface.text.contentassist.CompletionProposalPopup.verifyKey(CompletionProposalPopup.java:639) at org.eclipse.jface.text.contentassist.ContentAssistant$InternalListener.verifyKey(ContentAssistant.java:622) at org.eclipse.jface.text.TextViewer$VerifyKeyListenersManager.verifyKey(TextViewer.java:378) at org.eclipse.swt.custom.StyledTextListener.handleEvent(StyledTextListener.java:55) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:650) at org.eclipse.swt.custom.StyledText.handleKeyDown(StyledText.java:5321) at org.eclipse.swt.custom.StyledText$7.handleEvent(StyledText.java:5066) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:857) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:842) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1716) at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1712) at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3037) at org.eclipse.swt.widgets.Control.windowProc(Control.java:2940) at org.eclipse.swt.widgets.Display.windowProc(Display.java:2865) at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method) at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1371) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2019) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1530) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1506) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:221) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:101) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581) !ENTRY org.eclipse.jdt.ui 4 4 Feb 11, 2004 15:32:14.486 !MESSAGE /IAE/src/x/Foo.java is unsaved
|
verified fixed
|
b705204
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T18:39:36Z | 2004-02-11T14:33:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/changes/RenameSourceFolderChange.java
| |
51,648 |
Bug 51648 ClassCastException after aborted local rename
| null |
verified fixed
|
597f55e
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-12T18:42:09Z | 2004-02-11T14:33:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/LinkedNamesAssistProposal.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.Arrays;
import java.util.Comparator;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
import org.eclipse.jdt.internal.corext.dom.LinkedNodeFinder;
import org.eclipse.jdt.internal.corext.dom.NodeFinder;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
import org.eclipse.jdt.internal.ui.text.link.LinkedEnvironment;
import org.eclipse.jdt.internal.ui.text.link.LinkedPositionGroup;
import org.eclipse.jdt.internal.ui.text.link.LinkedUIControl;
/**
* A template proposal.
*/
public class LinkedNamesAssistProposal implements IJavaCompletionProposal, ICompletionProposalExtension2 {
private SimpleName fNode;
private IRegion fSelectedRegion; // initialized by apply()
private ICompilationUnit fCompilationUnit;
public LinkedNamesAssistProposal(ICompilationUnit cu, SimpleName node) {
fNode= node;
fCompilationUnit= cu;
}
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer, char, int, int)
*/
public void apply(ITextViewer viewer, char trigger, int stateMask, final int offset) {
try {
// create full ast
CompilationUnit root= AST.parseCompilationUnit(fCompilationUnit, true); // full AST needed
SimpleName nameNode= (SimpleName) NodeFinder.perform(root, fNode.getStartPosition(), fNode.getLength());
ASTNode[] sameNodes= LinkedNodeFinder.findByNode(root, nameNode);
// sort for iteration order, starting with the node @ offset
Arrays.sort(sameNodes, new Comparator() {
public int compare(Object o1, Object o2) {
return rank((ASTNode) o1) - rank((ASTNode) o2);
}
/**
* Returns the absolute rank of an <code>ASTNode</code>. Nodes
* preceding <code>offset</code> are ranked last.
*
* @param node the node to compute the rank for
* @return the rank of the node with respect to the invocation offset
*/
private int rank(ASTNode node) {
int relativeRank= node.getStartPosition() + node.getLength() - offset;
if (relativeRank < 0)
return Integer.MAX_VALUE + relativeRank;
else
return relativeRank;
}
});
IDocument document= viewer.getDocument();
LinkedPositionGroup group= new LinkedPositionGroup();
for (int i= 0; i < sameNodes.length; i++) {
ASTNode elem= sameNodes[i];
group.createPosition(document, elem.getStartPosition(), elem.getLength(), i);
}
LinkedEnvironment enviroment= new LinkedEnvironment();
enviroment.addGroup(group);
enviroment.forceInstall();
LinkedUIControl ui= new LinkedUIControl(enviroment, viewer);
// ui.setInitialOffset(offset);
ui.setExitPosition(viewer, offset, 0, LinkedPositionGroup.NO_STOP);
ui.enter();
fSelectedRegion= ui.getSelectedRegion();
} catch (BadLocationException e) {
JavaPlugin.log(e);
}
}
/*
* @see ICompletionProposal#apply(IDocument)
*/
public void apply(IDocument document) {
// can't do anything
}
/*
* @see ICompletionProposal#getSelection(IDocument)
*/
public Point getSelection(IDocument document) {
return new Point(fSelectedRegion.getOffset(), fSelectedRegion.getLength());
}
/*
* @see ICompletionProposal#getAdditionalProposalInfo()
*/
public String getAdditionalProposalInfo() {
return CorrectionMessages.getString("LinkedNamesAssistProposal.proposalinfo"); //$NON-NLS-1$
}
/*
* @see ICompletionProposal#getDisplayString()
*/
public String getDisplayString() {
return CorrectionMessages.getString("LinkedNamesAssistProposal.description"); //$NON-NLS-1$
}
/*
* @see ICompletionProposal#getImage()
*/
public Image getImage() {
return JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
}
/*
* @see ICompletionProposal#getContextInformation()
*/
public IContextInformation getContextInformation() {
return null;
}
/*
* @see IJavaCompletionProposal#getRelevance()
*/
public int getRelevance() {
return 1;
}
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer, boolean)
*/
public void selected(ITextViewer textViewer, boolean smartToggle) {
}
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
*/
public void unselected(ITextViewer textViewer) {
}
/* (non-Javadoc)
* @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
*/
public boolean validate(IDocument document, int offset, DocumentEvent event) {
return false;
}
}
|
51,093 |
Bug 51093 [typing] Pressing enter after an opening curly brace closes the curly brace repeatedly.
|
Pressing enter after an opening curly brace closes the curly brace repeatedly. IF you are about to define a method and you open a curly brace, the completion closing curly brace is added automatically. If you go and press "enter" again in front of the opening curly brace , it adds another closing brace repeatedly.
|
resolved fixed
|
3377f2d
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-13T09:42:10Z | 2004-02-03T09:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/JavaAutoIndentStrategy.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
* Nikolay Metchev - Fixed bug 29909
*******************************************************************************/
package org.eclipse.jdt.internal.ui.text.java;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultAutoIndentStrategy;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.DocumentCommand;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.jface.text.rules.DefaultPartitioner;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.texteditor.ITextEditorExtension3;
import org.eclipse.jdt.core.ToolFactory;
import org.eclipse.jdt.core.compiler.IProblem;
import org.eclipse.jdt.core.compiler.IScanner;
import org.eclipse.jdt.core.compiler.ITerminalSymbols;
import org.eclipse.jdt.core.compiler.InvalidInputException;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.DoStatement;
import org.eclipse.jdt.core.dom.Expression;
import org.eclipse.jdt.core.dom.ForStatement;
import org.eclipse.jdt.core.dom.IfStatement;
import org.eclipse.jdt.core.dom.Statement;
import org.eclipse.jdt.core.dom.WhileStatement;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.internal.corext.Assert;
import org.eclipse.jdt.internal.corext.dom.NodeFinder;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.text.FastJavaPartitionScanner;
import org.eclipse.jdt.internal.ui.text.IJavaPartitions;
import org.eclipse.jdt.internal.ui.text.JavaHeuristicScanner;
import org.eclipse.jdt.internal.ui.text.JavaIndenter;
import org.eclipse.jdt.internal.ui.text.Symbols;
/**
* Auto indent strategy sensitive to brackets.
*/
public class JavaAutoIndentStrategy extends DefaultAutoIndentStrategy {
/** The line comment introducer. Value is "{@value}" */
private static final String LINE_COMMENT= "//"; //$NON-NLS-1$
private static class CompilationUnitInfo {
char[] buffer;
int delta;
CompilationUnitInfo(char[] buffer, int delta) {
this.buffer= buffer;
this.delta= delta;
}
}
private boolean fCloseBrace;
private boolean fIsSmartMode;
private String fPartitioning;
/**
* Creates a new Java auto indent strategy for the given document partitioning.
*
* @param partitioning the document partitioning
*/
public JavaAutoIndentStrategy(String partitioning) {
fPartitioning= partitioning;
}
private int getBracketCount(IDocument d, int startOffset, int endOffset, boolean ignoreCloseBrackets) throws BadLocationException {
int bracketCount= 0;
while (startOffset < endOffset) {
char curr= d.getChar(startOffset);
startOffset++;
switch (curr) {
case '/' :
if (startOffset < endOffset) {
char next= d.getChar(startOffset);
if (next == '*') {
// a comment starts, advance to the comment end
startOffset= getCommentEnd(d, startOffset + 1, endOffset);
} else if (next == '/') {
// '//'-comment: nothing to do anymore on this line
startOffset= endOffset;
}
}
break;
case '*' :
if (startOffset < endOffset) {
char next= d.getChar(startOffset);
if (next == '/') {
// we have been in a comment: forget what we read before
bracketCount= 0;
startOffset++;
}
}
break;
case '{' :
bracketCount++;
ignoreCloseBrackets= false;
break;
case '}' :
if (!ignoreCloseBrackets) {
bracketCount--;
}
break;
case '"' :
case '\'' :
startOffset= getStringEnd(d, startOffset, endOffset, curr);
break;
default :
}
}
return bracketCount;
}
// ----------- bracket counting ------------------------------------------------------
private int getCommentEnd(IDocument d, int offset, int endOffset) throws BadLocationException {
while (offset < endOffset) {
char curr= d.getChar(offset);
offset++;
if (curr == '*') {
if (offset < endOffset && d.getChar(offset) == '/') {
return offset + 1;
}
}
}
return endOffset;
}
private String getIndentOfLine(IDocument d, int line) throws BadLocationException {
if (line > -1) {
int start= d.getLineOffset(line);
int end= start + d.getLineLength(line) - 1;
int whiteEnd= findEndOfWhiteSpace(d, start, end);
return d.get(start, whiteEnd - start);
} else {
return ""; //$NON-NLS-1$
}
}
private int getStringEnd(IDocument d, int offset, int endOffset, char ch) throws BadLocationException {
while (offset < endOffset) {
char curr= d.getChar(offset);
offset++;
if (curr == '\\') {
// ignore escaped characters
offset++;
} else if (curr == ch) {
return offset;
}
}
return endOffset;
}
private void smartIndentAfterClosingBracket(IDocument d, DocumentCommand c) {
if (c.offset == -1 || d.getLength() == 0)
return;
try {
int p= (c.offset == d.getLength() ? c.offset - 1 : c.offset);
int line= d.getLineOfOffset(p);
int start= d.getLineOffset(line);
int whiteend= findEndOfWhiteSpace(d, start, c.offset);
JavaHeuristicScanner scanner= new JavaHeuristicScanner(d);
JavaIndenter indenter= new JavaIndenter(d, scanner);
// shift only when line does not contain any text up to the closing bracket
if (whiteend == c.offset) {
// evaluate the line with the opening bracket that matches out closing bracket
int reference= indenter.findReferencePosition(c.offset, false, true, false, false);
int indLine= d.getLineOfOffset(reference);
if (indLine != -1 && indLine != line) {
// take the indent of the found line
StringBuffer replaceText= new StringBuffer(getIndentOfLine(d, indLine));
// add the rest of the current line including the just added close bracket
replaceText.append(d.get(whiteend, c.offset - whiteend));
replaceText.append(c.text);
// modify document command
c.length += c.offset - start;
c.offset= start;
c.text= replaceText.toString();
}
}
} catch (BadLocationException e) {
JavaPlugin.log(e);
}
}
private void smartIndentAfterOpeningBracket(IDocument d, DocumentCommand c) {
if (c.offset < 1 || d.getLength() == 0)
return;
JavaHeuristicScanner scanner= new JavaHeuristicScanner(d);
int p= (c.offset == d.getLength() ? c.offset - 1 : c.offset);
try {
// current line
int line= d.getLineOfOffset(p);
int lineOffset= d.getLineOffset(line);
// make sure we don't have any leading comments etc.
if (d.get(lineOffset, p - lineOffset).trim().length() != 0)
return;
// line of last javacode
int pos= scanner.findNonWhitespaceBackward(p, JavaHeuristicScanner.UNBOUND);
if (pos == -1)
return;
int lastLine= d.getLineOfOffset(pos);
// only shift if the last java line is further up and is a braceless block candidate
if (lastLine < line) {
JavaIndenter indenter= new JavaIndenter(d, scanner);
StringBuffer indent= indenter.computeIndentation(p, true);
if (indent != null) {
c.text= indent.append(c.text).toString();
c.length += c.offset - lineOffset;
c.offset= lineOffset;
}
}
} catch (BadLocationException e) {
JavaPlugin.log(e);
}
}
private void smartIndentAfterNewLine(IDocument d, DocumentCommand c) {
JavaHeuristicScanner scanner= new JavaHeuristicScanner(d);
JavaIndenter indenter= new JavaIndenter(d, scanner);
StringBuffer indent= indenter.computeIndentation(c.offset);
if (indent == null)
indent= new StringBuffer(); //$NON-NLS-1$
int docLength= d.getLength();
if (c.offset == -1 || docLength == 0)
return;
try {
int p= (c.offset == docLength ? c.offset - 1 : c.offset);
int line= d.getLineOfOffset(p);
StringBuffer buf= new StringBuffer(c.text + indent);
IRegion reg= d.getLineInformation(line);
int lineEnd= reg.getOffset() + reg.getLength();
int contentStart= findEndOfWhiteSpace(d, c.offset, lineEnd);
c.length= Math.max(contentStart - c.offset, 0);
int start= reg.getOffset();
ITypedRegion region= TextUtilities.getPartition(d, fPartitioning, start);
if (IJavaPartitions.JAVA_DOC.equals(region.getType()))
start= d.getLineInformationOfOffset(region.getOffset()).getOffset();
if (getBracketCount(d, start, c.offset, true) > 0 && closeBrace() && !isClosed(d, c.offset, c.length)) {
c.caretOffset= c.offset + buf.length();
c.shiftsCaret= false;
// copy old content of line behind insertion point to new line
// unless we think we are inserting an anonymous type definition
if (c.offset == 0 || !(computeAnonymousPosition(d, c.offset - 1, fPartitioning, lineEnd) != -1)) {
if (lineEnd - contentStart > 0) {
c.length= lineEnd - c.offset;
buf.append(d.get(contentStart, lineEnd - contentStart).toCharArray());
}
}
buf.append(getLineDelimiter(d));
StringBuffer reference= indenter.getReferenceIndentation(c.offset);
if (reference != null)
buf.append(reference);
buf.append('}');
}
c.text= buf.toString();
} catch (BadLocationException e) {
JavaPlugin.log(e);
}
}
/**
* Computes an insert position for an opening brace if <code>offset</code> maps to a position in
* <code>document</code> with a expression in parenthesis that will take a block after the closing parenthesis.
*
* @param document the document being modified
* @param offset the offset of the caret position, relative to the line start.
* @param partitioning the document partitioning
* @param max the max position
* @return an insert position relative to the line start if <code>line</code> contains a parenthesized expression that can be followed by a block, -1 otherwise
*/
private static int computeAnonymousPosition(IDocument document, int offset, String partitioning, int max) {
// find the opening parenthesis for every closing parenthesis on the current line after offset
// return the position behind the closing parenthesis if it looks like a method declaration
// or an expression for an if, while, for, catch statement
JavaHeuristicScanner scanner= new JavaHeuristicScanner(document);
int pos= offset;
int length= max;
int scanTo= scanner.scanForward(pos, length, '}');
if (scanTo == -1)
scanTo= length;
int closingParen= findClosingParenToLeft(scanner, pos) - 1;
while (true) {
int startScan= closingParen + 1;
closingParen= scanner.scanForward(startScan, scanTo, ')');
if (closingParen == -1)
break;
int openingParen= scanner.findOpeningPeer(closingParen - 1, '(', ')');
// no way an expression at the beginning of the document can mean anything
if (openingParen < 1)
break;
// only select insert positions for parenthesis currently embracing the caret
if (openingParen > pos)
continue;
if (looksLikeAnonymousClassDef(document, partitioning, scanner, openingParen - 1))
return closingParen + 1;
}
return -1;
}
/**
* Finds a closing parenthesis to the left of <code>position</code> in document, where that parenthesis is only
* separated by whitespace from <code>position</code>. If no such parenthesis can be found, <code>position</code> is returned.
*
* @param document the document being modified
* @param position the first character position in <code>document</code> to be considered
* @param partitioning the document partitioning
* @return the position of a closing parenthesis left to <code>position</code> separated only by whitespace, or <code>position</code> if no parenthesis can be found
*/
private static int findClosingParenToLeft(JavaHeuristicScanner scanner, int position) {
if (position < 1)
return position;
if (scanner.previousToken(position - 1, JavaHeuristicScanner.UNBOUND) == Symbols.TokenRPAREN)
return scanner.getPosition() + 1;
return position;
}
/**
* Checks whether the content of <code>document</code> in the range (<code>offset</code>, <code>length</code>)
* contains the <code>new</code> keyword.
*
* @param document the document being modified
* @param offset the first character position in <code>document</code> to be considered
* @param length the length of the character range to be considered
* @param partitioning the document partitioning
* @return <code>true</code> if the specified character range contains a <code>new</code> keyword, <code>false</code> otherwise.
*/
private static boolean isNewMatch(IDocument document, int offset, int length, String partitioning) {
Assert.isTrue(length >= 0);
Assert.isTrue(offset >= 0);
Assert.isTrue(offset + length < document.getLength() + 1);
try {
String text= document.get(offset, length);
int pos= text.indexOf("new"); //$NON-NLS-1$
while (pos != -1 && !isDefaultPartition(document, pos + offset, partitioning))
pos= text.indexOf("new", pos + 2); //$NON-NLS-1$
if (pos < 0)
return false;
if (pos != 0 && Character.isJavaIdentifierPart(text.charAt(pos - 1)))
return false;
if (pos + 3 < length && Character.isJavaIdentifierPart(text.charAt(pos + 3)))
return false;
return true;
} catch (BadLocationException e) {
}
return false;
}
/**
* Checks whether the content of <code>document</code> at <code>position</code> looks like an
* anonymous class definition. <code>position</code> must be to the left of the opening
* parenthesis of the definition's parameter list.
*
* @param document the document being modified
* @param position the first character position in <code>document</code> to be considered
* @param partitioning the document partitioning
* @return <code>true</code> if the content of <code>document</code> looks like an anonymous class definition, <code>false</code> otherwise
*/
private static boolean looksLikeAnonymousClassDef(IDocument document, String partitioning, JavaHeuristicScanner scanner, int position) {
int previousCommaOrParen= scanner.scanBackward(position - 1, JavaHeuristicScanner.UNBOUND, new char[] {',', '('});
if (previousCommaOrParen == -1 || position < previousCommaOrParen + 5) // 2 for borders, 3 for "new"
return false;
if (isNewMatch(document, previousCommaOrParen + 1, position - previousCommaOrParen - 2, partitioning))
return true;
return false;
}
/**
* Checks whether <code>position</code> resides in a default (Java) partition of <code>document</code>.
*
* @param document the document being modified
* @param position the position to be checked
* @param partitioning the document partitioning
* @return <code>true</code> if <code>position</code> is in the default partition of <code>document</code>, <code>false</code> otherwise
*/
private static boolean isDefaultPartition(IDocument document, int position, String partitioning) {
Assert.isTrue(position >= 0);
Assert.isTrue(position <= document.getLength());
try {
ITypedRegion region= TextUtilities.getPartition(document, partitioning, position);
return region.getType().equals(IDocument.DEFAULT_CONTENT_TYPE);
} catch (BadLocationException e) {
}
return false;
}
private boolean isClosed(IDocument document, int offset, int length) {
CompilationUnitInfo info= getCompilationUnitForMethod(document, offset, fPartitioning);
if (info == null)
return false;
CompilationUnit compilationUnit= null;
try {
compilationUnit= AST.parseCompilationUnit(info.buffer);
} catch (ArrayIndexOutOfBoundsException x) {
// work around for parser problem
return false;
}
IProblem[] problems= compilationUnit.getProblems();
for (int i= 0; i != problems.length; ++i) {
if (problems[i].getID() == IProblem.UnmatchedBracket)
return true;
}
final int relativeOffset= offset - info.delta;
ASTNode node= NodeFinder.perform(compilationUnit, relativeOffset, length);
if (node == null)
return false;
if (length == 0) {
while (node != null && (relativeOffset == node.getStartPosition() || relativeOffset == node.getStartPosition() + node.getLength()))
node= node.getParent();
}
switch (node.getNodeType()) {
case ASTNode.BLOCK:
return areBlocksConsistent(document, offset, fPartitioning);
case ASTNode.IF_STATEMENT:
{
IfStatement ifStatement= (IfStatement) node;
Expression expression= ifStatement.getExpression();
IRegion expressionRegion= createRegion(expression, info.delta);
Statement thenStatement= ifStatement.getThenStatement();
IRegion thenRegion= createRegion(thenStatement, info.delta);
// between expression and then statement
if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= thenRegion.getOffset())
return thenStatement != null;
Statement elseStatement= ifStatement.getElseStatement();
IRegion elseRegion= createRegion(elseStatement, info.delta);
IRegion elseToken= null;
if (elseStatement != null) {
int sourceOffset= thenRegion.getOffset() + thenRegion.getLength();
int sourceLength= elseRegion.getOffset() - sourceOffset;
elseToken= getToken(document, new Region(sourceOffset, sourceLength), ITerminalSymbols.TokenNameelse);
}
// between 'else' keyword and else statement
if (elseToken.getOffset() + elseToken.getLength() <= offset && offset + length < elseRegion.getOffset())
return elseStatement != null;
}
break;
case ASTNode.WHILE_STATEMENT:
case ASTNode.FOR_STATEMENT:
{
Expression expression= node.getNodeType() == ASTNode.WHILE_STATEMENT ? ((WhileStatement) node).getExpression() : ((ForStatement) node).getExpression();
IRegion expressionRegion= createRegion(expression, info.delta);
Statement body= node.getNodeType() == ASTNode.WHILE_STATEMENT ? ((WhileStatement) node).getBody() : ((ForStatement) node).getBody();
IRegion bodyRegion= createRegion(body, info.delta);
// between expression and body statement
if (expressionRegion.getOffset() + expressionRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset())
return body != null;
}
break;
case ASTNode.DO_STATEMENT:
{
DoStatement doStatement= (DoStatement) node;
IRegion doRegion= createRegion(doStatement, info.delta);
Statement body= doStatement.getBody();
IRegion bodyRegion= createRegion(body, info.delta);
if (doRegion.getOffset() + doRegion.getLength() <= offset && offset + length <= bodyRegion.getOffset())
return body != null;
}
break;
}
return true;
}
private static String getLineDelimiter(IDocument document) {
try {
if (document.getNumberOfLines() > 1)
return document.getLineDelimiter(0);
} catch (BadLocationException e) {
JavaPlugin.log(e);
}
return System.getProperty("line.separator"); //$NON-NLS-1$
}
/**
* Installs a java partitioner with <code>document</code>.
*
* @param document the document
*/
private static void installJavaStuff(Document document) {
String[] types= new String[] {
IJavaPartitions.JAVA_DOC,
IJavaPartitions.JAVA_MULTI_LINE_COMMENT,
IJavaPartitions.JAVA_SINGLE_LINE_COMMENT,
IJavaPartitions.JAVA_STRING,
IJavaPartitions.JAVA_CHARACTER,
IDocument.DEFAULT_CONTENT_TYPE
};
DefaultPartitioner partitioner= new DefaultPartitioner(new FastJavaPartitionScanner(), types);
partitioner.connect(document);
document.setDocumentPartitioner(IJavaPartitions.JAVA_PARTITIONING, partitioner);
}
private static void smartPaste(IDocument document, DocumentCommand command) {
try {
JavaHeuristicScanner scanner= new JavaHeuristicScanner(document);
JavaIndenter indenter= new JavaIndenter(document, scanner);
int offset= command.offset;
// reference position to get the indent from
int refOffset= indenter.findReferencePosition(offset);
if (refOffset == JavaHeuristicScanner.NOT_FOUND)
return;
int peerOffset= getPeerPosition(document, command);
peerOffset= indenter.findReferencePosition(peerOffset);
refOffset= Math.min(refOffset, peerOffset);
// eat any WS before the insertion to the beginning of the line
int firstLine= 1; // don't format the first line per default, as it has other content before it
IRegion line= document.getLineInformationOfOffset(offset);
String notSelected= document.get(line.getOffset(), offset - line.getOffset());
if (notSelected.trim().length() == 0) {
command.length += notSelected.length();
command.offset= line.getOffset();
firstLine= 0;
}
// prefix: the part we need for formatting but won't paste
IRegion refLine= document.getLineInformationOfOffset(refOffset);
String prefix= document.get(refLine.getOffset(), command.offset - refLine.getOffset());
// handle the indentation computation inside a temporary document
Document temp= new Document(prefix + command.text);
scanner= new JavaHeuristicScanner(temp);
indenter= new JavaIndenter(temp, scanner);
installJavaStuff(temp);
// indent the first and second line
// compute the relative indentation difference from the second line
// (as the first might be partially selected) and use the value to
// indent all other lines.
boolean isIndentDetected= false;
StringBuffer addition= new StringBuffer();
int insertLength= 0;
int first= document.computeNumberOfLines(prefix) + firstLine; // don't format first line
int lines= temp.getNumberOfLines();
for (int l= first; l < lines; l++) { // we don't change the number of lines while adding indents
IRegion r= temp.getLineInformation(l);
int lineOffset= r.getOffset();
int lineLength= r.getLength();
if (lineLength == 0) // don't modify empty lines
continue;
if (!isIndentDetected){
// indent the first pasted line
String current= getCurrentIndent(temp, l);
StringBuffer correct= indenter.computeIndentation(lineOffset);
if (correct == null)
return; // bail out
insertLength= subtractIndent(correct, current, addition);
if (l != first)
isIndentDetected= true;
}
// relatively indent all pasted lines
if (insertLength > 0)
addIndent(temp, l, addition);
else if (insertLength < 0)
cutIndent(temp, l, -insertLength);
}
// modify the command
command.text= temp.get(prefix.length(), temp.getLength() - prefix.length());
} catch (BadLocationException e) {
JavaPlugin.log(e);
}
}
/**
* Returns the indentation of the line <code>line</code> in <code>document</code>.
* The returned string may contain pairs of leading slashes that are considered
* part of the indentation. The space before the asterix in a javadoc-like
* comment is not considered part of the indentation.
*
* @param document the document
* @param line the line
* @return the indentation of <code>line</code> in <code>document</code>
* @throws BadLocationException if the document is changed concurrently
*/
private static String getCurrentIndent(Document document, int line) throws BadLocationException {
IRegion region= document.getLineInformation(line);
int from= region.getOffset();
int endOffset= region.getOffset() + region.getLength();
// go behind line comments
int to= from;
while (to < endOffset - 2 && document.get(to, 2).equals(LINE_COMMENT))
to += 2;
while (to < endOffset) {
char ch= document.getChar(to);
if (!Character.isWhitespace(ch))
break;
to++;
}
// don't count the space before javadoc like, asterix-style comment lines
if (to > from && to < endOffset - 1 && document.get(to - 1, 2).equals(" *")) { //$NON-NLS-1$
String type= TextUtilities.getContentType(document, IJavaPartitions.JAVA_PARTITIONING, to);
if (type.equals(IJavaPartitions.JAVA_DOC) || type.equals(IJavaPartitions.JAVA_MULTI_LINE_COMMENT))
to--;
}
return document.get(from, to - from);
}
/**
* Computes the difference of two indentations and returns the difference in
* length of current and correct. If the return value is positive, <code>addition</code>
* is initialized with a substring of that length of <code>correct</code>.
*
* @param correct the correct indentation
* @param current the current indentation (migth contain non-whitespace)
* @param difference a string buffer - if the return value is positive, it will be cleared and set to the substring of <code>current</code> of that length
* @return the difference in lenght of <code>correct</code> and <code>current</code>
*/
private static int subtractIndent(CharSequence correct, CharSequence current, StringBuffer difference) {
int c1= computeVisualLength(correct);
int c2= computeVisualLength(current);
int diff= c1 - c2;
if (diff <= 0)
return diff;
difference.setLength(0);
int len= 0, i= 0;
while (len < diff) {
char c= correct.charAt(i++);
difference.append(c);
len += computeVisualLength(c);
}
return diff;
}
/**
* Indents line <code>line</code> in <code>document</code> with <code>indent</code>.
* Leaves leading comment signs alone.
*
* @param document the document
* @param line the line
* @param indent the indentation to insert
* @throws BadLocationException on concurrent document modification
*/
private static void addIndent(Document document, int line, CharSequence indent) throws BadLocationException {
IRegion region= document.getLineInformation(line);
int insert= region.getOffset();
int endOffset= region.getOffset() + region.getLength();
// go behind line comments
while (insert < endOffset - 2 && document.get(insert, 2).equals(LINE_COMMENT))
insert += 2;
// insert indent
document.replace(insert, 0, indent.toString());
}
/**
* Cuts the visual equivalent of <code>toDelete</code> characters out of the
* indentation of line <code>line</code> in <code>document</code>. Leaves
* leading comment signs alone.
*
* @param document the document
* @param line the line
* @param toDelete the number of space equivalents to delete.
* @throws BadLocationException on concurrent document modification
*/
private static void cutIndent(Document document, int line, int toDelete) throws BadLocationException {
IRegion region= document.getLineInformation(line);
int from= region.getOffset();
int endOffset= region.getOffset() + region.getLength();
// go behind line comments
while (from < endOffset - 2 && document.get(from, 2).equals(LINE_COMMENT))
from += 2;
int to= from;
while (toDelete > 0 && to < endOffset) {
char ch= document.getChar(to);
if (!Character.isWhitespace(ch))
break;
toDelete -= computeVisualLength(ch);
if (toDelete >= 0)
to++;
else
break;
}
document.replace(from, to - from, null);
}
/**
* Returns the visual length of a given <code>CharSequence</code> taking into
* account the visual tabulator length.
*
* @param seq the string to measure
* @return the visual length of <code>seq</code>
*/
private static int computeVisualLength(CharSequence seq) {
int size= 0;
int tablen= getVisualTabLengthPreference();
for (int i= 0; i < seq.length(); i++) {
char ch= seq.charAt(i);
if (ch == '\t')
size += tablen - size % tablen;
else
size++;
}
return size;
}
/**
* Returns the visual length of a given character taking into
* account the visual tabulator length.
*
* @param ch the character to measure
* @return the visual length of <code>ch</code>
*/
private static int computeVisualLength(char ch) {
if (ch == '\t')
return getVisualTabLengthPreference();
else
return 1;
}
/**
* The preference setting for the visual tabulator display.
*
* @return the number of spaces displayed for a tabulator in the editor
*/
private static int getVisualTabLengthPreference() {
return JavaPlugin.getDefault().getPreferenceStore().getInt(PreferenceConstants.EDITOR_TAB_WIDTH);
}
private static int getPeerPosition(IDocument document, DocumentCommand command) {
/*
* Search for scope closers in the pasted text and find their opening peers
* in the document.
*/
Document pasted= new Document(command.text);
installJavaStuff(pasted);
int firstPeer= command.offset;
JavaHeuristicScanner pScanner= new JavaHeuristicScanner(pasted);
JavaHeuristicScanner dScanner= new JavaHeuristicScanner(document);
// add scope relevant after context to peer search
int afterToken= dScanner.nextToken(command.offset + command.length, JavaHeuristicScanner.UNBOUND);
try {
switch (afterToken) {
case Symbols.TokenRBRACE:
pasted.replace(pasted.getLength(), 0, "}"); //$NON-NLS-1$
break;
case Symbols.TokenRPAREN:
pasted.replace(pasted.getLength(), 0, ")"); //$NON-NLS-1$
break;
case Symbols.TokenRBRACKET:
pasted.replace(pasted.getLength(), 0, "]"); //$NON-NLS-1$
break;
}
} catch (BadLocationException e) {
// cannot happen
Assert.isTrue(false);
}
int pPos= 0; // paste text position (increasing from 0)
int dPos= Math.max(0, command.offset - 1); // document position (decreasing from paste offset)
while (true) {
int token= pScanner.nextToken(pPos, JavaHeuristicScanner.UNBOUND);
pPos= pScanner.getPosition();
switch (token) {
case Symbols.TokenLBRACE:
case Symbols.TokenLBRACKET:
case Symbols.TokenLPAREN:
pPos= skipScope(pScanner, pPos, token);
if (pPos == JavaHeuristicScanner.NOT_FOUND)
return firstPeer;
break; // closed scope -> keep searching
case Symbols.TokenRBRACE:
int peer= dScanner.findOpeningPeer(dPos, '{', '}');
dPos= peer - 1;
if (peer == JavaHeuristicScanner.NOT_FOUND)
return firstPeer;
firstPeer= peer;
break; // keep searching
case Symbols.TokenRBRACKET:
peer= dScanner.findOpeningPeer(dPos, '[', ']');
dPos= peer - 1;
if (peer == JavaHeuristicScanner.NOT_FOUND)
return firstPeer;
firstPeer= peer;
break; // keep searching
case Symbols.TokenRPAREN:
peer= dScanner.findOpeningPeer(dPos, '(', ')');
dPos= peer - 1;
if (peer == JavaHeuristicScanner.NOT_FOUND)
return firstPeer;
firstPeer= peer;
break; // keep searching
case Symbols.TokenCASE:
case Symbols.TokenDEFAULT:
JavaIndenter indenter= new JavaIndenter(document, dScanner);
peer= indenter.findReferencePosition(dPos, false, false, false, true);
if (peer == JavaHeuristicScanner.NOT_FOUND)
return firstPeer;
firstPeer= peer;
break; // keep searching
case Symbols.TokenEOF:
return firstPeer;
default:
// keep searching
}
}
}
/**
* Skips the scope opened by <code>token</code> in <code>document</code>,
* returns either the position of the
* @param pos
* @param token
* @return
*/
private static int skipScope(JavaHeuristicScanner scanner, int pos, int token) {
int openToken= token;
int closeToken;
switch (token) {
case Symbols.TokenLPAREN:
closeToken= Symbols.TokenRPAREN;
break;
case Symbols.TokenLBRACKET:
closeToken= Symbols.TokenRBRACKET;
break;
case Symbols.TokenLBRACE:
closeToken= Symbols.TokenRBRACE;
break;
default:
Assert.isTrue(false);
return -1; // dummy
}
int depth= 1;
int p= pos;
while (true) {
int tok= scanner.nextToken(p, JavaHeuristicScanner.UNBOUND);
p= scanner.getPosition();
if (tok == openToken) {
depth++;
} else if (tok == closeToken) {
depth--;
if (depth == 0)
return p + 1;
} else if (tok == Symbols.TokenEOF) {
return JavaHeuristicScanner.NOT_FOUND;
}
}
}
private boolean isLineDelimiter(IDocument document, String text) {
String[] delimiters= document.getLegalLineDelimiters();
if (delimiters != null)
return TextUtilities.equals(delimiters, text) > -1;
return false;
}
private void smartIndentAfterBlockDelimiter(IDocument document, DocumentCommand command) {
if (command.text.charAt(0) == '}')
smartIndentAfterClosingBracket(document, command);
else if (command.text.charAt(0) == '{')
smartIndentAfterOpeningBracket(document, command);
}
/*
* @see org.eclipse.jface.text.IAutoIndentStrategy#customizeDocumentCommand(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.DocumentCommand)
*/
public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
if (c.doit == false)
return;
clearCachedValues();
if (!isSmartMode()) {
super.customizeDocumentCommand(d, c);
return;
}
if (c.length == 0 && c.text != null && isLineDelimiter(d, c.text))
smartIndentAfterNewLine(d, c);
else if (c.text.length() == 1)
smartIndentAfterBlockDelimiter(d, c);
else if (c.text.length() > 1 && getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_PASTE))
smartPaste(d, c);
}
private static IPreferenceStore getPreferenceStore() {
return JavaPlugin.getDefault().getPreferenceStore();
}
private boolean closeBrace() {
return fCloseBrace;
}
private boolean isSmartMode() {
return fIsSmartMode;
}
private void clearCachedValues() {
IPreferenceStore preferenceStore= getPreferenceStore();
fCloseBrace= preferenceStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_BRACES);
fIsSmartMode= computeSmartMode();
}
private boolean computeSmartMode() {
IWorkbenchPage page= JavaPlugin.getActivePage();
if (page != null) {
IEditorPart part= page.getActiveEditor();
if (part instanceof ITextEditorExtension3) {
ITextEditorExtension3 extension= (ITextEditorExtension3) part;
return extension.getInsertMode() == ITextEditorExtension3.SMART_INSERT;
}
}
return false;
}
private static CompilationUnitInfo getCompilationUnitForMethod(IDocument document, int offset, String partitioning) {
try {
JavaHeuristicScanner scanner= new JavaHeuristicScanner(document);
IRegion sourceRange= scanner.findSurroundingBlock(offset);
if (sourceRange == null)
return null;
String source= document.get(sourceRange.getOffset(), sourceRange.getLength());
StringBuffer contents= new StringBuffer();
contents.append("class ____C{void ____m()"); //$NON-NLS-1$
final int methodOffset= contents.length();
contents.append(source);
contents.append('}');
char[] buffer= contents.toString().toCharArray();
return new CompilationUnitInfo(buffer, sourceRange.getOffset() - methodOffset);
} catch (BadLocationException e) {
JavaPlugin.log(e);
}
return null;
}
private static boolean areBlocksConsistent(IDocument document, int offset, String partitioning) {
if (offset < 1 || offset >= document.getLength())
return false;
int begin= offset;
int end= offset - 1;
JavaHeuristicScanner scanner= new JavaHeuristicScanner(document);
while (true) {
begin= scanner.findOpeningPeer(begin - 1, '{', '}');
end= scanner.findClosingPeer(end + 1, '{', '}');
if (begin == -1 && end == -1)
return true;
if (begin == -1 || end == -1)
return false;
}
}
private static IRegion createRegion(ASTNode node, int delta) {
return node == null ? null : new Region(node.getStartPosition() + delta, node.getLength());
}
private static IRegion getToken(IDocument document, IRegion scanRegion, int tokenId) {
try {
final String source= document.get(scanRegion.getOffset(), scanRegion.getLength());
IScanner scanner= ToolFactory.createScanner(false, false, false, false);
scanner.setSource(source.toCharArray());
int id= scanner.getNextToken();
while (id != ITerminalSymbols.TokenNameEOF && id != tokenId)
id= scanner.getNextToken();
if (id == ITerminalSymbols.TokenNameEOF)
return null;
int tokenOffset= scanner.getCurrentTokenStartPosition();
int tokenLength= scanner.getCurrentTokenEndPosition() + 1 - tokenOffset; // inclusive end
return new Region(tokenOffset + scanRegion.getOffset(), tokenLength);
} catch (InvalidInputException x) {
return null;
} catch (BadLocationException x) {
return null;
}
}
}
|
51,644 |
Bug 51644 [typing] The word "squigglies" does not exist
|
I200402102000 We can either use "squiggles" or "squiggly lines"
|
resolved fixed
|
9f1ca64
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-13T14:19:04Z | 2004-02-11T14:33:20Z |
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.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.ExtendedTextEditorPreferenceConstants;
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.IJavaPartitions;
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.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"), ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR}, //$NON-NLS-1$
{PreferencesMessages.getString("JavaEditorPreferencePage.matchingBracketsHighlightColor2"), PreferenceConstants.EDITOR_MATCHING_BRACKETS_COLOR}, //$NON-NLS-1$
{PreferencesMessages.getString("JavaEditorPreferencePage.currentLineHighlighColor"), ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR}, //$NON-NLS-1$
{PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColor2"), ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR}, //$NON-NLS-1$
{PreferencesMessages.getString("JavaEditorPreferencePage.findScopeColor2"), PreferenceConstants.EDITOR_FIND_SCOPE_COLOR}, //$NON-NLS-1$
{PreferencesMessages.getString("JavaEditorPreferencePage.linkColor2"), PreferenceConstants.EDITOR_LINK_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.SQUIGGLIES"), AnnotationPreference.STYLE_SQUIGGLIES}, //$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 JavaTextTools fJavaTextTools;
private JavaEditorHoverConfigurationBlock fJavaEditorHoverConfigurationBlock;
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 ColorEditor fAnnotationForegroundColorEditor;
private ColorEditor fContentAssistColorEditor;
private ColorEditor fBackgroundColorEditor;
private Button fBackgroundDefaultRadioButton;
private Button fBackgroundCustomRadioButton;
private Button fBackgroundColorButton;
private Button fBoldCheckBox;
private Button fAddJavaDocTagsButton;
private Button fEscapeStringsButton;
private Button fGuessMethodArgumentsButton;
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;
private Button fStickyOccurrencesButton;
/**
* 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.INT, PreferenceConstants.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_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, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OCCURRENCES));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STICKY_OCCURRENCES));
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, ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ExtendedTextEditorPreferenceConstants.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.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_SHOW_TEXT_HOVER_AFFORDANCE));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS));
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));
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);
}
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 squigglies 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) {
Preferences coreStore= createTemporaryCorePreferenceStore();
fJavaTextTools= new JavaTextTools(fOverlayStore, coreStore, false);
fPreviewViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
fPreviewViewer.configure(new JavaSourceViewerConfiguration(fJavaTextTools, null, IJavaPartitions.JAVA_PARTITIONING));
Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
fPreviewViewer.getTextWidget().setFont(font);
new JavaSourcePreviewerUpdater(fPreviewViewer, fJavaTextTools);
fPreviewViewer.setEditable(false);
String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
IDocument document= new Document(content);
fJavaTextTools.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, PreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
label= PreferencesMessages.getString("JavaEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
addTextField(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
label= PreferencesMessages.getString("JavaEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
label= PreferencesMessages.getString("JavaEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.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, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
label= PreferencesMessages.getString("JavaEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
addCheckBox(appearanceComposite, label, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
label= PreferencesMessages.getString("JavaEditorPreferencePage.markOccurrences"); //$NON-NLS-1$
Button master= addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_MARK_OCCURRENCES, 0); //$NON-NLS-1$
label= PreferencesMessages.getString("JavaEditorPreferencePage.stickyOccurrences"); //$NON-NLS-1$
fStickyOccurrencesButton= addCheckBox(appearanceComposite, label, PreferenceConstants.EDITOR_STICKY_OCCURRENCES, 0); //$NON-NLS-1$
createDependency(master, fStickyOccurrencesButton);
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);
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() {
/**
* {@inheritdoc}
*/
public void widgetDefaultSelected(SelectionEvent e) {
// do nothing
}
/**
* {@inheritdoc}
*/
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();
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 button= addCheckBox(group, label, PreferenceConstants.EDITOR_WRAP_STRINGS, 1);
label= PreferencesMessages.getString("JavaEditorPreferencePage.escapeStrings"); //$NON-NLS-1$
fEscapeStringsButton= addCheckBox(group, label, PreferenceConstants.EDITOR_ESCAPE_STRINGS, 1);
createDependency(button, fEscapeStringsButton);
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$
button= addCheckBox(group, label, PreferenceConstants.EDITOR_CLOSE_JAVADOCS, 1);
label= PreferencesMessages.getString("JavaEditorPreferencePage.addJavaDocTags"); //$NON-NLS-1$
fAddJavaDocTagsButton= addCheckBox(group, label, PreferenceConstants.EDITOR_ADD_JAVADOC_TAGS, 1);
createDependency(button, fAddJavaDocTagsButton);
// 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 static void createDependency(final Button master, final Control slave) {
indent(slave);
master.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
slave.setEnabled(master.getSelection());
}
public void widgetDefaultSelected(SelectionEvent e) {}
});
}
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.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 button= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES, 0);
label= PreferencesMessages.getString("JavaEditorPreferencePage.guessArgumentNamesOnMethodCompletion"); //$NON-NLS-1$
fGuessMethodArgumentsButton= addCheckBox(contentAssistComposite, label, PreferenceConstants.CODEASSIST_GUESS_METHOD_ARGUMENTS, 0);
createDependency(button, fGuessMethodArgumentsButton);
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();
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$
fJavaEditorHoverConfigurationBlock= new JavaEditorHoverConfigurationBlock(this, fOverlayStore);
item.setControl(fJavaEditorHoverConfigurationBlock.createControl(folder));
item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("JavaEditorPreferencePage.navigationTab.title")); //$NON-NLS-1$
item.setControl(createNavigationPage(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();
}
}
});
}
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 closeJavaDocs= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_CLOSE_JAVADOCS);
fAddJavaDocTagsButton.setEnabled(closeJavaDocs);
fEscapeStringsButton.setEnabled(fOverlayStore.getBoolean(PreferenceConstants.EDITOR_WRAP_STRINGS));
boolean fillMethodArguments= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES);
fGuessMethodArgumentsButton.setEnabled(fillMethodArguments);
boolean completionInserts= fOverlayStore.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION);
fCompletionInsertsRadioButton.setSelection(completionInserts);
fCompletionOverwritesRadioButton.setSelection(! completionInserts);
fBrowserLikeLinksKeyModifierText.setEnabled(fBrowserLikeLinksCheckBox.getSelection());
boolean markOccurrences= fOverlayStore.getBoolean(PreferenceConstants.EDITOR_MARK_OCCURRENCES);
fStickyOccurrencesButton.setEnabled(markOccurrences);
updateAutoactivationControls();
}
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);
}
}
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();
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();
super.performDefaults();
fPreviewViewer.invalidateTextPresentation();
}
/*
* @see DialogPage#dispose()
*/
public void dispose() {
if (fJavaTextTools != null) {
fJavaTextTools.dispose();
fJavaTextTools= null;
}
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.
*/
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 (!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(fJavaEditorHoverConfigurationBlock.getStatus(), status);
status= StatusUtil.getMoreSevere(getBrowserLikeLinksKeyModifierStatus(), status);
setValid(!status.matches(IStatus.ERROR));
StatusUtil.applyToStatusLine(this, status);
}
}
|
48,069 |
Bug 48069 [reconciling] Reconciling too much
|
Build 20031202 Whenever the editor gains focus; it is triggering a forced reconciliation. This is too naive, and wastes lots of cycles. e.g.: - open editor - select one element in outliner - go back to editor A reconciliation is triggered even though nothing has changed which requires this.
|
resolved fixed
|
391135f
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-13T15:42:59Z | 2003-12-04T15:00:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaReconciler.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;
import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.events.ShellListener;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.reconciler.MonoReconciler;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.texteditor.ITextEditor;
/**
* A reconciler that is also activated on editor activation.
*/
public class JavaReconciler extends MonoReconciler {
/**
* Internal part listener for activating the reconciler.
*/
class PartListener implements IPartListener {
/*
* @see IPartListener#partActivated(IWorkbenchPart)
*/
public void partActivated(IWorkbenchPart part) {
if (part == fTextEditor)
JavaReconciler.this.forceReconciling();
}
/*
* @see IPartListener#partBroughtToTop(IWorkbenchPart)
*/
public void partBroughtToTop(IWorkbenchPart part) {
}
/*
* @see IPartListener#partClosed(IWorkbenchPart)
*/
public void partClosed(IWorkbenchPart part) {
}
/*
* @see IPartListener#partDeactivated(IWorkbenchPart)
*/
public void partDeactivated(IWorkbenchPart part) {
}
/*
* @see IPartListener#partOpened(IWorkbenchPart)
*/
public void partOpened(IWorkbenchPart part) {
}
}
/**
* Internal Shell activation listener for activating the reconciler.
*/
class ActivationListener extends ShellAdapter {
private Control fControl;
public ActivationListener(Control control) {
fControl= control;
}
/*
* @see org.eclipse.swt.events.ShellAdapter#shellActivated(org.eclipse.swt.events.ShellEvent)
*/
public void shellActivated(ShellEvent e) {
if (!fControl.isDisposed() && fControl.isVisible())
JavaReconciler.this.forceReconciling();
}
}
/** The reconciler's editor */
private ITextEditor fTextEditor;
/** The part listener */
private IPartListener fPartListener;
/** The shell listener */
private ShellListener fActivationListener;
/**
* Creates a new reconciler.
*/
public JavaReconciler(ITextEditor editor, JavaCompositeReconcilingStrategy strategy, boolean isIncremental) {
super(strategy, isIncremental);
fTextEditor= editor;
}
/*
* @see IReconciler#install(ITextViewer)
*/
public void install(ITextViewer textViewer) {
super.install(textViewer);
fPartListener= new PartListener();
IWorkbenchPartSite site= fTextEditor.getSite();
IWorkbenchWindow window= site.getWorkbenchWindow();
window.getPartService().addPartListener(fPartListener);
fActivationListener= new ActivationListener(textViewer.getTextWidget());
Shell shell= window.getShell();
shell.addShellListener(fActivationListener);
}
/*
* @see IReconciler#uninstall()
*/
public void uninstall() {
IWorkbenchPartSite site= fTextEditor.getSite();
IWorkbenchWindow window= site.getWorkbenchWindow();
window.getPartService().removePartListener(fPartListener);
fPartListener= null;
Shell shell= window.getShell();
if (shell != null && !shell.isDisposed())
shell.removeShellListener(fActivationListener);
fActivationListener= null;
super.uninstall();
}
/*
* @see AbstractReconciler#forceReconciling()
*/
protected void forceReconciling() {
super.forceReconciling();
JavaCompositeReconcilingStrategy strategy= (JavaCompositeReconcilingStrategy) getReconcilingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
strategy.notifyParticipants(false);
}
/*
* @see AbstractReconciler#reconcilerReset()
*/
protected void reconcilerReset() {
super.reconcilerReset();
JavaCompositeReconcilingStrategy strategy= (JavaCompositeReconcilingStrategy) getReconcilingStrategy(IDocument.DEFAULT_CONTENT_TYPE);
strategy.notifyParticipants(true);
}
}
|
51,683 |
Bug 51683 Occurences In Exceptions: Not Javadoc aware
|
20040211 - Enable 'Mark Occurences' - Open java.ui.FileInputStream, close() - In the Javadoc comment select 'IOException' - In the signature select 'IOException': Not the same result
|
resolved fixed
|
73829cb
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-13T17:42:37Z | 2004-02-11T17:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/ExceptionOccurrencesFinder.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 java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTNode;
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.AnonymousClassDeclaration;
import org.eclipse.jdt.core.dom.CastExpression;
import org.eclipse.jdt.core.dom.CatchClause;
import org.eclipse.jdt.core.dom.ClassInstanceCreation;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jdt.core.dom.ConstructorInvocation;
import org.eclipse.jdt.core.dom.IMethodBinding;
import org.eclipse.jdt.core.dom.ITypeBinding;
import org.eclipse.jdt.core.dom.IVariableBinding;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.MethodInvocation;
import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SingleVariableDeclaration;
import org.eclipse.jdt.core.dom.SuperConstructorInvocation;
import org.eclipse.jdt.core.dom.SuperMethodInvocation;
import org.eclipse.jdt.core.dom.ThrowStatement;
import org.eclipse.jdt.core.dom.TryStatement;
import org.eclipse.jdt.core.dom.Type;
import org.eclipse.jdt.core.dom.TypeDeclarationStatement;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.ui.texteditor.MarkerUtilities;
import org.eclipse.search.ui.ISearchResultView;
import org.eclipse.search.ui.SearchUI;
import org.eclipse.jdt.internal.corext.dom.ASTNodes;
import org.eclipse.jdt.internal.corext.dom.Bindings;
import org.eclipse.jdt.internal.corext.dom.NodeFinder;
import org.eclipse.jdt.internal.ui.JavaPluginImages;
public class ExceptionOccurrencesFinder extends ASTVisitor implements IOccurrencesFinder {
public static final String IS_EXCEPTION= "isException"; //$NON-NLS-1$
private AST fAST;
private Name fSelectedName;
private ITypeBinding fException;
private ASTNode fStart;
private List fResult;
public ExceptionOccurrencesFinder() {
fResult= new ArrayList();
}
public String initialize(CompilationUnit root, int offset, int length) {
fAST= root.getAST();
ASTNode node= NodeFinder.perform(root, offset, length);
if (!(node instanceof Name)) {
return SearchMessages.getString("ExceptionOccurrencesFinder.no_exception"); //$NON-NLS-1$
}
fSelectedName= ASTNodes.getTopMostName((Name)node);
ASTNode parent= fSelectedName.getParent();
if (parent instanceof MethodDeclaration) {
MethodDeclaration decl= (MethodDeclaration)parent;
if (decl.thrownExceptions().contains(fSelectedName)) {
fException= fSelectedName.resolveTypeBinding();
fStart= decl.getBody();
}
} else if (parent instanceof Type) {
parent= parent.getParent();
if (parent instanceof SingleVariableDeclaration && parent.getParent() instanceof CatchClause) {
CatchClause catchClause= (CatchClause)parent.getParent();
TryStatement tryStatement= (TryStatement)catchClause.getParent();
if (tryStatement != null) {
IVariableBinding var= catchClause.getException().resolveBinding();
if (var != null && var.getType() != null) {
fException= var.getType();
fStart= tryStatement.getBody();
}
}
}
}
if (fException == null || fStart == null)
return SearchMessages.getString("ExceptionOccurrencesFinder.no_exception"); //$NON-NLS-1$
return null;
}
public List perform() {
fStart.accept(this);
if (fResult.size() > 0 && fSelectedName != null) {
fResult.add(fSelectedName);
}
return fResult;
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.search.IPositionFinder#createMarkers(org.eclipse.core.resources.IResource, org.eclipse.jface.text.IDocument)
*/
public IMarker[] createMarkers(IResource file, IDocument document) throws CoreException {
List result= new ArrayList();
for (Iterator iter = fResult.iterator(); iter.hasNext();) {
ASTNode node = (ASTNode) iter.next();
result.add(createMarker(file, document, node));
}
return (IMarker[]) result.toArray(new IMarker[result.size()]);
}
private IMarker createMarker(IResource file, IDocument document, ASTNode node) throws CoreException {
Map attributes= new HashMap(10);
IMarker marker= file.createMarker(SearchUI.SEARCH_MARKER);
int startPosition= node.getStartPosition();
MarkerUtilities.setCharStart(attributes, startPosition);
MarkerUtilities.setCharEnd(attributes, startPosition + node.getLength());
if (node == fSelectedName) {
attributes.put(IS_EXCEPTION, Boolean.TRUE);
}
try {
int line= document.getLineOfOffset(startPosition);
MarkerUtilities.setLineNumber(attributes, line);
IRegion region= document.getLineInformation(line);
String lineContents= document.get(region.getOffset(), region.getLength());
MarkerUtilities.setMessage(attributes, lineContents.trim());
} catch (BadLocationException e) {
}
marker.setAttributes(attributes);
return marker;
}
public void searchStarted(ISearchResultView view, String inputName) {
String elementName= ASTNodes.asString(fSelectedName);
view.searchStarted(
null,
SearchMessages.getFormattedString(
"ExceptionOccurrencesFinder.label.singular", //$NON-NLS-1$
new Object[] { elementName, "{0}", inputName}), //$NON-NLS-1$
SearchMessages.getFormattedString(
"ExceptionOccurrencesFinder.label.plural", //$NON-NLS-1$
new Object[] { elementName, "{0}", inputName}), //$NON-NLS-1$
JavaPluginImages.DESC_OBJS_SEARCH_REF,
"org.eclipse.jdt.ui.JavaFileSearch", //$NON-NLS-1$
new ExceptionOccurrencesLabelProvider(),
new GotoMarkerAction(),
new SearchGroupByKeyComputer(),
null
);
}
public boolean visit(AnonymousClassDeclaration node) {
return false;
}
public boolean visit(CastExpression node) {
if ("java.lang.ClassCastException".equals(fException.getQualifiedName())) //$NON-NLS-1$
fResult.add(node.getType());
return super.visit(node);
}
public boolean visit(ClassInstanceCreation node) {
if (matches(node.resolveConstructorBinding())) {
fResult.add(node.getName());
}
return super.visit(node);
}
public boolean visit(ConstructorInvocation node) {
if (matches(node.resolveConstructorBinding())) {
SimpleName name= fAST.newSimpleName("xxxx"); //$NON-NLS-1$
name.setSourceRange(node.getStartPosition(), 4);
fResult.add(name);
}
return super.visit(node);
}
public boolean visit(MethodInvocation node) {
if (matches(node.resolveMethodBinding()))
fResult.add(node.getName());
return super.visit(node);
}
public boolean visit(SuperConstructorInvocation node) {
if (matches(node.resolveConstructorBinding())) {
SimpleName name= fAST.newSimpleName("xxxxx"); //$NON-NLS-1$
name.setSourceRange(node.getStartPosition(), 5);
fResult.add(name);
}
return super.visit(node);
}
public boolean visit(SuperMethodInvocation node) {
if (matches(node.resolveMethodBinding())) {
SimpleName name= fAST.newSimpleName("xxxxx"); //$NON-NLS-1$
name.setSourceRange(node.getStartPosition(), 5);
fResult.add(name);
}
return super.visit(node);
}
public boolean visit(ThrowStatement node) {
if (matches(node.getExpression().resolveTypeBinding())) {
SimpleName name= fAST.newSimpleName("xxxxx"); //$NON-NLS-1$
name.setSourceRange(node.getStartPosition(), 5);
fResult.add(name);
}
return super.visit(node);
}
public boolean visit(TypeDeclarationStatement node) {
// don't dive into local type declarations.
return false;
}
private boolean matches(IMethodBinding binding) {
if (binding == null)
return false;
ITypeBinding[] exceptions= binding.getExceptionTypes();
for (int i = 0; i < exceptions.length; i++) {
ITypeBinding exception= exceptions[i];
if(matches(exception))
return true;
}
return false;
}
private boolean matches(ITypeBinding exception) {
if (exception == null)
return false;
while (exception != null) {
if (Bindings.equals(fException, exception))
return true;
exception= exception.getSuperclass();
}
return false;
}
}
|
36,571 |
Bug 36571 Refactoring inline throws [refactoring]
|
Unfortunately I could not come up with a scenario to reproduce this and I did not see any obvious reasons why the refactoring might have failed. When doing refactor -> inline on a method call of a protected method with "all occurences" and "delete original" switched on, preview throws this: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:313) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:252) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run (RefactoringWizardDialog2.java:266) at org.eclipse.jdt.internal.ui.refactoring.PerformRefactoringUtil.performRefactorin g(PerformRefactoringUtil.java:53) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:363) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.performFinish (UserInputWizardPage.java:119) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:426) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.okPressed (RefactoringWizardDialog2.java:383) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:256) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:423) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1838) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1545) at org.eclipse.jface.window.Window.runEventLoop(Window.java:583) at org.eclipse.jface.window.Window.open(Window.java:563) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:70) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.activate (InlineMethodAction.java:128) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.run (InlineMethodAction.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.run (InlineMethodAction.java:82) at org.eclipse.jdt.ui.actions.InlineAction.tryInlineMethod (InlineAction.java:132) at org.eclipse.jdt.ui.actions.InlineAction.run(InlineAction.java:109) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:193) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:169) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:456) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:403) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:397) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:72) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1838) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1545) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) 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:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583) Caused by: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.addNewLocals (CallInliner.java:232) at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.perform (CallInliner.java:166) at org.eclipse.jdt.internal.corext.refactoring.code.InlineMethodRefactoring.checkIn put(InlineMethodRefactoring.java:220) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:100) at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:138) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:302) ... 44 more Log Session info: java.version=1.4.1_01 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE Command-line arguments: -os win32 -ws win32 -arch x86 -install file:C:/Programme/eclipse/
|
resolved fixed
|
e70e8e2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-13T17:59:31Z | 2003-04-16T13:33:20Z |
org.eclipse.jdt.ui/core
| |
36,571 |
Bug 36571 Refactoring inline throws [refactoring]
|
Unfortunately I could not come up with a scenario to reproduce this and I did not see any obvious reasons why the refactoring might have failed. When doing refactor -> inline on a method call of a protected method with "all occurences" and "delete original" switched on, preview throws this: java.lang.reflect.InvocationTargetException at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:313) at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:252) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.run (RefactoringWizardDialog2.java:266) at org.eclipse.jdt.internal.ui.refactoring.PerformRefactoringUtil.performRefactorin g(PerformRefactoringUtil.java:53) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:363) at org.eclipse.jdt.internal.ui.refactoring.UserInputWizardPage.performFinish (UserInputWizardPage.java:119) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizard.performFinish (RefactoringWizard.java:426) at org.eclipse.jdt.internal.ui.refactoring.RefactoringWizardDialog2.okPressed (RefactoringWizardDialog2.java:383) at org.eclipse.jface.dialogs.Dialog.buttonPressed(Dialog.java:256) at org.eclipse.jface.dialogs.Dialog$1.widgetSelected(Dialog.java:423) at org.eclipse.swt.widgets.TypedListener.handleEvent (TypedListener.java:89) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1838) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1545) at org.eclipse.jface.window.Window.runEventLoop(Window.java:583) at org.eclipse.jface.window.Window.open(Window.java:563) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:70) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.activate (InlineMethodAction.java:128) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.run (InlineMethodAction.java:121) at org.eclipse.jdt.internal.ui.refactoring.actions.InlineMethodAction.run (InlineMethodAction.java:82) at org.eclipse.jdt.ui.actions.InlineAction.tryInlineMethod (InlineAction.java:132) at org.eclipse.jdt.ui.actions.InlineAction.run(InlineAction.java:109) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:193) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.run (SelectionDispatchAction.java:169) at org.eclipse.jface.action.Action.runWithEvent(Action.java:842) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection (ActionContributionItem.java:456) at org.eclipse.jface.action.ActionContributionItem.handleWidgetEvent (ActionContributionItem.java:403) at org.eclipse.jface.action.ActionContributionItem.access$0 (ActionContributionItem.java:397) at org.eclipse.jface.action.ActionContributionItem$ActionListener.handleEvent (ActionContributionItem.java:72) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:81) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:840) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:1838) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1545) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1402) at org.eclipse.ui.internal.Workbench.run(Workbench.java:1385) at org.eclipse.core.internal.boot.InternalBootLoader.run (InternalBootLoader.java:845) at org.eclipse.core.boot.BootLoader.run(BootLoader.java:461) 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:291) at org.eclipse.core.launcher.Main.run(Main.java:747) at org.eclipse.core.launcher.Main.main(Main.java:583) Caused by: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.addNewLocals (CallInliner.java:232) at org.eclipse.jdt.internal.corext.refactoring.code.CallInliner.perform (CallInliner.java:166) at org.eclipse.jdt.internal.corext.refactoring.code.InlineMethodRefactoring.checkIn put(InlineMethodRefactoring.java:220) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:65) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:100) at org.eclipse.jdt.internal.ui.refactoring.PerformChangeOperation.run (PerformChangeOperation.java:138) at org.eclipse.jface.operation.ModalContext.runInCurrentThread (ModalContext.java:302) ... 44 more Log Session info: java.version=1.4.1_01 java.vendor=Sun Microsystems Inc. BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=de_DE Command-line arguments: -os win32 -ws win32 -arch x86 -install file:C:/Programme/eclipse/
|
resolved fixed
|
e70e8e2
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-13T17:59:31Z | 2003-04-16T13:33:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/code/CallInliner.java
| |
52,072 |
Bug 52072 Code formatter -> white space -> control statements -> do while shows while example
|
The formatting options for the 'do while' statement shows an example of a 'while' loop rather than a 'do while' loop. Seems odd; either the option should be 'while' or the preview should show a do-while loop. Mac OS X.3.2 Eclipse 3.0M7
|
verified fixed
|
95156aa
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T09:56:33Z | 2004-02-15T01:53:20Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/WhiteSpaceOptions.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.preferences.formatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.formatter.CodeFormatter;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.jdt.internal.ui.preferences.formatter.SnippetPreview.PreviewSnippet;
/**
* Manage code formatter white space options on a higher level.
*/
public final class WhiteSpaceOptions {
/**
* Represents a node in the options tree.
*/
public abstract static class Node {
private final InnerNode fParent;
private final String fName;
public int index;
protected final Map fWorkingValues;
protected final ArrayList fChildren;
public Node(InnerNode parent, Map workingValues, String messageKey) {
if (workingValues == null || messageKey == null)
throw new IllegalArgumentException();
fParent= parent;
fWorkingValues= workingValues;
fName= FormatterMessages.getString(messageKey);
fChildren= new ArrayList();
if (fParent != null)
fParent.add(this);
}
public abstract void setChecked(boolean checked);
public boolean hasChildren() {
return !fChildren.isEmpty();
}
public List getChildren() {
return Collections.unmodifiableList(fChildren);
}
public InnerNode getParent() {
return fParent;
}
public final String toString() {
return fName;
}
public abstract List getSnippets();
public abstract void getCheckedLeafs(List list);
}
/**
* A node representing a group of options in the tree.
*/
public static class InnerNode extends Node {
public InnerNode(InnerNode parent, Map workingValues, String messageKey) {
super(parent, workingValues, messageKey);
}
public void setChecked(boolean checked) {
for (final Iterator iter = fChildren.iterator(); iter.hasNext();)
((Node)iter.next()).setChecked(checked);
}
public void add(Node child) {
fChildren.add(child);
}
public List getSnippets() {
final ArrayList snippets= new ArrayList(fChildren.size());
for (Iterator iter= fChildren.iterator(); iter.hasNext();) {
final List childSnippets= ((Node)iter.next()).getSnippets();
for (final Iterator chIter= childSnippets.iterator(); chIter.hasNext(); ) {
final Object snippet= chIter.next();
if (!snippets.contains(snippet))
snippets.add(snippet);
}
}
return snippets;
}
public void getCheckedLeafs(List list) {
for (Iterator iter= fChildren.iterator(); iter.hasNext();) {
((Node)iter.next()).getCheckedLeafs(list);
}
}
}
/**
* A node representing a concrete white space option in the tree.
*/
public static class OptionNode extends Node {
private final String fKey;
private final ArrayList fSnippets;
public OptionNode(InnerNode parent, Map workingValues, String messageKey, String key, PreviewSnippet snippet) {
super(parent, workingValues, messageKey);
fKey= key;
fSnippets= new ArrayList(1);
fSnippets.add(snippet);
}
public void setChecked(boolean checked) {
fWorkingValues.put(fKey, checked ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
}
public boolean getChecked() {
return JavaCore.INSERT.equals(fWorkingValues.get(fKey));
}
public List getSnippets() {
return fSnippets;
}
public void getCheckedLeafs(List list) {
if (getChecked())
list.add(this);
}
}
/**
* Preview snippets.
*/
private final static PreviewSnippet FOR_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"for (int i= 0, j= array.length; i < array.length; i++, j--) {}" //$NON-NLS-1$
);
private final static PreviewSnippet WHILE_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"while (condition) {}" //$NON-NLS-1$
);
private final static PreviewSnippet CATCH_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"try { number= Integer.parseInt(value); } catch (NumberFormatException e) {}"); //$NON-NLS-1$
private final static PreviewSnippet IF_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"if (condition) { return foo; } else {return bar;}"); //$NON-NLS-1$
private final static PreviewSnippet SYNCHRONIZED_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"synchronized (list) { list.add(element); }"); //$NON-NLS-1$
private final static PreviewSnippet SWITCH_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"switch (number) { case RED: return GREEN; case GREEN: return BLUE; case BLUE: return RED; default: return BLACK;}"); //$NON-NLS-1$
private final static PreviewSnippet CONSTRUCTOR_DECL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_CLASS_BODY_DECLARATIONS,
"MyClass() throws E0, E1 { this(0,0,0);}" + //$NON-NLS-1$
"MyClass(int x, int y, int z) throws E0, E1 { super(x, y, z, true);}"); //$NON-NLS-1$
private final static PreviewSnippet METHOD_DECL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_CLASS_BODY_DECLARATIONS,
"void foo() throws E0, E1 {};" + //$NON-NLS-1$
"void bar(int x, int y) throws E0, E1 {}"); //$NON-NLS-1$
private final static PreviewSnippet ARRAY_DECL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"int [] array0= new int [] {};\n" + //$NON-NLS-1$
"int [] array1= new int [] {1, 2, 3};\n" + //$NON-NLS-1$
"int [] array2= new int[3];"); //$NON-NLS-1$
private final static PreviewSnippet ARRAY_REF_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"array[i].foo();"); //$NON-NLS-1$
private final static PreviewSnippet METHOD_CALL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"foo();\n" + //$NON-NLS-1$
"bar(x, y);"); //$NON-NLS-1$
// private final static PreviewSnippet CONSTR_CALL_PREVIEW= new PreviewSnippet(
// CodeFormatter.K_STATEMENTS,
// "this();\n\n" + //$NON-NLS-1$
// "this(x, y);\n"); //$NON-NLS-1$
private final static PreviewSnippet ALLOC_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"String str= new String(); Point point= new Point(x, y);"); //$NON-NLS-1$
private final static PreviewSnippet LABEL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"label: for (int i= 0; i<list.length; i++) {for (int j= 0; j < list[i].length; j++) continue label;}"); //$NON-NLS-1$
private final static PreviewSnippet SEMICOLON_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"int a= 4; foo(); bar(x, y);"); //$NON-NLS-1$
private final static PreviewSnippet CONDITIONAL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"String value= condition ? TRUE : FALSE;"); //$NON-NLS-1$
private final static PreviewSnippet CLASS_DECL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_COMPILATION_UNIT,
"class MyClass implements I0, I1, I2 {}"); //$NON-NLS-1$
private final static PreviewSnippet ANON_CLASS_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"AnonClass= new AnonClass() {void foo(Some s) { }};"); //$NON-NLS-1$
private final static PreviewSnippet OPERATOR_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"List list= new ArrayList(); int a= -4 + -9; b= a++ / --number; c += 4; boolean value= true && false;"); //$NON-NLS-1$
private final static PreviewSnippet CAST_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"String s= ((String)object);"); //$NON-NLS-1$
private final static PreviewSnippet MULT_LOCAL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"int a= 0, b= 1, c= 2, d= 3;"); //$NON-NLS-1$
private final static PreviewSnippet MULT_FIELD_PREVIEW= new PreviewSnippet(
CodeFormatter.K_CLASS_BODY_DECLARATIONS,
"int a=0,b=1,c=2,d=3;"); //$NON-NLS-1$
private final static PreviewSnippet BLOCK_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"if (true) { return 1; } else { return 2; }"); //$NON-NLS-1$
private final static PreviewSnippet PAREN_EXPR_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"result= (a *( b + c + d) * (e + f));"); //$NON-NLS-1$
//TODO: integrate this
// private final static PreviewSnippet ASSERT_PREVIEW= new PreviewSnippet(
// CodeFormatter.K_STATEMENTS,
// "assert condition : reportError();"
// );
/**
* Create the tree, in this order: position - syntax element - abstract
* element
*/
public static ArrayList createTreeByPosition(Map workingValues) {
final ArrayList roots= new ArrayList();
final InnerNode before= new InnerNode(null, workingValues, "WhiteSpaceOptions.before"); //$NON-NLS-1$
createBeforeOpenParenTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.opening_paren")); //$NON-NLS-1$
createBeforeClosingParenTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.closing_paren")); //$NON-NLS-1$
createBeforeOpenBraceTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.opening_brace")); //$NON-NLS-1$
createBeforeClosingBraceTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.closing_brace")); //$NON-NLS-1$
createBeforeOpenBracketTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.opening_bracket")); //$NON-NLS-1$
createBeforeClosingBracketTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.closing_bracket")); //$NON-NLS-1$
createBeforeOperatorTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.operator")); //$NON-NLS-1$
createBeforeCommaTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.comma")); //$NON-NLS-1$
createBeforeColonTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.colon")); //$NON-NLS-1$
createBeforeSemicolonTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.semicolon")); //$NON-NLS-1$
createBeforeQuestionTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.question_mark")); //$NON-NLS-1$
roots.add(before);
final InnerNode after= new InnerNode(null, workingValues, "WhiteSpaceOptions.after"); //$NON-NLS-1$
createAfterOpenParenTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.opening_paren")); //$NON-NLS-1$
createAfterCloseParenTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.closing_paren")); //$NON-NLS-1$
createAfterOpenBraceTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.opening_brace")); //$NON-NLS-1$
createAfterCloseBraceTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.closing_brace")); //$NON-NLS-1$
createAfterOpenBracketTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.opening_bracket")); //$NON-NLS-1$
createAfterOperatorTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.operator")); //$NON-NLS-1$
createAfterCommaTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.comma")); //$NON-NLS-1$
createAfterColonTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.colon")); //$NON-NLS-1$
createAfterSemicolonTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.semicolon")); //$NON-NLS-1$
createAfterQuestionTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.question_mark")); //$NON-NLS-1$
roots.add(after);
final InnerNode between= new InnerNode(null, workingValues, "WhiteSpaceOptions.between"); //$NON-NLS-1$
createBetweenEmptyBracesTree(workingValues, createChild(between, workingValues, "WhiteSpaceOptions.empty_braces")); //$NON-NLS-1$
createBetweenEmptyBracketsTree(workingValues, createChild(between, workingValues, "WhiteSpaceOptions.empty_brackets")); //$NON-NLS-1$
createBetweenEmptyParenTree(workingValues, createChild(between, workingValues, "WhiteSpaceOptions.empty_parens")); //$NON-NLS-1$
roots.add(between);
return roots;
}
/**
* Create the tree, in this order: syntax element - position - abstract element
*/
public static ArrayList createTreeBySyntaxElem(Map workingValues) {
final ArrayList roots= new ArrayList();
InnerNode element;
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.opening_paren"); //$NON-NLS-1$
createBeforeOpenParenTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterOpenParenTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.closing_paren"); //$NON-NLS-1$
createBeforeClosingParenTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterCloseParenTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.opening_brace"); //$NON-NLS-1$
createBeforeOpenBraceTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterOpenBraceTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.closing_brace"); //$NON-NLS-1$
createBeforeClosingBraceTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterCloseBraceTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.opening_bracket"); //$NON-NLS-1$
createBeforeOpenBracketTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterOpenBracketTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.closing_bracket"); //$NON-NLS-1$
createBeforeClosingBracketTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.operator"); //$NON-NLS-1$
createBeforeOperatorTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterOperatorTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.comma"); //$NON-NLS-1$
createBeforeCommaTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterCommaTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.colon"); //$NON-NLS-1$
createBeforeColonTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterColonTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.semicolon"); //$NON-NLS-1$
createBeforeSemicolonTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterSemicolonTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.question_mark"); //$NON-NLS-1$
createBeforeQuestionTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterQuestionTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.between_empty_parens"); //$NON-NLS-1$
createBetweenEmptyParenTree(workingValues, element);
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.between_empty_braces"); //$NON-NLS-1$
createBetweenEmptyBracesTree(workingValues, element);
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.between_empty_brackets"); //$NON-NLS-1$
createBetweenEmptyBracketsTree(workingValues, element);
roots.add(element);
return roots;
}
/**
* Create the tree, in this order: position - syntax element - abstract
* element
*/
public static ArrayList createAltTree(Map workingValues) {
final ArrayList roots= new ArrayList();
InnerNode parent;
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_opening_paren"); //$NON-NLS-1$
createBeforeOpenParenTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_opening_paren"); //$NON-NLS-1$
createAfterOpenParenTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_closing_paren"); //$NON-NLS-1$
createBeforeClosingParenTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_closing_paren"); //$NON-NLS-1$
createAfterCloseParenTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.between_empty_parens"); //$NON-NLS-1$
createBetweenEmptyParenTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_opening_brace"); //$NON-NLS-1$
createBeforeOpenBraceTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_opening_brace"); //$NON-NLS-1$
createAfterOpenBraceTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_closing_brace"); //$NON-NLS-1$
createBeforeClosingBraceTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_closing_brace"); //$NON-NLS-1$
createAfterCloseBraceTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.between_empty_braces"); //$NON-NLS-1$
createBetweenEmptyBracesTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_opening_bracket"); //$NON-NLS-1$
createBeforeOpenBracketTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_opening_bracket"); //$NON-NLS-1$
createAfterOpenBracketTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_closing_bracket"); //$NON-NLS-1$
createBeforeClosingBracketTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.between_empty_brackets"); //$NON-NLS-1$
createBetweenEmptyBracketsTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_operator"); //$NON-NLS-1$
createBeforeOperatorTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_operator"); //$NON-NLS-1$
createAfterOperatorTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_comma"); //$NON-NLS-1$
createBeforeCommaTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_comma"); //$NON-NLS-1$
createAfterCommaTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_colon"); //$NON-NLS-1$
createAfterColonTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_colon"); //$NON-NLS-1$
createBeforeColonTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_semicolon"); //$NON-NLS-1$
createBeforeSemicolonTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_semicolon"); //$NON-NLS-1$
createAfterSemicolonTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_question_mark"); //$NON-NLS-1$
createBeforeQuestionTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_question_mark"); //$NON-NLS-1$
createAfterQuestionTree(workingValues, parent);
return roots;
}
private static InnerNode createParentNode(List roots, Map workingValues, String text) {
final InnerNode parent= new InnerNode(null, workingValues, text);
roots.add(parent);
return parent;
}
public static ArrayList createTreeByJavaElement(Map workingValues) {
final InnerNode declarations= new InnerNode(null, workingValues, "WhiteSpaceTabPage.declarations"); //$NON-NLS-1$
createClassTree(workingValues, declarations);
createFieldTree(workingValues, declarations);
createLocalVariableTree(workingValues, declarations);
createConstructorTree(workingValues, declarations);
createMethodDeclTree(workingValues, declarations);
createLabelTree(workingValues, declarations);
final InnerNode statements= new InnerNode(null, workingValues, "WhiteSpaceTabPage.statements"); //$NON-NLS-1$
createOption(statements, workingValues, "WhiteSpaceOptions.before_semicolon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW); //$NON-NLS-1$
createBlockTree(workingValues, statements);
createIfStatementTree(workingValues, statements);
createForStatementTree(workingValues, statements);
createSwitchStatementTree(workingValues, statements);
createDoWhileTree(workingValues, statements);
createSynchronizedTree(workingValues, statements);
createTryStatementTree(workingValues, statements);
final InnerNode expressions= new InnerNode(null, workingValues, "WhiteSpaceTabPage.expressions"); //$NON-NLS-1$
createFunctionCallTree(workingValues, expressions);
createAssignmentTree(workingValues, expressions);
createOperatorTree(workingValues, expressions);
createParenthesizedExpressionTree(workingValues, expressions);
createTypecastTree(workingValues, expressions);
createConditionalTree(workingValues, expressions);
final InnerNode arrays= new InnerNode(null, workingValues, "WhiteSpaceTabPage.arrays"); //$NON-NLS-1$
createArrayDeclarationTree(workingValues, arrays);
createArrayAllocTree(workingValues, arrays);
createArrayInitializerTree(workingValues, arrays);
createArrayElementAccessTree(workingValues, arrays);
final ArrayList roots= new ArrayList();
roots.add(declarations);
roots.add(statements);
roots.add(expressions);
roots.add(arrays);
return roots;
}
private static void createBeforeQuestionTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.conditional", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeSemicolonTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.for", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.statements", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeColonTree(Map workingValues, final InnerNode parent) {
//TODO: createOption(parent, workingValues, "WhiteSpaceOptions.assert", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT, ASSERT_PREVIEW);
createOption(parent, workingValues, "WhiteSpaceOptions.conditional", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.label", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); //$NON-NLS-1$
final InnerNode switchStatement= createChild(parent, workingValues, "WhiteSpaceOptions.switch"); //$NON-NLS-1$
createOption(switchStatement, workingValues, "WhiteSpaceOptions.case", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(switchStatement, workingValues, "WhiteSpaceOptions.default", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, SWITCH_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeCommaTree(Map workingValues, final InnerNode parent) {
final InnerNode forStatement= createChild(parent, workingValues, "WhiteSpaceOptions.for"); //$NON-NLS-1$
createOption(forStatement, workingValues, "WhiteSpaceOptions.initialization", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW); //$NON-NLS-1$
createOption(forStatement, workingValues, "WhiteSpaceOptions.incrementation", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW); //$NON-NLS-1$
final InnerNode invocation= createChild(parent, workingValues, "WhiteSpaceOptions.arguments"); //$NON-NLS-1$
createOption(invocation, workingValues, "WhiteSpaceOptions.method_call", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(invocation, workingValues, "WhiteSpaceOptions.explicit_constructor_call", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(invocation, workingValues, "WhiteSpaceOptions.alloc_expr", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW); //$NON-NLS-1$
final InnerNode decl= createChild(parent, workingValues, "WhiteSpaceOptions.parameters"); //$NON-NLS-1$
createOption(decl, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(decl, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
final InnerNode throwsDecl= createChild(parent, workingValues, "WhiteSpaceOptions.throws"); //$NON-NLS-1$
createOption(throwsDecl, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(throwsDecl, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
final InnerNode multDecls= createChild(parent, workingValues, "WhiteSpaceOptions.mult_decls"); //$NON-NLS-1$
createOption(multDecls, workingValues, "WhiteSpaceOptions.fields", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, MULT_FIELD_PREVIEW); //$NON-NLS-1$
createOption(multDecls, workingValues, "WhiteSpaceOptions.local_vars", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, MULT_LOCAL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.initializer", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.implements_clause", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES, CLASS_DECL_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeOperatorTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.assignment_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.unary_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.binary_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.prefix_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.postfix_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeClosingBracketTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.array_alloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.array_element_access", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeOpenBracketTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.array_decl", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.array_alloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.array_element_access", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeClosingBraceTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.array_init", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, CLASS_DECL_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeOpenBraceTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.class_decl", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, CLASS_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.anon_class_decl", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION, ANON_CLASS_PREVIEW); //$NON-NLS-1$
final InnerNode functionDecl= createChild(parent, workingValues, "WhiteSpaceOptions.member_function_declaration"); { //$NON-NLS-1$
createOption(functionDecl, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(functionDecl, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
}
createOption(parent, workingValues, "WhiteSpaceOptions.initializer", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.block", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, BLOCK_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.switch", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeClosingParenTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.catch", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.for", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.if", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, IF_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.switch", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.synchronized", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.while", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE, WHILE_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.type_cast", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST, CAST_PREVIEW); //$NON-NLS-1$
final InnerNode decl= createChild(parent, workingValues, "WhiteSpaceOptions.member_function_declaration"); //$NON-NLS-1$
createOption(decl, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(decl, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.method_call", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.paren_expr", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeOpenParenTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.catch", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.for", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.if", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.switch", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.synchronized", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.while", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW); //$NON-NLS-1$
final InnerNode decls= createChild(parent, workingValues, "WhiteSpaceOptions.member_function_declaration"); //$NON-NLS-1$
createOption(decls, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(decls, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.method_call", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.paren_expr", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); //$NON-NLS-1$
}
private static void createAfterQuestionTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.conditional", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
}
private static void createAfterSemicolonTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.for", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
}
private static void createAfterColonTree(Map workingValues, final InnerNode parent) {
//TODO: createOption(parent, workingValues, "'assert'", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT, ASSERT_PREVIEW);
createOption(parent, workingValues, "WhiteSpaceOptions.conditional", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.label", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); //$NON-NLS-1$
}
private static void createAfterCommaTree(Map workingValues, final InnerNode parent) {
final InnerNode forStatement= createChild(parent, workingValues, "WhiteSpaceOptions.for"); { //$NON-NLS-1$
createOption(forStatement, workingValues, "WhiteSpaceOptions.initialization", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW); //$NON-NLS-1$
createOption(forStatement, workingValues, "WhiteSpaceOptions.incrementation", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW); //$NON-NLS-1$
}
final InnerNode invocation= createChild(parent, workingValues, "WhiteSpaceOptions.arguments"); { //$NON-NLS-1$
createOption(invocation, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(invocation, workingValues, "WhiteSpaceOptions.explicit_constructor_call", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(invocation, workingValues, "WhiteSpaceOptions.alloc_expr", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW); //$NON-NLS-1$
}
final InnerNode decl= createChild(parent, workingValues, "WhiteSpaceOptions.parameters"); { //$NON-NLS-1$
createOption(decl, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(decl, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
}
final InnerNode throwsDecl= createChild(parent, workingValues, "WhiteSpaceOptions.throws"); { //$NON-NLS-1$
createOption(throwsDecl, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(throwsDecl, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
}
final InnerNode multDecls= createChild(parent, workingValues, "WhiteSpaceOptions.mult_decls"); { //$NON-NLS-1$
createOption(multDecls, workingValues, "WhiteSpaceOptions.fields", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, MULT_FIELD_PREVIEW); //$NON-NLS-1$
createOption(multDecls, workingValues, "WhiteSpaceOptions.local_vars", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, MULT_LOCAL_PREVIEW); //$NON-NLS-1$
}
createOption(parent, workingValues, "WhiteSpaceOptions.initializer", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.implements_clause", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES, CLASS_DECL_PREVIEW); //$NON-NLS-1$
}
private static void createAfterOperatorTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.assignment_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.unary_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.binary_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.prefix_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.postfix_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
}
private static void createAfterOpenBracketTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.array_alloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.array_element_access", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW); //$NON-NLS-1$
}
private static void createAfterOpenBraceTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.initializer", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
}
private static void createAfterCloseBraceTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.block", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, BLOCK_PREVIEW); //$NON-NLS-1$
}
private static void createAfterCloseParenTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.type_cast", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, CAST_PREVIEW); //$NON-NLS-1$
}
private static void createAfterOpenParenTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.catch", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.for", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.if", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.switch", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.synchronized", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.while", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW); //$NON-NLS-1$
final InnerNode decls= createChild(parent, workingValues, "WhiteSpaceOptions.member_function_declaration"); { //$NON-NLS-1$
createOption(decls, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(decls, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
}
createOption(parent, workingValues, "WhiteSpaceOptions.type_cast", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.method_call", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.paren_expr", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); //$NON-NLS-1$
}
private static void createBetweenEmptyParenTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.constructor_decl", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.method_decl", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.method_call", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
}
private static void createBetweenEmptyBracketsTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.array_alloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.array_decl", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
}
private static void createBetweenEmptyBracesTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.initializer", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
}
private static InnerNode createClassTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.classes"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.classes.before_opening_brace_of_a_class", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, CLASS_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.classes.before_opening_brace_of_anon_class", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION, ANON_CLASS_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.classes.before_comma_implements", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES, CLASS_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.classes.after_comma_implements", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES, CLASS_DECL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createAssignmentTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.assignments"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.assignments.before_assignment_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.assignments.after_assignment_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createOperatorTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.operators"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.before_binary_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.after_binary_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.before_unary_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.after_unary_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.before_prefix_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.after_prefix_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.before_postfix_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.after_postfix_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createMethodDeclTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.methods"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.between_empty_parens", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_brace", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_comma_in_params", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_comma_in_params", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_comma_in_throws", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_comma_in_throws", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createConstructorTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.constructors"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.between_empty_parens", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_brace", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_comma_in_params", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_comma_in_params", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_comma_in_throws", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_comma_in_throws", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createFieldTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.fields"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.fields.before_comma", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, MULT_FIELD_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.fields.after_comma", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, MULT_LOCAL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createLocalVariableTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.localvars"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.localvars.before_comma", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, MULT_LOCAL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.localvars.after_comma", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, MULT_LOCAL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createArrayInitializerTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.arrayinit"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_brace", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_brace", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_comma", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_comma", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.between_empty_braces", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createArrayDeclarationTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.arraydecls"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.between_empty_brackets", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createArrayElementAccessTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.arrayelem"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createArrayAllocTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.arrayalloc"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createFunctionCallTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.calls"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.between_empty_parens", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.calls.before_comma_in_method_args", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.calls.after_comma_in_method_args", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.calls.before_comma_in_alloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.calls.after_comma_in_alloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.calls.before_comma_in_qalloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.calls.after_comma_in_qalloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createBlockTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.blocks"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_brace", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, BLOCK_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_closing_brace", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, BLOCK_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createSwitchStatementTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.switch"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.switch.before_case_colon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.switch.before_default_colon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_brace", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createDoWhileTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.do"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE, WHILE_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createSynchronizedTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.synchronized"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createTryStatementTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.try"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createIfStatementTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.if"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, IF_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createForStatementTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.for"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.for.before_comma_init", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.for.after_comma_init", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.for.before_comma_inc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.for.after_comma_inc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_semicolon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
return root;
}
// TODO: include this category
// private static InnerNode createAssertTree(Map workingValues, InnerNode parent) {
// "'assert'",
//
// new Option(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT, "WhiteSpaceTabPage.before_colon"),
// new Option(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT, "WhiteSpaceTabPage.after_colon")
// }
private static InnerNode createLabelTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.labels"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_colon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_colon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createConditionalTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.conditionals"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_question", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_question", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_colon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_colon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createTypecastTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.typecasts"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST, CAST_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, CAST_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createParenthesizedExpressionTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.parenexpr"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createChild(InnerNode root, Map workingValues, String messageKey) {
return new InnerNode(root, workingValues, messageKey);
}
private static OptionNode createOption(InnerNode root, Map workingValues, String messageKey, String key, PreviewSnippet snippet) {
return new OptionNode(root,workingValues, messageKey, key, snippet);
}
public static void makeIndexForNodes(List tree, List flatList) {
for (final Iterator iter= tree.iterator(); iter.hasNext();) {
final Node node= (Node) iter.next();
node.index= flatList.size();
flatList.add(node);
makeIndexForNodes(node.getChildren(), flatList);
}
}
}
|
51,984 |
Bug 51984 Compiler settings: enable state not correctly updated
|
I200402122000 In the Java/Compiler/Advanced preference page, 'Include constructor or setter method parameter' is not correctly enable/disable when modifying the option 'Local variable declaration hides another field or variable'. Modifying one the options with sub-checkbox in 'Unused code' set the correct enable state in 'Advanced'.
|
resolved fixed
|
859b6b9
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T10:34:25Z | 2004-02-13T19:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CompilerConfigurationBlock.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.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
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.TabFolder;
import org.eclipse.swt.widgets.TabItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.internal.ui.dialogs.StatusInfo;
import org.eclipse.jdt.internal.ui.dialogs.StatusUtil;
import org.eclipse.jdt.internal.ui.util.PixelConverter;
import org.eclipse.jdt.internal.ui.util.TabFolderLayout;
import org.eclipse.jdt.internal.ui.wizards.IStatusChangeListener;
/**
*/
public class CompilerConfigurationBlock extends OptionsConfigurationBlock {
// Preference store keys, see JavaCore.getOptions
private static final String PREF_LOCAL_VARIABLE_ATTR= JavaCore.COMPILER_LOCAL_VARIABLE_ATTR;
private static final String PREF_LINE_NUMBER_ATTR= JavaCore.COMPILER_LINE_NUMBER_ATTR;
private static final String PREF_SOURCE_FILE_ATTR= JavaCore.COMPILER_SOURCE_FILE_ATTR;
private static final String PREF_CODEGEN_UNUSED_LOCAL= JavaCore.COMPILER_CODEGEN_UNUSED_LOCAL;
private static final String PREF_CODEGEN_TARGET_PLATFORM= JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM;
//private static final String PREF_PB_UNREACHABLE_CODE= JavaCore.COMPILER_PB_UNREACHABLE_CODE;
//private static final String PREF_PB_INVALID_IMPORT= JavaCore.COMPILER_PB_INVALID_IMPORT;
private static final String PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD= JavaCore.COMPILER_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD;
private static final String PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME= JavaCore.COMPILER_PB_METHOD_WITH_CONSTRUCTOR_NAME;
private static final String PREF_PB_DEPRECATION= JavaCore.COMPILER_PB_DEPRECATION;
private static final String PREF_PB_DEPRECATION_WHEN_OVERRIDING= JavaCore.COMPILER_PB_DEPRECATION_WHEN_OVERRIDING_DEPRECATED_METHOD;
private static final String PREF_PB_HIDDEN_CATCH_BLOCK= JavaCore.COMPILER_PB_HIDDEN_CATCH_BLOCK;
private static final String PREF_PB_UNUSED_LOCAL= JavaCore.COMPILER_PB_UNUSED_LOCAL;
private static final String PREF_PB_UNUSED_PARAMETER= JavaCore.COMPILER_PB_UNUSED_PARAMETER;
private static final String PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING= JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_OVERRIDING_CONCRETE;
private static final String PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT= JavaCore.COMPILER_PB_UNUSED_PARAMETER_WHEN_IMPLEMENTING_ABSTRACT;
private static final String PREF_PB_SYNTHETIC_ACCESS_EMULATION= JavaCore.COMPILER_PB_SYNTHETIC_ACCESS_EMULATION;
private static final String PREF_PB_NON_EXTERNALIZED_STRINGS= JavaCore.COMPILER_PB_NON_NLS_STRING_LITERAL;
private static final String PREF_PB_ASSERT_AS_IDENTIFIER= JavaCore.COMPILER_PB_ASSERT_IDENTIFIER;
private static final String PREF_PB_MAX_PER_UNIT= JavaCore.COMPILER_PB_MAX_PER_UNIT;
private static final String PREF_PB_UNUSED_IMPORT= JavaCore.COMPILER_PB_UNUSED_IMPORT;
private static final String PREF_PB_UNUSED_PRIVATE= JavaCore.COMPILER_PB_UNUSED_PRIVATE_MEMBER;
private static final String PREF_PB_STATIC_ACCESS_RECEIVER= JavaCore.COMPILER_PB_STATIC_ACCESS_RECEIVER;
private static final String PREF_PB_NO_EFFECT_ASSIGNMENT= JavaCore.COMPILER_PB_NO_EFFECT_ASSIGNMENT;
private static final String PREF_PB_CHAR_ARRAY_IN_CONCAT= JavaCore.COMPILER_PB_CHAR_ARRAY_IN_STRING_CONCATENATION;
private static final String PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT= JavaCore.COMPILER_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT;
private static final String PREF_PB_LOCAL_VARIABLE_HIDING= JavaCore.COMPILER_PB_LOCAL_VARIABLE_HIDING;
private static final String PREF_PB_FIELD_HIDING= JavaCore.COMPILER_PB_FIELD_HIDING;
private static final String PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD= JavaCore.COMPILER_PB_SPECIAL_PARAMETER_HIDING_FIELD;
private static final String PREF_PB_INDIRECT_STATIC_ACCESS= JavaCore.COMPILER_PB_INDIRECT_STATIC_ACCESS;
private static final String PREF_PB_SUPERFLUOUS_SEMICOLON= JavaCore.COMPILER_PB_SUPERFLUOUS_SEMICOLON;
private static final String PREF_PB_UNNECESSARY_TYPE_CHECK= JavaCore.COMPILER_PB_UNNECESSARY_TYPE_CHECK;
private static final String PREF_PB_INVALID_JAVADOC= JavaCore.COMPILER_PB_INVALID_JAVADOC;
private static final String PREF_PB_INVALID_JAVADOC_TAGS= JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS;
private static final String PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY= JavaCore.COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY;
private static final String PREF_PB_MISSING_JAVADOC_TAGS= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS;
private static final String PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY;
private static final String PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING= JavaCore.COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING;
private static final String PREF_PB_MISSING_JAVADOC_COMMENTS= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS;
private static final String PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY;
private static final String PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING= JavaCore.COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING;
private static final String PREF_SOURCE_COMPATIBILITY= JavaCore.COMPILER_SOURCE;
private static final String PREF_COMPLIANCE= JavaCore.COMPILER_COMPLIANCE;
private static final String PREF_RESOURCE_FILTER= JavaCore.CORE_JAVA_BUILD_RESOURCE_COPY_FILTER;
private static final String PREF_BUILD_INVALID_CLASSPATH= JavaCore.CORE_JAVA_BUILD_INVALID_CLASSPATH;
private static final String PREF_BUILD_CLEAN_OUTPUT_FOLDER= JavaCore.CORE_JAVA_BUILD_CLEAN_OUTPUT_FOLDER;
private static final String PREF_ENABLE_EXCLUSION_PATTERNS= JavaCore.CORE_ENABLE_CLASSPATH_EXCLUSION_PATTERNS;
private static final String PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS= JavaCore.CORE_ENABLE_CLASSPATH_MULTIPLE_OUTPUT_LOCATIONS;
private static final String PREF_PB_INCOMPLETE_BUILDPATH= JavaCore.CORE_INCOMPLETE_CLASSPATH;
private static final String PREF_PB_CIRCULAR_BUILDPATH= JavaCore.CORE_CIRCULAR_CLASSPATH;
private static final String PREF_PB_INCOMPATIBLE_JDK_LEVEL= JavaCore.CORE_INCOMPATIBLE_JDK_LEVEL;
private static final String PREF_PB_DEPRECATION_IN_DEPRECATED_CODE= JavaCore.COMPILER_PB_DEPRECATION_IN_DEPRECATED_CODE;
private static final String PREF_PB_DUPLICATE_RESOURCE= JavaCore.CORE_JAVA_BUILD_DUPLICATE_RESOURCE;
private static final String PREF_PB_INCOMPATIBLE_INTERFACE_METHOD= JavaCore.COMPILER_PB_INCOMPATIBLE_NON_INHERITED_INTERFACE_METHOD;
private static final String PREF_PB_UNDOCUMENTED_EMPTY_BLOCK= JavaCore.COMPILER_PB_UNDOCUMENTED_EMPTY_BLOCK;
private static final String PREF_PB_FINALLY_BLOCK_NOT_COMPLETING= JavaCore.COMPILER_PB_FINALLY_BLOCK_NOT_COMPLETING;
private static final String PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION= JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION;
private static final String PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING= JavaCore.COMPILER_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING;
private static final String PREF_PB_UNQUALIFIED_FIELD_ACCESS= JavaCore.COMPILER_PB_UNQUALIFIED_FIELD_ACCESS;
private static final String INTR_DEFAULT_COMPLIANCE= "internal.default.compliance"; //$NON-NLS-1$
// values
private static final String GENERATE= JavaCore.GENERATE;
private static final String DO_NOT_GENERATE= JavaCore.DO_NOT_GENERATE;
private static final String PRESERVE= JavaCore.PRESERVE;
private static final String OPTIMIZE_OUT= JavaCore.OPTIMIZE_OUT;
private static final String VERSION_1_1= JavaCore.VERSION_1_1;
private static final String VERSION_1_2= JavaCore.VERSION_1_2;
private static final String VERSION_1_3= JavaCore.VERSION_1_3;
private static final String VERSION_1_4= JavaCore.VERSION_1_4;
private static final String ERROR= JavaCore.ERROR;
private static final String WARNING= JavaCore.WARNING;
private static final String IGNORE= JavaCore.IGNORE;
private static final String ABORT= JavaCore.ABORT;
private static final String CLEAN= JavaCore.CLEAN;
private static final String ENABLED= JavaCore.ENABLED;
private static final String DISABLED= JavaCore.DISABLED;
private static final String PUBLIC= JavaCore.PUBLIC;
private static final String PROTECTED= JavaCore.PROTECTED;
private static final String DEFAULT= JavaCore.DEFAULT;
private static final String PRIVATE= JavaCore.PRIVATE;
private static final String DEFAULT_CONF= "default"; //$NON-NLS-1$
private static final String USER_CONF= "user"; //$NON-NLS-1$
private ArrayList fComplianceControls;
private PixelConverter fPixelConverter;
private IStatus fComplianceStatus, fMaxNumberProblemsStatus, fResourceFilterStatus;
public CompilerConfigurationBlock(IStatusChangeListener context, IJavaProject project) {
super(context, project);
fComplianceControls= new ArrayList();
fComplianceStatus= new StatusInfo();
fMaxNumberProblemsStatus= new StatusInfo();
fResourceFilterStatus= new StatusInfo();
// compatibilty code for the merge of the two option PB_SIGNAL_PARAMETER:
if (ENABLED.equals(fWorkingValues.get(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT))) {
fWorkingValues.put(PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, ENABLED);
}
}
private final String[] KEYS= new String[] {
PREF_LOCAL_VARIABLE_ATTR, PREF_LINE_NUMBER_ATTR, PREF_SOURCE_FILE_ATTR, PREF_CODEGEN_UNUSED_LOCAL,
PREF_CODEGEN_TARGET_PLATFORM, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD,
PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, PREF_PB_DEPRECATION, PREF_PB_HIDDEN_CATCH_BLOCK, PREF_PB_UNUSED_LOCAL,
PREF_PB_UNUSED_PARAMETER, PREF_PB_SYNTHETIC_ACCESS_EMULATION, PREF_PB_NON_EXTERNALIZED_STRINGS,
PREF_PB_ASSERT_AS_IDENTIFIER, PREF_PB_UNUSED_IMPORT, PREF_PB_MAX_PER_UNIT, PREF_SOURCE_COMPATIBILITY, PREF_COMPLIANCE,
PREF_RESOURCE_FILTER, PREF_BUILD_INVALID_CLASSPATH, PREF_PB_STATIC_ACCESS_RECEIVER, PREF_PB_INCOMPLETE_BUILDPATH,
PREF_PB_CIRCULAR_BUILDPATH, PREF_PB_DEPRECATION_IN_DEPRECATED_CODE, PREF_BUILD_CLEAN_OUTPUT_FOLDER,
PREF_PB_DUPLICATE_RESOURCE, PREF_PB_NO_EFFECT_ASSIGNMENT, PREF_PB_INCOMPATIBLE_INTERFACE_METHOD,
PREF_PB_UNUSED_PRIVATE, PREF_PB_CHAR_ARRAY_IN_CONCAT, PREF_ENABLE_EXCLUSION_PATTERNS, PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS,
PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, PREF_PB_LOCAL_VARIABLE_HIDING, PREF_PB_FIELD_HIDING,
PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD, PREF_PB_INCOMPATIBLE_JDK_LEVEL, PREF_PB_INDIRECT_STATIC_ACCESS,
PREF_PB_SUPERFLUOUS_SEMICOLON, PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT,
PREF_PB_UNNECESSARY_TYPE_CHECK, PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION, PREF_PB_UNQUALIFIED_FIELD_ACCESS,
PREF_PB_UNDOCUMENTED_EMPTY_BLOCK, PREF_PB_FINALLY_BLOCK_NOT_COMPLETING, PREF_PB_DEPRECATION_WHEN_OVERRIDING,
PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING,
PREF_PB_INVALID_JAVADOC, PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY,
PREF_PB_MISSING_JAVADOC_TAGS, PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING,
PREF_PB_MISSING_JAVADOC_COMMENTS, PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING
};
protected String[] getAllKeys() {
return KEYS;
}
protected final Map getOptions(boolean inheritJavaCoreOptions) {
Map map= super.getOptions(inheritJavaCoreOptions);
map.put(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance(map));
return map;
}
protected final Map getDefaultOptions() {
Map map= super.getDefaultOptions();
map.put(INTR_DEFAULT_COMPLIANCE, getCurrentCompliance(map));
return map;
}
/*
* @see org.eclipse.jface.preference.PreferencePage#createContents(Composite)
*/
protected Control createContents(Composite parent) {
fPixelConverter= new PixelConverter(parent);
setShell(parent.getShell());
TabFolder folder= new TabFolder(parent, SWT.NONE);
folder.setLayout(new TabFolderLayout());
folder.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite commonComposite= createStyleTabContent(folder);
Composite unusedComposite= createUnusedCodeTabContent(folder);
Composite advancedComposite= createAdvancedTabContent(folder);
Composite javadocComposite= createJavadocTabContent(folder);
Composite complianceComposite= createComplianceTabContent(folder);
Composite othersComposite= createBuildPathTabContent(folder);
TabItem item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.common.tabtitle")); //$NON-NLS-1$
item.setControl(commonComposite);
item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.advanced.tabtitle")); //$NON-NLS-1$
item.setControl(advancedComposite);
item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.unused.tabtitle")); //$NON-NLS-1$
item.setControl(unusedComposite);
item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.javadoc.tabtitle")); //$NON-NLS-1$
item.setControl(javadocComposite);
item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.compliance.tabtitle")); //$NON-NLS-1$
item.setControl(complianceComposite);
item= new TabItem(folder, SWT.NONE);
item.setText(PreferencesMessages.getString("CompilerConfigurationBlock.others.tabtitle")); //$NON-NLS-1$
item.setControl(othersComposite);
validateSettings(null, null);
return folder;
}
private Composite createStyleTabContent(Composite folder) {
String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
String[] errorWarningIgnoreLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
};
int nColumns= 3;
GridLayout layout= new GridLayout();
layout.numColumns= nColumns;
Composite composite= new Composite(folder, SWT.NULL);
composite.setLayout(layout);
Label description= new Label(composite, SWT.WRAP);
description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.common.description")); //$NON-NLS-1$
GridData gd= new GridData();
gd.horizontalSpan= nColumns;
gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50);
description.setLayoutData(gd);
String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_overriding_pkg_dflt.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_OVERRIDING_PACKAGE_DEFAULT_METHOD, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_method_naming.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_METHOD_WITH_CONSTRUCTOR_NAME, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_hidden_catchblock.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_HIDDEN_CATCH_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_static_access_receiver.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_STATIC_ACCESS_RECEIVER, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_no_effect_assignment.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_NO_EFFECT_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_indirect_access_to_static.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_INDIRECT_STATIC_ACCESS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_accidential_assignement.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_POSSIBLE_ACCIDENTAL_BOOLEAN_ASSIGNMENT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_finally_block_not_completing.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_FINALLY_BLOCK_NOT_COMPLETING, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_undocumented_empty_block.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNDOCUMENTED_EMPTY_BLOCK, errorWarningIgnore, errorWarningIgnoreLabels, 0);
return composite;
}
private Composite createAdvancedTabContent(TabFolder folder) {
String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
String[] errorWarningIgnoreLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
};
String[] enabledDisabled= new String[] { ENABLED, DISABLED };
int nColumns= 3;
GridLayout layout= new GridLayout();
layout.numColumns= nColumns;
Composite composite= new Composite(folder, SWT.NULL);
composite.setLayout(layout);
Label description= new Label(composite, SWT.WRAP);
description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.advanced.description")); //$NON-NLS-1$
GridData gd= new GridData();
gd.horizontalSpan= nColumns;
gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50);
description.setLayoutData(gd);
String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_synth_access_emul.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_SYNTHETIC_ACCESS_EMULATION, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_local_variable_hiding.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_LOCAL_VARIABLE_HIDING, errorWarningIgnore, errorWarningIgnoreLabels, 0);
int indent= fPixelConverter.convertWidthInCharsToPixels(2);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_special_param_hiding.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD, enabledDisabled, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_field_hiding.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_FIELD_HIDING, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_non_externalized_strings.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_NON_EXTERNALIZED_STRINGS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_incompatible_interface_method.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_INCOMPATIBLE_INTERFACE_METHOD, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_char_array_in_concat.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_CHAR_ARRAY_IN_CONCAT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unqualified_field_access.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNQUALIFIED_FIELD_ACCESS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
gd= new GridData();
gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(6);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_max_per_unit.label"); //$NON-NLS-1$
Text text= addTextField(composite, label, PREF_PB_MAX_PER_UNIT, 0, 0);
text.setTextLimit(6);
text.setLayoutData(gd);
return composite;
}
private Composite createUnusedCodeTabContent(TabFolder folder) {
String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
String[] errorWarningIgnoreLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
};
String[] enabledDisabled= new String[] { ENABLED, DISABLED };
int nColumns= 3;
GridLayout layout= new GridLayout();
layout.numColumns= nColumns;
Composite composite= new Composite(folder, SWT.NULL);
composite.setLayout(layout);
Label description= new Label(composite, SWT.WRAP);
description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.unused.description")); //$NON-NLS-1$
GridData gd= new GridData();
gd.horizontalSpan= nColumns;
gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50);
description.setLayoutData(gd);
String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_local.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNUSED_LOCAL, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_parameter.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNUSED_PARAMETER, errorWarningIgnore, errorWarningIgnoreLabels, 0);
int indent= fPixelConverter.convertWidthInCharsToPixels(2);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_signal_param_in_overriding.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING, enabledDisabled, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_imports.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNUSED_IMPORT, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_private.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNUSED_PRIVATE, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_deprecation.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_DEPRECATION, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_deprecation_in_deprecation.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_DEPRECATION_IN_DEPRECATED_CODE, enabledDisabled, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_deprecation_when_overriding.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_DEPRECATION_WHEN_OVERRIDING, enabledDisabled, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_superfluous_semicolon.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_SUPERFLUOUS_SEMICOLON, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unnecessary_type_check.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNNECESSARY_TYPE_CHECK, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_throwing_exception.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_unused_throwing_exception_when_overriding.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING, enabledDisabled, indent);
return composite;
}
private Composite createJavadocTabContent(TabFolder folder) {
String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
String[] errorWarningIgnoreLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
};
String[] enabledDisabled= new String[] { ENABLED, DISABLED };
String[] visibilities= new String[] { PUBLIC, PROTECTED, DEFAULT, PRIVATE };
String[] visibilitiesLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.public"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.protected"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.default"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.private") //$NON-NLS-1$
};
int nColumns= 3;
/*
* COMPILER_PB_INVALID_JAVADOC: "ignore", "warning", "error"
COMPILER_PB_INVALID_JAVADOC_TAGS: "enabled", "disabled"
COMPILER_PB_INVALID_JAVADOC_TAGS_VISIBILITY: "public", "protected", "default", "private"
COMPILER_PB_MISSING_JAVADOC_TAGS: "ignore", "warning", "error"
COMPILER_PB_MISSING_JAVADOC_TAGS_VISIBILITY: "public", "protected", "default", "private"
COMPILER_PB_MISSING_JAVADOC_TAGS_OVERRIDING: "enabled", "disabled"
COMPILER_PB_MISSING_JAVADOC_COMMENTS: "ignore", "warning", "error"
COMPILER_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY: "public", "protected", "default", "private"
COMPILER_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING: "enabled", "disabled"
*/
// GridLayout layout = new GridLayout();
// layout.numColumns= nColumns;
//
// Composite composite= new Composite(folder, SWT.NULL);
// composite.setLayout(layout);
//
// Label description= new Label(composite, SWT.WRAP);
// description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.javadoc.description")); //$NON-NLS-1$
// GridData gd= new GridData();
// gd.horizontalSpan= nColumns;
// gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50);
// description.setLayoutData(gd);
GridLayout layout = new GridLayout();
layout.numColumns= nColumns;
Composite composite= new Composite(folder, SWT.NULL);
composite.setLayout(layout);
Label description= new Label(composite, SWT.WRAP);
description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.javadoc.description")); //$NON-NLS-1$
GridData gd= new GridData();
gd.horizontalSpan= nColumns;
gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(50);
description.setLayoutData(gd);
int indent= fPixelConverter.convertWidthInCharsToPixels(2);
String label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_comments.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_COMMENTS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_comments_visibility.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, visibilities, visibilitiesLabels, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_comments_overriding.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING, enabledDisabled, indent);
Label separator= new Label(composite, SWT.HORIZONTAL);
gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan= nColumns;
separator.setLayoutData(gd);
label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_javadoc.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_TAGS, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_javadoc_tags_visibility.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, visibilities, visibilitiesLabels, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_missing_javadoc_tags_overriding.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING, enabledDisabled, indent);
separator= new Label(composite, SWT.HORIZONTAL);
gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
gd.horizontalSpan= nColumns;
separator.setLayoutData(gd);
label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_invalid_javadoc.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_INVALID_JAVADOC, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label = PreferencesMessages.getString("CompilerConfigurationBlock.pb_invalid_javadoc_tags_visibility.label"); //$NON-NLS-1$
addComboBox(composite, label, PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, visibilities, visibilitiesLabels, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_invalid_javadoc_tags.label"); //$NON-NLS-1$
addCheckBox(composite, label, PREF_PB_INVALID_JAVADOC_TAGS, enabledDisabled, indent);
return composite;
}
private Composite createBuildPathTabContent(TabFolder folder) {
String[] abortIgnoreValues= new String[] { ABORT, IGNORE };
String[] cleanIgnoreValues= new String[] { CLEAN, IGNORE };
String[] enableDisableValues= new String[] { ENABLED, DISABLED };
String[] errorWarning= new String[] { ERROR, WARNING };
String[] errorWarningLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.warning") //$NON-NLS-1$
};
int nColumns= 3;
GridLayout layout= new GridLayout();
layout.numColumns= nColumns;
Composite othersComposite= new Composite(folder, SWT.NULL);
othersComposite.setLayout(layout);
Label description= new Label(othersComposite, SWT.WRAP);
description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.build_warnings.description")); //$NON-NLS-1$
GridData gd= new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
gd.horizontalSpan= nColumns;
description.setLayoutData(gd);
String label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_incomplete_build_path.label"); //$NON-NLS-1$
addComboBox(othersComposite, label, PREF_PB_INCOMPLETE_BUILDPATH, errorWarning, errorWarningLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_build_path_cycles.label"); //$NON-NLS-1$
addComboBox(othersComposite, label, PREF_PB_CIRCULAR_BUILDPATH, errorWarning, errorWarningLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_duplicate_resources.label"); //$NON-NLS-1$
addComboBox(othersComposite, label, PREF_PB_DUPLICATE_RESOURCE, errorWarning, errorWarningLabels, 0);
String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
String[] errorWarningIgnoreLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
};
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_check_prereq_binary_level.label"); //$NON-NLS-1$
addComboBox(othersComposite, label, PREF_PB_INCOMPATIBLE_JDK_LEVEL, errorWarningIgnore, errorWarningIgnoreLabels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.build_invalid_classpath.label"); //$NON-NLS-1$
addCheckBox(othersComposite, label, PREF_BUILD_INVALID_CLASSPATH, abortIgnoreValues, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.build_clean_outputfolder.label"); //$NON-NLS-1$
addCheckBox(othersComposite, label, PREF_BUILD_CLEAN_OUTPUT_FOLDER, cleanIgnoreValues, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.enable_exclusion_patterns.label"); //$NON-NLS-1$
addCheckBox(othersComposite, label, PREF_ENABLE_EXCLUSION_PATTERNS, enableDisableValues, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.enable_multiple_outputlocations.label"); //$NON-NLS-1$
addCheckBox(othersComposite, label, PREF_ENABLE_MULTIPLE_OUTPUT_LOCATIONS, enableDisableValues, 0);
description= new Label(othersComposite, SWT.WRAP);
description.setText(PreferencesMessages.getString("CompilerConfigurationBlock.resource_filter.description")); //$NON-NLS-1$
gd= new GridData(GridData.FILL);
gd.horizontalSpan= nColumns;
gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(60);
description.setLayoutData(gd);
label= PreferencesMessages.getString("CompilerConfigurationBlock.resource_filter.label"); //$NON-NLS-1$
Text text= addTextField(othersComposite, label, PREF_RESOURCE_FILTER, 0, 0);
gd= (GridData) text.getLayoutData();
gd.grabExcessHorizontalSpace= true;
gd.widthHint= fPixelConverter.convertWidthInCharsToPixels(10);
return othersComposite;
}
private Composite createComplianceTabContent(Composite folder) {
GridLayout layout= new GridLayout();
layout.numColumns= 1;
String[] values34= new String[] { VERSION_1_3, VERSION_1_4 };
String[] values34Labels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.version13"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.version14") //$NON-NLS-1$
};
Composite compComposite= new Composite(folder, SWT.NULL);
compComposite.setLayout(layout);
int nColumns= 3;
layout= new GridLayout();
layout.numColumns= nColumns;
Group group= new Group(compComposite, SWT.NONE);
group.setText(PreferencesMessages.getString("CompilerConfigurationBlock.compliance.group.label")); //$NON-NLS-1$
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
group.setLayout(layout);
String label= PreferencesMessages.getString("CompilerConfigurationBlock.compiler_compliance.label"); //$NON-NLS-1$
addComboBox(group, label, PREF_COMPLIANCE, values34, values34Labels, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.default_settings.label"); //$NON-NLS-1$
addCheckBox(group, label, INTR_DEFAULT_COMPLIANCE, new String[] { DEFAULT_CONF, USER_CONF }, 0);
int indent= fPixelConverter.convertWidthInCharsToPixels(2);
Control[] otherChildren= group.getChildren();
String[] values14= new String[] { VERSION_1_1, VERSION_1_2, VERSION_1_3, VERSION_1_4 };
String[] values14Labels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.version11"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.version12"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.version13"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.version14") //$NON-NLS-1$
};
label= PreferencesMessages.getString("CompilerConfigurationBlock.codegen_targetplatform.label"); //$NON-NLS-1$
addComboBox(group, label, PREF_CODEGEN_TARGET_PLATFORM, values14, values14Labels, indent);
label= PreferencesMessages.getString("CompilerConfigurationBlock.source_compatibility.label"); //$NON-NLS-1$
addComboBox(group, label, PREF_SOURCE_COMPATIBILITY, values34, values34Labels, indent);
String[] errorWarningIgnore= new String[] { ERROR, WARNING, IGNORE };
String[] errorWarningIgnoreLabels= new String[] {
PreferencesMessages.getString("CompilerConfigurationBlock.error"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.warning"), //$NON-NLS-1$
PreferencesMessages.getString("CompilerConfigurationBlock.ignore") //$NON-NLS-1$
};
label= PreferencesMessages.getString("CompilerConfigurationBlock.pb_assert_as_identifier.label"); //$NON-NLS-1$
addComboBox(group, label, PREF_PB_ASSERT_AS_IDENTIFIER, errorWarningIgnore, errorWarningIgnoreLabels, indent);
Control[] allChildren= group.getChildren();
fComplianceControls.addAll(Arrays.asList(allChildren));
fComplianceControls.removeAll(Arrays.asList(otherChildren));
layout= new GridLayout();
layout.numColumns= nColumns;
group= new Group(compComposite, SWT.NONE);
group.setText(PreferencesMessages.getString("CompilerConfigurationBlock.classfiles.group.label")); //$NON-NLS-1$
group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
group.setLayout(layout);
String[] generateValues= new String[] { GENERATE, DO_NOT_GENERATE };
label= PreferencesMessages.getString("CompilerConfigurationBlock.variable_attr.label"); //$NON-NLS-1$
addCheckBox(group, label, PREF_LOCAL_VARIABLE_ATTR, generateValues, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.line_number_attr.label"); //$NON-NLS-1$
addCheckBox(group, label, PREF_LINE_NUMBER_ATTR, generateValues, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.source_file_attr.label"); //$NON-NLS-1$
addCheckBox(group, label, PREF_SOURCE_FILE_ATTR, generateValues, 0);
label= PreferencesMessages.getString("CompilerConfigurationBlock.codegen_unused_local.label"); //$NON-NLS-1$
addCheckBox(group, label, PREF_CODEGEN_UNUSED_LOCAL, new String[] { PRESERVE, OPTIMIZE_OUT }, 0);
return compComposite;
}
/* (non-javadoc)
* Update fields and validate.
* @param changedKey Key that changed, or null, if all changed.
*/
protected void validateSettings(String changedKey, String newValue) {
if (changedKey != null) {
if (INTR_DEFAULT_COMPLIANCE.equals(changedKey)) {
updateComplianceEnableState();
if (DEFAULT_CONF.equals(newValue)) {
updateComplianceDefaultSettings();
}
fComplianceStatus= validateCompliance();
} else if (PREF_COMPLIANCE.equals(changedKey)) {
if (checkValue(INTR_DEFAULT_COMPLIANCE, DEFAULT_CONF)) {
updateComplianceDefaultSettings();
}
fComplianceStatus= validateCompliance();
} else if (PREF_SOURCE_COMPATIBILITY.equals(changedKey) ||
PREF_CODEGEN_TARGET_PLATFORM.equals(changedKey) ||
PREF_PB_ASSERT_AS_IDENTIFIER.equals(changedKey)) {
fComplianceStatus= validateCompliance();
} else if (PREF_PB_MAX_PER_UNIT.equals(changedKey)) {
fMaxNumberProblemsStatus= validateMaxNumberProblems();
} else if (PREF_RESOURCE_FILTER.equals(changedKey)) {
fResourceFilterStatus= validateResourceFilters();
} else if (PREF_PB_UNUSED_PARAMETER.equals(changedKey) ||
PREF_PB_DEPRECATION.equals(changedKey) ||
PREF_PB_INVALID_JAVADOC.equals(changedKey) ||
PREF_PB_MISSING_JAVADOC_TAGS.equals(changedKey) ||
PREF_PB_MISSING_JAVADOC_COMMENTS.equals(changedKey) ||
PREF_PB_MISSING_JAVADOC_COMMENTS.equals(changedKey) ||
PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION.equals(changedKey)) {
updateEnableStates();
} else if (PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING.equals(changedKey)) {
// merging the two options
fWorkingValues.put(PREF_PB_SIGNAL_PARAMETER_IN_ABSTRACT, newValue);
} else {
return;
}
} else {
updateEnableStates();
updateComplianceEnableState();
fComplianceStatus= validateCompliance();
fMaxNumberProblemsStatus= validateMaxNumberProblems();
fResourceFilterStatus= validateResourceFilters();
}
IStatus status= StatusUtil.getMostSevere(new IStatus[] { fComplianceStatus, fMaxNumberProblemsStatus, fResourceFilterStatus });
fContext.statusChanged(status);
}
private void updateEnableStates() {
boolean enableUnusedParams= !checkValue(PREF_PB_UNUSED_PARAMETER, IGNORE);
getCheckBox(PREF_PB_SIGNAL_PARAMETER_IN_OVERRIDING).setEnabled(enableUnusedParams);
boolean enableDeprecation= !checkValue(PREF_PB_DEPRECATION, IGNORE);
getCheckBox(PREF_PB_DEPRECATION_IN_DEPRECATED_CODE).setEnabled(enableDeprecation);
getCheckBox(PREF_PB_DEPRECATION_WHEN_OVERRIDING).setEnabled(enableDeprecation);
boolean enableThrownExceptions= !checkValue(PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION, IGNORE);
getCheckBox(PREF_PB_UNUSED_DECLARED_THROWN_EXCEPTION_WHEN_OVERRIDING).setEnabled(enableThrownExceptions);
boolean enableHiding= !checkValue(PREF_PB_LOCAL_VARIABLE_HIDING, IGNORE);
getCheckBox(PREF_PB_SPECIAL_PARAMETER_HIDING_FIELD).setEnabled(enableHiding);
boolean enableInvalidTagsErrors= !checkValue(PREF_PB_INVALID_JAVADOC, IGNORE);
getCheckBox(PREF_PB_INVALID_JAVADOC_TAGS).setEnabled(enableInvalidTagsErrors);
setComboEnabled(PREF_PB_INVALID_JAVADOC_TAGS_VISIBILITY, enableInvalidTagsErrors);
boolean enableMissingTagsErrors= !checkValue(PREF_PB_MISSING_JAVADOC_TAGS, IGNORE);
getCheckBox(PREF_PB_MISSING_JAVADOC_TAGS_OVERRIDING).setEnabled(enableMissingTagsErrors);
setComboEnabled(PREF_PB_MISSING_JAVADOC_TAGS_VISIBILITY, enableMissingTagsErrors);
boolean enableMissingCommentsErrors= !checkValue(PREF_PB_MISSING_JAVADOC_COMMENTS, IGNORE);
getCheckBox(PREF_PB_MISSING_JAVADOC_COMMENTS_OVERRIDING).setEnabled(enableMissingCommentsErrors);
setComboEnabled(PREF_PB_MISSING_JAVADOC_COMMENTS_VISIBILITY, enableMissingCommentsErrors);
}
private IStatus validateCompliance() {
StatusInfo status= new StatusInfo();
if (checkValue(PREF_COMPLIANCE, VERSION_1_3)) {
if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) {
status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl13src14.error")); //$NON-NLS-1$
return status;
} else if (checkValue(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_4)) {
status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.cpl13trg14.error")); //$NON-NLS-1$
return status;
}
}
if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) {
if (!checkValue(PREF_PB_ASSERT_AS_IDENTIFIER, ERROR)) {
status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.src14asrterr.error")); //$NON-NLS-1$
return status;
}
}
if (checkValue(PREF_SOURCE_COMPATIBILITY, VERSION_1_4)) {
if (!checkValue(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_4)) {
status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.src14tgt14.error")); //$NON-NLS-1$
return status;
}
}
return status;
}
private IStatus validateMaxNumberProblems() {
String number= (String) fWorkingValues.get(PREF_PB_MAX_PER_UNIT);
StatusInfo status= new StatusInfo();
if (number.length() == 0) {
status.setError(PreferencesMessages.getString("CompilerConfigurationBlock.empty_input")); //$NON-NLS-1$
} else {
try {
int value= Integer.parseInt(number);
if (value <= 0) {
status.setError(PreferencesMessages.getFormattedString("CompilerConfigurationBlock.invalid_input", number)); //$NON-NLS-1$
}
} catch (NumberFormatException e) {
status.setError(PreferencesMessages.getFormattedString("CompilerConfigurationBlock.invalid_input", number)); //$NON-NLS-1$
}
}
return status;
}
private IStatus validateResourceFilters() {
String text= (String) fWorkingValues.get(PREF_RESOURCE_FILTER);
IWorkspace workspace= ResourcesPlugin.getWorkspace();
String[] filters= getTokens(text, ","); //$NON-NLS-1$
for (int i= 0; i < filters.length; i++) {
String fileName= filters[i].replace('*', 'x');
int resourceType= IResource.FILE;
int lastCharacter= fileName.length() - 1;
if (lastCharacter >= 0 && fileName.charAt(lastCharacter) == '/') {
fileName= fileName.substring(0, lastCharacter);
resourceType= IResource.FOLDER;
}
IStatus status= workspace.validateName(fileName, resourceType);
if (status.matches(IStatus.ERROR)) {
String message= PreferencesMessages.getFormattedString("CompilerConfigurationBlock.filter.invalidsegment.error", status.getMessage()); //$NON-NLS-1$
return new StatusInfo(IStatus.ERROR, message);
}
}
return new StatusInfo();
}
/*
* Update the compliance controls' enable state
*/
private void updateComplianceEnableState() {
boolean enabled= checkValue(INTR_DEFAULT_COMPLIANCE, USER_CONF);
for (int i= fComplianceControls.size() - 1; i >= 0; i--) {
Control curr= (Control) fComplianceControls.get(i);
curr.setEnabled(enabled);
}
}
/*
* Set the default compliance values derived from the chosen level
*/
private void updateComplianceDefaultSettings() {
Object complianceLevel= fWorkingValues.get(PREF_COMPLIANCE);
if (VERSION_1_3.equals(complianceLevel)) {
fWorkingValues.put(PREF_PB_ASSERT_AS_IDENTIFIER, IGNORE);
fWorkingValues.put(PREF_SOURCE_COMPATIBILITY, VERSION_1_3);
fWorkingValues.put(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_1);
} else if (VERSION_1_4.equals(complianceLevel)) {
fWorkingValues.put(PREF_PB_ASSERT_AS_IDENTIFIER, WARNING);
fWorkingValues.put(PREF_SOURCE_COMPATIBILITY, VERSION_1_3);
fWorkingValues.put(PREF_CODEGEN_TARGET_PLATFORM, VERSION_1_2);
}
updateControls();
}
/*
* Evaluate if the current compliance setting correspond to a default setting
*/
private static String getCurrentCompliance(Map map) {
Object complianceLevel= map.get(PREF_COMPLIANCE);
if ((VERSION_1_3.equals(complianceLevel)
&& IGNORE.equals(map.get(PREF_PB_ASSERT_AS_IDENTIFIER))
&& VERSION_1_3.equals(map.get(PREF_SOURCE_COMPATIBILITY))
&& VERSION_1_1.equals(map.get(PREF_CODEGEN_TARGET_PLATFORM)))
|| (VERSION_1_4.equals(complianceLevel)
&& WARNING.equals(map.get(PREF_PB_ASSERT_AS_IDENTIFIER))
&& VERSION_1_3.equals(map.get(PREF_SOURCE_COMPATIBILITY))
&& VERSION_1_2.equals(map.get(PREF_CODEGEN_TARGET_PLATFORM)))) {
return DEFAULT_CONF;
}
return USER_CONF;
}
protected String[] getFullBuildDialogStrings(boolean workspaceSettings) {
String title= PreferencesMessages.getString("CompilerConfigurationBlock.needsbuild.title"); //$NON-NLS-1$
String message;
if (workspaceSettings) {
message= PreferencesMessages.getString("CompilerConfigurationBlock.needsfullbuild.message"); //$NON-NLS-1$
} else {
message= PreferencesMessages.getString("CompilerConfigurationBlock.needsprojectbuild.message"); //$NON-NLS-1$
}
return new String[] { title, message };
}
}
|
51,890 |
Bug 51890 [Code formatter] Option to insert space inside empty brackets in allocation expression
|
Using 200402121200, this option is not visible if I display the tree by Java element. If I display the tree by Syntax element, I can find it. This seems inconsistent. I can provide screenshots if necessary.
|
resolved fixed
|
975765b
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T12:04:13Z | 2004-02-12T18:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/formatter/WhiteSpaceOptions.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.preferences.formatter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.formatter.CodeFormatter;
import org.eclipse.jdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.jdt.internal.ui.preferences.formatter.SnippetPreview.PreviewSnippet;
/**
* Manage code formatter white space options on a higher level.
*/
public final class WhiteSpaceOptions {
/**
* Represents a node in the options tree.
*/
public abstract static class Node {
private final InnerNode fParent;
private final String fName;
public int index;
protected final Map fWorkingValues;
protected final ArrayList fChildren;
public Node(InnerNode parent, Map workingValues, String messageKey) {
if (workingValues == null || messageKey == null)
throw new IllegalArgumentException();
fParent= parent;
fWorkingValues= workingValues;
fName= FormatterMessages.getString(messageKey);
fChildren= new ArrayList();
if (fParent != null)
fParent.add(this);
}
public abstract void setChecked(boolean checked);
public boolean hasChildren() {
return !fChildren.isEmpty();
}
public List getChildren() {
return Collections.unmodifiableList(fChildren);
}
public InnerNode getParent() {
return fParent;
}
public final String toString() {
return fName;
}
public abstract List getSnippets();
public abstract void getCheckedLeafs(List list);
}
/**
* A node representing a group of options in the tree.
*/
public static class InnerNode extends Node {
public InnerNode(InnerNode parent, Map workingValues, String messageKey) {
super(parent, workingValues, messageKey);
}
public void setChecked(boolean checked) {
for (final Iterator iter = fChildren.iterator(); iter.hasNext();)
((Node)iter.next()).setChecked(checked);
}
public void add(Node child) {
fChildren.add(child);
}
public List getSnippets() {
final ArrayList snippets= new ArrayList(fChildren.size());
for (Iterator iter= fChildren.iterator(); iter.hasNext();) {
final List childSnippets= ((Node)iter.next()).getSnippets();
for (final Iterator chIter= childSnippets.iterator(); chIter.hasNext(); ) {
final Object snippet= chIter.next();
if (!snippets.contains(snippet))
snippets.add(snippet);
}
}
return snippets;
}
public void getCheckedLeafs(List list) {
for (Iterator iter= fChildren.iterator(); iter.hasNext();) {
((Node)iter.next()).getCheckedLeafs(list);
}
}
}
/**
* A node representing a concrete white space option in the tree.
*/
public static class OptionNode extends Node {
private final String fKey;
private final ArrayList fSnippets;
public OptionNode(InnerNode parent, Map workingValues, String messageKey, String key, PreviewSnippet snippet) {
super(parent, workingValues, messageKey);
fKey= key;
fSnippets= new ArrayList(1);
fSnippets.add(snippet);
}
public void setChecked(boolean checked) {
fWorkingValues.put(fKey, checked ? JavaCore.INSERT : JavaCore.DO_NOT_INSERT);
}
public boolean getChecked() {
return JavaCore.INSERT.equals(fWorkingValues.get(fKey));
}
public List getSnippets() {
return fSnippets;
}
public void getCheckedLeafs(List list) {
if (getChecked())
list.add(this);
}
}
/**
* Preview snippets.
*/
private final static PreviewSnippet FOR_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"for (int i= 0, j= array.length; i < array.length; i++, j--) {}" //$NON-NLS-1$
);
private final static PreviewSnippet WHILE_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"while (condition) {}; do {} while (condition);" //$NON-NLS-1$
);
private final static PreviewSnippet CATCH_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"try { number= Integer.parseInt(value); } catch (NumberFormatException e) {}"); //$NON-NLS-1$
private final static PreviewSnippet IF_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"if (condition) { return foo; } else {return bar;}"); //$NON-NLS-1$
private final static PreviewSnippet SYNCHRONIZED_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"synchronized (list) { list.add(element); }"); //$NON-NLS-1$
private final static PreviewSnippet SWITCH_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"switch (number) { case RED: return GREEN; case GREEN: return BLUE; case BLUE: return RED; default: return BLACK;}"); //$NON-NLS-1$
private final static PreviewSnippet CONSTRUCTOR_DECL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_CLASS_BODY_DECLARATIONS,
"MyClass() throws E0, E1 { this(0,0,0);}" + //$NON-NLS-1$
"MyClass(int x, int y, int z) throws E0, E1 { super(x, y, z, true);}"); //$NON-NLS-1$
private final static PreviewSnippet METHOD_DECL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_CLASS_BODY_DECLARATIONS,
"void foo() throws E0, E1 {};" + //$NON-NLS-1$
"void bar(int x, int y) throws E0, E1 {}"); //$NON-NLS-1$
private final static PreviewSnippet ARRAY_DECL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"int [] array0= new int [] {};\n" + //$NON-NLS-1$
"int [] array1= new int [] {1, 2, 3};\n" + //$NON-NLS-1$
"int [] array2= new int[3];"); //$NON-NLS-1$
private final static PreviewSnippet ARRAY_REF_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"array[i].foo();"); //$NON-NLS-1$
private final static PreviewSnippet METHOD_CALL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"foo();\n" + //$NON-NLS-1$
"bar(x, y);"); //$NON-NLS-1$
// private final static PreviewSnippet CONSTR_CALL_PREVIEW= new PreviewSnippet(
// CodeFormatter.K_STATEMENTS,
// "this();\n\n" + //$NON-NLS-1$
// "this(x, y);\n"); //$NON-NLS-1$
private final static PreviewSnippet ALLOC_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"String str= new String(); Point point= new Point(x, y);"); //$NON-NLS-1$
private final static PreviewSnippet LABEL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"label: for (int i= 0; i<list.length; i++) {for (int j= 0; j < list[i].length; j++) continue label;}"); //$NON-NLS-1$
private final static PreviewSnippet SEMICOLON_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"int a= 4; foo(); bar(x, y);"); //$NON-NLS-1$
private final static PreviewSnippet CONDITIONAL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"String value= condition ? TRUE : FALSE;"); //$NON-NLS-1$
private final static PreviewSnippet CLASS_DECL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_COMPILATION_UNIT,
"class MyClass implements I0, I1, I2 {}"); //$NON-NLS-1$
private final static PreviewSnippet ANON_CLASS_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"AnonClass= new AnonClass() {void foo(Some s) { }};"); //$NON-NLS-1$
private final static PreviewSnippet OPERATOR_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"List list= new ArrayList(); int a= -4 + -9; b= a++ / --number; c += 4; boolean value= true && false;"); //$NON-NLS-1$
private final static PreviewSnippet CAST_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"String s= ((String)object);"); //$NON-NLS-1$
private final static PreviewSnippet MULT_LOCAL_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"int a= 0, b= 1, c= 2, d= 3;"); //$NON-NLS-1$
private final static PreviewSnippet MULT_FIELD_PREVIEW= new PreviewSnippet(
CodeFormatter.K_CLASS_BODY_DECLARATIONS,
"int a=0,b=1,c=2,d=3;"); //$NON-NLS-1$
private final static PreviewSnippet BLOCK_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"if (true) { return 1; } else { return 2; }"); //$NON-NLS-1$
private final static PreviewSnippet PAREN_EXPR_PREVIEW= new PreviewSnippet(
CodeFormatter.K_STATEMENTS,
"result= (a *( b + c + d) * (e + f));"); //$NON-NLS-1$
//TODO: integrate this
// private final static PreviewSnippet ASSERT_PREVIEW= new PreviewSnippet(
// CodeFormatter.K_STATEMENTS,
// "assert condition : reportError();"
// );
/**
* Create the tree, in this order: position - syntax element - abstract
* element
*/
public static ArrayList createTreeByPosition(Map workingValues) {
final ArrayList roots= new ArrayList();
final InnerNode before= new InnerNode(null, workingValues, "WhiteSpaceOptions.before"); //$NON-NLS-1$
createBeforeOpenParenTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.opening_paren")); //$NON-NLS-1$
createBeforeClosingParenTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.closing_paren")); //$NON-NLS-1$
createBeforeOpenBraceTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.opening_brace")); //$NON-NLS-1$
createBeforeClosingBraceTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.closing_brace")); //$NON-NLS-1$
createBeforeOpenBracketTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.opening_bracket")); //$NON-NLS-1$
createBeforeClosingBracketTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.closing_bracket")); //$NON-NLS-1$
createBeforeOperatorTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.operator")); //$NON-NLS-1$
createBeforeCommaTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.comma")); //$NON-NLS-1$
createBeforeColonTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.colon")); //$NON-NLS-1$
createBeforeSemicolonTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.semicolon")); //$NON-NLS-1$
createBeforeQuestionTree(workingValues, createChild(before, workingValues, "WhiteSpaceOptions.question_mark")); //$NON-NLS-1$
roots.add(before);
final InnerNode after= new InnerNode(null, workingValues, "WhiteSpaceOptions.after"); //$NON-NLS-1$
createAfterOpenParenTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.opening_paren")); //$NON-NLS-1$
createAfterCloseParenTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.closing_paren")); //$NON-NLS-1$
createAfterOpenBraceTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.opening_brace")); //$NON-NLS-1$
createAfterCloseBraceTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.closing_brace")); //$NON-NLS-1$
createAfterOpenBracketTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.opening_bracket")); //$NON-NLS-1$
createAfterOperatorTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.operator")); //$NON-NLS-1$
createAfterCommaTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.comma")); //$NON-NLS-1$
createAfterColonTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.colon")); //$NON-NLS-1$
createAfterSemicolonTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.semicolon")); //$NON-NLS-1$
createAfterQuestionTree(workingValues, createChild(after, workingValues, "WhiteSpaceOptions.question_mark")); //$NON-NLS-1$
roots.add(after);
final InnerNode between= new InnerNode(null, workingValues, "WhiteSpaceOptions.between"); //$NON-NLS-1$
createBetweenEmptyBracesTree(workingValues, createChild(between, workingValues, "WhiteSpaceOptions.empty_braces")); //$NON-NLS-1$
createBetweenEmptyBracketsTree(workingValues, createChild(between, workingValues, "WhiteSpaceOptions.empty_brackets")); //$NON-NLS-1$
createBetweenEmptyParenTree(workingValues, createChild(between, workingValues, "WhiteSpaceOptions.empty_parens")); //$NON-NLS-1$
roots.add(between);
return roots;
}
/**
* Create the tree, in this order: syntax element - position - abstract element
*/
public static ArrayList createTreeBySyntaxElem(Map workingValues) {
final ArrayList roots= new ArrayList();
InnerNode element;
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.opening_paren"); //$NON-NLS-1$
createBeforeOpenParenTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterOpenParenTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.closing_paren"); //$NON-NLS-1$
createBeforeClosingParenTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterCloseParenTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.opening_brace"); //$NON-NLS-1$
createBeforeOpenBraceTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterOpenBraceTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.closing_brace"); //$NON-NLS-1$
createBeforeClosingBraceTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterCloseBraceTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.opening_bracket"); //$NON-NLS-1$
createBeforeOpenBracketTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterOpenBracketTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.closing_bracket"); //$NON-NLS-1$
createBeforeClosingBracketTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.operator"); //$NON-NLS-1$
createBeforeOperatorTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterOperatorTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.comma"); //$NON-NLS-1$
createBeforeCommaTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterCommaTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.colon"); //$NON-NLS-1$
createBeforeColonTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterColonTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.semicolon"); //$NON-NLS-1$
createBeforeSemicolonTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterSemicolonTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.question_mark"); //$NON-NLS-1$
createBeforeQuestionTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.before")); //$NON-NLS-1$
createAfterQuestionTree(workingValues, createChild(element, workingValues, "WhiteSpaceOptions.after")); //$NON-NLS-1$
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.between_empty_parens"); //$NON-NLS-1$
createBetweenEmptyParenTree(workingValues, element);
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.between_empty_braces"); //$NON-NLS-1$
createBetweenEmptyBracesTree(workingValues, element);
roots.add(element);
element= new InnerNode(null, workingValues, "WhiteSpaceOptions.between_empty_brackets"); //$NON-NLS-1$
createBetweenEmptyBracketsTree(workingValues, element);
roots.add(element);
return roots;
}
/**
* Create the tree, in this order: position - syntax element - abstract
* element
*/
public static ArrayList createAltTree(Map workingValues) {
final ArrayList roots= new ArrayList();
InnerNode parent;
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_opening_paren"); //$NON-NLS-1$
createBeforeOpenParenTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_opening_paren"); //$NON-NLS-1$
createAfterOpenParenTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_closing_paren"); //$NON-NLS-1$
createBeforeClosingParenTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_closing_paren"); //$NON-NLS-1$
createAfterCloseParenTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.between_empty_parens"); //$NON-NLS-1$
createBetweenEmptyParenTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_opening_brace"); //$NON-NLS-1$
createBeforeOpenBraceTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_opening_brace"); //$NON-NLS-1$
createAfterOpenBraceTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_closing_brace"); //$NON-NLS-1$
createBeforeClosingBraceTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_closing_brace"); //$NON-NLS-1$
createAfterCloseBraceTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.between_empty_braces"); //$NON-NLS-1$
createBetweenEmptyBracesTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_opening_bracket"); //$NON-NLS-1$
createBeforeOpenBracketTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_opening_bracket"); //$NON-NLS-1$
createAfterOpenBracketTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_closing_bracket"); //$NON-NLS-1$
createBeforeClosingBracketTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.between_empty_brackets"); //$NON-NLS-1$
createBetweenEmptyBracketsTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_operator"); //$NON-NLS-1$
createBeforeOperatorTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_operator"); //$NON-NLS-1$
createAfterOperatorTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_comma"); //$NON-NLS-1$
createBeforeCommaTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_comma"); //$NON-NLS-1$
createAfterCommaTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_colon"); //$NON-NLS-1$
createAfterColonTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_colon"); //$NON-NLS-1$
createBeforeColonTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_semicolon"); //$NON-NLS-1$
createBeforeSemicolonTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_semicolon"); //$NON-NLS-1$
createAfterSemicolonTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.before_question_mark"); //$NON-NLS-1$
createBeforeQuestionTree(workingValues, parent);
parent= createParentNode(roots, workingValues, "WhiteSpaceOptions.after_question_mark"); //$NON-NLS-1$
createAfterQuestionTree(workingValues, parent);
return roots;
}
private static InnerNode createParentNode(List roots, Map workingValues, String text) {
final InnerNode parent= new InnerNode(null, workingValues, text);
roots.add(parent);
return parent;
}
public static ArrayList createTreeByJavaElement(Map workingValues) {
final InnerNode declarations= new InnerNode(null, workingValues, "WhiteSpaceTabPage.declarations"); //$NON-NLS-1$
createClassTree(workingValues, declarations);
createFieldTree(workingValues, declarations);
createLocalVariableTree(workingValues, declarations);
createConstructorTree(workingValues, declarations);
createMethodDeclTree(workingValues, declarations);
createLabelTree(workingValues, declarations);
final InnerNode statements= new InnerNode(null, workingValues, "WhiteSpaceTabPage.statements"); //$NON-NLS-1$
createOption(statements, workingValues, "WhiteSpaceOptions.before_semicolon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW); //$NON-NLS-1$
createBlockTree(workingValues, statements);
createIfStatementTree(workingValues, statements);
createForStatementTree(workingValues, statements);
createSwitchStatementTree(workingValues, statements);
createDoWhileTree(workingValues, statements);
createSynchronizedTree(workingValues, statements);
createTryStatementTree(workingValues, statements);
final InnerNode expressions= new InnerNode(null, workingValues, "WhiteSpaceTabPage.expressions"); //$NON-NLS-1$
createFunctionCallTree(workingValues, expressions);
createAssignmentTree(workingValues, expressions);
createOperatorTree(workingValues, expressions);
createParenthesizedExpressionTree(workingValues, expressions);
createTypecastTree(workingValues, expressions);
createConditionalTree(workingValues, expressions);
final InnerNode arrays= new InnerNode(null, workingValues, "WhiteSpaceTabPage.arrays"); //$NON-NLS-1$
createArrayDeclarationTree(workingValues, arrays);
createArrayAllocTree(workingValues, arrays);
createArrayInitializerTree(workingValues, arrays);
createArrayElementAccessTree(workingValues, arrays);
final ArrayList roots= new ArrayList();
roots.add(declarations);
roots.add(statements);
roots.add(expressions);
roots.add(arrays);
return roots;
}
private static void createBeforeQuestionTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.conditional", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeSemicolonTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.for", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.statements", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeColonTree(Map workingValues, final InnerNode parent) {
//TODO: createOption(parent, workingValues, "WhiteSpaceOptions.assert", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT, ASSERT_PREVIEW);
createOption(parent, workingValues, "WhiteSpaceOptions.conditional", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.label", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); //$NON-NLS-1$
final InnerNode switchStatement= createChild(parent, workingValues, "WhiteSpaceOptions.switch"); //$NON-NLS-1$
createOption(switchStatement, workingValues, "WhiteSpaceOptions.case", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(switchStatement, workingValues, "WhiteSpaceOptions.default", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, SWITCH_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeCommaTree(Map workingValues, final InnerNode parent) {
final InnerNode forStatement= createChild(parent, workingValues, "WhiteSpaceOptions.for"); //$NON-NLS-1$
createOption(forStatement, workingValues, "WhiteSpaceOptions.initialization", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW); //$NON-NLS-1$
createOption(forStatement, workingValues, "WhiteSpaceOptions.incrementation", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW); //$NON-NLS-1$
final InnerNode invocation= createChild(parent, workingValues, "WhiteSpaceOptions.arguments"); //$NON-NLS-1$
createOption(invocation, workingValues, "WhiteSpaceOptions.method_call", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(invocation, workingValues, "WhiteSpaceOptions.explicit_constructor_call", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(invocation, workingValues, "WhiteSpaceOptions.alloc_expr", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW); //$NON-NLS-1$
final InnerNode decl= createChild(parent, workingValues, "WhiteSpaceOptions.parameters"); //$NON-NLS-1$
createOption(decl, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(decl, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
final InnerNode throwsDecl= createChild(parent, workingValues, "WhiteSpaceOptions.throws"); //$NON-NLS-1$
createOption(throwsDecl, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(throwsDecl, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
final InnerNode multDecls= createChild(parent, workingValues, "WhiteSpaceOptions.mult_decls"); //$NON-NLS-1$
createOption(multDecls, workingValues, "WhiteSpaceOptions.fields", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, MULT_FIELD_PREVIEW); //$NON-NLS-1$
createOption(multDecls, workingValues, "WhiteSpaceOptions.local_vars", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, MULT_LOCAL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.initializer", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.implements_clause", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES, CLASS_DECL_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeOperatorTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.assignment_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.unary_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.binary_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.prefix_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.postfix_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeClosingBracketTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.array_alloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.array_element_access", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeOpenBracketTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.array_decl", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.array_alloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.array_element_access", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeClosingBraceTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.array_init", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, CLASS_DECL_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeOpenBraceTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.class_decl", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, CLASS_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.anon_class_decl", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION, ANON_CLASS_PREVIEW); //$NON-NLS-1$
final InnerNode functionDecl= createChild(parent, workingValues, "WhiteSpaceOptions.member_function_declaration"); { //$NON-NLS-1$
createOption(functionDecl, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(functionDecl, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
}
createOption(parent, workingValues, "WhiteSpaceOptions.initializer", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.block", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, BLOCK_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.switch", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeClosingParenTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.catch", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.for", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.if", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, IF_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.switch", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.synchronized", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.while", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE, WHILE_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.type_cast", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST, CAST_PREVIEW); //$NON-NLS-1$
final InnerNode decl= createChild(parent, workingValues, "WhiteSpaceOptions.member_function_declaration"); //$NON-NLS-1$
createOption(decl, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(decl, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.method_call", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.paren_expr", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); //$NON-NLS-1$
}
private static void createBeforeOpenParenTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.catch", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.for", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.if", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.switch", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.synchronized", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.while", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW); //$NON-NLS-1$
final InnerNode decls= createChild(parent, workingValues, "WhiteSpaceOptions.member_function_declaration"); //$NON-NLS-1$
createOption(decls, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(decls, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.method_call", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.paren_expr", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); //$NON-NLS-1$
}
private static void createAfterQuestionTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.conditional", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
}
private static void createAfterSemicolonTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.for", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
}
private static void createAfterColonTree(Map workingValues, final InnerNode parent) {
//TODO: createOption(parent, workingValues, "'assert'", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT, ASSERT_PREVIEW);
createOption(parent, workingValues, "WhiteSpaceOptions.conditional", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.label", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); //$NON-NLS-1$
}
private static void createAfterCommaTree(Map workingValues, final InnerNode parent) {
final InnerNode forStatement= createChild(parent, workingValues, "WhiteSpaceOptions.for"); { //$NON-NLS-1$
createOption(forStatement, workingValues, "WhiteSpaceOptions.initialization", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW); //$NON-NLS-1$
createOption(forStatement, workingValues, "WhiteSpaceOptions.incrementation", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW); //$NON-NLS-1$
}
final InnerNode invocation= createChild(parent, workingValues, "WhiteSpaceOptions.arguments"); { //$NON-NLS-1$
createOption(invocation, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(invocation, workingValues, "WhiteSpaceOptions.explicit_constructor_call", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(invocation, workingValues, "WhiteSpaceOptions.alloc_expr", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW); //$NON-NLS-1$
}
final InnerNode decl= createChild(parent, workingValues, "WhiteSpaceOptions.parameters"); { //$NON-NLS-1$
createOption(decl, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(decl, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
}
final InnerNode throwsDecl= createChild(parent, workingValues, "WhiteSpaceOptions.throws"); { //$NON-NLS-1$
createOption(throwsDecl, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(throwsDecl, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
}
final InnerNode multDecls= createChild(parent, workingValues, "WhiteSpaceOptions.mult_decls"); { //$NON-NLS-1$
createOption(multDecls, workingValues, "WhiteSpaceOptions.fields", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, MULT_FIELD_PREVIEW); //$NON-NLS-1$
createOption(multDecls, workingValues, "WhiteSpaceOptions.local_vars", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, MULT_LOCAL_PREVIEW); //$NON-NLS-1$
}
createOption(parent, workingValues, "WhiteSpaceOptions.initializer", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.implements_clause", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES, CLASS_DECL_PREVIEW); //$NON-NLS-1$
}
private static void createAfterOperatorTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.assignment_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.unary_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.binary_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.prefix_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.postfix_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
}
private static void createAfterOpenBracketTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.array_alloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.array_element_access", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW); //$NON-NLS-1$
}
private static void createAfterOpenBraceTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.initializer", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
}
private static void createAfterCloseBraceTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.block", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, BLOCK_PREVIEW); //$NON-NLS-1$
}
private static void createAfterCloseParenTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.type_cast", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, CAST_PREVIEW); //$NON-NLS-1$
}
private static void createAfterOpenParenTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.catch", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.for", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.if", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.switch", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.synchronized", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.while", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW); //$NON-NLS-1$
final InnerNode decls= createChild(parent, workingValues, "WhiteSpaceOptions.member_function_declaration"); { //$NON-NLS-1$
createOption(decls, workingValues, "WhiteSpaceOptions.constructor", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(decls, workingValues, "WhiteSpaceOptions.method", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
}
createOption(parent, workingValues, "WhiteSpaceOptions.type_cast", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.method_call", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.paren_expr", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); //$NON-NLS-1$
}
private static void createBetweenEmptyParenTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.constructor_decl", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.method_decl", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.method_call", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
}
private static void createBetweenEmptyBracketsTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.array_alloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, "WhiteSpaceOptions.array_decl", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
}
private static void createBetweenEmptyBracesTree(Map workingValues, final InnerNode parent) {
createOption(parent, workingValues, "WhiteSpaceOptions.initializer", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
}
private static InnerNode createClassTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.classes"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.classes.before_opening_brace_of_a_class", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, CLASS_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.classes.before_opening_brace_of_anon_class", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_ANONYMOUS_TYPE_DECLARATION, ANON_CLASS_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.classes.before_comma_implements", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_SUPERINTERFACES, CLASS_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.classes.after_comma_implements", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_SUPERINTERFACES, CLASS_DECL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createAssignmentTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.assignments"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.assignments.before_assignment_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.assignments.after_assignment_operator", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createOperatorTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.operators"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.before_binary_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.after_binary_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_BINARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.before_unary_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.after_unary_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.before_prefix_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_PREFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.after_prefix_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_PREFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.before_postfix_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.operators.after_postfix_operators", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createMethodDeclTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.methods"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.between_empty_parens", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_brace", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_comma_in_params", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_comma_in_params", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_PARAMETERS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_comma_in_throws", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_comma_in_throws", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_DECLARATION_THROWS, METHOD_DECL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createConstructorTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.constructors"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.between_empty_parens", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_brace", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_comma_in_params", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_comma_in_params", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_PARAMETERS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_comma_in_throws", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_comma_in_throws", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_CONSTRUCTOR_DECLARATION_THROWS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createFieldTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.fields"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.fields.before_comma", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, MULT_FIELD_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.fields.after_comma", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_FIELD_DECLARATIONS, MULT_LOCAL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createLocalVariableTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.localvars"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.localvars.before_comma", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, MULT_LOCAL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.localvars.after_comma", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_MULTIPLE_LOCAL_DECLARATIONS, MULT_LOCAL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createArrayInitializerTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.arrayinit"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_brace", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_brace", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_comma", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_comma", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.between_empty_braces", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_ARRAY_INITIALIZER, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createArrayDeclarationTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.arraydecls"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_TYPE_REFERENCE, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.between_empty_brackets", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_BRACKETS_IN_ARRAY_TYPE_REFERENCE, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createArrayElementAccessTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.arrayelem"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_REFERENCE, ARRAY_REF_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createArrayAllocTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.arrayalloc"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_bracket", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET_IN_ARRAY_ALLOCATION_EXPRESSION, ARRAY_DECL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createFunctionCallTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.calls"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.between_empty_parens", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.calls.before_comma_in_method_args", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.calls.after_comma_in_method_args", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_METHOD_INVOCATION_ARGUMENTS, METHOD_CALL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.calls.before_comma_in_alloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.calls.after_comma_in_alloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_ALLOCATION_EXPRESSION, ALLOC_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.calls.before_comma_in_qalloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.calls.after_comma_in_qalloc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPLICIT_CONSTRUCTOR_CALL_ARGUMENTS, CONSTRUCTOR_DECL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createBlockTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.blocks"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_brace", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, BLOCK_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_closing_brace", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, BLOCK_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createSwitchStatementTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.switch"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.switch.before_case_colon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.switch.before_default_colon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_brace", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SWITCH, SWITCH_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createDoWhileTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.do"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_WHILE, WHILE_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createSynchronizedTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.synchronized"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_SYNCHRONIZED, SYNCHRONIZED_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createTryStatementTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.try"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createIfStatementTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.if"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_IF, IF_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createForStatementTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.for"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.for.before_comma_init", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.for.after_comma_init", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.for.before_comma_inc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.for.after_comma_inc", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INCREMENTS, FOR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_semicolon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW); //$NON-NLS-1$
return root;
}
// TODO: include this category
// private static InnerNode createAssertTree(Map workingValues, InnerNode parent) {
// "'assert'",
//
// new Option(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_ASSERT, "WhiteSpaceTabPage.before_colon"),
// new Option(DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_ASSERT, "WhiteSpaceTabPage.after_colon")
// }
private static InnerNode createLabelTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.labels"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_colon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_colon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createConditionalTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.conditionals"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_question", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_question", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_colon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_colon", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createTypecastTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.typecasts"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CAST, CAST_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, CAST_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createParenthesizedExpressionTree(Map workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, "WhiteSpaceTabPage.parenexpr"); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.after_opening_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); //$NON-NLS-1$
createOption(root, workingValues, "WhiteSpaceTabPage.before_closing_paren", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); //$NON-NLS-1$
return root;
}
private static InnerNode createChild(InnerNode root, Map workingValues, String messageKey) {
return new InnerNode(root, workingValues, messageKey);
}
private static OptionNode createOption(InnerNode root, Map workingValues, String messageKey, String key, PreviewSnippet snippet) {
return new OptionNode(root,workingValues, messageKey, key, snippet);
}
public static void makeIndexForNodes(List tree, List flatList) {
for (final Iterator iter= tree.iterator(); iter.hasNext();) {
final Node node= (Node) iter.next();
node.index= flatList.size();
flatList.add(node);
makeIndexForNodes(node.getChildren(), flatList);
}
}
}
|
52,062 |
Bug 52062 [spell checking] SpellCheckEngine.getAvailableLocales() should close its input streams
|
3.0M7 stable. I was just digging around the new code out of curiousity and found a place where streams are opened but never closed. I believe this is not strictly a resource leak because Java finalization will eventually close the stream, but it wouldn't hurt to do it explicitly. stream= url.openStream(); if (stream != null) result.add(locale); stream.close(); // add me As an aside, this looks like a very indirect way of iterating over dictionaries. Perhaps they should be supplied via fragments bound to an appropriate extension point. Also, the function always includes the default locale even if no dictionaries were found. I think this behaviour is misleading and prevents the UI from presenting a more useful "no dictionaries available" kind of cue, if none were installed (as in M7?). Looks good. I hope this support gets generalized somewhat and moved into org.eclipse.text eventually.
|
resolved fixed
|
865a4a8
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T14:09:25Z | 2004-02-14T20:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/spelling/SpellCheckEngine.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.spelling;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jdt.internal.ui.text.spelling.engine.DefaultSpellChecker;
import org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellCheckEngine;
import org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellCheckPreferenceKeys;
import org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellChecker;
import org.eclipse.jdt.internal.ui.text.spelling.engine.ISpellDictionary;
import org.eclipse.jdt.internal.ui.text.spelling.engine.PersistentSpellDictionary;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
/**
* Spell check engine for Java source spell checking.
*
* @since 3.0
*/
public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListener {
/** The dictionary location */
public static final String DICTIONARY_LOCATION= "dictionaries/"; //$NON-NLS-1$
/** The singleton spell checker instance */
private static ISpellChecker fChecker= null;
/** The singleton engine instance */
private static ISpellCheckEngine fEngine= null;
/**
* Returns the available locales for this spell check engine.
*
* @return The available locales for this engine
*/
public static Set getAvailableLocales() {
URL url= null;
Locale locale= null;
InputStream stream= null;
final Set result= new HashSet();
try {
final URL location= getDictionaryLocation();
final Locale[] locales= Locale.getAvailableLocales();
for (int index= 0; index < locales.length; index++) {
locale= locales[index];
url= new URL(location, locale.toString().toLowerCase() + "." + JavaUIMessages.getString("Spelling.dictionary.file.extension")); //$NON-NLS-1$ //$NON-NLS-2$
try {
stream= url.openStream();
if (stream != null)
result.add(locale);
} catch (IOException exception) {
// Do nothing
}
}
} catch (MalformedURLException exception) {
// Do nothing
}
result.add(getDefaultLocale());
return result;
}
/**
* Returns the default locale for this engine.
*
* @return The default locale
*/
public static Locale getDefaultLocale() {
return Locale.US;
}
/**
* Returns the dictionary location.
*
* @throws MalformedURLException
* if the URL could not be created
* @return The dictionary location, or <code>null</code> iff the location
* is not known
*/
public static URL getDictionaryLocation() throws MalformedURLException {
final JavaPlugin plugin= JavaPlugin.getDefault();
if (plugin != null)
return new URL(plugin.getDescriptor().getInstallURL(), DICTIONARY_LOCATION);
return null;
}
/**
* Returns the singleton instance of the spell check engine.
*
* @return The singleton instance of the spell check engine
*/
public static final synchronized ISpellCheckEngine getInstance() {
if (fEngine == null)
fEngine= new SpellCheckEngine();
return fEngine;
}
/** The registered locale insenitive dictionaries */
private final Set fGlobalDictionaries= new HashSet();
/** The current locale */
private Locale fLocale= null;
/** The registered locale sensitive dictionaries */
private final Map fLocaleDictionaries= new HashMap();
/** The preference store where to listen */
private IPreferenceStore fPreferences= null;
/** The user dictionary */
private ISpellDictionary fUserDictionary= null;
/**
* Creates a new spell check manager.
*/
private SpellCheckEngine() {
fGlobalDictionaries.add(new TaskTagDictionary());
fGlobalDictionaries.add(new HtmlTagDictionary());
fGlobalDictionaries.add(new JavaDocTagDictionary());
try {
Locale locale= null;
final URL location= getDictionaryLocation();
for (final Iterator iterator= getAvailableLocales().iterator(); iterator.hasNext();) {
locale= (Locale)iterator.next();
fLocaleDictionaries.put(locale, new SpellReconcileDictionary(locale, location));
}
} catch (MalformedURLException exception) {
// Do nothing
}
}
/*
* @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#createSpellChecker(java.util.Locale,org.eclipse.jface.preference.IPreferenceStore)
*/
public final synchronized ISpellChecker createSpellChecker(final Locale locale, final IPreferenceStore store) {
if (fLocale != null && fLocale.equals(locale))
return fChecker;
if (fChecker == null) {
fChecker= new DefaultSpellChecker(store);
store.addPropertyChangeListener(this);
fPreferences= store;
ISpellDictionary dictionary= null;
for (Iterator iterator= fGlobalDictionaries.iterator(); iterator.hasNext();) {
dictionary= (ISpellDictionary)iterator.next();
fChecker.addDictionary(dictionary);
}
}
ISpellDictionary dictionary= null;
if (fLocale != null) {
dictionary= (ISpellDictionary)fLocaleDictionaries.get(fLocale);
if (dictionary != null) {
fChecker.removeDictionary(dictionary);
dictionary.unload();
}
}
fLocale= locale;
dictionary= (ISpellDictionary)fLocaleDictionaries.get(locale);
if (dictionary == null) {
if (!getDefaultLocale().equals(locale)) {
if (fPreferences != null)
fPreferences.removePropertyChangeListener(this);
fChecker= null;
fLocale= null;
}
} else
fChecker.addDictionary(dictionary);
if (fPreferences != null)
propertyChange(new PropertyChangeEvent(this, ISpellCheckPreferenceKeys.SPELLING_USER_DICTIONARY, null, fPreferences.getString(ISpellCheckPreferenceKeys.SPELLING_USER_DICTIONARY)));
return fChecker;
}
/*
* @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#getLocale()
*/
public final Locale getLocale() {
return fLocale;
}
/*
* @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
public final void propertyChange(final PropertyChangeEvent event) {
if (fChecker != null && event.getProperty().equals(ISpellCheckPreferenceKeys.SPELLING_USER_DICTIONARY)) {
if (fUserDictionary != null) {
fChecker.removeDictionary(fUserDictionary);
fUserDictionary= null;
}
final String file= (String)event.getNewValue();
if (file.length() > 0) {
try {
final URL url= new URL("file", null, file);
if (url.openStream() != null) {
fUserDictionary= new PersistentSpellDictionary(url);
fChecker.addDictionary(fUserDictionary);
}
} catch (MalformedURLException exception) {
// Do nothing
} catch (IOException exception) {
// Do nothing
}
}
}
}
/*
* @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#registerDictionary(org.eclipse.jdt.ui.text.spelling.engine.ISpellDictionary)
*/
public synchronized final void registerDictionary(final ISpellDictionary dictionary) {
fGlobalDictionaries.add(dictionary);
if (fChecker != null)
fChecker.addDictionary(dictionary);
}
/*
* @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#registerDictionary(java.util.Locale,org.eclipse.jdt.ui.text.spelling.engine.ISpellDictionary)
*/
public synchronized final void registerDictionary(final Locale locale, final ISpellDictionary dictionary) {
fLocaleDictionaries.put(locale, dictionary);
if (fChecker != null && fLocale != null && fLocale.equals(locale))
fChecker.addDictionary(dictionary);
}
/*
* @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#unload()
*/
public synchronized final void unload() {
ISpellDictionary dictionary= null;
for (final Iterator iterator= fGlobalDictionaries.iterator(); iterator.hasNext();) {
dictionary= (ISpellDictionary)iterator.next();
dictionary.unload();
}
for (final Iterator iterator= fLocaleDictionaries.values().iterator(); iterator.hasNext();) {
dictionary= (ISpellDictionary)iterator.next();
dictionary.unload();
}
if (fPreferences != null)
fPreferences.removePropertyChangeListener(this);
fUserDictionary= null;
fChecker= null;
}
/*
* @see org.eclipse.jdt.ui.text.spelling.engine.ISpellCheckEngine#unregisterDictionary(org.eclipse.jdt.ui.text.spelling.engine.ISpellDictionary)
*/
public synchronized final void unregisterDictionary(final ISpellDictionary dictionary) {
fGlobalDictionaries.remove(dictionary);
fLocaleDictionaries.values().remove(dictionary);
if (fChecker != null)
fChecker.removeDictionary(dictionary);
dictionary.unload();
}
}
|
51,978 |
Bug 51978 NPE editing a compilation unit
|
Using 200402102000, I got this NPE. java.lang.NullPointerException at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$RememberedOffset.getOffset(CompilationUnitEditor.java:786) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor$RememberedSelection.restore(CompilationUnitEditor.java:672) at org.eclipse.jdt.internal.ui.javaeditor.CompilationUnitEditor.restoreSelection(CompilationUnitEditor.java:1547) at org.eclipse.ui.texteditor.AbstractTextEditor$4.run(AbstractTextEditor.java:299) at org.eclipse.ui.texteditor.AbstractTextEditor$ElementStateListener.execute(AbstractTextEditor.java:385) at org.eclipse.ui.texteditor.AbstractTextEditor$ElementStateListener.elementContentReplaced(AbstractTextEditor.java:302) at org.eclipse.ui.editors.text.TextFileDocumentProvider$FileBufferListener.bufferContentReplaced(TextFileDocumentProvider.java:214) at org.eclipse.core.internal.filebuffers.TextFileBufferManager.fireBufferContentReplaced(TextFileBufferManager.java:242) at org.eclipse.core.internal.filebuffers.ResourceTextFileBuffer.revert(ResourceTextFileBuffer.java:169) at org.eclipse.ui.editors.text.TextFileDocumentProvider$1.execute(TextFileDocumentProvider.java:574) at org.eclipse.ui.editors.text.TextFileDocumentProvider$DocumentProviderOperation.run(TextFileDocumentProvider.java:93) at org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation.execute(WorkspaceModifyDelegatingOperation.java:67) at org.eclipse.ui.actions.WorkspaceModifyOperation$1.run(WorkspaceModifyOperation.java:91) at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1567) at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:105) at org.eclipse.ui.editors.text.WorkspaceOperationRunner.run(WorkspaceOperationRunner.java:72) at org.eclipse.ui.editors.text.WorkspaceOperationRunner.run(WorkspaceOperationRunner.java:62) at org.eclipse.ui.editors.text.TextFileDocumentProvider.executeOperation(TextFileDocumentProvider.java:391) at org.eclipse.ui.editors.text.TextFileDocumentProvider.resetDocument(TextFileDocumentProvider.java:586) at org.eclipse.ui.texteditor.AbstractTextEditor.performRevert(AbstractTextEditor.java:3180) at org.eclipse.ui.texteditor.AbstractTextEditor.doRevertToSaved(AbstractTextEditor.java:3163) at org.eclipse.ui.texteditor.StatusTextEditor.doRevertToSaved(StatusTextEditor.java:183) at org.eclipse.ui.texteditor.RevertToSavedAction.run(RevertToSavedAction.java:47) at org.eclipse.jface.action.Action.runWithEvent(Action.java:881) at org.eclipse.jface.action.ActionContributionItem.handleWidgetSelection(ActionContributionItem.java:536) at org.eclipse.jface.action.ActionContributionItem.access$2(ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent(ActionContributionItem.java:420) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2029) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1550) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1526) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:257) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:104) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
verified fixed
|
a93af00
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T14:10:57Z | 2004-02-13T19:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/CompilationUnitEditor.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.javaeditor;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Stack;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.VerifyKeyListener;
import org.eclipse.swt.events.VerifyEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.window.Window;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.DocumentCommand;
import org.eclipse.jface.text.IAutoEditStrategy;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentExtension;
import org.eclipse.jface.text.IDocumentListener;
import org.eclipse.jface.text.ILineTracker;
import org.eclipse.jface.text.IPositionUpdater;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.ITextViewerExtension;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.IWidgetTokenKeeper;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.TextUtilities;
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.contentassist.IContentAssistantExtension;
import org.eclipse.jface.text.source.IOverviewRuler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.dialogs.SaveAsDialog;
import org.eclipse.ui.editors.text.IStorageDocumentProvider;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.texteditor.ContentAssistAction;
import org.eclipse.ui.texteditor.ExtendedTextEditorPreferenceConstants;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
import org.eclipse.ui.texteditor.TextOperationAction;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMember;
import org.eclipse.jdt.core.ISourceRange;
import org.eclipse.jdt.core.ISourceReference;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.IWorkingCopyManager;
import org.eclipse.jdt.ui.PreferenceConstants;
import org.eclipse.jdt.ui.actions.GenerateActionGroup;
import org.eclipse.jdt.ui.actions.IJavaEditorActionDefinitionIds;
import org.eclipse.jdt.ui.actions.RefactorActionGroup;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.actions.AddBlockCommentAction;
import org.eclipse.jdt.internal.ui.actions.CompositeActionGroup;
import org.eclipse.jdt.internal.ui.actions.IndentAction;
import org.eclipse.jdt.internal.ui.actions.RemoveBlockCommentAction;
import org.eclipse.jdt.internal.ui.compare.LocalHistoryActionGroup;
import org.eclipse.jdt.internal.ui.text.ContentAssistPreference;
import org.eclipse.jdt.internal.ui.text.IJavaPartitions;
import org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionAssistant;
import org.eclipse.jdt.internal.ui.text.java.IReconcilingParticipant;
import org.eclipse.jdt.internal.ui.text.java.SmartSemicolonAutoEditStrategy;
import org.eclipse.jdt.internal.ui.text.link.ExclusivePositionUpdater;
import org.eclipse.jdt.internal.ui.text.link.ILinkedListener;
import org.eclipse.jdt.internal.ui.text.link.LinkedEnvironment;
import org.eclipse.jdt.internal.ui.text.link.LinkedPositionGroup;
import org.eclipse.jdt.internal.ui.text.link.LinkedUIControl;
import org.eclipse.jdt.internal.ui.text.link.LinkedUIControl.ExitFlags;
import org.eclipse.jdt.internal.ui.text.link.LinkedUIControl.IExitPolicy;
/**
* Java specific text editor.
*/
public class CompilationUnitEditor extends JavaEditor implements IReconcilingParticipant {
/**
* Text operation code for requesting correction assist to show correction
* proposals for the current position.
*/
public static final int CORRECTIONASSIST_PROPOSALS= 50;
/**
* Text operation code for requesting common prefix completion.
*/
public static final int CONTENTASSIST_COMPLETE_PREFIX= 60;
interface ITextConverter {
void customizeDocumentCommand(IDocument document, DocumentCommand command);
}
class AdaptedSourceViewer extends JavaSourceViewer {
private List fTextConverters;
private boolean fIgnoreTextConverters= false;
private JavaCorrectionAssistant fCorrectionAssistant;
public AdaptedSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles) {
super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);
}
public IContentAssistant getContentAssistant() {
return fContentAssistant;
}
/*
* @see ITextOperationTarget#doOperation(int)
*/
public void doOperation(int operation) {
if (getTextWidget() == null)
return;
switch (operation) {
case CONTENTASSIST_PROPOSALS:
String msg= fContentAssistant.showPossibleCompletions();
setStatusLineErrorMessage(msg);
return;
case CORRECTIONASSIST_PROPOSALS:
msg= fCorrectionAssistant.showPossibleCompletions();
setStatusLineErrorMessage(msg);
return;
case UNDO:
fIgnoreTextConverters= true;
break;
case REDO:
fIgnoreTextConverters= true;
break;
case CONTENTASSIST_COMPLETE_PREFIX:
if (fContentAssistant instanceof IContentAssistantExtension) {
msg= ((IContentAssistantExtension) fContentAssistant).completePrefix();
setStatusLineErrorMessage(msg);
return;
} else
break;
}
super.doOperation(operation);
}
/*
* @see ITextOperationTarget#canDoOperation(int)
*/
public boolean canDoOperation(int operation) {
if (operation == CORRECTIONASSIST_PROPOSALS)
return isEditable();
else if (operation == CONTENTASSIST_COMPLETE_PREFIX)
return isEditable();
return super.canDoOperation(operation);
}
/**
* @inheritDoc
* @since 3.0
*/
public void unconfigure() {
if (fCorrectionAssistant != null) {
fCorrectionAssistant.uninstall();
fCorrectionAssistant= null;
}
super.unconfigure();
}
public void insertTextConverter(ITextConverter textConverter, int index) {
throw new UnsupportedOperationException();
}
public void addTextConverter(ITextConverter textConverter) {
if (fTextConverters == null) {
fTextConverters= new ArrayList(1);
fTextConverters.add(textConverter);
} else if (!fTextConverters.contains(textConverter))
fTextConverters.add(textConverter);
}
public void removeTextConverter(ITextConverter textConverter) {
if (fTextConverters != null) {
fTextConverters.remove(textConverter);
if (fTextConverters.size() == 0)
fTextConverters= null;
}
}
/*
* @see TextViewer#customizeDocumentCommand(DocumentCommand)
*/
protected void customizeDocumentCommand(DocumentCommand command) {
super.customizeDocumentCommand(command);
if (!fIgnoreTextConverters && fTextConverters != null) {
for (Iterator e = fTextConverters.iterator(); e.hasNext();)
((ITextConverter) e.next()).customizeDocumentCommand(getDocument(), command);
}
fIgnoreTextConverters= false;
}
// http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
public void updateIndentationPrefixes() {
SourceViewerConfiguration configuration= getSourceViewerConfiguration();
String[] types= configuration.getConfiguredContentTypes(this);
for (int i= 0; i < types.length; i++) {
String[] prefixes= configuration.getIndentPrefixes(this, types[i]);
if (prefixes != null && prefixes.length > 0)
setIndentPrefixes(prefixes, types[i]);
}
}
/*
* @see IWidgetTokenOwner#requestWidgetToken(IWidgetTokenKeeper)
*/
public boolean requestWidgetToken(IWidgetTokenKeeper requester) {
if (WorkbenchHelp.isContextHelpDisplayed())
return false;
return super.requestWidgetToken(requester);
}
/*
* @see IWidgetTokenOwnerExtension#requestWidgetToken(IWidgetTokenKeeper, int)
* @since 3.0
*/
public boolean requestWidgetToken(IWidgetTokenKeeper requester, int priority) {
if (WorkbenchHelp.isContextHelpDisplayed())
return false;
return super.requestWidgetToken(requester, priority);
}
/*
* @see org.eclipse.jface.text.source.ISourceViewer#configure(org.eclipse.jface.text.source.SourceViewerConfiguration)
*/
public void configure(SourceViewerConfiguration configuration) {
super.configure(configuration);
fCorrectionAssistant= new JavaCorrectionAssistant(CompilationUnitEditor.this);
fCorrectionAssistant.install(this);
IAutoEditStrategy smartSemi= new SmartSemicolonAutoEditStrategy(IJavaPartitions.JAVA_PARTITIONING);
prependAutoEditStrategy(smartSemi, IDocument.DEFAULT_CONTENT_TYPE);
}
}
static class TabConverter implements ITextConverter {
private int fTabRatio;
private ILineTracker fLineTracker;
public TabConverter() {
}
public void setNumberOfSpacesPerTab(int ratio) {
fTabRatio= ratio;
}
public void setLineTracker(ILineTracker lineTracker) {
fLineTracker= lineTracker;
}
private int insertTabString(StringBuffer buffer, int offsetInLine) {
if (fTabRatio == 0)
return 0;
int remainder= offsetInLine % fTabRatio;
remainder= fTabRatio - remainder;
for (int i= 0; i < remainder; i++)
buffer.append(' ');
return remainder;
}
public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
String text= command.text;
if (text == null)
return;
int index= text.indexOf('\t');
if (index > -1) {
StringBuffer buffer= new StringBuffer();
fLineTracker.set(command.text);
int lines= fLineTracker.getNumberOfLines();
try {
for (int i= 0; i < lines; i++) {
int offset= fLineTracker.getLineOffset(i);
int endOffset= offset + fLineTracker.getLineLength(i);
String line= text.substring(offset, endOffset);
int position= 0;
if (i == 0) {
IRegion firstLine= document.getLineInformationOfOffset(command.offset);
position= command.offset - firstLine.getOffset();
}
int length= line.length();
for (int j= 0; j < length; j++) {
char c= line.charAt(j);
if (c == '\t') {
position += insertTabString(buffer, position);
} else {
buffer.append(c);
++ position;
}
}
}
command.text= buffer.toString();
} catch (BadLocationException x) {
}
}
}
}
private class ExitPolicy implements IExitPolicy {
final char fExitCharacter;
final char fEscapeCharacter;
final Stack fStack;
final int fSize;
public ExitPolicy(char exitCharacter, char escapeCharacter, Stack stack) {
fExitCharacter= exitCharacter;
fEscapeCharacter= escapeCharacter;
fStack= stack;
fSize= fStack.size();
}
/*
* @see org.eclipse.jdt.internal.ui.text.link.LinkedPositionUI.ExitPolicy#doExit(org.eclipse.jdt.internal.ui.text.link.LinkedPositionManager, org.eclipse.swt.events.VerifyEvent, int, int)
*/
public ExitFlags doExit(LinkedEnvironment environment, VerifyEvent event, int offset, int length) {
if (event.character == fExitCharacter) {
if (fSize == fStack.size() && !isMasked(offset)) {
BracketLevel level= (BracketLevel) fStack.peek();
if (level.fFirstPosition.offset > offset || level.fSecondPosition.offset < offset)
return null;
if (level.fSecondPosition.offset == offset && length == 0)
// don't enter the character if if its the closing peer
return new ExitFlags(ILinkedListener.UPDATE_CARET, false);
else
return new ExitFlags(ILinkedListener.UPDATE_CARET, true);
}
}
return null;
}
private boolean isMasked(int offset) {
IDocument document= getSourceViewer().getDocument();
try {
return fEscapeCharacter == document.getChar(offset - 1);
} catch (BadLocationException e) {
}
return false;
}
}
private static class BracketLevel {
int fOffset;
int fLength;
LinkedUIControl fEditor;
Position fFirstPosition;
Position fSecondPosition;
}
private class BracketInserter implements VerifyKeyListener, ILinkedListener {
private boolean fCloseBrackets= true;
private boolean fCloseStrings= true;
private final String CATEGORY= toString();
private IPositionUpdater fUpdater= new ExclusivePositionUpdater(CATEGORY);
private Stack fBracketLevelStack= new Stack();
public void setCloseBracketsEnabled(boolean enabled) {
fCloseBrackets= enabled;
}
public void setCloseStringsEnabled(boolean enabled) {
fCloseStrings= enabled;
}
private boolean hasIdentifierToTheRight(IDocument document, int offset) {
try {
int end= offset;
IRegion endLine= document.getLineInformationOfOffset(end);
int maxEnd= endLine.getOffset() + endLine.getLength();
while (end != maxEnd && Character.isWhitespace(document.getChar(end)))
++end;
return end != maxEnd && Character.isJavaIdentifierPart(document.getChar(end));
} catch (BadLocationException e) {
// be conservative
return true;
}
}
private boolean hasIdentifierToTheLeft(IDocument document, int offset) {
try {
int start= offset;
IRegion startLine= document.getLineInformationOfOffset(start);
int minStart= startLine.getOffset();
while (start != minStart && Character.isWhitespace(document.getChar(start - 1)))
--start;
return start != minStart && Character.isJavaIdentifierPart(document.getChar(start - 1));
} catch (BadLocationException e) {
return true;
}
}
private boolean hasCharacterToTheRight(IDocument document, int offset, char character) {
try {
int end= offset;
IRegion endLine= document.getLineInformationOfOffset(end);
int maxEnd= endLine.getOffset() + endLine.getLength();
while (end != maxEnd && Character.isWhitespace(document.getChar(end)))
++end;
return end != maxEnd && document.getChar(end) == character;
} catch (BadLocationException e) {
// be conservative
return true;
}
}
/*
* @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent)
*/
public void verifyKey(VerifyEvent event) {
if (!event.doit || getInsertMode() != SMART_INSERT)
return;
final ISourceViewer sourceViewer= getSourceViewer();
IDocument document= sourceViewer.getDocument();
final Point selection= sourceViewer.getSelectedRange();
final int offset= selection.x;
final int length= selection.y;
switch (event.character) {
case '(':
if (hasCharacterToTheRight(document, offset + length, '('))
return;
// fall through
case '[':
if (!fCloseBrackets)
return;
if (hasIdentifierToTheRight(document, offset + length))
return;
// fall through
case '\'':
if (event.character == '\'') {
if (!fCloseStrings)
return;
if (hasIdentifierToTheLeft(document, offset) || hasIdentifierToTheRight(document, offset + length))
return;
}
// fall through
case '"':
if (event.character == '"') {
if (!fCloseStrings)
return;
if (hasIdentifierToTheLeft(document, offset) || hasIdentifierToTheRight(document, offset + length))
return;
}
try {
ITypedRegion partition= TextUtilities.getPartition(document, IJavaPartitions.JAVA_PARTITIONING, offset);
if (! IDocument.DEFAULT_CONTENT_TYPE.equals(partition.getType()) && partition.getOffset() != offset)
return;
if (!validateEditorInputState())
return;
final char character= event.character;
final char closingCharacter= getPeerCharacter(character);
final StringBuffer buffer= new StringBuffer();
buffer.append(character);
buffer.append(closingCharacter);
document.replace(offset, length, buffer.toString());
BracketLevel level= new BracketLevel();
fBracketLevelStack.push(level);
LinkedPositionGroup group= new LinkedPositionGroup();
group.createPosition(document, offset + 1, 0);
LinkedEnvironment env= new LinkedEnvironment();
env.addLinkedListener(this);
env.addGroup(group);
env.forceInstall();
level.fOffset= offset;
level.fLength= 2;
// set up position tracking for our magic peers
if (fBracketLevelStack.size() == 1) {
document.addPositionCategory(CATEGORY);
document.addPositionUpdater(fUpdater);
}
level.fFirstPosition= new Position(offset, 1);
level.fSecondPosition= new Position(offset + 1, 1);
document.addPosition(CATEGORY, level.fFirstPosition);
document.addPosition(CATEGORY, level.fSecondPosition);
level.fEditor= new LinkedUIControl(env, sourceViewer);
level.fEditor.setExitPolicy(new ExitPolicy(closingCharacter, getEscapeCharacter(closingCharacter), fBracketLevelStack));
level.fEditor.setExitPosition(sourceViewer, offset + 2, 0, Integer.MAX_VALUE);
level.fEditor.setCyclingMode(LinkedUIControl.CYCLE_NEVER);
level.fEditor.enter();
IRegion newSelection= level.fEditor.getSelectedRegion();
sourceViewer.setSelectedRange(newSelection.getOffset(), newSelection.getLength());
event.doit= false;
} catch (BadLocationException e) {
JavaPlugin.log(e);
} catch (BadPositionCategoryException e) {
JavaPlugin.log(e);
}
break;
}
}
/*
* @see org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment.ILinkedListener#left(org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment, int)
*/
public void left(LinkedEnvironment environment, int flags) {
final BracketLevel level= (BracketLevel) fBracketLevelStack.pop();
if (flags != ILinkedListener.EXTERNAL_MODIFICATION)
return;
// remove brackets
final ISourceViewer sourceViewer= getSourceViewer();
final IDocument document= sourceViewer.getDocument();
if (document instanceof IDocumentExtension) {
IDocumentExtension extension= (IDocumentExtension) document;
extension.registerPostNotificationReplace(null, new IDocumentExtension.IReplace() {
public void perform(IDocument d, IDocumentListener owner) {
if ((level.fFirstPosition.isDeleted || level.fFirstPosition.length == 0) && !level.fSecondPosition.isDeleted && level.fSecondPosition.offset == level.fFirstPosition.offset) {
try {
document.replace(level.fSecondPosition.offset, level.fSecondPosition.length, null);
} catch (BadLocationException e) {
}
}
if (fBracketLevelStack.size() == 0) {
document.removePositionUpdater(fUpdater);
try {
document.removePositionCategory(CATEGORY);
} catch (BadPositionCategoryException e) {
}
}
}
});
}
}
/*
* @see org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment.ILinkedListener#suspend(org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment)
*/
public void suspend(LinkedEnvironment environment) {
}
/*
* @see org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment.ILinkedListener#resume(org.eclipse.jdt.internal.ui.text.link2.LinkedEnvironment, int)
*/
public void resume(LinkedEnvironment environment, int flags) {
}
}
/**
* Remembers data related to the current selection to be able to
* restore it later.
*
* @since 3.0
*/
private class RememberedSelection {
/** The remembered selection start. */
private RememberedOffset fStartOffset= new RememberedOffset();
/** The remembered selection end. */
private RememberedOffset fEndOffset= new RememberedOffset();
/**
* Remember current selection.
*/
public void remember() {
IRegion selection= getSignedSelection(getSourceViewer());
int startOffset= selection.getOffset();
int endOffset= startOffset + selection.getLength();
fStartOffset.setOffset(startOffset);
fEndOffset.setOffset(endOffset);
}
/**
* Restore remembered selection.
*/
public void restore() {
try {
int startOffset= fStartOffset.getOffset();
int endOffset= fEndOffset.getOffset();
if (startOffset == -1)
startOffset= endOffset; // fallback to carret offset
if (endOffset == -1)
endOffset= startOffset; // fallback to other offset
IJavaElement element;
if (endOffset == -1) {
// fallback to element selection
element= fEndOffset.getElement();
if (element == null)
element= fStartOffset.getElement();
if (element != null)
setSelection(element);
return;
}
if (isValidSelection(startOffset, endOffset - startOffset))
selectAndReveal(startOffset, endOffset - startOffset);
} finally {
fStartOffset.clear();
fEndOffset.clear();
}
}
private boolean isValidSelection(int offset, int length) {
IDocumentProvider provider= getDocumentProvider();
if (provider != null) {
IDocument document= provider.getDocument(getEditorInput());
if (document != null) {
int end= offset + length;
int documentLength= document.getLength();
return 0 <= offset && offset <= documentLength && 0 <= end && end <= documentLength;
}
}
return false;
}
}
/**
* Remembers additional data for a given
* offset to be able restore it later.
*
* @since 3.0
*/
private class RememberedOffset {
/** Remembered line for the given offset */
private int fLine;
/** Remembered column for the given offset*/
private int fColumn;
/** Remembered Java element for the given offset*/
private IJavaElement fElement;
/** Remembered Java element line for the given offset*/
private int fElementLine;
/**
* Store visual properties of the given offset.
*
* @param offset Offset in the document
*/
public void setOffset(int offset) {
try {
IDocument document= getSourceViewer().getDocument();
fLine= document.getLineOfOffset(offset);
fColumn= offset - document.getLineOffset(fLine);
fElement= getElementAt(offset, true);
fElementLine= -1;
if (fElement instanceof IMember) {
ISourceRange range= ((IMember) fElement).getNameRange();
if (range != null)
fElementLine= document.getLineOfOffset(range.getOffset());
}
if (fElementLine == -1)
fElementLine= document.getLineOfOffset(getOffset(fElement));
} catch (BadLocationException e) {
// should not happen
JavaPlugin.log(e);
clear();
} catch (JavaModelException e) {
// should not happen
JavaPlugin.log(e.getStatus());
clear();
}
}
/**
* Return offset recomputed from stored visual properties.
*
* @return Offset in the document
*/
public int getOffset() {
try {
IJavaElement newElement= getElement();
if (newElement == null)
return -1;
IDocument document= getSourceViewer().getDocument();
int newElementLine= -1;
if (newElement instanceof IMember) {
ISourceRange range= ((IMember) newElement).getNameRange();
if (range != null)
newElementLine= document.getLineOfOffset(range.getOffset());
}
if (newElementLine == -1)
newElementLine= document.getLineOfOffset(getOffset(newElement));
if (newElementLine == -1)
return -1;
int newLine= fLine + newElementLine - fElementLine;
int maxColumn= document.getLineLength(newLine) - document.getLineDelimiter(newLine).length();
int offset;
if (fColumn > maxColumn)
offset= document.getLineOffset(newLine) + maxColumn;
else
offset= document.getLineOffset(newLine) + fColumn;
if (!containsOffset(newElement, offset) && (offset == 0 || !containsOffset(newElement, offset - 1)))
return -1;
return offset;
} catch (BadLocationException e) {
// should not happen
JavaPlugin.log(e);
return -1;
} catch (JavaModelException e) {
// should not happen
JavaPlugin.log(e.getStatus());
return -1;
}
}
/**
* Return Java element recomputed from stored visual properties.
*
* @return Java element
*/
public IJavaElement getElement() {
if (fElement == null)
return null;
return findElement(fElement);
}
/**
* Clears the stored position
*/
public void clear() {
fLine= -1;
fColumn= -1;
fElement= null;
fElementLine= -1;
}
/**
* Does the given Java element contain the given offset?
* @param element Java element
* @param offset Offset
* @return <code>true</code> iff the Java element contains the offset
*/
private boolean containsOffset(IJavaElement element, int offset) {
int elementOffset= getOffset(element);
int elementLength= getLength(element);
return (elementOffset > -1 && elementLength > -1) ? (offset >= elementOffset && offset < elementOffset + elementLength) : false;
}
/**
* Returns the offset of the given Java element.
*
* @param element Java element
* @return Offset of the given Java element
*/
private int getOffset(IJavaElement element) {
if (element instanceof ISourceReference) {
ISourceReference sr= (ISourceReference) element;
try {
ISourceRange srcRange= sr.getSourceRange();
if (srcRange != null)
return srcRange.getOffset();
} catch (JavaModelException e) {
}
}
return -1;
}
/**
* Returns the length of the given Java element.
*
* @param element Java element
* @return Length of the given Java element
*/
private int getLength(IJavaElement element) {
if (element instanceof ISourceReference) {
ISourceReference sr= (ISourceReference) element;
try {
ISourceRange srcRange= sr.getSourceRange();
if (srcRange != null)
return srcRange.getLength();
} catch (JavaModelException e) {
}
}
return -1;
}
/**
* Returns the updated java element for the old java element.
*
* @param element Old Java element
* @return Updated Java element
*/
private IJavaElement findElement(IJavaElement element) {
if (element == null)
return null;
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
ICompilationUnit unit= manager.getWorkingCopy(getEditorInput());
if (unit != null) {
try {
synchronized (unit) {
unit.reconcile(false, null);
}
IJavaElement[] findings= unit.findElements(element);
if (findings != null && findings.length > 0)
return findings[0];
} catch (JavaModelException x) {
JavaPlugin.log(x.getStatus());
// nothing found, be tolerant and go on
}
}
return null;
}
}
/** Preference key for code formatter tab size */
private final static String CODE_FORMATTER_TAB_SIZE= JavaCore.FORMATTER_TAB_SIZE;
/** Preference key for inserting spaces rather than tabs */
private final static String SPACES_FOR_TABS= PreferenceConstants.EDITOR_SPACES_FOR_TABS;
/** Preference key for automatically closing strings */
private final static String CLOSE_STRINGS= PreferenceConstants.EDITOR_CLOSE_STRINGS;
/** Preference key for automatically closing brackets and parenthesis */
private final static String CLOSE_BRACKETS= PreferenceConstants.EDITOR_CLOSE_BRACKETS;
/** The editor's save policy */
protected ISavePolicy fSavePolicy;
/** Listener to annotation model changes that updates the error tick in the tab image */
private JavaEditorErrorTickUpdater fJavaEditorErrorTickUpdater;
/** The editor's tab converter */
private TabConverter fTabConverter;
/**
* The remembered selection.
* @since 3.0
*/
private RememberedSelection fRememberedSelection= new RememberedSelection();
/** The bracket inserter. */
private BracketInserter fBracketInserter= new BracketInserter();
/** The standard action groups added to the menu */
private GenerateActionGroup fGenerateActionGroup;
private CompositeActionGroup fContextMenuGroup;
/**
* Creates a new compilation unit editor.
*/
public CompilationUnitEditor() {
super();
setDocumentProvider(JavaPlugin.getDefault().getCompilationUnitDocumentProvider());
setEditorContextMenuId("#CompilationUnitEditorContext"); //$NON-NLS-1$
setRulerContextMenuId("#CompilationUnitRulerContext"); //$NON-NLS-1$
setOutlinerContextMenuId("#CompilationUnitOutlinerContext"); //$NON-NLS-1$
// don't set help contextId, we install our own help context
fSavePolicy= null;
fJavaEditorErrorTickUpdater= new JavaEditorErrorTickUpdater(this);
}
/*
* @see AbstractTextEditor#createActions()
*/
protected void createActions() {
super.createActions();
Action action= new TextOperationAction(JavaEditorMessages.getResourceBundle(), "CorrectionAssistProposal.", this, CORRECTIONASSIST_PROPOSALS); //$NON-NLS-1$
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.CORRECTION_ASSIST_PROPOSALS);
setAction("CorrectionAssistProposal", action); //$NON-NLS-1$
markAsStateDependentAction("CorrectionAssistProposal", true); //$NON-NLS-1$
WorkbenchHelp.setHelp(action, IJavaHelpContextIds.QUICK_FIX_ACTION);
action= new ContentAssistAction(JavaEditorMessages.getResourceBundle(), "ContentAssistProposal.", this); //$NON-NLS-1$
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
setAction("ContentAssistProposal", action); //$NON-NLS-1$
markAsStateDependentAction("ContentAssistProposal", true); //$NON-NLS-1$
WorkbenchHelp.setHelp(action, IJavaHelpContextIds.CONTENT_ASSIST_ACTION);
action= new TextOperationAction(JavaEditorMessages.getResourceBundle(), "ContentAssistContextInformation.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
setAction("ContentAssistContextInformation", action); //$NON-NLS-1$
markAsStateDependentAction("ContentAssistContextInformation", true); //$NON-NLS-1$
WorkbenchHelp.setHelp(action, IJavaHelpContextIds.PARAMETER_HINTS_ACTION);
action= new TextOperationAction(JavaEditorMessages.getResourceBundle(), "ContentAssistCompletePrefix.", this, CONTENTASSIST_COMPLETE_PREFIX); //$NON-NLS-1$
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.CONTENT_ASSIST_COMPLETE_PREFIX);
setAction("ContentAssistCompletePrefix", action); //$NON-NLS-1$
markAsStateDependentAction("ContentAssistCompletePrefix", true); //$NON-NLS-1$
WorkbenchHelp.setHelp(action, IJavaHelpContextIds.PARAMETER_HINTS_ACTION);
action= new TextOperationAction(JavaEditorMessages.getResourceBundle(), "Comment.", this, ITextOperationTarget.PREFIX); //$NON-NLS-1$
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.COMMENT);
setAction("Comment", action); //$NON-NLS-1$
markAsStateDependentAction("Comment", true); //$NON-NLS-1$
WorkbenchHelp.setHelp(action, IJavaHelpContextIds.COMMENT_ACTION);
action= new TextOperationAction(JavaEditorMessages.getResourceBundle(), "Uncomment.", this, ITextOperationTarget.STRIP_PREFIX); //$NON-NLS-1$
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.UNCOMMENT);
setAction("Uncomment", action); //$NON-NLS-1$
markAsStateDependentAction("Uncomment", true); //$NON-NLS-1$
WorkbenchHelp.setHelp(action, IJavaHelpContextIds.UNCOMMENT_ACTION);
action= new ToggleCommentAction(JavaEditorMessages.getResourceBundle(), "ToggleComment.", this, getSourceViewerConfiguration().getDefaultPrefixes(getSourceViewer(), "")); //$NON-NLS-1$ //$NON-NLS-2$
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.TOGGLE_COMMENT);
setAction("ToggleComment", action); //$NON-NLS-1$
markAsStateDependentAction("ToggleComment", true); //$NON-NLS-1$
WorkbenchHelp.setHelp(action, IJavaHelpContextIds.TOGGLE_COMMENT_ACTION);
action= new TextOperationAction(JavaEditorMessages.getResourceBundle(), "Format.", this, ISourceViewer.FORMAT); //$NON-NLS-1$
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.FORMAT);
setAction("Format", action); //$NON-NLS-1$
markAsStateDependentAction("Format", true); //$NON-NLS-1$
markAsSelectionDependentAction("Format", true); //$NON-NLS-1$
WorkbenchHelp.setHelp(action, IJavaHelpContextIds.FORMAT_ACTION);
action= new AddBlockCommentAction(JavaEditorMessages.getResourceBundle(), "AddBlockComment.", this); //$NON-NLS-1$
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.ADD_BLOCK_COMMENT);
setAction("AddBlockComment", action); //$NON-NLS-1$
markAsStateDependentAction("AddBlockComment", true); //$NON-NLS-1$
markAsSelectionDependentAction("AddBlockComment", true); //$NON-NLS-1$
WorkbenchHelp.setHelp(action, IJavaHelpContextIds.ADD_BLOCK_COMMENT_ACTION);
action= new RemoveBlockCommentAction(JavaEditorMessages.getResourceBundle(), "RemoveBlockComment.", this); //$NON-NLS-1$
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.REMOVE_BLOCK_COMMENT);
setAction("RemoveBlockComment", action); //$NON-NLS-1$
markAsStateDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
markAsSelectionDependentAction("RemoveBlockComment", true); //$NON-NLS-1$
WorkbenchHelp.setHelp(action, IJavaHelpContextIds.REMOVE_BLOCK_COMMENT_ACTION);
action= new IndentAction(JavaEditorMessages.getResourceBundle(), "Indent.", this, false); //$NON-NLS-1$
action.setActionDefinitionId(IJavaEditorActionDefinitionIds.INDENT);
setAction("Indent", action); //$NON-NLS-1$
markAsStateDependentAction("Indent", true); //$NON-NLS-1$
markAsSelectionDependentAction("Indent", true); //$NON-NLS-1$
WorkbenchHelp.setHelp(action, IJavaHelpContextIds.INDENT_ACTION);
action= new IndentAction(JavaEditorMessages.getResourceBundle(), "Indent.", this, true); //$NON-NLS-1$
setAction("IndentOnTab", action); //$NON-NLS-1$
markAsStateDependentAction("IndentOnTab", true); //$NON-NLS-1$
markAsSelectionDependentAction("IndentOnTab", true); //$NON-NLS-1$
if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) {
// don't replace Shift Right - have to make sure their enablement is mutually exclusive
// removeActionActivationCode(ITextEditorActionConstants.SHIFT_RIGHT);
setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
}
fGenerateActionGroup= new GenerateActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
ActionGroup rg= new RefactorActionGroup(this, ITextEditorActionConstants.GROUP_EDIT);
fActionGroups.addGroup(rg);
fActionGroups.addGroup(fGenerateActionGroup);
// We have to keep the context menu group separate to have better control over positioning
fContextMenuGroup= new CompositeActionGroup(new ActionGroup[] {
fGenerateActionGroup,
rg,
new LocalHistoryActionGroup(this, ITextEditorActionConstants.GROUP_EDIT)});
}
/*
* @see JavaEditor#getElementAt(int)
*/
protected IJavaElement getElementAt(int offset) {
return getElementAt(offset, true);
}
/**
* Returns the most narrow element including the given offset. If <code>reconcile</code>
* is <code>true</code> the editor's input element is reconciled in advance. If it is
* <code>false</code> this method only returns a result if the editor's input element
* does not need to be reconciled.
*
* @param offset the offset included by the retrieved element
* @param reconcile <code>true</code> if working copy should be reconciled
*/
protected IJavaElement getElementAt(int offset, boolean reconcile) {
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
ICompilationUnit unit= manager.getWorkingCopy(getEditorInput());
if (unit != null) {
try {
if (reconcile) {
synchronized (unit) {
unit.reconcile(false, null);
}
return unit.getElementAt(offset);
} else if (unit.isConsistent())
return unit.getElementAt(offset);
} catch (JavaModelException x) {
if (!x.isDoesNotExist())
JavaPlugin.log(x.getStatus());
// nothing found, be tolerant and go on
}
}
return null;
}
/*
* @see JavaEditor#getCorrespondingElement(IJavaElement)
*/
protected IJavaElement getCorrespondingElement(IJavaElement element) {
try {
return EditorUtility.getWorkingCopy(element, true);
} catch (JavaModelException x) {
JavaPlugin.log(x.getStatus());
// nothing found, be tolerant and go on
}
return null;
}
/*
* @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#getInputElement()
*/
protected IJavaElement getInputJavaElement() {
return JavaPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(getEditorInput());
}
/*
* @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager)
*/
public void editorContextMenuAboutToShow(IMenuManager menu) {
super.editorContextMenuAboutToShow(menu);
ActionContext context= new ActionContext(getSelectionProvider().getSelection());
fContextMenuGroup.setContext(context);
fContextMenuGroup.fillContextMenu(menu);
fContextMenuGroup.setContext(null);
}
/*
* @see JavaEditor#setOutlinePageInput(JavaOutlinePage, IEditorInput)
*/
protected void setOutlinePageInput(JavaOutlinePage page, IEditorInput input) {
if (page != null) {
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
page.setInput(manager.getWorkingCopy(input));
}
}
/*
* @see org.eclipse.ui.texteditor.AbstractTextEditor#performSave(boolean, org.eclipse.core.runtime.IProgressMonitor)
*/
protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) {
IDocumentProvider p= getDocumentProvider();
if (p instanceof ICompilationUnitDocumentProvider) {
ICompilationUnitDocumentProvider cp= (ICompilationUnitDocumentProvider) p;
cp.setSavePolicy(fSavePolicy);
}
try {
super.performSave(overwrite, progressMonitor);
} finally {
if (p instanceof ICompilationUnitDocumentProvider) {
ICompilationUnitDocumentProvider cp= (ICompilationUnitDocumentProvider) p;
cp.setSavePolicy(null);
}
}
}
/*
* @see AbstractTextEditor#doSaveAs
*/
public void doSaveAs() {
if (askIfNonWorkbenchEncodingIsOk()) {
super.doSaveAs();
}
}
/*
* @see AbstractTextEditor#doSave(IProgressMonitor)
*/
public void doSave(IProgressMonitor progressMonitor) {
IDocumentProvider p= getDocumentProvider();
if (p == null) {
// editor has been closed
return;
}
if (!askIfNonWorkbenchEncodingIsOk()) {
progressMonitor.setCanceled(true);
return;
}
if (p.isDeleted(getEditorInput())) {
if (isSaveAsAllowed()) {
/*
* 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors.
* Changed Behavior to make sure that if called inside a regular save (because
* of deletion of input element) there is a way to report back to the caller.
*/
performSaveAs(progressMonitor);
} else {
/*
* 1GF5YOX: ITPJUI:ALL - Save of delete file claims it's still there
* Missing resources.
*/
Shell shell= getSite().getShell();
MessageDialog.openError(shell, JavaEditorMessages.getString("CompilationUnitEditor.error.saving.title1"), JavaEditorMessages.getString("CompilationUnitEditor.error.saving.message1")); //$NON-NLS-1$ //$NON-NLS-2$
}
} else {
setStatusLineErrorMessage(null);
IWorkingCopyManager manager= JavaPlugin.getDefault().getWorkingCopyManager();
ICompilationUnit unit= manager.getWorkingCopy(getEditorInput());
if (unit != null) {
synchronized (unit) {
performSave(false, progressMonitor);
}
} else
performSave(false, progressMonitor);
}
}
/**
* Asks the user if it is ok to store in non-workbench encoding.
* @return <true> if the user wants to continue
*/
private boolean askIfNonWorkbenchEncodingIsOk() {
IDocumentProvider provider= getDocumentProvider();
if (provider instanceof IStorageDocumentProvider) {
IEditorInput input= getEditorInput();
IStorageDocumentProvider storageProvider= (IStorageDocumentProvider)provider;
String encoding= storageProvider.getEncoding(input);
String defaultEncoding= storageProvider.getDefaultEncoding();
if (encoding != null && !encoding.equals(defaultEncoding)) {
Shell shell= getSite().getShell();
String title= JavaEditorMessages.getString("CompilationUnitEditor.warning.save.nonWorkbenchEncoding.title"); //$NON-NLS-1$
String msg;
if (input != null)
msg= MessageFormat.format(JavaEditorMessages.getString("CompilationUnitEditor.warning.save.nonWorkbenchEncoding.message1"), new String[] {input.getName(), encoding});//$NON-NLS-1$
else
msg= MessageFormat.format(JavaEditorMessages.getString("CompilationUnitEditor.warning.save.nonWorkbenchEncoding.message2"), new String[] {encoding});//$NON-NLS-1$
return MessageDialog.openQuestion(shell, title, msg);
}
}
return true;
}
public boolean isSaveAsAllowed() {
return true;
}
/**
* The compilation unit editor implementation of this <code>AbstractTextEditor</code>
* method asks the user for the workspace path of a file resource and saves the document
* there. See http://dev.eclipse.org/bugs/show_bug.cgi?id=6295
*/
protected void performSaveAs(IProgressMonitor progressMonitor) {
Shell shell= getSite().getShell();
IEditorInput input = getEditorInput();
SaveAsDialog dialog= new SaveAsDialog(shell);
IFile original= (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null;
if (original != null)
dialog.setOriginalFile(original);
dialog.create();
IDocumentProvider provider= getDocumentProvider();
if (provider == null) {
// editor has been programmatically closed while the dialog was open
return;
}
if (provider.isDeleted(input) && original != null) {
String message= JavaEditorMessages.getFormattedString("CompilationUnitEditor.warning.save.delete", new Object[] { original.getName() }); //$NON-NLS-1$
dialog.setErrorMessage(null);
dialog.setMessage(message, IMessageProvider.WARNING);
}
if (dialog.open() == Window.CANCEL) {
if (progressMonitor != null)
progressMonitor.setCanceled(true);
return;
}
IPath filePath= dialog.getResult();
if (filePath == null) {
if (progressMonitor != null)
progressMonitor.setCanceled(true);
return;
}
IWorkspaceRoot workspaceRoot= ResourcesPlugin.getWorkspace().getRoot();
IFile file= workspaceRoot.getFile(filePath);
final IEditorInput newInput= new FileEditorInput(file);
boolean success= false;
try {
provider.aboutToChange(newInput);
getDocumentProvider().saveDocument(progressMonitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true);
success= true;
} catch (CoreException x) {
ErrorDialog.openError(shell, JavaEditorMessages.getString("CompilationUnitEditor.error.saving.title2"), JavaEditorMessages.getString("CompilationUnitEditor.error.saving.message2"), x.getStatus()); //$NON-NLS-1$ //$NON-NLS-2$
} finally {
provider.changed(newInput);
if (success)
setInput(newInput);
}
if (progressMonitor != null)
progressMonitor.setCanceled(!success);
}
/*
* @see AbstractTextEditor#doSetInput(IEditorInput)
*/
protected void doSetInput(IEditorInput input) throws CoreException {
super.doSetInput(input);
configureTabConverter();
}
private void configureTabConverter() {
if (fTabConverter != null) {
IDocumentProvider provider= getDocumentProvider();
if (provider instanceof ICompilationUnitDocumentProvider) {
ICompilationUnitDocumentProvider cup= (ICompilationUnitDocumentProvider) provider;
fTabConverter.setLineTracker(cup.createLineTracker(getEditorInput()));
}
}
}
private int getTabSize() {
Preferences preferences= JavaCore.getPlugin().getPluginPreferences();
return preferences.getInt(CODE_FORMATTER_TAB_SIZE);
}
private void startTabConversion() {
if (fTabConverter == null) {
fTabConverter= new TabConverter();
configureTabConverter();
fTabConverter.setNumberOfSpacesPerTab(getTabSize());
AdaptedSourceViewer asv= (AdaptedSourceViewer) getSourceViewer();
asv.addTextConverter(fTabConverter);
// http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
asv.updateIndentationPrefixes();
}
}
private void stopTabConversion() {
if (fTabConverter != null) {
AdaptedSourceViewer asv= (AdaptedSourceViewer) getSourceViewer();
asv.removeTextConverter(fTabConverter);
// http://dev.eclipse.org/bugs/show_bug.cgi?id=19270
asv.updateIndentationPrefixes();
fTabConverter= null;
}
}
private boolean isTabConversionEnabled() {
IPreferenceStore store= getPreferenceStore();
return store.getBoolean(SPACES_FOR_TABS);
}
public void dispose() {
ISourceViewer sourceViewer= getSourceViewer();
if (sourceViewer instanceof ITextViewerExtension)
((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter);
if (fJavaEditorErrorTickUpdater != null) {
fJavaEditorErrorTickUpdater.dispose();
fJavaEditorErrorTickUpdater= null;
}
if (fActionGroups != null) {
fActionGroups.dispose();
fActionGroups= null;
}
super.dispose();
}
/*
* @see AbstractTextEditor#createPartControl(Composite)
*/
public void createPartControl(Composite parent) {
super.createPartControl(parent);
if (isTabConversionEnabled())
startTabConversion();
IPreferenceStore preferenceStore= getPreferenceStore();
boolean closeBrackets= preferenceStore.getBoolean(CLOSE_BRACKETS);
boolean closeStrings= preferenceStore.getBoolean(CLOSE_STRINGS);
fBracketInserter.setCloseBracketsEnabled(closeBrackets);
fBracketInserter.setCloseStringsEnabled(closeStrings);
ISourceViewer sourceViewer= getSourceViewer();
if (sourceViewer instanceof ITextViewerExtension)
((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);
}
private static char getEscapeCharacter(char character) {
switch (character) {
case '"':
case '\'':
return '\\';
default:
return 0;
}
}
private static char getPeerCharacter(char character) {
switch (character) {
case '(':
return ')';
case ')':
return '(';
case '[':
return ']';
case ']':
return '[';
case '"':
return character;
case '\'':
return character;
default:
throw new IllegalArgumentException();
}
}
/*
* @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent)
*/
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
try {
AdaptedSourceViewer asv= (AdaptedSourceViewer) getSourceViewer();
if (asv != null) {
String p= event.getProperty();
if (CLOSE_BRACKETS.equals(p)) {
fBracketInserter.setCloseBracketsEnabled(getPreferenceStore().getBoolean(p));
return;
}
if (CLOSE_STRINGS.equals(p)) {
fBracketInserter.setCloseStringsEnabled(getPreferenceStore().getBoolean(p));
return;
}
if (SPACES_FOR_TABS.equals(p)) {
if (isTabConversionEnabled())
startTabConversion();
else
stopTabConversion();
return;
}
if (PreferenceConstants.EDITOR_SMART_TAB.equals(p)) {
if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SMART_TAB)) {
setActionActivationCode("IndentOnTab", '\t', -1, SWT.NONE); //$NON-NLS-1$
} else {
removeActionActivationCode("IndentOnTab"); //$NON-NLS-1$
}
}
IContentAssistant c= asv.getContentAssistant();
if (c instanceof ContentAssistant)
ContentAssistPreference.changeConfiguration((ContentAssistant) c, getPreferenceStore(), event);
}
} finally {
super.handlePreferenceStoreChanged(event);
}
}
/*
* @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
*/
protected void handlePreferencePropertyChanged(org.eclipse.core.runtime.Preferences.PropertyChangeEvent event) {
AdaptedSourceViewer asv= (AdaptedSourceViewer) getSourceViewer();
if (asv != null) {
String p= event.getProperty();
if (CODE_FORMATTER_TAB_SIZE.equals(p)) {
asv.updateIndentationPrefixes();
if (fTabConverter != null)
fTabConverter.setNumberOfSpacesPerTab(getTabSize());
}
}
super.handlePreferencePropertyChanged(event);
}
/*
* @see org.eclipse.jdt.internal.ui.javaeditor.JavaEditor#createJavaSourceViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.source.IVerticalRuler, org.eclipse.jface.text.source.IOverviewRuler, boolean, int)
*/
protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles) {
return new AdaptedSourceViewer(parent, verticalRuler, overviewRuler, isOverviewRulerVisible, styles);
}
/*
* @see IReconcilingParticipant#reconciled()
*/
public void reconciled() {
if (PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE)) {
Shell shell= getSite().getShell();
if (shell != null && !shell.isDisposed()) {
shell.getDisplay().asyncExec(new Runnable() {
public void run() {
synchronizeOutlinePageSelection();
}
});
}
}
}
protected void updateStateDependentActions() {
super.updateStateDependentActions();
fGenerateActionGroup.editorStateChanged();
}
/*
* @see AbstractTextEditor#rememberSelection()
*/
protected void rememberSelection() {
fRememberedSelection.remember();
}
/*
* @see AbstractTextEditor#restoreSelection()
*/
protected void restoreSelection() {
fRememberedSelection.restore();
}
/*
* @see AbstractTextEditor#canHandleMove(IEditorInput, IEditorInput)
*/
protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) {
String oldExtension= ""; //$NON-NLS-1$
if (originalElement instanceof IFileEditorInput) {
IFile file= ((IFileEditorInput) originalElement).getFile();
if (file != null) {
String ext= file.getFileExtension();
if (ext != null)
oldExtension= ext;
}
}
String newExtension= ""; //$NON-NLS-1$
if (movedElement instanceof IFileEditorInput) {
IFile file= ((IFileEditorInput) movedElement).getFile();
if (file != null)
newExtension= file.getFileExtension();
}
return oldExtension.equals(newExtension);
}
/*
* @see org.eclipse.ui.texteditor.ExtendedTextEditor#isPrefQuickDiffAlwaysOn()
*/
protected boolean isPrefQuickDiffAlwaysOn() {
// reestablishes the behaviour from ExtendedTextEditor which was hacked by JavaEditor
// to disable the change bar for the class file (attached source) java editor.
IPreferenceStore store= getPreferenceStore();
return store.getBoolean(ExtendedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON);
}
}
|
51,653 |
Bug 51653 [navigation] Quick Outline: Should also show interface members
|
I200402102000 We should consider showing the inherited members for interfaces at least when the target type is an interface itself.
|
resolved fixed
|
39e311e
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T15:17:10Z | 2004-02-11T17:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaOutlineInformationControl.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;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Item;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.Widget;
import org.eclipse.jface.viewers.AbstractTreeViewer;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.ui.keys.KeySequence;
import org.eclipse.ui.keys.SWTKeySupport;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IImportDeclaration;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.ITypeHierarchy;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.ui.JavaElementSorter;
import org.eclipse.jdt.ui.StandardJavaElementContentProvider;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.JavaUIMessages;
import org.eclipse.jdt.internal.ui.viewsupport.AppearanceAwareLabelProvider;
import org.eclipse.jdt.internal.ui.viewsupport.DecoratingJavaLabelProvider;
import org.eclipse.jdt.internal.ui.viewsupport.JavaElementLabels;
import org.eclipse.jdt.internal.ui.viewsupport.MemberFilter;
/**
* Show outline in light-weight control.
*
* @since 2.1
*/
public class JavaOutlineInformationControl extends AbstractInformationControl {
private KeyAdapter fKeyAdapter;
private OutlineContentProvider fOutlineContentProvider;
private IJavaElement fInput= null;
private AppearanceAwareLabelProvider fInnerLabelProvider;
protected Color fForegroundColor;
private class OutlineLabelProvider extends AppearanceAwareLabelProvider {
private OutlineLabelProvider() {
super(AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaElementLabels.F_APP_TYPE_SIGNATURE, AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS);
}
/**
* {@inheritDoc}
*/
public Color getForeground(Object element) {
if (fOutlineContentProvider.isShowingInheritedMembers()) {
if (element instanceof IJavaElement) {
IJavaElement je= (IJavaElement)element;
if (fInput.getElementType() == IJavaElement.CLASS_FILE)
je= je.getAncestor(IJavaElement.CLASS_FILE);
else
je= je.getAncestor(IJavaElement.COMPILATION_UNIT);
if (fInput.equals(je)) {
return null;
}
}
return fForegroundColor;
}
return null;
}
}
private class OutlineTreeViewer extends TreeViewer {
private boolean fIsFiltering= false;
public OutlineTreeViewer(Tree tree) {
super(tree);
}
/**
* {@inheritDoc}
*/
protected Object[] getFilteredChildren(Object parent) {
Object[] result = getRawChildren(parent);
int unfilteredChildren= result.length;
ViewerFilter[] filters = getFilters();
if (filters != null) {
for (int i= 0; i < filters.length; i++)
result = filters[i].filter(this, parent, result);
}
fIsFiltering= unfilteredChildren != result.length;
return result;
}
/**
* {@inheritDoc}
*/
protected void internalExpandToLevel(Widget node, int level) {
if (!fIsFiltering && node instanceof Item) {
Item i= (Item) node;
if (i.getData() instanceof IJavaElement) {
IJavaElement je= (IJavaElement) i.getData();
if (je.getElementType() == IJavaElement.IMPORT_CONTAINER || isInnerType(je)) {
setExpanded(i, false);
return;
}
}
}
super.internalExpandToLevel(node, level);
}
private boolean isInnerType(IJavaElement element) {
if (element != null && element.getElementType() == IJavaElement.TYPE) {
IType type= (IType)element;
try {
return type.isMember();
} catch (JavaModelException e) {
IJavaElement parent= type.getParent();
if (parent != null) {
int parentElementType= parent.getElementType();
return (parentElementType != IJavaElement.COMPILATION_UNIT && parentElementType != IJavaElement.CLASS_FILE);
}
}
}
return false;
}
}
private class OutlineContentProvider extends StandardJavaElementContentProvider {
private Map fTypeHierarchies= new HashMap();
private boolean fShowInheritedMembers;
/**
* Creates a new Outline content provider.
*
* @param showInheritedMembers <code>true</code> iff inherited members are shown
*/
public OutlineContentProvider(boolean showInheritedMembers) {
super(true);
fShowInheritedMembers= showInheritedMembers;
}
public boolean isShowingInheritedMembers() {
return fShowInheritedMembers;
}
public void toggleShowInheritedMembers() {
fShowInheritedMembers= !fShowInheritedMembers;
getTreeViewer().refresh();
}
/**
* {@inheritDoc}
*/
public Object[] getChildren(Object element) {
if (fShowInheritedMembers && element instanceof IType) {
IType type= (IType)element;
if (type.getDeclaringType() == null) {
ITypeHierarchy th= getSuperTypeHierarchy(type);
if (th != null) {
List children= new ArrayList();
IType[] superClasses= th.getAllSuperclasses(type);
children.addAll(Arrays.asList(super.getChildren(type)));
for (int i= 0, scLength= superClasses.length; i < scLength; i++)
children.addAll(Arrays.asList(super.getChildren(superClasses[i])));
return children.toArray();
}
}
}
return super.getChildren(element);
}
private ITypeHierarchy getSuperTypeHierarchy(IType type) {
ITypeHierarchy th= (ITypeHierarchy)fTypeHierarchies.get(type);
if (th == null) {
try {
th= type.newSupertypeHierarchy(JavaPlugin.getActiveWorkbenchWindow().getActivePage().getActiveEditor().getEditorSite().getActionBars().getStatusLineManager().getProgressMonitor());
} catch (JavaModelException e) {
return null;
}
fTypeHierarchies.put(type, th);
}
return th;
}
/**
* {@inheritDoc}
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
super.inputChanged(viewer, oldInput, newInput);
fTypeHierarchies.clear();
}
/**
* {@inheritDoc}
*/
public void dispose() {
super.dispose();
fTypeHierarchies.clear();
}
}
/**
* Creates a new Java outline information control.
*
* @param parent
* @param shellStyle
* @param treeStyle
* @param commandId
*/
public JavaOutlineInformationControl(Shell parent, int shellStyle, int treeStyle, String commandId) {
super(parent, shellStyle, treeStyle, commandId, true);
fForegroundColor= parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
}
/**
* {@inheritDoc}
*/
protected Text createFilterText(Composite parent) {
Text text= super.createFilterText(parent);
text.addKeyListener(getKeyAdapter());
return text;
}
/**
* {@inheritDoc}
*/
protected TreeViewer createTreeViewer(Composite parent, int style) {
Tree tree= new Tree(parent, SWT.SINGLE | (style & ~SWT.MULTI));
tree.setLayoutData(new GridData(GridData.FILL_BOTH));
final TreeViewer treeViewer= new OutlineTreeViewer(tree);
// Hide import declartions but show the container
treeViewer.addFilter(new ViewerFilter() {
public boolean select(Viewer viewer, Object parentElement, Object element) {
return !(element instanceof IImportDeclaration);
}
});
treeViewer.addFilter(new NamePatternFilter());
treeViewer.addFilter(new MemberFilter());
fOutlineContentProvider= new OutlineContentProvider(false);
treeViewer.setContentProvider(fOutlineContentProvider);
treeViewer.setSorter(new JavaElementSorter());
treeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
fInnerLabelProvider= new OutlineLabelProvider();
treeViewer.setLabelProvider(new DecoratingJavaLabelProvider(fInnerLabelProvider));
treeViewer.getTree().addKeyListener(getKeyAdapter());
return treeViewer;
}
/**
* {@inheritDoc}
*/
protected String getStatusFieldText() {
KeySequence[] sequences= getInvokingCommandKeySequences();
if (sequences == null || sequences.length == 0)
return ""; //$NON-NLS-1$
String keySequence= sequences[0].format();
if (fOutlineContentProvider.isShowingInheritedMembers())
return JavaUIMessages.getFormattedString("JavaOutlineControl.statusFieldText.hideInheritedMembers", keySequence); //$NON-NLS-1$
else
return JavaUIMessages.getFormattedString("JavaOutlineControl.statusFieldText.showInheritedMembers", keySequence); //$NON-NLS-1$
}
/**
* {@inheritDoc}
*/
public void setInput(Object information) {
if (information == null || information instanceof String) {
inputChanged(null, null);
return;
}
IJavaElement je= (IJavaElement)information;
ICompilationUnit cu= (ICompilationUnit)je.getAncestor(IJavaElement.COMPILATION_UNIT);
if (cu != null)
fInput= cu;
else
fInput= je.getAncestor(IJavaElement.CLASS_FILE);
inputChanged(fInput, information);
}
private KeyAdapter getKeyAdapter() {
if (fKeyAdapter == null) {
fKeyAdapter= new KeyAdapter() {
public void keyPressed(KeyEvent e) {
int accelerator = SWTKeySupport.convertEventToUnmodifiedAccelerator(e);
KeySequence keySequence = KeySequence.getInstance(SWTKeySupport.convertAcceleratorToKeyStroke(accelerator));
KeySequence[] sequences= getInvokingCommandKeySequences();
if (sequences == null)
return;
for (int i= 0; i < sequences.length; i++) {
if (sequences[i].equals(keySequence)) {
e.doit= false;
toggleShowInheritedMembers();
return;
}
}
}
};
}
return fKeyAdapter;
}
/**
* {@inheritDoc}
*/
protected void handleStatusFieldClicked() {
toggleShowInheritedMembers();
}
protected void toggleShowInheritedMembers() {
int flags= AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS | JavaElementLabels.F_APP_TYPE_SIGNATURE;
if (!fOutlineContentProvider.isShowingInheritedMembers())
flags |= JavaElementLabels.ALL_POST_QUALIFIED;
fInnerLabelProvider.setTextFlags(flags);
fOutlineContentProvider.toggleShowInheritedMembers();
updateStatusFieldText();
}
}
|
52,091 |
Bug 52091 NPE when changing the signature of a method that declares an inavlid throw clause
|
M7 - public void foo() throws DummyClass - try to change the signature of foo where DummyClass is not a subclass of exception. Note that you don't get a dialog informing you about the error. It is simply logged. java.lang.NullPointerException at org.eclipse.jdt.internal.corext.dom.Bindings.findType (Bindings.java:546) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createExceptionInfoList(ChangeSignatureRefactoring.java:508) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkActivation(ChangeSignatureRefactoring.java:488) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:61) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.inte rnalRun(BusyIndicatorRunnableContext.java:113) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.run (BusyIndicatorRunnableContext.java:80) at org.eclipse.swt.custom.BusyIndicator.showWhile (BusyIndicator.java:84) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext.run (BusyIndicatorRunnableContext.java:126) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.checkActivat ion(RefactoringStarter.java:67) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:47) at org.eclipse.jdt.ui.actions.ModifyParametersAction.startRefactoring (ModifyParametersAction.java:209) at org.eclipse.jdt.ui.actions.ModifyParametersAction.run (ModifyParametersAction.java:148) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:216) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent (ActionContributionItem.java:420) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2029) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1550) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1526) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:257) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:104) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
4b7efcb
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:11:16Z | 2004-02-15T13:00:00Z |
org.eclipse.jdt.ui.tests.refactoring/resources/ChangeSignature/canModify/A_testException02_in.java
| |
52,091 |
Bug 52091 NPE when changing the signature of a method that declares an inavlid throw clause
|
M7 - public void foo() throws DummyClass - try to change the signature of foo where DummyClass is not a subclass of exception. Note that you don't get a dialog informing you about the error. It is simply logged. java.lang.NullPointerException at org.eclipse.jdt.internal.corext.dom.Bindings.findType (Bindings.java:546) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createExceptionInfoList(ChangeSignatureRefactoring.java:508) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkActivation(ChangeSignatureRefactoring.java:488) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:61) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.inte rnalRun(BusyIndicatorRunnableContext.java:113) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.run (BusyIndicatorRunnableContext.java:80) at org.eclipse.swt.custom.BusyIndicator.showWhile (BusyIndicator.java:84) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext.run (BusyIndicatorRunnableContext.java:126) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.checkActivat ion(RefactoringStarter.java:67) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:47) at org.eclipse.jdt.ui.actions.ModifyParametersAction.startRefactoring (ModifyParametersAction.java:209) at org.eclipse.jdt.ui.actions.ModifyParametersAction.run (ModifyParametersAction.java:148) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:216) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent (ActionContributionItem.java:420) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2029) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1550) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1526) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:257) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:104) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
4b7efcb
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:11:16Z | 2004-02-15T13:00:00Z |
org.eclipse.jdt.ui.tests.refactoring/resources/ChangeSignature/canModify/A_testException02_out.java
| |
52,091 |
Bug 52091 NPE when changing the signature of a method that declares an inavlid throw clause
|
M7 - public void foo() throws DummyClass - try to change the signature of foo where DummyClass is not a subclass of exception. Note that you don't get a dialog informing you about the error. It is simply logged. java.lang.NullPointerException at org.eclipse.jdt.internal.corext.dom.Bindings.findType (Bindings.java:546) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createExceptionInfoList(ChangeSignatureRefactoring.java:508) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkActivation(ChangeSignatureRefactoring.java:488) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:61) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.inte rnalRun(BusyIndicatorRunnableContext.java:113) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.run (BusyIndicatorRunnableContext.java:80) at org.eclipse.swt.custom.BusyIndicator.showWhile (BusyIndicator.java:84) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext.run (BusyIndicatorRunnableContext.java:126) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.checkActivat ion(RefactoringStarter.java:67) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:47) at org.eclipse.jdt.ui.actions.ModifyParametersAction.startRefactoring (ModifyParametersAction.java:209) at org.eclipse.jdt.ui.actions.ModifyParametersAction.run (ModifyParametersAction.java:148) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:216) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent (ActionContributionItem.java:420) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2029) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1550) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1526) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:257) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:104) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
4b7efcb
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:11:16Z | 2004-02-15T13:00:00Z |
org.eclipse.jdt.ui.tests.refactoring/resources/ChangeSignature/canModify/A_testException03_in.java
| |
52,091 |
Bug 52091 NPE when changing the signature of a method that declares an inavlid throw clause
|
M7 - public void foo() throws DummyClass - try to change the signature of foo where DummyClass is not a subclass of exception. Note that you don't get a dialog informing you about the error. It is simply logged. java.lang.NullPointerException at org.eclipse.jdt.internal.corext.dom.Bindings.findType (Bindings.java:546) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createExceptionInfoList(ChangeSignatureRefactoring.java:508) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkActivation(ChangeSignatureRefactoring.java:488) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:61) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.inte rnalRun(BusyIndicatorRunnableContext.java:113) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.run (BusyIndicatorRunnableContext.java:80) at org.eclipse.swt.custom.BusyIndicator.showWhile (BusyIndicator.java:84) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext.run (BusyIndicatorRunnableContext.java:126) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.checkActivat ion(RefactoringStarter.java:67) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:47) at org.eclipse.jdt.ui.actions.ModifyParametersAction.startRefactoring (ModifyParametersAction.java:209) at org.eclipse.jdt.ui.actions.ModifyParametersAction.run (ModifyParametersAction.java:148) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:216) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent (ActionContributionItem.java:420) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2029) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1550) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1526) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:257) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:104) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
4b7efcb
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:11:16Z | 2004-02-15T13:00:00Z |
org.eclipse.jdt.ui.tests.refactoring/resources/ChangeSignature/canModify/A_testException03_out.java
| |
52,091 |
Bug 52091 NPE when changing the signature of a method that declares an inavlid throw clause
|
M7 - public void foo() throws DummyClass - try to change the signature of foo where DummyClass is not a subclass of exception. Note that you don't get a dialog informing you about the error. It is simply logged. java.lang.NullPointerException at org.eclipse.jdt.internal.corext.dom.Bindings.findType (Bindings.java:546) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createExceptionInfoList(ChangeSignatureRefactoring.java:508) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkActivation(ChangeSignatureRefactoring.java:488) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:61) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.inte rnalRun(BusyIndicatorRunnableContext.java:113) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.run (BusyIndicatorRunnableContext.java:80) at org.eclipse.swt.custom.BusyIndicator.showWhile (BusyIndicator.java:84) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext.run (BusyIndicatorRunnableContext.java:126) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.checkActivat ion(RefactoringStarter.java:67) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:47) at org.eclipse.jdt.ui.actions.ModifyParametersAction.startRefactoring (ModifyParametersAction.java:209) at org.eclipse.jdt.ui.actions.ModifyParametersAction.run (ModifyParametersAction.java:148) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:216) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent (ActionContributionItem.java:420) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2029) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1550) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1526) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:257) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:104) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
4b7efcb
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:11:16Z | 2004-02-15T13:00:00Z |
org.eclipse.jdt.ui.tests.refactoring/resources/ChangeSignature/cannotModify/A_testFail1.java
|
package p;
class A{
private native int m(int i, int j);
}
|
52,091 |
Bug 52091 NPE when changing the signature of a method that declares an inavlid throw clause
|
M7 - public void foo() throws DummyClass - try to change the signature of foo where DummyClass is not a subclass of exception. Note that you don't get a dialog informing you about the error. It is simply logged. java.lang.NullPointerException at org.eclipse.jdt.internal.corext.dom.Bindings.findType (Bindings.java:546) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createExceptionInfoList(ChangeSignatureRefactoring.java:508) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkActivation(ChangeSignatureRefactoring.java:488) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:61) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.inte rnalRun(BusyIndicatorRunnableContext.java:113) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.run (BusyIndicatorRunnableContext.java:80) at org.eclipse.swt.custom.BusyIndicator.showWhile (BusyIndicator.java:84) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext.run (BusyIndicatorRunnableContext.java:126) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.checkActivat ion(RefactoringStarter.java:67) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:47) at org.eclipse.jdt.ui.actions.ModifyParametersAction.startRefactoring (ModifyParametersAction.java:209) at org.eclipse.jdt.ui.actions.ModifyParametersAction.run (ModifyParametersAction.java:148) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:216) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent (ActionContributionItem.java:420) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2029) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1550) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1526) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:257) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:104) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
4b7efcb
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:11:16Z | 2004-02-15T13:00:00Z |
org.eclipse.jdt.ui.tests.refactoring/test
| |
52,091 |
Bug 52091 NPE when changing the signature of a method that declares an inavlid throw clause
|
M7 - public void foo() throws DummyClass - try to change the signature of foo where DummyClass is not a subclass of exception. Note that you don't get a dialog informing you about the error. It is simply logged. java.lang.NullPointerException at org.eclipse.jdt.internal.corext.dom.Bindings.findType (Bindings.java:546) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createExceptionInfoList(ChangeSignatureRefactoring.java:508) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkActivation(ChangeSignatureRefactoring.java:488) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:61) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.inte rnalRun(BusyIndicatorRunnableContext.java:113) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.run (BusyIndicatorRunnableContext.java:80) at org.eclipse.swt.custom.BusyIndicator.showWhile (BusyIndicator.java:84) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext.run (BusyIndicatorRunnableContext.java:126) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.checkActivat ion(RefactoringStarter.java:67) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:47) at org.eclipse.jdt.ui.actions.ModifyParametersAction.startRefactoring (ModifyParametersAction.java:209) at org.eclipse.jdt.ui.actions.ModifyParametersAction.run (ModifyParametersAction.java:148) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:216) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent (ActionContributionItem.java:420) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2029) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1550) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1526) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:257) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:104) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
4b7efcb
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:11:16Z | 2004-02-15T13:00:00Z |
cases/org/eclipse/jdt/ui/tests/refactoring/ChangeSignatureTests.java
| |
52,091 |
Bug 52091 NPE when changing the signature of a method that declares an inavlid throw clause
|
M7 - public void foo() throws DummyClass - try to change the signature of foo where DummyClass is not a subclass of exception. Note that you don't get a dialog informing you about the error. It is simply logged. java.lang.NullPointerException at org.eclipse.jdt.internal.corext.dom.Bindings.findType (Bindings.java:546) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createExceptionInfoList(ChangeSignatureRefactoring.java:508) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkActivation(ChangeSignatureRefactoring.java:488) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:61) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.inte rnalRun(BusyIndicatorRunnableContext.java:113) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.run (BusyIndicatorRunnableContext.java:80) at org.eclipse.swt.custom.BusyIndicator.showWhile (BusyIndicator.java:84) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext.run (BusyIndicatorRunnableContext.java:126) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.checkActivat ion(RefactoringStarter.java:67) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:47) at org.eclipse.jdt.ui.actions.ModifyParametersAction.startRefactoring (ModifyParametersAction.java:209) at org.eclipse.jdt.ui.actions.ModifyParametersAction.run (ModifyParametersAction.java:148) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:216) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent (ActionContributionItem.java:420) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2029) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1550) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1526) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:257) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:104) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
4b7efcb
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:11:16Z | 2004-02-15T13:00:00Z |
org.eclipse.jdt.ui/core
| |
52,091 |
Bug 52091 NPE when changing the signature of a method that declares an inavlid throw clause
|
M7 - public void foo() throws DummyClass - try to change the signature of foo where DummyClass is not a subclass of exception. Note that you don't get a dialog informing you about the error. It is simply logged. java.lang.NullPointerException at org.eclipse.jdt.internal.corext.dom.Bindings.findType (Bindings.java:546) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createExceptionInfoList(ChangeSignatureRefactoring.java:508) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkActivation(ChangeSignatureRefactoring.java:488) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:61) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.inte rnalRun(BusyIndicatorRunnableContext.java:113) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext$BusyRunnable.run (BusyIndicatorRunnableContext.java:80) at org.eclipse.swt.custom.BusyIndicator.showWhile (BusyIndicator.java:84) at org.eclipse.jdt.internal.ui.util.BusyIndicatorRunnableContext.run (BusyIndicatorRunnableContext.java:126) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.checkActivat ion(RefactoringStarter.java:67) at org.eclipse.jdt.internal.ui.refactoring.actions.RefactoringStarter.activate (RefactoringStarter.java:47) at org.eclipse.jdt.ui.actions.ModifyParametersAction.startRefactoring (ModifyParametersAction.java:209) at org.eclipse.jdt.ui.actions.ModifyParametersAction.run (ModifyParametersAction.java:148) at org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun (SelectionDispatchAction.java:216) 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:536) at org.eclipse.jface.action.ActionContributionItem.access$2 (ActionContributionItem.java:488) at org.eclipse.jface.action.ActionContributionItem$5.handleEvent (ActionContributionItem.java:420) at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82) at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:833) at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:2348) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2029) at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1550) at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1526) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench (Workbench.java:265) at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139) at org.eclipse.ui.internal.ide.IDEApplication.run (IDEApplication.java:47) at org.eclipse.core.internal.runtime.PlatformActivator$1.run (PlatformActivator.java:257) at org.eclipse.core.runtime.adaptor.EclipseStarter.run (EclipseStarter.java:104) 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:279) at org.eclipse.core.launcher.Main.run(Main.java:742) at org.eclipse.core.launcher.Main.main(Main.java:581)
|
resolved fixed
|
4b7efcb
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:11:16Z | 2004-02-15T13:00:00Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeSignatureRefactoring.java
| |
52,058 |
Bug 52058 NPE in ChangeMethodSignature
|
M7 - tried to add the two exeption CoreException and ClassCastException to the method TypeExtension#findTypeExtender Got the following exception Caused by: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.addExceptionToNodeList(ChangeSignatureRefactoring.java:1373) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.changeExceptions(ChangeSignatureRefactoring.java:1346) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.updateDeclarationNode(ChangeSignatureRefactoring.java:1156) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.updateMethodOccurrenceNode(ChangeSignatureRefactoring.java:1021) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createChangeManager(ChangeSignatureRefactoring.java:998) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkInput(ChangeSignatureRefactoring.java:555) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:63) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:109) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101)
|
resolved fixed
|
0fe1286
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:57:30Z | 2004-02-14T17:33:20Z |
org.eclipse.jdt.ui.tests.refactoring/resources/ChangeSignature/canModify/A_testException04_in.java
| |
52,058 |
Bug 52058 NPE in ChangeMethodSignature
|
M7 - tried to add the two exeption CoreException and ClassCastException to the method TypeExtension#findTypeExtender Got the following exception Caused by: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.addExceptionToNodeList(ChangeSignatureRefactoring.java:1373) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.changeExceptions(ChangeSignatureRefactoring.java:1346) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.updateDeclarationNode(ChangeSignatureRefactoring.java:1156) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.updateMethodOccurrenceNode(ChangeSignatureRefactoring.java:1021) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createChangeManager(ChangeSignatureRefactoring.java:998) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkInput(ChangeSignatureRefactoring.java:555) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:63) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:109) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101)
|
resolved fixed
|
0fe1286
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:57:30Z | 2004-02-14T17:33:20Z |
org.eclipse.jdt.ui.tests.refactoring/resources/ChangeSignature/canModify/A_testException04_out.java
| |
52,058 |
Bug 52058 NPE in ChangeMethodSignature
|
M7 - tried to add the two exeption CoreException and ClassCastException to the method TypeExtension#findTypeExtender Got the following exception Caused by: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.addExceptionToNodeList(ChangeSignatureRefactoring.java:1373) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.changeExceptions(ChangeSignatureRefactoring.java:1346) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.updateDeclarationNode(ChangeSignatureRefactoring.java:1156) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.updateMethodOccurrenceNode(ChangeSignatureRefactoring.java:1021) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createChangeManager(ChangeSignatureRefactoring.java:998) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkInput(ChangeSignatureRefactoring.java:555) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:63) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:109) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101)
|
resolved fixed
|
0fe1286
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:57:30Z | 2004-02-14T17:33:20Z |
org.eclipse.jdt.ui.tests.refactoring/test
| |
52,058 |
Bug 52058 NPE in ChangeMethodSignature
|
M7 - tried to add the two exeption CoreException and ClassCastException to the method TypeExtension#findTypeExtender Got the following exception Caused by: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.addExceptionToNodeList(ChangeSignatureRefactoring.java:1373) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.changeExceptions(ChangeSignatureRefactoring.java:1346) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.updateDeclarationNode(ChangeSignatureRefactoring.java:1156) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.updateMethodOccurrenceNode(ChangeSignatureRefactoring.java:1021) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createChangeManager(ChangeSignatureRefactoring.java:998) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkInput(ChangeSignatureRefactoring.java:555) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:63) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:109) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101)
|
resolved fixed
|
0fe1286
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:57:30Z | 2004-02-14T17:33:20Z |
cases/org/eclipse/jdt/ui/tests/refactoring/ChangeSignatureTests.java
| |
52,058 |
Bug 52058 NPE in ChangeMethodSignature
|
M7 - tried to add the two exeption CoreException and ClassCastException to the method TypeExtension#findTypeExtender Got the following exception Caused by: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.addExceptionToNodeList(ChangeSignatureRefactoring.java:1373) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.changeExceptions(ChangeSignatureRefactoring.java:1346) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.updateDeclarationNode(ChangeSignatureRefactoring.java:1156) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.updateMethodOccurrenceNode(ChangeSignatureRefactoring.java:1021) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createChangeManager(ChangeSignatureRefactoring.java:998) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkInput(ChangeSignatureRefactoring.java:555) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:63) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:109) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101)
|
resolved fixed
|
0fe1286
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:57:30Z | 2004-02-14T17:33:20Z |
org.eclipse.jdt.ui/core
| |
52,058 |
Bug 52058 NPE in ChangeMethodSignature
|
M7 - tried to add the two exeption CoreException and ClassCastException to the method TypeExtension#findTypeExtender Got the following exception Caused by: java.lang.NullPointerException at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.addExceptionToNodeList(ChangeSignatureRefactoring.java:1373) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.changeExceptions(ChangeSignatureRefactoring.java:1346) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.updateDeclarationNode(ChangeSignatureRefactoring.java:1156) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.updateMethodOccurrenceNode(ChangeSignatureRefactoring.java:1021) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.createChangeManager(ChangeSignatureRefactoring.java:998) at org.eclipse.jdt.internal.corext.refactoring.structure.ChangeSignatureRefactorin g.checkInput(ChangeSignatureRefactoring.java:555) at org.eclipse.jdt.internal.ui.refactoring.CheckConditionsOperation.run (CheckConditionsOperation.java:63) at org.eclipse.jdt.internal.ui.refactoring.CreateChangeOperation.run (CreateChangeOperation.java:109) at org.eclipse.jdt.internal.core.BatchOperation.executeOperation (BatchOperation.java:34) at org.eclipse.jdt.internal.core.JavaModelOperation.run (JavaModelOperation.java:700) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1567) at org.eclipse.core.internal.resources.Workspace.run (Workspace.java:1586) at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3164) at org.eclipse.jdt.internal.ui.actions.WorkbenchRunnableAdapter.run (WorkbenchRunnableAdapter.java:42) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run (ModalContext.java:101)
|
resolved fixed
|
0fe1286
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T16:57:30Z | 2004-02-14T17:33:20Z |
refactoring/org/eclipse/jdt/internal/corext/refactoring/structure/ChangeSignatureRefactoring.java
| |
51,466 |
Bug 51466 TODO marker coloring: Update to new jdt.core behaviour
| null |
resolved fixed
|
323a1d7
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T17:11:33Z | 2004-02-10T16:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/JavaCommentScanner.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;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.Preferences;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.text.IColorManager;
import org.eclipse.jdt.ui.text.IJavaColorConstants;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.rules.IToken;
import org.eclipse.jface.text.rules.IWordDetector;
import org.eclipse.jface.text.rules.WordRule;
import org.eclipse.jface.util.PropertyChangeEvent;
/**
* AbstractJavaCommentScanner.java
*/
public class JavaCommentScanner extends AbstractJavaScanner{
private static class TaskTagDetector implements IWordDetector {
public boolean isWordStart(char c) {
return Character.isLetter(c);
}
public boolean isWordPart(char c) {
return Character.isLetter(c);
}
}
private class TaskTagRule extends WordRule {
private IToken fToken;
public TaskTagRule(IToken token, IToken defaultToken) {
super(new TaskTagDetector(), defaultToken);
fToken= token;
}
public void clearTaskTags() {
fWords.clear();
}
public void addTaskTags(String value) {
String[] tasks= split(value, ","); //$NON-NLS-1$
for (int i= 0; i < tasks.length; i++) {
if (tasks[i].length() > 0) {
addWord(tasks[i], fToken);
}
}
}
private String[] split(String value, String delimiters) {
StringTokenizer tokenizer= new StringTokenizer(value, delimiters);
int size= tokenizer.countTokens();
String[] tokens= new String[size];
int i= 0;
while (i < size)
tokens[i++]= tokenizer.nextToken();
return tokens;
}
}
private static final String COMPILER_TASK_TAGS= JavaCore.COMPILER_TASK_TAGS;
protected static final String TASK_TAG= IJavaColorConstants.TASK_TAG;
private TaskTagRule fTaskTagRule;
private Preferences fCorePreferenceStore;
private String fDefaultTokenProperty;
private String[] fTokenProperties;
public JavaCommentScanner(IColorManager manager, IPreferenceStore store, Preferences coreStore, String defaultTokenProperty) {
this(manager, store, coreStore, defaultTokenProperty, new String[] { defaultTokenProperty, TASK_TAG });
}
public JavaCommentScanner(IColorManager manager, IPreferenceStore store, Preferences coreStore, String defaultTokenProperty, String[] tokenProperties) {
super(manager, store);
fCorePreferenceStore= coreStore;
fDefaultTokenProperty= defaultTokenProperty;
fTokenProperties= tokenProperties;
initialize();
}
/*
* @see AbstractJavaScanner#createRules()
*/
protected List createRules() {
List list= new ArrayList();
if (fCorePreferenceStore != null) {
// Add rule for Task Tags.
fTaskTagRule= new TaskTagRule(getToken(TASK_TAG), getToken(fDefaultTokenProperty));
String tasks= fCorePreferenceStore.getString(COMPILER_TASK_TAGS);
fTaskTagRule.addTaskTags(tasks);
list.add(fTaskTagRule);
}
setDefaultReturnToken(getToken(fDefaultTokenProperty));
return list;
}
/*
* @see org.eclipse.jdt.internal.ui.text.AbstractJavaScanner#affectsBehavior(org.eclipse.jface.util.PropertyChangeEvent)
*/
public boolean affectsBehavior(PropertyChangeEvent event) {
return event.getProperty().equals(COMPILER_TASK_TAGS) || super.affectsBehavior(event);
}
/*
* @see org.eclipse.jdt.internal.ui.text.AbstractJavaScanner#adaptToPreferenceChange(org.eclipse.jface.util.PropertyChangeEvent)
*/
public void adaptToPreferenceChange(PropertyChangeEvent event) {
if (fTaskTagRule != null && event.getProperty().equals(COMPILER_TASK_TAGS)) {
Object value= event.getNewValue();
if (value instanceof String) {
fTaskTagRule.clearTaskTags();
fTaskTagRule.addTaskTags((String) value);
}
} else if (super.affectsBehavior(event)) {
super.adaptToPreferenceChange(event);
}
}
/*
* @see org.eclipse.jdt.internal.ui.text.AbstractJavaScanner#getTokenProperties()
*/
protected String[] getTokenProperties() {
return fTokenProperties;
}
}
|
47,207 |
Bug 47207 call hierarchy: Enablement of "Search Scope" item on view menu is wrong [call hierarchy]
|
At least on Windows NT/2000 this item is shown as disabled until the user clicks it it which case the submenu opens. I have been looking into this problem but without any results so far. Any suggestions are welcome.
|
resolved fixed
|
675825b
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T18:44:41Z | 2003-11-21T10:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchScopeAction.java
| |
47,207 |
Bug 47207 call hierarchy: Enablement of "Search Scope" item on view menu is wrong [call hierarchy]
|
At least on Windows NT/2000 this item is shown as disabled until the user clicks it it which case the submenu opens. I have been looking into this problem but without any results so far. Any suggestions are welcome.
|
resolved fixed
|
675825b
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T18:44:41Z | 2003-11-21T10:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchScopeActionGroup.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 java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.window.Window;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IMemento;
import org.eclipse.ui.IWorkingSet;
import org.eclipse.ui.IWorkingSetManager;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog;
import org.eclipse.ui.help.WorkbenchHelp;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
import org.eclipse.jdt.ui.IContextMenuConstants;
import org.eclipse.jdt.internal.ui.IJavaHelpContextIds;
import org.eclipse.jdt.internal.ui.JavaPlugin;
class SearchScopeActionGroup extends ActionGroup {
private static final String TAG_SEARCH_SCOPE_TYPE= "search_scope_type"; //$NON-NLS-1$
private static final String TAG_SELECTED_WORKING_SET= "working_set"; //$NON-NLS-1$
private static final String DIALOGSTORE_SCOPE_TYPE= "SearchScopeActionGroup.search_scope_type"; //$NON-NLS-1$
private static final String DIALOGSTORE_SELECTED_WORKING_SET= "SearchScopeActionGroup.working_set"; //$NON-NLS-1$
private static final int SEARCH_SCOPE_TYPE_WORKSPACE= 1;
private static final int SEARCH_SCOPE_TYPE_PROJECT= 2;
private static final int SEARCH_SCOPE_TYPE_HIERARCHY= 3;
private static final int SEARCH_SCOPE_TYPE_WORKING_SET= 4;
private SearchScopeAction fSelectedAction = null;
private String fSelectedWorkingSetName = null;
private CallHierarchyViewPart fView;
private IDialogSettings fDialogSettings;
private SearchScopeHierarchyAction fSearchScopeHierarchyAction;
private SearchScopeProjectAction fSearchScopeProjectAction;
private SearchScopeWorkspaceAction fSearchScopeWorkspaceAction;
private SelectWorkingSetAction fSelectWorkingSetAction;
private abstract class SearchScopeAction extends Action {
public SearchScopeAction(String text) {
super(text, AS_RADIO_BUTTON);
}
public abstract IJavaSearchScope getSearchScope();
public abstract int getSearchScopeType();
public void run() {
setSelected(this, true);
}
}
private class SearchScopeHierarchyAction extends SearchScopeAction {
public SearchScopeHierarchyAction() {
super(CallHierarchyMessages.getString("SearchScopeActionGroup.hierarchy.text")); //$NON-NLS-1$
setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.hierarchy.tooltip")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
}
public IJavaSearchScope getSearchScope() {
try {
IMethod method = getView().getMethod();
if (method != null) {
return SearchEngine.createHierarchyScope(method.getDeclaringType());
} else {
return null;
}
} catch (JavaModelException e) {
JavaPlugin.log(e);
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.callhierarchy.SearchScopeActionGroup.SearchScopeAction#getSearchScopeType()
*/
public int getSearchScopeType() {
return SEARCH_SCOPE_TYPE_HIERARCHY;
}
}
private class SearchScopeProjectAction extends SearchScopeAction {
public SearchScopeProjectAction() {
super(CallHierarchyMessages.getString("SearchScopeActionGroup.project.text")); //$NON-NLS-1$
setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.project.tooltip")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
}
public IJavaSearchScope getSearchScope() {
IMethod method = getView().getMethod();
IJavaProject project = null;
if (method != null) {
project = method.getJavaProject();
}
if (project != null) {
return SearchEngine.createJavaSearchScope(new IJavaElement[] { project },
false);
} else {
return null;
}
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.callhierarchy.SearchScopeActionGroup.SearchScopeAction#getSearchScopeType()
*/
public int getSearchScopeType() {
return SEARCH_SCOPE_TYPE_PROJECT;
}
}
private class SearchScopeWorkingSetAction extends SearchScopeAction {
private IWorkingSet mWorkingSet;
public SearchScopeWorkingSetAction(IWorkingSet workingSet) {
super(workingSet.getName());
setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.workingset.tooltip")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
this.mWorkingSet = workingSet;
}
public IJavaSearchScope getSearchScope() {
return SearchEngine.createJavaSearchScope(getJavaElements(
mWorkingSet.getElements()));
}
/**
*
*/
public IWorkingSet getWorkingSet() {
return mWorkingSet;
}
/**
* @param adaptables
* @return IResource[]
*/
private IJavaElement[] getJavaElements(IAdaptable[] adaptables) {
Collection result = new ArrayList();
for (int i = 0; i < adaptables.length; i++) {
IJavaElement element = (IJavaElement) adaptables[i].getAdapter(IJavaElement.class);
if (element != null) {
result.add(element);
}
}
return (IJavaElement[]) result.toArray(new IJavaElement[result.size()]);
}
/* (non-Javadoc)
* @see org.eclipse.jdt.internal.ui.callhierarchy.SearchScopeActionGroup.SearchScopeAction#getSearchScopeType()
*/
public int getSearchScopeType() {
return SEARCH_SCOPE_TYPE_WORKING_SET;
}
}
private class SearchScopeWorkspaceAction extends SearchScopeAction {
public SearchScopeWorkspaceAction() {
super(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 SEARCH_SCOPE_TYPE_WORKSPACE;
}
}
private class SelectWorkingSetAction extends Action {
public SelectWorkingSetAction() {
super(CallHierarchyMessages.getString("SearchScopeActionGroup.workingset.select.text")); //$NON-NLS-1$
setToolTipText(CallHierarchyMessages.getString("SearchScopeActionGroup.workingset.select.tooltip")); //$NON-NLS-1$
WorkbenchHelp.setHelp(this, IJavaHelpContextIds.CALL_HIERARCHY_SEARCH_SCOPE_ACTION);
}
/* (non-Javadoc)
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
IWorkingSetManager workingSetManager = getWorkingSetManager();
IWorkingSetSelectionDialog dialog = workingSetManager.createWorkingSetSelectionDialog(PlatformUI.getWorkbench()
.getActiveWorkbenchWindow()
.getShell(),
false);
IWorkingSet workingSet = getActiveWorkingSet();
if (workingSet != null) {
dialog.setSelection(new IWorkingSet[] { workingSet });
}
if (dialog.open() == Window.OK) {
IWorkingSet[] result = dialog.getSelection();
if ((result != null) && (result.length > 0)) {
setActiveWorkingSet(result[0]);
workingSetManager.addRecentWorkingSet(result[0]);
} else {
setActiveWorkingSet(null);
}
}
}
}
public SearchScopeActionGroup(CallHierarchyViewPart view, IDialogSettings dialogSettings) {
this.fView= view;
this.fDialogSettings= dialogSettings;
createActions();
}
/**
* @return IJavaSearchScope
*/
public IJavaSearchScope getSearchScope() {
if (fSelectedAction != null) {
return fSelectedAction.getSearchScope();
}
return null;
}
public void fillActionBars(IActionBars actionBars) {
super.fillActionBars(actionBars);
fillViewMenu(actionBars.getMenuManager());
}
public void fillContextMenu(IMenuManager menu) {
}
/**
* @param set
* @param b
*/
protected void setActiveWorkingSet(IWorkingSet set) {
if (set != null) {
fSelectedWorkingSetName = set.getName();
fSelectedAction = new SearchScopeWorkingSetAction(set);
} else {
fSelectedWorkingSetName = null;
fSelectedAction = null;
}
}
/**
* @return
*/
protected IWorkingSet getActiveWorkingSet() {
if (fSelectedWorkingSetName != null) {
return getWorkingSet(fSelectedWorkingSetName);
}
return null;
}
private IWorkingSet getWorkingSet(String workingSetName) {
return getWorkingSetManager().getWorkingSet(workingSetName);
}
/**
* Sets the new search scope type.
*
* @param newSelection New action which should be the checked one
* @param ignoreUnchecked Ignores actions which are unchecked (necessary since both the old and the new action fires).
*/
protected void setSelected(SearchScopeAction newSelection, boolean ignoreUnchecked) {
if (!ignoreUnchecked || newSelection.isChecked()) {
if (newSelection instanceof SearchScopeWorkingSetAction) {
fSelectedWorkingSetName = ((SearchScopeWorkingSetAction) newSelection).getWorkingSet()
.getName();
} else {
fSelectedWorkingSetName = null;
}
fSelectedAction = newSelection;
fDialogSettings.put(DIALOGSTORE_SCOPE_TYPE, getSearchScopeType());
fDialogSettings.put(DIALOGSTORE_SELECTED_WORKING_SET, fSelectedWorkingSetName);
}
}
/**
* @return CallHierarchyViewPart
*/
protected CallHierarchyViewPart getView() {
return fView;
}
protected IWorkingSetManager getWorkingSetManager() {
IWorkingSetManager workingSetManager = PlatformUI.getWorkbench()
.getWorkingSetManager();
return workingSetManager;
}
protected void fillSearchActions(IMenuManager javaSearchMM) {
javaSearchMM.removeAll();
Action[] actions = getActions();
for (int i = 0; i < actions.length; i++) {
Action action = actions[i];
if (action.isEnabled()) {
javaSearchMM.add(action);
}
}
javaSearchMM.setVisible(!javaSearchMM.isEmpty());
}
void fillViewMenu(IMenuManager menu) {
menu.add(new Separator(IContextMenuConstants.GROUP_SEARCH));
MenuManager javaSearchMM = new MenuManager(CallHierarchyMessages.getString("SearchScopeActionGroup.searchScope"), //$NON-NLS-1$
IContextMenuConstants.GROUP_SEARCH);
javaSearchMM.addMenuListener(new IMenuListener() {
/* (non-Javadoc)
* @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
*/
public void menuAboutToShow(IMenuManager manager) {
fillSearchActions(manager);
}
});
menu.appendToGroup(IContextMenuConstants.GROUP_SEARCH, javaSearchMM);
}
/**
* @return SearchScopeAction[]
*/
private Action[] getActions() {
List actions = new ArrayList();
addAction(actions, fSearchScopeWorkspaceAction);
addAction(actions, fSearchScopeProjectAction);
addAction(actions, fSearchScopeHierarchyAction);
addAction(actions, fSelectWorkingSetAction);
IWorkingSetManager workingSetManager = PlatformUI.getWorkbench()
.getWorkingSetManager();
IWorkingSet[] sets = workingSetManager.getRecentWorkingSets();
for (int i = 0; i < sets.length; i++) {
SearchScopeWorkingSetAction workingSetAction = new SearchScopeWorkingSetAction(sets[i]);
if (sets[i].getName().equals(fSelectedWorkingSetName)) {
workingSetAction.setChecked(true);
}
actions.add(workingSetAction);
}
return (Action[]) actions.toArray(new Action[actions.size()]);
}
private void addAction(List actions, Action action) {
if (action == fSelectedAction) {
action.setChecked(true);
} else {
action.setChecked(false);
}
actions.add(action);
}
/**
* @param view
*/
private void createActions() {
fSearchScopeWorkspaceAction = new SearchScopeWorkspaceAction();
fSelectWorkingSetAction = new SelectWorkingSetAction();
fSearchScopeHierarchyAction = new SearchScopeHierarchyAction();
fSearchScopeProjectAction = new SearchScopeProjectAction();
int searchScopeType;
try {
searchScopeType= fDialogSettings.getInt(DIALOGSTORE_SCOPE_TYPE);
} catch (NumberFormatException e) {
searchScopeType= SEARCH_SCOPE_TYPE_WORKSPACE;
}
String workingSetName= fDialogSettings.get(DIALOGSTORE_SELECTED_WORKING_SET);
SearchScopeAction action= getSearchScopeAction(searchScopeType, workingSetName);
if (action != null) {
setSelected(action, false);
} else {
// Default to workspace scope
setSelected(fSearchScopeWorkspaceAction, false);
}
}
/**
* @param memento
*/
public void saveState(IMemento memento) {
int type= getSearchScopeType();
memento.putInteger(TAG_SEARCH_SCOPE_TYPE, type);
if (type == SEARCH_SCOPE_TYPE_WORKING_SET) {
memento.putString(TAG_SELECTED_WORKING_SET, fSelectedWorkingSetName);
}
}
/**
* @param memento
*/
public void restoreState(IMemento memento) {
Integer scopeType= memento.getInteger(TAG_SEARCH_SCOPE_TYPE);
if (scopeType != null) {
String workingSetName= memento.getString(TAG_SELECTED_WORKING_SET);
SearchScopeAction searchScopeAction= getSearchScopeAction(scopeType.intValue(), workingSetName);
if (searchScopeAction != null) {
setSelected(searchScopeAction, false);
}
}
}
/**
* @param i
* @return
*/
private SearchScopeAction getSearchScopeAction(int searchScopeType, String workingSetName) {
switch (searchScopeType) {
case SEARCH_SCOPE_TYPE_WORKSPACE:
return fSearchScopeWorkspaceAction;
case SEARCH_SCOPE_TYPE_PROJECT:
return fSearchScopeProjectAction;
case SEARCH_SCOPE_TYPE_HIERARCHY:
return fSearchScopeHierarchyAction;
case SEARCH_SCOPE_TYPE_WORKING_SET:
IWorkingSet workingSet= getWorkingSet(workingSetName);
if (workingSet != null) {
return new SearchScopeWorkingSetAction(workingSet);
}
return null;
}
return null;
}
/**
* @return
*/
private int getSearchScopeType() {
if (fSelectedAction != null) {
return fSelectedAction.getSearchScopeType();
}
return 0;
}
}
|
47,207 |
Bug 47207 call hierarchy: Enablement of "Search Scope" item on view menu is wrong [call hierarchy]
|
At least on Windows NT/2000 this item is shown as disabled until the user clicks it it which case the submenu opens. I have been looking into this problem but without any results so far. Any suggestions are welcome.
|
resolved fixed
|
675825b
|
JDT
|
https://github.com/eclipse-jdt/eclipse.jdt.ui
|
eclipse-jdt/eclipse.jdt.ui
|
java
| null | null | null | 2004-02-16T18:44:41Z | 2003-11-21T10:20:00Z |
org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/callhierarchy/SearchScopeHierarchyAction.java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.