diff options
Diffstat (limited to 'core/org.eclipse.cdt.ui/src/org/eclipse/cdt')
59 files changed, 662 insertions, 814 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java index 2b9d284d810..104825814a9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java @@ -41,7 +41,7 @@ public class CHHistoryListAction extends Action { private class HistoryListDialog extends StatusDialog { - private ListDialogField fHistoryList; + private ListDialogField<ICElement> fHistoryList; private IStatus fHistoryStatus; private ICElement fResult; @@ -53,22 +53,22 @@ public class CHHistoryListAction extends Action { CHMessages.CHHistoryListAction_Remove_label, }; - IListAdapter adapter= new IListAdapter() { - public void customButtonPressed(ListDialogField field, int index) { + IListAdapter<ICElement> adapter= new IListAdapter<ICElement>() { + public void customButtonPressed(ListDialogField<ICElement> field, int index) { doCustomButtonPressed(); } - public void selectionChanged(ListDialogField field) { + public void selectionChanged(ListDialogField<ICElement> field) { doSelectionChanged(); } - public void doubleClicked(ListDialogField field) { + public void doubleClicked(ListDialogField<ICElement> field) { doDoubleClicked(); } }; LabelProvider labelProvider= new CUILabelProvider(CHHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS); - fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider); + fHistoryList= new ListDialogField<ICElement>(adapter, buttonLabels, labelProvider); fHistoryList.setLabelText(CHMessages.CHHistoryListAction_HistoryList_label); fHistoryList.setElements(Arrays.asList(historyEntries)); @@ -121,12 +121,12 @@ public class CHHistoryListAction extends Action { private void doSelectionChanged() { StatusInfo status= new StatusInfo(); - List<?> selected= fHistoryList.getSelectedElements(); + List<ICElement> selected= fHistoryList.getSelectedElements(); if (selected.size() != 1) { status.setError(""); //$NON-NLS-1$ fResult= null; } else { - fResult= (ICElement) selected.get(0); + fResult= selected.get(0); } fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0); fHistoryStatus= status; @@ -138,7 +138,7 @@ public class CHHistoryListAction extends Action { } public ICElement[] getRemaining() { - List<?> elems= fHistoryList.getElements(); + List<ICElement> elems= fHistoryList.getElements(); return elems.toArray(new ICElement[elems.size()]); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java index cc747182232..2e00e3c4b13 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java @@ -11,7 +11,6 @@ package org.eclipse.cdt.internal.ui.dnd; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.eclipse.core.runtime.Assert; @@ -52,8 +51,7 @@ public class DelegatingDragAdapter implements DragSourceListener { List<Transfer> transfers= new ArrayList<Transfer>(fPossibleListeners.length); fActiveListeners= new ArrayList<TransferDragSourceListener>(fPossibleListeners.length); - for (int i= 0; i < fPossibleListeners.length; i++) { - TransferDragSourceListener listener= fPossibleListeners[i]; + for (TransferDragSourceListener listener : fPossibleListeners) { event.doit= saveDoit; listener.dragStart(event); if (event.doit) { @@ -74,8 +72,9 @@ public class DelegatingDragAdapter implements DragSourceListener { */ public void dragSetData(DragSourceEvent event) { fFinishListener= getListener(event.dataType); - if (fFinishListener != null) + if (fFinishListener != null) { fFinishListener.dragSetData(event); + } } /* non Java-doc @@ -89,8 +88,9 @@ public class DelegatingDragAdapter implements DragSourceListener { // If the user presses Escape then we get a dragFinished without // getting a dragSetData before. fFinishListener= getListener(event.dataType); - if (fFinishListener != null) + if (fFinishListener != null) { fFinishListener.dragFinished(event); + } } } finally{ fFinishListener= null; @@ -102,11 +102,9 @@ public class DelegatingDragAdapter implements DragSourceListener { if (type == null) return null; - for (Iterator iter= fActiveListeners.iterator(); iter.hasNext();) { - TransferDragSourceListener listener= (TransferDragSourceListener)iter.next(); - if (listener.getTransfer().isSupportedType(type)) { + for (TransferDragSourceListener listener : fActiveListeners) { + if (listener.getTransfer().isSupportedType(type)) return listener; - } } return null; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java index 6ba17d1ad78..27f7edb2d58 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java @@ -81,15 +81,13 @@ public class FileTransferDragAdapter implements TransferDragSourceListener { private static class RefreshOperation extends WorkspaceModifyOperation { private final Set<IResource> roots; - public RefreshOperation(List resources) { + public RefreshOperation(List<IResource> resources) { super(); roots = new HashSet<IResource>(resources.size()); - for (Iterator iterator = resources.iterator(); iterator.hasNext();) { - IResource resource = (IResource) iterator.next(); + for (IResource resource : resources) { IResource parent = resource.getParent(); - roots.add(parent != null ? parent : resource); } } @@ -100,9 +98,7 @@ public class FileTransferDragAdapter implements TransferDragSourceListener { monitor.beginTask(CUIMessages.getString("FileTransferDragAdapter.refreshing"), roots.size()); //$NON-NLS-1$ MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, CUIMessages.getString("FileTransferDragAdapter.problem"), null); //$NON-NLS-1$ - for (Iterator iterator = roots.iterator(); iterator.hasNext();) { - IResource resource = (IResource) iterator.next(); - + for (IResource resource : roots) { try { resource.refreshLocal( IResource.DEPTH_ONE, @@ -120,7 +116,7 @@ public class FileTransferDragAdapter implements TransferDragSourceListener { } } - private List getResources() { + private List<IResource> getResources() { List<IResource> result = Collections.emptyList(); ISelection selection = provider.getSelection(); @@ -129,7 +125,7 @@ public class FileTransferDragAdapter implements TransferDragSourceListener { result = new ArrayList<IResource>(structured.size()); - for (Iterator iterator = structured.iterator(); iterator.hasNext();) { + for (Iterator<?> iterator = structured.iterator(); iterator.hasNext();) { Object object = iterator.next(); IResource resource = null; @@ -147,13 +143,12 @@ public class FileTransferDragAdapter implements TransferDragSourceListener { return result; } - private static String[] getResourceLocations(List resources) { + private static String[] getResourceLocations(List<IResource> resources) { if (!resources.isEmpty()) { int count = resources.size(); List<String> locations = new ArrayList<String>(count); - for (Iterator iterator = resources.iterator(); iterator.hasNext();) { - IResource resource = (IResource) iterator.next(); + for (IResource resource : resources) { IPath location = resource.getLocation(); if (location != null) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java index a5f122df7ad..9e0ba8037fb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java @@ -103,7 +103,7 @@ public class ResourceTransferDragAdapter implements TransferDragSourceListener { resources = new ArrayList<IResource>(structured.size()); - for (Iterator iterator = structured.iterator(); iterator.hasNext();) { + for (Iterator<?> iterator = structured.iterator(); iterator.hasNext();) { Object element = iterator.next(); IResource resource = null; if (element instanceof IResource) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java index f48e1bd8c83..ecc67e563b8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java @@ -137,7 +137,7 @@ public class ResourceTransferDropAdapter extends CDTViewerDropAdapter implements .getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; - for (Iterator i = ssel.iterator(); i.hasNext();) { + for (Iterator<?> i = ssel.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof IResource) { selectedResources.add((IResource) o); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextEditorDropAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextEditorDropAdapter.java index 1947f6fa0e1..94b9ad7d0cf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextEditorDropAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextEditorDropAdapter.java @@ -67,22 +67,23 @@ public class TextEditorDropAdapter extends DropTargetAdapter implements * @see ITextEditorDropTargetListener */ public static class Factory implements IAdapterFactory { - private static final Class[] CLASSES= { ITextEditorDropTargetListener.class }; + private static final Class<?>[] CLASSES= { ITextEditorDropTargetListener.class }; /* * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, * java.lang.Class) */ + @SuppressWarnings("unchecked") public Object getAdapter(Object adaptableObject, Class adapterType) { - if (adaptableObject instanceof ITextEditor) { + if (adaptableObject instanceof ITextEditor) return TextEditorDropAdapter.create((ITextEditor) adaptableObject); - } return null; } /* * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() */ + @SuppressWarnings("unchecked") public Class[] getAdapterList() { return CLASSES; } @@ -323,13 +324,13 @@ public class TextEditorDropAdapter extends DropTargetAdapter implements * @param fileNames */ private void dropFiles(String[] fileNames) throws CoreException { - for (int i= 0; i < fileNames.length; i++) { - Path path= new Path(fileNames[i]); + for (String fileName : fileNames) { + Path path= new Path(fileName); java.io.File file= path.toFile(); if (!file.isFile()) { throw new CoreException(new Status(IStatus.ERROR, CUIPlugin .getPluginId(), 0, CUIMessages.getFormattedString( - "TextEditorDropAdapter.noFile", fileNames[i]), //$NON-NLS-1$ + "TextEditorDropAdapter.noFile", fileName), //$NON-NLS-1$ null)); } if (file.canRead()) { @@ -337,7 +338,7 @@ public class TextEditorDropAdapter extends DropTargetAdapter implements } else { throw new CoreException(new Status(IStatus.ERROR, CUIPlugin .getPluginId(), 0, CUIMessages.getFormattedString( - "TextEditorDropAdapter.unreadableFile", fileNames[i]), //$NON-NLS-1$ + "TextEditorDropAdapter.unreadableFile", fileName), //$NON-NLS-1$ null)); } } @@ -350,8 +351,7 @@ public class TextEditorDropAdapter extends DropTargetAdapter implements * @throws PartInitException */ private void dropMarkers(IMarker[] markers) throws PartInitException { - for (int i= 0; i < markers.length; i++) { - IMarker marker= markers[i]; + for (IMarker marker : markers) { IDE.openEditor(getPage(), marker); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java index d8344351a01..a73e4bc4e0a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java @@ -41,7 +41,7 @@ public class IBHistoryListAction extends Action { private class HistoryListDialog extends StatusDialog { - private ListDialogField fHistoryList; + private ListDialogField<ITranslationUnit> fHistoryList; private IStatus fHistoryStatus; private ITranslationUnit fResult; @@ -53,22 +53,22 @@ public class IBHistoryListAction extends Action { IBMessages.IBHistoryListAction_Remove_label, }; - IListAdapter adapter= new IListAdapter() { - public void customButtonPressed(ListDialogField field, int index) { + IListAdapter<ITranslationUnit> adapter= new IListAdapter<ITranslationUnit>() { + public void customButtonPressed(ListDialogField<ITranslationUnit> field, int index) { doCustomButtonPressed(); } - public void selectionChanged(ListDialogField field) { + public void selectionChanged(ListDialogField<ITranslationUnit> field) { doSelectionChanged(); } - public void doubleClicked(ListDialogField field) { + public void doubleClicked(ListDialogField<ITranslationUnit> field) { doDoubleClicked(); } }; CUILabelProvider labelProvider= new CUILabelProvider(CElementBaseLabels.APPEND_ROOT_PATH, CElementImageProvider.OVERLAY_ICONS); - fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider); + fHistoryList= new ListDialogField<ITranslationUnit>(adapter, buttonLabels, labelProvider); fHistoryList.setLabelText(IBMessages.IBHistoryListAction_HistoryList_label); fHistoryList.setElements(Arrays.asList(elements)); @@ -121,12 +121,12 @@ public class IBHistoryListAction extends Action { private void doSelectionChanged() { StatusInfo status= new StatusInfo(); - List<?> selected= fHistoryList.getSelectedElements(); + List<ITranslationUnit> selected= fHistoryList.getSelectedElements(); if (selected.size() != 1) { status.setError(""); //$NON-NLS-1$ fResult= null; } else { - fResult= (ITranslationUnit) selected.get(0); + fResult= selected.get(0); } fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0); fHistoryStatus= status; @@ -138,7 +138,7 @@ public class IBHistoryListAction extends Action { } public ITranslationUnit[] getRemaining() { - List<?> elems= fHistoryList.getElements(); + List<ITranslationUnit> elems= fHistoryList.getElements(); return elems.toArray(new ITranslationUnit[elems.size()]); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java index ff56dd068fb..f2d87c12566 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java @@ -80,7 +80,7 @@ public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup { boolean hasBuilder= true; // false if any project is closed or does // not have builder - Iterator resources= selection.iterator(); + Iterator<?> resources= selection.iterator(); while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) { Object next= resources.next(); IProject project= null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java index 967c6713ff2..137695db349 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java @@ -272,6 +272,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I /* * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedChildren(java.lang.Object, java.util.Set) */ + @SuppressWarnings("unchecked") public void getPipelinedChildren(Object parent, Set currentChildren) { customizeCElements(getChildren(parent), currentChildren); } @@ -279,6 +280,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I /* * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedElements(java.lang.Object, java.util.Set) */ + @SuppressWarnings("unchecked") public void getPipelinedElements(Object input, Set currentElements) { // only replace plain resource elements with custom elements // and avoid duplicating elements already customized @@ -286,10 +288,9 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I customizeCElements(getElements(input), currentElements); } - private void customizeCElements(Object[] cChildren, Set proposedChildren) { - List elementList= Arrays.asList(cChildren); - for (Iterator iter= proposedChildren.iterator(); iter.hasNext();) { - Object element= iter.next(); + private void customizeCElements(Object[] cChildren, Set<Object> proposedChildren) { + List<Object> elementList= Arrays.asList(cChildren); + for (Object element : proposedChildren) { IResource resource= null; if (element instanceof IResource) { resource= (IResource)element; @@ -303,8 +304,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I } } } - for (int i= 0; i < cChildren.length; i++) { - Object element= cChildren[i]; + for (Object element : cChildren) { if (element instanceof ICElement) { ICElement cElement= (ICElement)element; IResource resource= cElement.getResource(); @@ -343,7 +343,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I } } else if (parent instanceof IWorkspaceRoot) { // ignore adds of C projects (we are issuing a refresh) - for (Iterator iterator = addModification.getChildren().iterator(); iterator.hasNext();) { + for (Iterator<?> iterator = addModification.getChildren().iterator(); iterator.hasNext();) { Object child= iterator.next(); if (child instanceof IProject) { if (CoreModel.hasCNature((IProject)child)) { @@ -360,14 +360,18 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRefresh(org.eclipse.ui.navigator.PipelinedViewerUpdate) */ public boolean interceptRefresh(PipelinedViewerUpdate refreshSynchronization) { - return convertToCElements(refreshSynchronization.getRefreshTargets()); + @SuppressWarnings("unchecked") + final Set<Object> refreshTargets = refreshSynchronization.getRefreshTargets(); + return convertToCElements(refreshTargets); } /* * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRemove(org.eclipse.ui.navigator.PipelinedShapeModification) */ public PipelinedShapeModification interceptRemove(PipelinedShapeModification removeModification) { - convertToCElements(removeModification.getChildren()); + @SuppressWarnings("unchecked") + final Set<Object> children = removeModification.getChildren(); + convertToCElements(children); return removeModification; } @@ -375,7 +379,9 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptUpdate(org.eclipse.ui.navigator.PipelinedViewerUpdate) */ public boolean interceptUpdate(PipelinedViewerUpdate updateSynchronization) { - return convertToCElements(updateSynchronization.getRefreshTargets()); + @SuppressWarnings("unchecked") + final Set<Object> refreshTargets = updateSynchronization.getRefreshTargets(); + return convertToCElements(refreshTargets); } /** @@ -399,7 +405,9 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I if( !(element instanceof ICModel) && !(element instanceof ICProject) ) { modification.setParent(element); } - return convertToCElements(modification.getChildren()); + @SuppressWarnings("unchecked") + final Set<Object> children = modification.getChildren(); + return convertToCElements(children); } } } @@ -414,10 +422,10 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I * refreshed in the viewer. * @return <code>true</code> if the input set was modified */ - private boolean convertToCElements(Set currentChildren) { - LinkedHashSet convertedChildren= new LinkedHashSet(); + private boolean convertToCElements(Set<Object> currentChildren) { + LinkedHashSet<ICElement> convertedChildren= new LinkedHashSet<ICElement>(); ICElement newChild; - for (Iterator iter= currentChildren.iterator(); iter.hasNext();) { + for (Iterator<Object> iter= currentChildren.iterator(); iter.hasNext();) { Object child= iter.next(); // do not convert IProject if (child instanceof IFile || child instanceof IFolder) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java index 4ff76d51ec2..26a1f242abe 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java @@ -45,11 +45,10 @@ public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant { * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#setDragData(org.eclipse.swt.dnd.DragSourceEvent, org.eclipse.jface.viewers.IStructuredSelection) */ @Override - public boolean setDragData(DragSourceEvent event, - IStructuredSelection selection) { + public boolean setDragData(DragSourceEvent event, IStructuredSelection selection) { if (selection != null) { boolean applicable= false; - for (Iterator iter= (selection).iterator(); iter.hasNext();) { + for (Iterator<?> iter= (selection).iterator(); iter.hasNext();) { Object element= iter.next(); if (element instanceof ICElement) { if (element instanceof ITranslationUnit) { @@ -68,5 +67,4 @@ public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant { } return false; } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java index 89fa2f11fc2..c0ffed22067 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java @@ -179,8 +179,7 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant { if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) { IResource[] selectedResources= getSelectedResources(); if (selectedResources.length > 0) { - for (int iRes = 0; iRes < selectedResources.length; iRes++) { - IResource res = selectedResources[iRes]; + for (IResource res : selectedResources) { if(res instanceof IProject) { // drop of projects not supported on other IResources // "Path for project must have only one segment." @@ -362,10 +361,9 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant { if (!(selection instanceof IStructuredSelection)) { return null; } - List elements = ((IStructuredSelection)selection).toList(); + List<?> elements = ((IStructuredSelection)selection).toList(); List<Object> resources= new ArrayList<Object>(elements.size()); - for (Iterator iter= elements.iterator(); iter.hasNext();) { - Object element= iter.next(); + for (Object element : elements) { if (element instanceof ITranslationUnit) { continue; } @@ -394,11 +392,12 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant { ICElement parent = elements[0]; for (int i = 0; i < elements.length; ++i) { ICElement p = elements[i].getParent(); - if (parent == null && p!= null) { + if (parent == null) { + if (p!= null) + return false; + } + else if (!parent.equals(p)) return false; - } else if (!parent.equals(p)){ - return false; - } } } return true; @@ -438,7 +437,7 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant { private IResource[] getSelectedResources(IStructuredSelection selection) { ArrayList<Object> selectedResources = new ArrayList<Object>(); - for (Iterator i = selection.iterator(); i.hasNext();) { + for (Iterator<?> i = selection.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof IResource) { selectedResources.add(o); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java index 97ac405ea30..922755286a7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.ui.navigator; import org.eclipse.core.resources.IResource; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.SameShellProvider; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IActionBars; @@ -111,6 +112,7 @@ public class CNavigatorEditActionGroup extends ActionGroup { } protected void makeActions() { + final SameShellProvider shellProvider= new SameShellProvider(shell); clipboard = new Clipboard(shell.getDisplay()); pasteAction = new PasteAction(shell, clipboard); @@ -128,7 +130,7 @@ public class CNavigatorEditActionGroup extends ActionGroup { .getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); copyAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.COPY); - deleteAction = new DeleteResourceAction(shell); + deleteAction = new DeleteResourceAction(shellProvider); deleteAction.setDisabledImageDescriptor(images .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED)); deleteAction.setImageDescriptor(images diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java index 559604c5fb7..67f0fb76b55 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java @@ -73,7 +73,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo protected final class SectionManager { /** The preference setting for keeping no section open. */ private static final String __NONE= "__none"; //$NON-NLS-1$ - private Set fSections= new HashSet(); + private Set<ExpandableComposite> fSections= new HashSet<ExpandableComposite>(); private boolean fIsBeingManaged= false; private ExpansionAdapter fListener= new ExpansionAdapter() { @Override @@ -85,8 +85,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo if (e.getState()) { try { fIsBeingManaged= true; - for (Iterator iter= fSections.iterator(); iter.hasNext();) { - ExpandableComposite composite= (ExpandableComposite) iter.next(); + for (ExpandableComposite composite : fSections) { if (composite != source) composite.setExpanded(false); } @@ -206,26 +205,26 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo protected static final int INDENT= 20; private OverlayPreferenceStore fStore; - private Map fCheckBoxes= new HashMap(); + private Map<Object, String> fCheckBoxes= new HashMap<Object, String>(); private SelectionListener fCheckBoxListener= new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { Button button= (Button) e.widget; - fStore.setValue((String) fCheckBoxes.get(button), button.getSelection()); + fStore.setValue(fCheckBoxes.get(button), button.getSelection()); } }; - private Map fTextFields= new HashMap(); + private Map<Object, String> fTextFields= new HashMap<Object, String>(); private ModifyListener fTextFieldListener= new ModifyListener() { public void modifyText(ModifyEvent e) { Text text= (Text) e.widget; - fStore.setValue((String) fTextFields.get(text), text.getText()); + fStore.setValue(fTextFields.get(text), text.getText()); } }; - private ArrayList fNumberFields= new ArrayList(); + private ArrayList<Text> fNumberFields= new ArrayList<Text>(); private ModifyListener fNumberFieldListener= new ModifyListener() { public void modifyText(ModifyEvent e) { numberFieldChanged((Text) e.widget); @@ -238,7 +237,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo * @see #createDependency(Button, Control) * @since 3.0 */ - private ArrayList fMasterSlaveListeners= new ArrayList(); + private ArrayList<Object> fMasterSlaveListeners= new ArrayList<Object>(); private StatusInfo fStatus; private final PreferencePage fMainPage; @@ -359,8 +358,8 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo SelectionListener listener= new SelectionListener() { public void widgetSelected(SelectionEvent e) { boolean state= master.getSelection(); - for (int i= 0; i < slaves.length; i++) { - slaves[i].setEnabled(state); + for (Control slave : slaves) { + slave.setEnabled(state); } } @@ -380,17 +379,17 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo private void initializeFields() { - Iterator iter= fCheckBoxes.keySet().iterator(); + Iterator<Object> iter= fCheckBoxes.keySet().iterator(); while (iter.hasNext()) { Button b= (Button) iter.next(); - String key= (String) fCheckBoxes.get(b); + String key= fCheckBoxes.get(b); b.setSelection(fStore.getBoolean(key)); } iter= fTextFields.keySet().iterator(); while (iter.hasNext()) { Text t= (Text) iter.next(); - String key= (String) fTextFields.get(t); + String key= fTextFields.get(t); t.setText(fStore.getString(key)); } @@ -427,7 +426,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo String number= textControl.getText(); IStatus status= validatePositiveNumber(number); if (!status.matches(IStatus.ERROR)) - fStore.setValue((String) fTextFields.get(textControl), number); + fStore.setValue(fTextFields.get(textControl), number); updateStatus(status); } @@ -461,12 +460,11 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo protected Composite createSubsection(Composite parent, SectionManager manager, String label) { if (manager != null) { return manager.createSection(label); - } else { - Group group= new Group(parent, SWT.SHADOW_NONE); - group.setText(label); - GridData data= new GridData(SWT.FILL, SWT.CENTER, true, false); - group.setLayoutData(data); - return group; } + Group group= new Group(parent, SWT.SHADOW_NONE); + group.setText(label); + GridData data= new GridData(SWT.FILL, SWT.CENTER, true, false); + group.setLayoutData(data); + return group; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java index f1b402f3268..ae34e13950c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java @@ -61,50 +61,50 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I * @see #createDependency(Button, String, Control) * @since 3.0 */ - private ArrayList fMasterSlaveListeners= new ArrayList(); + private ArrayList<SelectionListener> fMasterSlaveListeners= new ArrayList<SelectionListener>(); - protected Map fTextFields = new HashMap(); + protected Map<Object, String> fTextFields = new HashMap<Object, String>(); private ModifyListener fTextFieldListener = new ModifyListener() { public void modifyText(ModifyEvent e) { Text text = (Text) e.widget; - fOverlayStore.setValue((String) fTextFields.get(text), text.getText()); + fOverlayStore.setValue(fTextFields.get(text), text.getText()); } }; - protected Map fComboBoxes = new HashMap(); + protected Map<Object, String> fComboBoxes = new HashMap<Object, String>(); private ModifyListener fComboBoxListener = new ModifyListener() { public void modifyText(ModifyEvent e) { Combo combo = (Combo) e.widget; String state = ProposalFilterPreferencesUtil.comboStateAsString(combo); - fOverlayStore.setValue((String) fComboBoxes.get(combo), state); + fOverlayStore.setValue(fComboBoxes.get(combo), state); } }; - protected Map fCheckBoxes = new HashMap(); + protected Map<Object, String> fCheckBoxes = new HashMap<Object, String>(); 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()); + fOverlayStore.setValue(fCheckBoxes.get(button), button.getSelection()); } }; - protected ArrayList fNumberFields = new ArrayList(); + protected ArrayList<Text> fNumberFields = new ArrayList<Text>(); private ModifyListener fNumberFieldListener = new ModifyListener() { public void modifyText(ModifyEvent e) { numberFieldChanged((Text) e.widget); } }; - protected Map fColorButtons = new HashMap(); + protected Map<Object, String> fColorButtons = new HashMap<Object, String>(); private SelectionListener fColorButtonListener = new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { ColorSelector editor = (ColorSelector) e.widget.getData(); - PreferenceConverter.setValue(fOverlayStore, (String) fColorButtons.get(editor), editor.getColorValue()); + PreferenceConverter.setValue(fOverlayStore, fColorButtons.get(editor), editor.getColorValue()); } }; @@ -224,7 +224,7 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I String number = textControl.getText(); IStatus status = validatePositiveNumber(number); if (!status.matches(IStatus.ERROR)) - fOverlayStore.setValue((String) fTextFields.get(textControl), number); + fOverlayStore.setValue(fTextFields.get(textControl), number); updateStatus(status); } @@ -247,7 +247,7 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I protected void updateStatus(IStatus status) { if (!status.matches(IStatus.ERROR)) { for (int i = 0; i < fNumberFields.size(); i++) { - Text text = (Text) fNumberFields.get(i); + Text text = fNumberFields.get(i); IStatus s = validatePositiveNumber(text.getText()); status = StatusUtil.getMoreSevere(s, status); } @@ -310,10 +310,10 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I protected void initializeFields() { - Iterator e = fColorButtons.keySet().iterator(); + Iterator<Object> e = fColorButtons.keySet().iterator(); while (e.hasNext()) { ColorSelector c = (ColorSelector) e.next(); - String key = (String) fColorButtons.get(c); + String key = fColorButtons.get(c); RGB rgb = PreferenceConverter.getColor(fOverlayStore, key); c.setColorValue(rgb); } @@ -321,21 +321,21 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I e = fCheckBoxes.keySet().iterator(); while (e.hasNext()) { Button b = (Button) e.next(); - String key = (String) fCheckBoxes.get(b); + String key = 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); + String key = fTextFields.get(t); t.setText(fOverlayStore.getString(key)); } e = fComboBoxes.keySet().iterator(); while (e.hasNext()) { Combo c = (Combo) e.next(); - String key = (String) fComboBoxes.get(c); + String key = fComboBoxes.get(c); String state = fOverlayStore.getString(key); // Interpret the state string as a Combo state description ProposalFilterPreferencesUtil.restoreComboFromString(c, state); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java index 6218c723a18..4d51d9b0a14 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java @@ -17,7 +17,6 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.eclipse.jface.dialogs.Dialog; @@ -371,26 +370,26 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { fColorManager= new CColorManager(false); - for (int i= 0, n= fSyntaxColorListModel.length; i < n; i++) + for (String[] element : fSyntaxColorListModel) fListModel.add(new HighlightingColorListItem ( - fSyntaxColorListModel[i][0], - fSyntaxColorListModel[i][1], - fSyntaxColorListModel[i][1] + BOLD, - fSyntaxColorListModel[i][1] + ITALIC, - fSyntaxColorListModel[i][1] + STRIKETHROUGH, - fSyntaxColorListModel[i][1] + UNDERLINE)); + element[0], + element[1], + element[1] + BOLD, + element[1] + ITALIC, + element[1] + STRIKETHROUGH, + element[1] + UNDERLINE)); SemanticHighlighting[] semanticHighlightings= SemanticHighlightings.getSemanticHighlightings(); - for (int i= 0, n= semanticHighlightings.length; i < n; i++) + for (SemanticHighlighting semanticHighlighting : semanticHighlightings) fListModel.add( new SemanticHighlightingColorListItem( - semanticHighlightings[i].getDisplayName(), - SemanticHighlightings.getColorPreferenceKey(semanticHighlightings[i]), - SemanticHighlightings.getBoldPreferenceKey(semanticHighlightings[i]), - SemanticHighlightings.getItalicPreferenceKey(semanticHighlightings[i]), - SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlightings[i]), - SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlightings[i]), - SemanticHighlightings.getEnabledPreferenceKey(semanticHighlightings[i]) + semanticHighlighting.getDisplayName(), + SemanticHighlightings.getColorPreferenceKey(semanticHighlighting), + SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting), + SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting), + SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting), + SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting), + SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting) )); store.addKeys(createOverlayStoreKeys()); @@ -613,8 +612,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { gd= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, true); gd.heightHint= convertHeightInCharsToPixels(9); int maxWidth= 0; - for (Iterator it= fListModel.iterator(); it.hasNext();) { - HighlightingColorListItem item= (HighlightingColorListItem) it.next(); + for (HighlightingColorListItem item : fListModel) { maxWidth= Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length())); } ScrollBar vBar= ((Scrollable) fListViewer.getControl()).getVerticalBar(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java index 9ddfdec8f60..2e8dd0ab24d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java @@ -59,6 +59,7 @@ import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; import org.eclipse.cdt.internal.ui.dialogs.StatusUtil; +import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey; import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor; import org.eclipse.cdt.internal.ui.util.PixelConverter; import org.eclipse.cdt.internal.ui.util.SWTUtil; @@ -171,7 +172,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { - ArrayList overlayKeys= new ArrayList(); + ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>(); //overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER)); //overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE)); @@ -437,7 +438,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB String compiledTextHoverModifiers= fStore.getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS); StringTokenizer tokenizer= new StringTokenizer(compiledTextHoverModifiers, CEditorTextHoverDescriptor.VALUE_SEPARATOR); - HashMap idToModifier= new HashMap(tokenizer.countTokens() / 2); + HashMap<String, String> idToModifier= new HashMap<String, String>(tokenizer.countTokens() / 2); while (tokenizer.hasMoreTokens()) { String id= tokenizer.nextToken(); @@ -448,7 +449,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB String compiledTextHoverModifierMasks= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS); tokenizer= new StringTokenizer(compiledTextHoverModifierMasks, CEditorTextHoverDescriptor.VALUE_SEPARATOR); - HashMap idToModifierMask= new HashMap(tokenizer.countTokens() / 2); + HashMap<String, String> idToModifierMask= new HashMap<String, String>(tokenizer.countTokens() / 2); while (tokenizer.hasMoreTokens()) { String id= tokenizer.nextToken(); @@ -457,7 +458,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB } for (int i= 0; i < fHoverConfigs.length; i++) { - String modifierString= (String)idToModifier.get(getContributedHovers()[i].getId()); + String modifierString= idToModifier.get(getContributedHovers()[i].getId()); boolean enabled= true; if (modifierString == null) modifierString= CEditorTextHoverDescriptor.DISABLED_TAG; @@ -476,7 +477,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB if (fHoverConfigs[i].fStateMask == -1) { try { - fHoverConfigs[i].fStateMask= Integer.parseInt((String)idToModifierMask.get(getContributedHovers()[i].getId())); + fHoverConfigs[i].fStateMask= Integer.parseInt(idToModifierMask.get(getContributedHovers()[i].getId())); } catch (NumberFormatException ex) { fHoverConfigs[i].fStateMask= -1; } @@ -531,7 +532,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB fStatus= new StatusInfo(); int i= 0; - HashMap stateMasks= new HashMap(fHoverConfigs.length); + HashMap<Integer, String> stateMasks= new HashMap<Integer, String>(fHoverConfigs.length); while (fStatus.isOK() && i < fHoverConfigs.length) { if (fHoverConfigs[i].fIsEnabled) { String label= getContributedHovers()[i].getLabel(); @@ -539,7 +540,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB if (fHoverConfigs[i].fStateMask == -1) fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValidForHover, new String[] {fHoverConfigs[i].fModifierString, label})); else if (stateMasks.containsKey(stateMask)) - fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_duplicateModifier, new String[] {label, (String)stateMasks.get(stateMask)})); + fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_duplicateModifier, new String[] {label, stateMasks.get(stateMask)})); else stateMasks.put(stateMask, label); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java index 28e9e3828af..a2b4759ba7c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java @@ -34,7 +34,6 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Listener; -import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PreferencesUtil; @@ -52,7 +51,7 @@ import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager; /* * The page for setting the editor options. */ -public class CEditorPreferencePage extends AbstractPreferencePage implements IWorkbenchPreferencePage { +public class CEditorPreferencePage extends AbstractPreferencePage { protected final String[][] fAppearanceColorListModel = new String[][] { {PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBracketColor, CEditor.MATCHING_BRACKETS_COLOR, null }, @@ -120,8 +119,8 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo if (control instanceof Composite) { Composite composite = (Composite) control; Control[] children = composite.getChildren(); - for (int i = 0; i < children.length; i++) - setEnabled(children[i], enable); + for (Control element : children) + setEnabled(element, enable); } } @@ -302,8 +301,8 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo initializeFields(); initializeDefaultColors(); - for (int i = 0; i < fAppearanceColorListModel.length; i++) { - fAppearanceColorList.add(fAppearanceColorListModel[i][0]); + for (String[] element : fAppearanceColorListModel) { + fAppearanceColorList.add(element[0]); } fAppearanceColorList.getDisplay().asyncExec(new Runnable() { public void run() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java index eb97e629af9..a06220df72d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.ui.preferences; import java.util.ArrayList; -import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.content.IContentType; import org.eclipse.core.runtime.content.IContentTypeManager; @@ -31,6 +30,8 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +import org.eclipse.cdt.core.model.CoreModel; + public class CFileTypeDialog extends Dialog { public CFileTypeDialog(Shell parentShell) { @@ -112,9 +113,9 @@ public class CFileTypeDialog extends Dialog { private void populateTypesCombo() { IContentTypeManager manager = Platform.getContentTypeManager(); String[] ids = CoreModel.getRegistedContentTypeIds(); - ArrayList list = new ArrayList(ids.length); - for (int i = 0; i < ids.length; i++) { - IContentType ctype = manager.getContentType(ids[i]); + ArrayList<IContentType> list = new ArrayList<IContentType>(ids.length); + for (String id : ids) { + IContentType ctype = manager.getContentType(id); if (ctype != null) { list.add(ctype); } @@ -124,8 +125,8 @@ public class CFileTypeDialog extends Dialog { list.toArray(ctypes); int index = -1; - for (int i = 0; i < ctypes.length; i++) { - fComboType.add(ctypes[i].getName()); + for (IContentType ctype : ctypes) { + fComboType.add(ctype.getName()); } fComboType.setData(ctypes); @@ -152,9 +153,9 @@ public class CFileTypeDialog extends Dialog { if (-1 != index) { String name = fComboType.getItem(index); IContentType[] types = (IContentType[]) fComboType.getData(); - for (int i = 0; i < types.length; i++) { - if (name.equals(types[i].getName())) { - type = types[i]; + for (IContentType type2 : types) { + if (name.equals(type2.getName())) { + type = type2; } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java index 9a30848ad4b..b5c6131e17d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java @@ -67,8 +67,8 @@ public class CFileTypesPreferenceBlock { private static final int COL_DESCRIPTION = 1; private static final int COL_STATUS = 2; - private ArrayList fAddAssoc; - private ArrayList fRemoveAssoc; + private ArrayList<CFileTypeAssociation> fAddAssoc; + private ArrayList<CFileTypeAssociation> fRemoveAssoc; private boolean fDirty = false; private IProject fInput; private IContentType[] fContentTypes; @@ -175,8 +175,8 @@ public class CFileTypesPreferenceBlock { } public CFileTypesPreferenceBlock(IProject input) { - fAddAssoc = new ArrayList(); - fRemoveAssoc = new ArrayList(); + fAddAssoc = new ArrayList<CFileTypeAssociation>(); + fRemoveAssoc = new ArrayList<CFileTypeAssociation>(); fInput = input; setDirty(false); } @@ -318,8 +318,8 @@ public class CFileTypesPreferenceBlock { boolean changed = fDirty; if (fDirty) { - CFileTypeAssociation[] add = (CFileTypeAssociation[]) fAddAssoc.toArray(new CFileTypeAssociation[fAddAssoc.size()]); - CFileTypeAssociation[] rem = (CFileTypeAssociation[]) fRemoveAssoc.toArray(new CFileTypeAssociation[fRemoveAssoc.size()]); + CFileTypeAssociation[] add = fAddAssoc.toArray(new CFileTypeAssociation[fAddAssoc.size()]); + CFileTypeAssociation[] rem = fRemoveAssoc.toArray(new CFileTypeAssociation[fRemoveAssoc.size()]); changed = add.length > 0 || rem.length > 0; adjustAssociations(add, rem); @@ -333,7 +333,7 @@ public class CFileTypesPreferenceBlock { } private CFileTypeAssociation[] getCFileTypeAssociations() { - ArrayList list = new ArrayList(); + ArrayList<CFileTypeAssociation> list = new ArrayList<CFileTypeAssociation>(); if (fInput == null) { fillWithUserDefinedCFileTypeAssociations(list); fillWithPredefinedCFileTypeAssociations(list); @@ -411,33 +411,32 @@ public class CFileTypesPreferenceBlock { return fContentTypes; } - private void fillWithUserDefinedCFileTypeAssociations(ArrayList list) { + private void fillWithUserDefinedCFileTypeAssociations(ArrayList<CFileTypeAssociation> list) { IContentType[] ctypes = getRegistedContentTypes(); fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_EXTENSION_SPEC, list); fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_NAME_SPEC, list); } - private void fillWithPredefinedCFileTypeAssociations(ArrayList list) { + private void fillWithPredefinedCFileTypeAssociations(ArrayList<CFileTypeAssociation> list) { IContentType[] ctypes = getRegistedContentTypes(); fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_USER_DEFINED | IContentType.FILE_EXTENSION_SPEC, list); fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_USER_DEFINED | IContentType.FILE_NAME_SPEC, list); } - private void fillWithProjectCFileTypeAssociations(ArrayList list, IProject project) { + private void fillWithProjectCFileTypeAssociations(ArrayList<CFileTypeAssociation> list, IProject project) { IContentType[] ctypes = getRegistedContentTypes(); IScopeContext context = new ProjectScope(project); fillWithCFileTypeAssociations(ctypes, context, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_EXTENSION_SPEC, list); fillWithCFileTypeAssociations(ctypes, context, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_NAME_SPEC, list); } - private void fillWithCFileTypeAssociations(IContentType[] ctypes, IScopeContext context, int type, ArrayList list) { - for (int i = 0; i < ctypes.length; i++) { + private void fillWithCFileTypeAssociations(IContentType[] ctypes, IScopeContext context, int type, ArrayList<CFileTypeAssociation> list) { + for (IContentType ctype : ctypes) { try { - IContentType ctype = ctypes[i]; IContentTypeSettings setting = ctype.getSettings(context); String[] specs = setting.getFileSpecs(type); - for (int j = 0; j < specs.length; j++) { - CFileTypeAssociation assoc = new CFileTypeAssociation(specs[j], type, ctype); + for (String spec : specs) { + CFileTypeAssociation assoc = new CFileTypeAssociation(spec, type, ctype); list.add(assoc); } } catch (CoreException e) { @@ -461,9 +460,9 @@ public class CFileTypesPreferenceBlock { fBtnRemove.setEnabled(false); } else { boolean enabled = true; - List elements = sel.toList(); - for (Iterator i = elements.iterator(); i.hasNext();) { - CFileTypeAssociation assoc = (CFileTypeAssociation) i.next(); + List<?> elements = sel.toList(); + for (Object element : elements) { + CFileTypeAssociation assoc = (CFileTypeAssociation) element; if (assoc.isPredefined()) enabled = false; } @@ -516,8 +515,7 @@ public class CFileTypesPreferenceBlock { } String newSpec= assoc.getSpec(); String[] specs= settings.getFileSpecs(assoc.getFileSpecType()); - for (int i = 0; i < specs.length; i++) { - String spec = specs[i]; + for (String spec : specs) { if (spec.equalsIgnoreCase(newSpec)) { reportDuplicateAssociation(assoc); return false; @@ -527,9 +525,8 @@ public class CFileTypesPreferenceBlock { return true; } - private boolean containsIgnoreCaseOfSpec(Collection collection, CFileTypeAssociation assoc) { - for (Iterator iter = collection.iterator(); iter.hasNext(); ) { - CFileTypeAssociation existing = (CFileTypeAssociation) iter.next(); + private boolean containsIgnoreCaseOfSpec(Collection<CFileTypeAssociation> collection, CFileTypeAssociation assoc) { + for (CFileTypeAssociation existing : collection) { if (assoc.equalsIgnoreCaseOfSpec(existing)) { return true; } @@ -547,7 +544,7 @@ public class CFileTypesPreferenceBlock { final protected void handleRemove() { IStructuredSelection sel = getSelection(); if ((null != sel) && (!sel.isEmpty())) { - for (Iterator iter = sel.iterator(); iter.hasNext();) { + for (Iterator<?> iter = sel.iterator(); iter.hasNext();) { CFileTypeAssociation assoc = (CFileTypeAssociation) iter.next(); handleRemove(assoc); fAssocViewer.remove(assoc); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java index a08407397f5..b0a048f3c6f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java @@ -22,6 +22,7 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.content.IContentType; import org.eclipse.core.runtime.content.IContentTypeManager; import org.eclipse.core.runtime.content.IContentTypeSettings; +import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEvent; import org.eclipse.core.runtime.preferences.IScopeContext; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -48,7 +49,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds; public class CFileTypesPropertyPage extends PropertyPage { class FixCFileTypesPreferenceBlock extends CFileTypesPreferenceBlock { - ArrayList list = new ArrayList(); + ArrayList<ContentTypeChangeEvent> list = new ArrayList<ContentTypeChangeEvent>(); public FixCFileTypesPreferenceBlock() { super(); @@ -229,9 +230,8 @@ public class CFileTypesPropertyPage extends PropertyPage { void computeEvents(IProject project) { IScopeContext projectScope = new ProjectScope(project); IContentType[] ctypes = getRegistedContentTypes(); - ArrayList list = new ArrayList(ctypes.length); - for (int i = 0; i < ctypes.length; i++) { - IContentType ctype = ctypes[i]; + ArrayList<IContentType> list = new ArrayList<IContentType>(ctypes.length); + for (IContentType ctype : ctypes) { try { IContentTypeSettings projectSettings = ctype.getSettings(projectScope); String[] projectSpecs = projectSettings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); @@ -252,7 +252,7 @@ public class CFileTypesPropertyPage extends PropertyPage { if (list.size() > 0) { IContentTypeManager.ContentTypeChangeEvent[] events = new IContentTypeManager.ContentTypeChangeEvent[list.size()]; for (int i = 0; i < list.size(); ++i) { - IContentType source = (IContentType)list.get(i); + IContentType source = list.get(i); events[i] = new IContentTypeManager.ContentTypeChangeEvent(source, projectScope); } CModelManager.getDefault().contentTypeChanged(events); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java index 4ab99c75b67..dd677b2c1f7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java @@ -13,11 +13,6 @@ package org.eclipse.cdt.internal.ui.preferences; import java.util.ArrayList; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.CDOM; -import org.eclipse.cdt.core.parser.CodeReaderCache; -import org.eclipse.cdt.core.parser.ICodeReaderCache; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.runtime.Preferences; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.preference.IPreferenceStore; @@ -33,6 +28,14 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.CDOM; +import org.eclipse.cdt.core.parser.CodeReaderCache; +import org.eclipse.cdt.core.parser.ICodeReaderCache; +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey; + /** * @author dsteffle * @deprecated the one preference found on the page was moved to the @@ -51,7 +54,7 @@ public class CParserPreferencePage extends PreferencePage implements } private OverlayPreferenceStore createOverlayStore() { - ArrayList overlayKeys = new ArrayList(); + ArrayList<OverlayKey> overlayKeys = new ArrayList<OverlayKey>(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CodeReaderCache.CODE_READER_BUFFER)); OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java index 90efbd6baf1..ba16999c206 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java @@ -24,9 +24,19 @@ import org.eclipse.core.commands.IParameter; import org.eclipse.core.commands.Parameterization; import org.eclipse.core.commands.ParameterizedCommand; import org.eclipse.core.commands.common.NotDefinedException; - import org.eclipse.core.runtime.Assert; - +import org.eclipse.jface.bindings.Binding; +import org.eclipse.jface.bindings.TriggerSequence; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -41,20 +51,6 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; - -import org.eclipse.jface.bindings.Binding; -import org.eclipse.jface.bindings.TriggerSequence; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.ViewerComparator; - import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.dialogs.PreferencesUtil; @@ -148,13 +144,9 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo } } - private final Comparator fCategoryComparator= new Comparator() { - private int getRank(Object o) { - return ((ModelElement) o).getRank(); - } - - public int compare(Object o1, Object o2) { - return getRank(o1) - getRank(o2); + private final Comparator<ModelElement> fCategoryComparator= new Comparator<ModelElement>() { + public int compare(ModelElement o1, ModelElement o2) { + return o1.getRank() - o2.getRank(); } }; @@ -163,17 +155,16 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private static final String COLON= ":"; //$NON-NLS-1$ private static final String SEPARATOR= "\0"; //$NON-NLS-1$ - private final List fElements; + private final List<ModelElement> fElements; /** * The read-only list of elements. */ - final List elements; + final List<ModelElement> elements; public PreferenceModel(CompletionProposalComputerRegistry registry) { - List categories= registry.getProposalCategories(); - fElements= new ArrayList(); - for (Iterator it= categories.iterator(); it.hasNext();) { - CompletionProposalCategory category= (CompletionProposalCategory) it.next(); + List<CompletionProposalCategory> categories= registry.getProposalCategories(); + fElements= new ArrayList<ModelElement>(); + for (CompletionProposalCategory category : categories) { if (category.hasComputers()) { fElements.add(new ModelElement(category, this)); } @@ -185,7 +176,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo public void moveUp(ModelElement category) { int index= fElements.indexOf(category); if (index > 0) { - Object item= fElements.remove(index); + ModelElement item= fElements.remove(index); fElements.add(index - 1, item); writeOrderPreference(null, false); } @@ -194,7 +185,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo public void moveDown(ModelElement category) { int index= fElements.indexOf(category); if (index < fElements.size() - 1) { - Object item= fElements.remove(index); + ModelElement item= fElements.remove(index); fElements.add(index + 1, item); writeOrderPreference(null, false); } @@ -202,8 +193,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private void writeInclusionPreference(ModelElement changed, boolean isInDefaultCategory) { StringBuffer buf= new StringBuffer(); - for (Iterator it= fElements.iterator(); it.hasNext();) { - ModelElement item= (ModelElement) it.next(); + for (Object element : fElements) { + ModelElement item= (ModelElement) element; boolean included= changed == item ? isInDefaultCategory : item.isInDefaultCategory(); if (!included) buf.append(item.getId() + SEPARATOR); @@ -217,8 +208,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private void writeOrderPreference(ModelElement changed, boolean isSeparate) { StringBuffer buf= new StringBuffer(); int i= 0; - for (Iterator it= fElements.iterator(); it.hasNext(); i++) { - ModelElement item= (ModelElement) it.next(); + for (Iterator<ModelElement> it= fElements.iterator(); it.hasNext(); i++) { + ModelElement item= it.next(); boolean separate= changed == item ? isSeparate : item.isSeparateCommand(); int rank= separate ? i : i + LIMIT; buf.append(item.getId() + COLON + rank + SEPARATOR); @@ -232,8 +223,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private boolean readInclusionPreference(CompletionProposalCategory cat) { String[] ids= getTokens(getValue(PREF_EXCLUDED_CATEGORIES), SEPARATOR); - for (int i= 0; i < ids.length; i++) { - if (ids[i].equals(cat.getId())) + for (String id : ids) { + if (id.equals(cat.getId())) return false; } return true; @@ -241,8 +232,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private int readOrderPreference(CompletionProposalCategory cat) { String[] sortOrderIds= getTokens(getValue(PREF_CATEGORY_ORDER), SEPARATOR); - for (int i= 0; i < sortOrderIds.length; i++) { - String[] idAndRank= getTokens(sortOrderIds[i], COLON); + for (String sortOrderId : sortOrderIds) { + String[] idAndRank= getTokens(sortOrderId, COLON); if (idAndRank[0].equals(cat.getId())) return Integer.parseInt(idAndRank[1]); } @@ -330,7 +321,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo /** element type: {@link ModelElement}. */ private final PreferenceModel fModel; - private final Map fImages= new HashMap(); + private final Map<ImageDescriptor, Image> fImages= new HashMap<ImageDescriptor, Image>(); private CheckboxTableViewer fDefaultViewer; private CheckboxTableViewer fSeparateViewer; @@ -550,7 +541,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo public void widgetSelected(SelectionEvent e) { int index= getSelectionIndex(); if (index != -1) { - ((ModelElement) fModel.elements.get(index)).moveUp(); + (fModel.elements.get(index)).moveUp(); fSeparateViewer.refresh(); handleTableSelection(); } @@ -566,7 +557,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo public void widgetSelected(SelectionEvent e) { int index= getSelectionIndex(); if (index != -1) { - ((ModelElement) fModel.elements.get(index)).moveDown(); + (fModel.elements.get(index)).moveDown(); fSeparateViewer.refresh(); handleTableSelection(); } @@ -612,11 +603,11 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private void updateCheckedState() { final int size= fModel.elements.size(); - List defaultChecked= new ArrayList(size); - List separateChecked= new ArrayList(size); + List<ModelElement> defaultChecked= new ArrayList<ModelElement>(size); + List<ModelElement> separateChecked= new ArrayList<ModelElement>(size); - for (Iterator it= fModel.elements.iterator(); it.hasNext();) { - ModelElement element= (ModelElement) it.next(); + for (Object element2 : fModel.elements) { + ModelElement element= (ModelElement) element2; if (element.isInDefaultCategory()) defaultChecked.add(element); if (element.isSeparateCommand()) @@ -632,8 +623,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo */ @Override protected boolean processChanges(IWorkbenchPreferenceContainer container) { - for (Iterator it= fModel.elements.iterator(); it.hasNext();) { - ModelElement item= (ModelElement) it.next(); + for (Object element : fModel.elements) { + ModelElement item= (ModelElement) element; item.update(); } @@ -660,8 +651,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo */ @Override public void dispose() { - for (Iterator it= fImages.values().iterator(); it.hasNext();) { - Image image= (Image) it.next(); + for (Image image : fImages.values()) { image.dispose(); } @@ -683,8 +673,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private static String getKeyboardShortcut(ParameterizedCommand command) { final IBindingService bindingSvc= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); final Binding[] bindings= bindingSvc.getBindings(); - for (int i= 0; i < bindings.length; i++) { - Binding binding= bindings[i]; + for (Binding binding : bindings) { if (command.equals(binding.getParameterizedCommand())) { TriggerSequence triggers= bindingSvc.getBestActiveBindingFor(command.getId()); return triggers.format(); @@ -697,7 +686,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo if (imgDesc == null) return null; - Image img= (Image) fImages.get(imgDesc); + Image img= fImages.get(imgDesc); if (img == null) { img= imgDesc.createImage(false); fImages.put(imgDesc, img); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java index a740a57a36f..034a186af9b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java @@ -25,6 +25,7 @@ import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PlatformUI; import org.eclipse.cdt.internal.ui.ICHelpContextIds; +import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey; import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference; /** @@ -42,7 +43,7 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage { @Override protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { - ArrayList overlayKeys = new ArrayList(); + ArrayList<OverlayKey> overlayKeys = new ArrayList<OverlayKey>(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT)); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java index f99e53e8ab6..f207c565d27 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java @@ -90,7 +90,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { } public void selectionChanged(TreeListDialogField field) { - List selected= field.getSelectedElements(); + List<Object> selected= field.getSelectedElements(); field.enableButton(IDX_ADD, canAdd(selected)); field.enableButton(IDX_EDIT, canEdit(selected)); field.enableButton(IDX_REMOVE, canRemove(selected)); @@ -100,7 +100,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { } public void doubleClicked(TreeListDialogField field) { - List selected= field.getSelectedElements(); + List<Object> selected= field.getSelectedElements(); if (canEdit(selected)) { doButtonPressed(IDX_EDIT, selected); } @@ -451,8 +451,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { protected TemplatePersistenceData[] getCodeTemplatesOfCategory(boolean isComment) { ArrayList<TemplatePersistenceData> res= new ArrayList<TemplatePersistenceData>(); TemplatePersistenceData[] templates= fTemplateStore.getTemplateData(); - for (int i= 0; i < templates.length; i++) { - TemplatePersistenceData curr= templates[i]; + for (TemplatePersistenceData curr : templates) { boolean isUserAdded= curr.getId() == null; boolean isFileTemplate= FileTemplateContextType.isFileTemplateContextType(curr.getTemplate().getContextTypeId()); if (!isUserAdded && !isFileTemplate && isComment == curr.getTemplate().getName().endsWith(CodeTemplateContextType.COMMENT_SUFFIX)) { @@ -469,8 +468,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { protected TemplatePersistenceData[] getTemplatesOfContextType(String contextTypeId) { ArrayList<TemplatePersistenceData> res= new ArrayList<TemplatePersistenceData>(); TemplatePersistenceData[] templates= fTemplateStore.getTemplateData(); - for (int i= 0; i < templates.length; i++) { - TemplatePersistenceData curr= templates[i]; + for (TemplatePersistenceData curr : templates) { if (contextTypeId.equals(curr.getTemplate().getContextTypeId())) { res.add(curr); } @@ -481,7 +479,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { protected ContextTypeRegistry getFileTemplateContextRegistry() { if (fFileTemplateContextTypes == null) { fFileTemplateContextTypes= new ContextTypeRegistry(); - Iterator contextTypesIter= CUIPlugin.getDefault().getCodeTemplateContextRegistry().contextTypes(); + Iterator<?> contextTypesIter= CUIPlugin.getDefault().getCodeTemplateContextRegistry().contextTypes(); while(contextTypesIter.hasNext()) { TemplateContextType contextType= (TemplateContextType)contextTypesIter.next(); final String contextTypeId= contextType.getId(); @@ -495,7 +493,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { } protected TemplateContextType[] getFileTemplateContextTypes() { - Iterator iter= getFileTemplateContextRegistry().contextTypes(); + Iterator<?> iter= getFileTemplateContextRegistry().contextTypes(); ArrayList<TemplateContextType> result= new ArrayList<TemplateContextType>(); while (iter.hasNext()) { TemplateContextType contextType= (TemplateContextType)iter.next(); @@ -506,7 +504,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { return result.toArray(new TemplateContextType[0]); } - protected static boolean canAdd(List selected) { + protected static boolean canAdd(List<Object> selected) { if (selected.size() == 1) { Object element= selected.get(0); if (element instanceof TemplateContextType || element == FILE_NODE) { @@ -522,11 +520,11 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { return false; } - protected static boolean canEdit(List selected) { + protected static boolean canEdit(List<Object> selected) { return selected.size() == 1 && (selected.get(0) instanceof TemplatePersistenceData); } - protected static boolean canRemove(List selected) { + protected static boolean canRemove(List<Object> selected) { if (selected.size() == 1 && (selected.get(0) instanceof TemplatePersistenceData)) { TemplatePersistenceData data= (TemplatePersistenceData)selected.get(0); return data.isUserAdded(); @@ -534,7 +532,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { return false; } - protected void updateSourceViewerInput(List selection) { + protected void updateSourceViewerInput(List<Object> selection) { if (fPatternViewer == null || fPatternViewer.getTextWidget().isDisposed()) { return; } @@ -550,7 +548,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { } } - protected void doButtonPressed(int buttonIndex, List selected) { + protected void doButtonPressed(int buttonIndex, List<Object> selected) { switch (buttonIndex) { case IDX_EDIT: edit((TemplatePersistenceData) selected.get(0), false); @@ -643,8 +641,8 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { InputStream input= new BufferedInputStream(new FileInputStream(file)); try { TemplatePersistenceData[] datas= reader.read(input, null); - for (int i= 0; i < datas.length; i++) { - updateTemplate(datas[i]); + for (TemplatePersistenceData data : datas) { + updateTemplate(data); } } finally { try { @@ -670,22 +668,22 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { TemplatePersistenceData[] datas= fTemplateStore.getTemplateData(); if (dataId != null) { // predefined - for (int i= 0; i < datas.length; i++) { - String id= datas[i].getId(); + for (TemplatePersistenceData data2 : datas) { + String id= data2.getId(); if (id != null && id.equals(dataId)) { - datas[i].setTemplate(data.getTemplate()); + data2.setTemplate(data.getTemplate()); return; } } } else { // user added String dataName= data.getTemplate().getName(); - for (int i= 0; i < datas.length; i++) { - if (datas[i].getId() == null) { - String name= datas[i].getTemplate().getName(); - String contextTypeId= datas[i].getTemplate().getContextTypeId(); + for (TemplatePersistenceData data2 : datas) { + if (data2.getId() == null) { + String name= data2.getTemplate().getName(); + String contextTypeId= data2.getTemplate().getContextTypeId(); if (name != null && name.equals(dataName) && contextTypeId.equals(data.getTemplate().getContextTypeId())) { - datas[i].setTemplate(data.getTemplate()); + data2.setTemplate(data.getTemplate()); return; } } @@ -699,7 +697,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { export(fTemplateStore.getTemplateData()); } - private void export(List selected) { + private void export(List<Object> selected) { Set<Object> datas= new HashSet<Object>(); for (int i= 0; i < selected.size(); i++) { Object curr= selected.get(i); @@ -710,8 +708,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { datas.addAll(Arrays.asList(cat)); } else if (curr == FILE_NODE) { TemplateContextType[] types= getFileTemplateContextTypes(); - for (int j = 0; j < types.length; j++) { - TemplateContextType contextType = types[j]; + for (TemplateContextType contextType : types) { TemplatePersistenceData[] cat= getTemplatesOfContextType(contextType); datas.addAll(Arrays.asList(cat)); } @@ -793,8 +790,8 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { if (fProject != null) { TemplatePersistenceData[] templateData= fTemplateStore.getTemplateData(); - for (int i= 0; i < templateData.length; i++) { - fTemplateStore.setProjectSpecific(templateData[i].getId(), enabled); + for (TemplatePersistenceData element : templateData) { + fTemplateStore.setProjectSpecific(element.getId(), enabled); } } try { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java index ef246f46ab2..7bd72552340 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java @@ -160,12 +160,10 @@ public class CodeTemplatePreferencePage extends PropertyAndPreferencePage { @Override public void applyData(Object data) { if (data instanceof Map) { - Object id= ((Map) data).get(DATA_SELECT_TEMPLATE); + Object id= ((Map<?, ?>) data).get(DATA_SELECT_TEMPLATE); if (id instanceof String) { final TemplatePersistenceData[] templates= fCodeTemplateConfigurationBlock.fTemplateStore.getTemplateData(); - TemplatePersistenceData template= null; - for (int index= 0; index < templates.length; index++) { - template= templates[index]; + for (TemplatePersistenceData template : templates) { if (id.equals(template.getId()) || id.equals(template.getTemplate().getName())) { fCodeTemplateConfigurationBlock.postSetSelection(template); break; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java index 7a561006725..13c96338284 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java @@ -69,7 +69,7 @@ public class CodeTemplateSourceViewerConfiguration extends SimpleCSourceViewerCo String varName= doc.get(offset, subject.getLength()); TemplateContextType contextType= fProcessor.getContextType(); if (contextType != null) { - Iterator iter= contextType.resolvers(); + Iterator<?> iter= contextType.resolvers(); while (iter.hasNext()) { TemplateVariableResolver var= (TemplateVariableResolver) iter.next(); if (varName.equals(var.getType())) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java index 7ba80b7ba21..e457989f0af 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java @@ -191,7 +191,7 @@ class EditTemplateDialog extends StatusDialog { // String delim= new Document().getLegalLineDelimiters()[0]; List<String[]> contexts= new ArrayList<String[]>(); - for (Iterator it= registry.contextTypes(); it.hasNext();) { + for (Iterator<?> it= registry.contextTypes(); it.hasNext();) { TemplateContextType type= (TemplateContextType) it.next(); // TODO cppdoc? doxygen? // if (type.getId().equals("javadoc")) //$NON-NLS-1$ @@ -277,8 +277,8 @@ class EditTemplateDialog extends StatusDialog { createLabel(composite, PreferencesMessages.EditTemplateDialog_contextType); fContextCombo= new Combo(composite, SWT.READ_ONLY); fContextCombo.setVisibleItemCount(10); - for (int i= 0; i < fContextTypes.length; i++) { - fContextCombo.add(fContextTypes[i][1]); + for (String[] contextType : fContextTypes) { + fContextCombo.add(contextType[1]); } fContextCombo.addModifyListener(listener); @@ -359,9 +359,9 @@ class EditTemplateDialog extends StatusDialog { private String getContextId() { if (fContextCombo != null && !fContextCombo.isDisposed()) { String name= fContextCombo.getText(); - for (int i= 0; i < fContextTypes.length; i++) { - if (name.equals(fContextTypes[i][1])) { - return fContextTypes[i][0]; + for (String[] contextType : fContextTypes) { + if (name.equals(contextType[1])) { + return contextType[0]; } } } @@ -475,8 +475,7 @@ class EditTemplateDialog extends StatusDialog { int idx= getIndex(id); if (idx != -1) return fContextTypes[idx][2]; - else - return ""; //$NON-NLS-1$ + return ""; //$NON-NLS-1$ } private void initializeActions() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java index 3190450d528..cb715185fb4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java @@ -46,6 +46,7 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock; +import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey; import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderDescriptor; import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderRegistry; import org.eclipse.cdt.internal.ui.util.PixelConverter; @@ -98,10 +99,10 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { private Combo fProviderCombo; protected Button fFoldingCheckbox; private ComboViewer fProviderViewer; - protected Map fProviderDescriptors; + protected Map<String, CFoldingStructureProviderDescriptor> fProviderDescriptors; private Composite fGroup; - private Map fProviderPreferences; - private Map fProviderControls; + private Map<String, ICFoldingPreferenceBlock> fProviderPreferences; + private Map<String, Control> fProviderControls; private StackLayout fStackLayout; @@ -110,15 +111,15 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { fStore= store; fStore.addKeys(createOverlayStoreKeys()); fProviderDescriptors= createListModel(); - fProviderPreferences= new HashMap(); - fProviderControls= new HashMap(); + fProviderPreferences= new HashMap<String, ICFoldingPreferenceBlock>(); + fProviderControls= new HashMap<String, Control>(); } - private Map createListModel() { + private Map<String, CFoldingStructureProviderDescriptor> createListModel() { CFoldingStructureProviderRegistry reg= CUIPlugin.getDefault().getFoldingStructureProviderRegistry(); reg.reloadExtensions(); CFoldingStructureProviderDescriptor[] descs= reg.getFoldingProviderDescriptors(); - Map map= new HashMap(); + Map<String, CFoldingStructureProviderDescriptor> map= new HashMap<String, CFoldingStructureProviderDescriptor>(); for (int i= 0; i < descs.length; i++) { map.put(descs[i].getId(), descs[i]); } @@ -127,7 +128,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { - ArrayList overlayKeys= new ArrayList(); + ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_ENABLED)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FOLDING_PROVIDER)); @@ -269,7 +270,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { void updateListDependencies() { String id= fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER); - CFoldingStructureProviderDescriptor desc= (CFoldingStructureProviderDescriptor) fProviderDescriptors.get(id); + CFoldingStructureProviderDescriptor desc= fProviderDescriptors.get(id); ICFoldingPreferenceBlock prefs; if (desc == null) { @@ -278,7 +279,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { CUIPlugin.log(new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null)); prefs= new ErrorPreferences(message); } else { - prefs= (ICFoldingPreferenceBlock) fProviderPreferences.get(id); + prefs= fProviderPreferences.get(id); if (prefs == null) { try { prefs= desc.createPreferences(); @@ -290,7 +291,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { } } - Control control= (Control) fProviderControls.get(id); + Control control= fProviderControls.get(id); if (control == null) { control= prefs.createControl(fGroup); if (control == null) { @@ -319,8 +320,8 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performOk() */ public void performOk() { - for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) { - ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next(); + for (Iterator<ICFoldingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) { + ICFoldingPreferenceBlock prefs= it.next(); prefs.performOk(); } } @@ -330,8 +331,8 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { */ public void performDefaults() { restoreFromPreferences(); - for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) { - ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next(); + for (Iterator<ICFoldingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) { + ICFoldingPreferenceBlock prefs= it.next(); prefs.performDefaults(); } } @@ -340,8 +341,8 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose() */ public void dispose() { - for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) { - ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next(); + for (Iterator<ICFoldingPreferenceBlock> it= fProviderPreferences.values().iterator(); it.hasNext();) { + ICFoldingPreferenceBlock prefs= it.next(); prefs.dispose(); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java index f43ba797a1e..5e2e8a39c2c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java @@ -35,6 +35,7 @@ import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; +import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey; import org.eclipse.cdt.internal.ui.util.PixelConverter; /** @@ -47,13 +48,13 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock private OverlayPreferenceStore fStore; - private Map fCheckBoxes= new HashMap(); + private Map<Object, String> fCheckBoxes= new HashMap<Object, String>(); private SelectionListener fCheckBoxListener= new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { Button button= (Button) e.widget; - fStore.setValue((String) fCheckBoxes.get(button), button.getSelection()); + fStore.setValue(fCheckBoxes.get(button), button.getSelection()); } }; @@ -62,7 +63,7 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock * * @see #createDependency(Button, String, Control) */ - private ArrayList fMasterSlaveListeners= new ArrayList(); + private ArrayList<Object> fMasterSlaveListeners= new ArrayList<Object>(); private StatusInfo fStatus; @@ -75,7 +76,7 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { - ArrayList overlayKeys= new ArrayList(); + ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OCCURRENCES)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STICKY_OCCURRENCES)); @@ -180,10 +181,10 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock void initializeFields() { - Iterator iter= fCheckBoxes.keySet().iterator(); + Iterator<Object> iter= fCheckBoxes.keySet().iterator(); while (iter.hasNext()) { Button b= (Button) iter.next(); - String key= (String) fCheckBoxes.get(b); + String key= fCheckBoxes.get(b); b.setSelection(fStore.getBoolean(key)); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java index 6ee84085f43..c32ebb55e29 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java @@ -93,7 +93,7 @@ public class PathEntryVariableDialog extends TitleAreaDialog { * Set of variable names currently in use. Used when warning the user that * the currently selected name is already in use by another variable. */ - private Set namesInUse; + private Set<String> namesInUse; /** * The current validation status. Its value can be one of the following:<ul> @@ -149,7 +149,7 @@ public class PathEntryVariableDialog extends TitleAreaDialog { * this dialog. <code>IResource.FILE</code> or <code>IResource.FOLDER</code> * @param namesInUse a set of variable names currently in use */ - public PathEntryVariableDialog(Shell parentShell, int type, int variableType, Set namesInUse) { + public PathEntryVariableDialog(Shell parentShell, int type, int variableType, Set<String> namesInUse) { super(parentShell); this.type = type; this.newVariable = type == NEW_VARIABLE; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java index d95c0d6a9c9..4ce226abcde 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java @@ -14,15 +14,12 @@ package org.eclipse.cdt.internal.ui.preferences; import java.io.File; import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; +import java.util.Map.Entry; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.resources.IPathEntryVariableManager; -import org.eclipse.cdt.internal.ui.CPluginImages; +import org.eclipse.core.resources.IPathVariableManager; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -53,6 +50,11 @@ import org.eclipse.swt.widgets.TableItem; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.resources.IPathEntryVariableManager; + +import org.eclipse.cdt.internal.ui.CPluginImages; + public class PathEntryVariablesGroup { /** @@ -93,10 +95,10 @@ public class PathEntryVariablesGroup { protected Listener selectionListener; // temporary collection for keeping currently defined variables - private SortedMap tempPathVariables; + private SortedMap<String, IPath> tempPathVariables; // set of removed variables' names - private Set removedVariableNames; + private Set<String> removedVariableNames; // reference to the workspace's path variable manager private IPathEntryVariableManager pathEntryVariableManager; @@ -124,8 +126,8 @@ public class PathEntryVariablesGroup { this.multiSelect = multiSelect; this.variableType = variableType; pathEntryVariableManager = CCorePlugin.getDefault().getPathEntryVariableManager(); - removedVariableNames = new HashSet(); - tempPathVariables = new TreeMap(); + removedVariableNames = new HashSet<String>(); + tempPathVariables = new TreeMap<String, IPath>(); // initialize internal model initTemporaryState(); } @@ -252,7 +254,7 @@ public class PathEntryVariablesGroup { TableItem item = variableTable.getItem(variableTable .getSelectionIndex()); String variableName = (String) item.getData(); - IPath variableValue = (IPath) tempPathVariables.get(variableName); + IPath variableValue = tempPathVariables.get(variableName); // constructs a dialog for editing the variable's current name and value PathEntryVariableDialog dialog = new PathEntryVariableDialog(shell, @@ -312,7 +314,7 @@ public class PathEntryVariablesGroup { String name = (String) items[i].getData(); selection[i] = new PathEntryVariableElement(); selection[i].name = name; - selection[i].path = (IPath)tempPathVariables.get(name); + selection[i].path = tempPathVariables.get(name); } return selection; } @@ -394,8 +396,8 @@ public class PathEntryVariablesGroup { String[] varNames = pathEntryVariableManager.getVariableNames(); tempPathVariables.clear(); - for (int i = 0; i < varNames.length; i++) { - IPath value = pathEntryVariableManager.getValue(varNames[i]); + for (String varName : varNames) { + IPath value = pathEntryVariableManager.getValue(varName); // the value may not exist any more if (value != null) { @@ -403,7 +405,7 @@ public class PathEntryVariablesGroup { if ((isFile && (variableType & IResource.FILE) != 0) || (isFile == false && (variableType & IResource.FOLDER) != 0)) { - tempPathVariables.put(varNames[i], value); + tempPathVariables.put(varName, value); } } } @@ -434,10 +436,9 @@ public class PathEntryVariablesGroup { private void updateVariableTable(String selectedVarName) { variableTable.removeAll(); int selectedVarIndex = 0; - for (Iterator varNames = tempPathVariables.keySet().iterator(); varNames.hasNext();) { + for (String varName : tempPathVariables.keySet()) { TableItem item = new TableItem(variableTable, SWT.NONE); - String varName = (String) varNames.next(); - IPath value = (IPath) tempPathVariables.get(varName); + IPath value = tempPathVariables.get(varName); File file = value.toFile(); item.setText(varName + " - " + value.toOSString()); //$NON-NLS-1$ @@ -466,18 +467,16 @@ public class PathEntryVariablesGroup { public boolean performOk() { try { // first process removed variables - for (Iterator removed = removedVariableNames.iterator(); removed.hasNext();) { - String removedVariableName = (String) removed.next(); + for (String removedVariableName : removedVariableNames) { // only removes variables that have not been added again if (!tempPathVariables.containsKey(removedVariableName)) pathEntryVariableManager.setValue(removedVariableName, null); } // then process the current collection of variables, adding/updating them - for (Iterator current = tempPathVariables.entrySet().iterator(); current.hasNext();) { - Map.Entry entry = (Map.Entry) current.next(); - String variableName = (String) entry.getKey(); - IPath variableValue = (IPath) entry.getValue(); + for (Entry<String, IPath> entry : tempPathVariables.entrySet()) { + String variableName = entry.getKey(); + IPath variableValue = entry.getValue(); pathEntryVariableManager.setValue(variableName, variableValue); } // re-initialize temporary state @@ -497,8 +496,8 @@ public class PathEntryVariablesGroup { protected void removeSelectedVariables() { // remove each selected element int[] selectedIndices = variableTable.getSelectionIndices(); - for (int i = 0; i < selectedIndices.length; i++) { - TableItem selectedItem = variableTable.getItem(selectedIndices[i]); + for (int selectedIndice : selectedIndices) { + TableItem selectedItem = variableTable.getItem(selectedIndice); String varName = (String) selectedItem.getData(); removedVariableNames.add(varName); tempPathVariables.remove(varName); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java index 4ef3098d6ed..44e1b87c744 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java @@ -37,6 +37,7 @@ import org.eclipse.ui.dialogs.SelectionStatusDialog; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICModel; +import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.ui.CElementContentProvider; import org.eclipse.cdt.ui.CElementLabelProvider; import org.eclipse.cdt.ui.CElementSorter; @@ -48,7 +49,7 @@ public class ProjectSelectionDialog extends SelectionStatusDialog { // the visual selection widget group private TableViewer fTableViewer; - private Set fProjectsWithSpecifics; + private Set<ICProject> fProjectsWithSpecifics; // sizing constants private final static int SIZING_SELECTION_WIDGET_HEIGHT= 250; @@ -58,7 +59,7 @@ public class ProjectSelectionDialog extends SelectionStatusDialog { private ViewerFilter fFilter; - public ProjectSelectionDialog(Shell parentShell, Set projectsWithSpecifics) { + public ProjectSelectionDialog(Shell parentShell, Set<ICProject> projectsWithSpecifics) { super(parentShell); setTitle(PreferencesMessages.ProjectSelectionDialog_title); setMessage(PreferencesMessages.ProjectSelectionDialog_desciption); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java index 76a69c0f588..d68bffe8820 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java @@ -63,7 +63,7 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement private Composite fParentComposite; private IProject fProject; // project or null - private Map fData; // page data + private Map <?,?> fData; // page data public static final String DATA_NO_LINK= "PropertyAndPreferencePage.nolink"; //$NON-NLS-1$ @@ -191,17 +191,16 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement * @param link the link */ final void doLinkActivated(Link link) { - Map data= new HashMap(); + Map<String, Boolean> data= new HashMap<String, Boolean>(); data.put(DATA_NO_LINK, Boolean.TRUE); if (isProjectPreferencePage()) { openWorkspacePreferences(data); } else { - HashSet projectsWithSpecifics= new HashSet(); + HashSet<ICProject> projectsWithSpecifics= new HashSet<ICProject>(); try { ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects(); - for (int i= 0; i < projects.length; i++) { - ICProject curr= projects[i]; + for (ICProject curr : projects) { if (hasProjectSpecificOptions(curr.getProject())) { projectsWithSpecifics.add(curr); } @@ -334,7 +333,7 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement @Override public void applyData(Object data) { if (data instanceof Map) { - fData= (Map) data; + fData= (Map<?,?>) data; } if (fChangeWorkspaceSettings != null) { if (!offerLink()) { @@ -344,8 +343,7 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement } } - protected Map getData() { + protected Map<?,?> getData() { return fData; } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java index 5aa70e74f78..ee772736c17 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java @@ -12,8 +12,6 @@ package org.eclipse.cdt.internal.ui.preferences; import java.util.ArrayList; -import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; @@ -22,6 +20,10 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.widgets.Combo; +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference; + /** * A class which encapsulates several utility functions * related to code completion preference settings. @@ -40,16 +42,14 @@ public class ProposalFilterPreferencesUtil { * to fill into the Combo) */ public static String[] getProposalFilterNames() { - ArrayList names = new ArrayList(); + ArrayList<String> names = new ArrayList<String>(); try { IExtensionPoint point = Platform.getExtensionRegistry() .getExtensionPoint(CUIPlugin.PLUGIN_ID, "ProposalFilter"); //$NON-NLS-1$ if (point != null) { IExtension[] extensions = point.getExtensions(); - for (int i = 0; i < extensions.length; i++) { - IExtension extension = extensions[i]; - IConfigurationElement[] elements = extension - .getConfigurationElements(); + for (IExtension extension : extensions) { + IConfigurationElement[] elements = extension.getConfigurationElements(); for (int j = 0; j < elements.length; ++j) { IConfigurationElement element = elements[j]; if ("ProposalFilter".equals(element.getName())) { //$NON-NLS-1$ @@ -65,8 +65,7 @@ public class ProposalFilterPreferencesUtil { // No action required since we will at least be using the fail-safe default filter CUIPlugin.log(e); } - String[] filterNames = (String[]) names - .toArray(new String[names.size()]); + String[] filterNames = names.toArray(new String[names.size()]); return filterNames; } @@ -82,8 +81,7 @@ public class ProposalFilterPreferencesUtil { StringBuffer filterNames = new StringBuffer("0;"); //$NON-NLS-1$ filterNames.append(PreferencesMessages.ProposalFilterPreferencesUtil_defaultFilterName); String[] names = getProposalFilterNames(); - for (int i = 0; i < names.length; i++) { - String name = names[i]; + for (String name : names) { filterNames.append(";"); //$NON-NLS-1$ filterNames.append(name); } @@ -104,9 +102,7 @@ public class ProposalFilterPreferencesUtil { try { IExtension[] extensions = point.getExtensions(); if (extensions.length >= 1) { - for (int i = 0; i < extensions.length; i++) { - IExtension extension = extensions[i]; - + for (IExtension extension : extensions) { IConfigurationElement[] elements = extension .getConfigurationElements(); @@ -153,9 +149,9 @@ public class ProposalFilterPreferencesUtil { int selectionIndex = combo.getSelectionIndex(); text.append(selectionIndex); String[] entries = combo.getItems(); - for (int i = 0; i < entries.length; i++) { + for (String entrie : entries) { text.append(";"); //$NON-NLS-1$ - String entry = entries[i].replaceAll(";", ","); //$NON-NLS-1$ //$NON-NLS-2$ + String entry = entrie.replaceAll(";", ","); //$NON-NLS-1$ //$NON-NLS-2$ text.append(entry); } return text.toString(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java index 24d78eee37c..68177de3a8d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java @@ -13,20 +13,21 @@ package org.eclipse.cdt.internal.ui.preferences; import java.io.File; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Set; -import org.eclipse.core.variables.IStringVariableManager; -import org.eclipse.core.variables.VariablesPlugin; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; - import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; - +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.variables.IStringVariableManager; +import org.eclipse.core.variables.VariablesPlugin; +import org.eclipse.jface.dialogs.DialogPage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceStore; +import org.eclipse.jface.window.Window; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -42,16 +43,9 @@ import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; - -import org.eclipse.jface.dialogs.DialogPage; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceStore; -import org.eclipse.jface.window.Window; - import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; - import org.eclipse.ui.ide.dialogs.EncodingFieldEditor; +import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; import org.eclipse.cdt.ui.PreferenceConstants; @@ -123,13 +117,11 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock { * The list of locales * @return Array of locale codes for the list */ - protected static String[] getDictionaryCodes(final Set locales) { + protected static String[] getDictionaryCodes(final Set<Locale> locales) { int index= 0; - Locale locale= null; final String[] codes= new String[locales.size() + 1]; - for (final Iterator iterator= locales.iterator(); iterator.hasNext();) { - locale= (Locale)iterator.next(); + for (Locale locale : locales) { codes[index++]= locale.toString(); } codes[index++]= PREF_VALUE_NO_LOCALE; @@ -142,14 +134,11 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock { * @param locales The list of locales * @return Array of display labels for the list */ - protected static String[] getDictionaryLabels(final Set locales) { + protected static String[] getDictionaryLabels(final Set<Locale> locales) { int index= 0; - Locale locale= null; final String[] labels= new String[locales.size() + 1]; - for (final Iterator iterator= locales.iterator(); iterator.hasNext();) { - - locale= (Locale)iterator.next(); + for (Locale locale : locales) { labels[index++]= locale.getDisplayName(); } labels[index++]= PreferencesMessages.SpellingPreferencePage_dictionary_none; @@ -214,10 +203,10 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock { try { final int value= Integer.parseInt(number); if (value < 0) { - status.setError(PreferencesMessages.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number)); + status.setError(NLS.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number)); } } catch (NumberFormatException exception) { - status.setError(PreferencesMessages.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number)); + status.setError(NLS.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number)); } } return status; @@ -354,7 +343,7 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock { slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_STRING_LITERALS, trueFalse, 0); allControls.add(slave); - final Set locales= SpellCheckEngine.getLocalesWithInstalledDictionaries(); + final Set<Locale> locales= SpellCheckEngine.getLocalesWithInstalledDictionaries(); boolean hasPlaformDictionaries= locales.size() > 0; final Group engine= new Group(composite, SWT.NONE); @@ -518,8 +507,7 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock { private static Key[] getAllKeys() { if (SUPPORT_CONTENT_ASSIST_PROPOSALS) return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_ENABLE_CONTENTASSIST, PREF_SPELLING_IGNORE_STRING_LITERALS }; - else - return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_IGNORE_STRING_LITERALS }; + return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_IGNORE_STRING_LITERALS }; } /* diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java index e1d1443301a..613d5258965 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java @@ -15,18 +15,8 @@ package org.eclipse.cdt.internal.ui.preferences; import java.util.ArrayList; import java.util.List; -import org.eclipse.core.runtime.IStatus; - import org.eclipse.core.resources.IProject; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -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.core.runtime.IStatus; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.viewers.IFontProvider; import org.eclipse.jface.viewers.ITableLabelProvider; @@ -34,7 +24,13 @@ import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.jface.window.Window; - +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; +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.ui.preferences.IWorkbenchPreferenceContainer; import org.eclipse.cdt.core.CCorePreferenceConstants; @@ -106,16 +102,15 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { name = Messages.format(PreferencesMessages.TodoTaskConfigurationBlock_tasks_default, name); } return name; - } else { - if (TASK_PRIORITY_HIGH.equals(task.priority)) { - return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority; - } else if (TASK_PRIORITY_NORMAL.equals(task.priority)) { - return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority; - } else if (TASK_PRIORITY_LOW.equals(task.priority)) { - return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority; - } - return ""; //$NON-NLS-1$ - } + } + if (TASK_PRIORITY_HIGH.equals(task.priority)) { + return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority; + } else if (TASK_PRIORITY_NORMAL.equals(task.priority)) { + return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority; + } else if (TASK_PRIORITY_LOW.equals(task.priority)) { + return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority; + } + return ""; //$NON-NLS-1$ } /* (non-Javadoc) @@ -130,6 +125,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { } private static class TodoTaskSorter extends ViewerComparator { + @SuppressWarnings("unchecked") @Override public int compare(Viewer viewer, Object e1, Object e2) { return getComparator().compare(((TodoTask) e1).name, ((TodoTask) e2).name); @@ -142,7 +138,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { private static final int IDX_DEFAULT = 4; private IStatus fTaskTagsStatus; - private ListDialogField fTodoTasksList; + private ListDialogField<TodoTask> fTodoTasksList; private SelectionButtonDialogField fCaseSensitiveCheckBox; @@ -157,7 +153,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { null, PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_setdefault_button, }; - fTodoTasksList = new ListDialogField(adapter, buttons, new TodoTaskLabelProvider()); + fTodoTasksList = new ListDialogField<TodoTask>(adapter, buttons, new TodoTaskLabelProvider()); fTodoTasksList.setDialogFieldListener(adapter); fTodoTasksList.setRemoveButtonIndex(IDX_REMOVE); @@ -194,7 +190,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { } private void setToDefaultTask(TodoTask task) { - List elements = fTodoTasksList.getElements(); + List<TodoTask> elements = fTodoTasksList.getElements(); elements.remove(task); elements.add(0, task); fTodoTasksList.setElements(elements); @@ -207,26 +203,26 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { }; } - public class TaskTagAdapter implements IListAdapter, IDialogFieldListener { - private boolean canEdit(List selectedElements) { + public class TaskTagAdapter implements IListAdapter<TodoTask>, IDialogFieldListener { + private boolean canEdit(List<TodoTask> selectedElements) { return selectedElements.size() == 1; } - private boolean canSetToDefault(List selectedElements) { - return selectedElements.size() == 1 && !isDefaultTask((TodoTask) selectedElements.get(0)); + private boolean canSetToDefault(List<TodoTask> selectedElements) { + return selectedElements.size() == 1 && !isDefaultTask(selectedElements.get(0)); } - public void customButtonPressed(ListDialogField field, int index) { + public void customButtonPressed(ListDialogField<TodoTask> field, int index) { doTodoButtonPressed(index); } - public void selectionChanged(ListDialogField field) { - List selectedElements = field.getSelectedElements(); + public void selectionChanged(ListDialogField<TodoTask> field) { + List<TodoTask> selectedElements = field.getSelectedElements(); field.enableButton(IDX_EDIT, canEdit(selectedElements)); field.enableButton(IDX_DEFAULT, canSetToDefault(selectedElements)); } - public void doubleClicked(ListDialogField field) { + public void doubleClicked(ListDialogField<TodoTask> field) { if (canEdit(field.getSelectedElements())) { doTodoButtonPressed(IDX_EDIT); } @@ -300,13 +296,13 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { if (field == fTodoTasksList) { StringBuffer tags = new StringBuffer(); StringBuffer prios = new StringBuffer(); - List list = fTodoTasksList.getElements(); + List<TodoTask> list = fTodoTasksList.getElements(); for (int i = 0; i < list.size(); i++) { if (i > 0) { tags.append(','); prios.append(','); } - TodoTask elem = (TodoTask) list.get(i); + TodoTask elem = list.get(i); tags.append(elem.name); prios.append(elem.priority); } @@ -332,7 +328,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { String currPrios = getValue(PREF_TODO_TASK_PRIORITIES); String[] tags = getTokens(currTags, ","); //$NON-NLS-1$ String[] prios = getTokens(currPrios, ","); //$NON-NLS-1$ - ArrayList elements = new ArrayList(tags.length); + ArrayList<TodoTask> elements = new ArrayList<TodoTask>(tags.length); for (int i = 0; i < tags.length; i++) { TodoTask task = new TodoTask(); task.name = tags[i].trim(); @@ -348,7 +344,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { private void doTodoButtonPressed(int index) { TodoTask edited = null; if (index != IDX_ADD) { - edited = (TodoTask) fTodoTasksList.getSelectedElements().get(0); + edited = fTodoTasksList.getSelectedElements().get(0); } if (index == IDX_ADD || index == IDX_EDIT) { TodoTaskInputDialog dialog = new TodoTaskInputDialog(getShell(), edited, fTodoTasksList.getElements()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java index d43c303b158..02167a708e0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java @@ -15,14 +15,12 @@ package org.eclipse.cdt.internal.ui.preferences; import java.util.ArrayList; import java.util.List; +import org.eclipse.jface.dialogs.StatusDialog; 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.swt.widgets.Shell; - -import org.eclipse.jface.dialogs.StatusDialog; - import org.eclipse.ui.PlatformUI; import org.eclipse.cdt.core.CCorePreferenceConstants; @@ -50,14 +48,14 @@ public class TodoTaskInputDialog extends StatusDialog { private StringDialogField fNameDialogField; private ComboDialogField fPriorityDialogField; - private List fExistingNames; + private List<String> fExistingNames; - public TodoTaskInputDialog(Shell parent, TodoTask task, List existingEntries) { + public TodoTaskInputDialog(Shell parent, TodoTask task, List<TodoTask> existingEntries) { super(parent); - fExistingNames = new ArrayList(existingEntries.size()); + fExistingNames = new ArrayList<String>(existingEntries.size()); for (int i = 0; i < existingEntries.size(); i++) { - TodoTask curr = (TodoTask) existingEntries.get(i); + TodoTask curr = existingEntries.get(i); if (!curr.equals(task)) { fExistingNames.add(curr.name); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java index 07f58208203..830add87a8a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java @@ -36,18 +36,18 @@ import org.eclipse.cdt.ui.CUIPlugin; */ public class WorkInProgressPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - private List fCheckBoxes; - private List fRadioButtons; - private List fTextControls; + private List<Button> fCheckBoxes; + private List<Button> fRadioButtons; + private List<Text> fTextControls; /** * creates a new preference page. */ public WorkInProgressPreferencePage() { setPreferenceStore(getPreferenceStore()); - fRadioButtons= new ArrayList(); - fCheckBoxes= new ArrayList(); - fTextControls= new ArrayList(); + fRadioButtons= new ArrayList<Button>(); + fCheckBoxes= new ArrayList<Button>(); + fTextControls= new ArrayList<Text>(); } Button addCheckBox(Composite parent, String label, String key) { @@ -120,17 +120,17 @@ public class WorkInProgressPreferencePage extends PreferencePage implements IWor protected void performDefaults() { IPreferenceStore store= getPreferenceStore(); for (int i= 0; i < fCheckBoxes.size(); i++) { - Button button= (Button) fCheckBoxes.get(i); + Button button= fCheckBoxes.get(i); String key= (String) button.getData(); button.setSelection(store.getDefaultBoolean(key)); } for (int i= 0; i < fRadioButtons.size(); i++) { - Button button= (Button) fRadioButtons.get(i); + Button button= fRadioButtons.get(i); String[] info= (String[]) button.getData(); button.setSelection(info[1].equals(store.getDefaultString(info[0]))); } for (int i= 0; i < fTextControls.size(); i++) { - Text text= (Text) fTextControls.get(i); + Text text= fTextControls.get(i); String key= (String) text.getData(); text.setText(store.getDefaultString(key)); } @@ -145,19 +145,19 @@ public class WorkInProgressPreferencePage extends PreferencePage implements IWor public boolean performOk() { IPreferenceStore store= getPreferenceStore(); for (int i= 0; i < fCheckBoxes.size(); i++) { - Button button= (Button) fCheckBoxes.get(i); + Button button= fCheckBoxes.get(i); String key= (String) button.getData(); store.setValue(key, button.getSelection()); } for (int i= 0; i < fRadioButtons.size(); i++) { - Button button= (Button) fRadioButtons.get(i); + Button button= fRadioButtons.get(i); if (button.getSelection()) { String[] info= (String[]) button.getData(); store.setValue(info[0], info[1]); } } for (int i= 0; i < fTextControls.size(); i++) { - Text text= (Text) fTextControls.get(i); + Text text= fTextControls.get(i); String key= (String) text.getData(); store.setValue(key, text.getText()); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CreateFileChange.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CreateFileChange.java index 68afe18c594..5e2a7bcdf48 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CreateFileChange.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/CreateFileChange.java @@ -63,9 +63,8 @@ public class CreateFileChange extends Change { public String getName() { if(name == null) { return NLS.bind(Messages.CreateFileChange_CreateFile, path.toOSString()); - }else { - return name; } + return name; } @Override diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java index 6f179286ea6..93565319794 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/MethodContext.java @@ -61,9 +61,8 @@ public class MethodContext { IASTNode parent = declarationName.getParent().getParent(); if (parent instanceof IASTSimpleDeclaration) { return (IASTSimpleDeclaration) parent; - } else { - return null; } + return null; } public ICPPASTVisiblityLabel getMethodDeclarationASTVisibility(){ @@ -101,9 +100,8 @@ public class MethodContext { ICPPInternalBinding subclassBind = getICPPInternalBinding(contextOfSameOrSubclass); if(isSameClass(bind1,subclassBind)){ return true; - } else { - return isSubclass(bind1,subclassBind); } + return isSubclass(bind1,subclassBind); } private static boolean isSubclass(ICPPInternalBinding bind1, ICPPInternalBinding subclassBind) { @@ -148,12 +146,10 @@ public class MethodContext { if (bind1 instanceof ICPPInternalBinding) { ICPPInternalBinding bind1int = (ICPPInternalBinding) bind1; return bind1int.getDefinition().equals(bind2.getDefinition()); - } else { - return false; } - } else { return false; } + return false; } catch (DOMException e) { return false; } @@ -173,9 +169,8 @@ public class MethodContext { if( node1.equals(node2) ){ return bind1.getDefinition().equals(bind2.getDefinition()); - } else { - return false; } + return false; } catch (DOMException e) { return false; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java index 937262c1500..d7e1f39b954 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/dialogs/CTextEditChangePreviewViewer.java @@ -245,9 +245,8 @@ public class CTextEditChangePreviewViewer implements IChangePreviewViewer { CTextFileChange editChange= (CTextFileChange)change; setInput(editChange, editChange.getCurrentContent(new NullProgressMonitor()), editChange.getPreviewContent(new NullProgressMonitor()), editChange.getTextType()); return; - } else { - viewer.setInput(null); } + viewer.setInput(null); } catch (CoreException e) { viewer.setInput(null); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java index 3d155ae41d3..f5b7f1e2ace 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java @@ -403,9 +403,7 @@ public class ASTManager { // todo check for const, restrict return r1; } - else { - return FALSE; - } + return FALSE; } return r1; } @@ -693,8 +691,7 @@ public class ASTManager { ICPPClassScope classScope = (ICPPClassScope) scope; ICPPClassType classType= classScope.getClassType(); ICPPBase[] bases= classType.getBases(); - for (int i = 0; i < bases.length; i++) { - ICPPBase base = bases[i]; + for (ICPPBase base : bases) { if( !(base.getBaseClass() instanceof ICPPClassType) ) continue; ICPPClassType baseType= (ICPPClassType) base.getBaseClass(); @@ -702,8 +699,7 @@ public class ASTManager { IScope baseScope= baseType.getCompositeScope(); if (baseScope != null) { IBinding[] alternates= baseScope.find(method.getName()); - for (int j = 0; j < alternates.length; j++) { - IBinding binding = alternates[j]; + for (IBinding binding : alternates) { if (binding instanceof CPPMethod) { CPPMethod alternateMethod = (CPPMethod) binding; if (hasSameSignature(method, alternateMethod)!=FALSE) { @@ -773,8 +769,7 @@ public class ASTManager { if (count < result.length) { IBinding[] copy= new IBinding[count]; int i=0; - for (int j = 0; j < result.length; j++) { - IBinding b = result[j]; + for (IBinding b : result) { if (b != null) { copy[i++]= b; } @@ -861,7 +856,7 @@ public class ASTManager { } catch (CoreException e) { status.addError(e.getMessage()); } - if (tu != null && cacheit) { + if (cacheit) { fTranslationUnits.put(sourceFile, ast); } } @@ -869,11 +864,10 @@ public class ASTManager { return ast; } - public void analyzeTextMatches(IIndex index, ArrayList matches, IProgressMonitor monitor, + public void analyzeTextMatches(IIndex index, ArrayList<CRefactoringMatch> matches, IProgressMonitor monitor, RefactoringStatus status) { CRefactoringMatchStore store= new CRefactoringMatchStore(); - for (Iterator iter = matches.iterator(); iter.hasNext();) { - CRefactoringMatch match = (CRefactoringMatch) iter.next(); + for (CRefactoringMatch match : matches) { store.addMatch(match); } @@ -897,9 +891,9 @@ public class ASTManager { update= now+1000; } boolean doParse= false; - Collection fm= store.getMatchesForFile(file); - for (Iterator iterator = fm.iterator(); !doParse && iterator.hasNext();) { - CRefactoringMatch match = (CRefactoringMatch) iterator.next(); + Collection<CRefactoringMatch> fm= store.getMatchesForFile(file); + for (Iterator<CRefactoringMatch> iterator = fm.iterator(); !doParse && iterator.hasNext();) { + CRefactoringMatch match = iterator.next(); switch (match.getLocation()) { case CRefactory.OPTION_IN_COMMENT: case CRefactory.OPTION_IN_INCLUDE_DIRECTIVE: @@ -951,8 +945,7 @@ public class ASTManager { analyzeLanguageMatches(tu, store, paths, status); if (status.hasFatalError()) return; - for (Iterator<IPath> iter = paths.iterator(); iter.hasNext();) { - IPath path = iter.next(); + for (IPath path : paths) { if (path != null) { store.removePath(path); } @@ -981,8 +974,7 @@ public class ASTManager { final RefactoringStatus status) { String lookfor= fArgument.getName(); IASTPreprocessorMacroDefinition[] mdefs= tu.getMacroDefinitions(); - for (int i = 0; i < mdefs.length; i++) { - IASTPreprocessorMacroDefinition mdef = mdefs[i]; + for (IASTPreprocessorMacroDefinition mdef : mdefs) { IASTName macroName= mdef.getName(); String macroNameStr= macroName.toString(); if (fRenameTo.equals(macroNameStr)) { @@ -997,8 +989,8 @@ public class ASTManager { IBinding macroBinding= macroName.resolveBinding(); if (macroBinding != null) { IASTName[] refs= tu.getReferences(macroBinding); - for (int j = 0; j < refs.length; j++) { - path= analyzeAstMatch(refs[j], store, false, status); + for (IASTName ref : refs) { + path= analyzeAstMatch(ref, store, false, status); pathsVisited.add(path); } } @@ -1019,10 +1011,9 @@ public class ASTManager { IASTFileLocation floc= mdef.getNodeLocations()[0].asFileLocation(); int offset= floc.getNodeOffset(); int end= offset+ floc.getNodeLength(); - Collection matches= store.findMatchesInRange( + Collection<CRefactoringMatch> matches= store.findMatchesInRange( new Path(floc.getFileName()), offset, end); - for (Iterator iter = matches.iterator(); iter.hasNext();) { - CRefactoringMatch match = (CRefactoringMatch) iter.next(); + for (CRefactoringMatch match : matches) { match.setASTInformation(CRefactoringMatch.AST_REFERENCE_OTHER); } } @@ -1081,15 +1072,13 @@ public class ASTManager { IASTFileLocation floc= loc.asFileLocation(); if (floc != null) { path= new Path(floc.getFileName()); - if (path != null) { - IBinding binding= name.resolveBinding(); - if (binding instanceof IProblemBinding) { - handleProblemBinding(name.getTranslationUnit(), - (IProblemBinding) binding, status); - } - else if (binding != null) { - fConflictingBinding.add(binding); - } + IBinding binding= name.resolveBinding(); + if (binding instanceof IProblemBinding) { + handleProblemBinding(name.getTranslationUnit(), + (IProblemBinding) binding, status); + } + else if (binding != null) { + fConflictingBinding.add(binding); } } } @@ -1130,8 +1119,7 @@ public class ASTManager { handleProblemBinding(name.getTranslationUnit(), (IProblemBinding) binding, status); } else { - for (int i = 0; i < fValidBindings.length; i++) { - IBinding renameBinding = fValidBindings[i]; + for (IBinding renameBinding : fValidBindings) { try { int cmp0= isSameBinding(binding, renameBinding); if (cmp0 != FALSE) { @@ -1221,6 +1209,8 @@ public class ASTManager { case CRefactory.ARGUMENT_LOCAL_VAR: case CRefactory.ARGUMENT_PARAMETER: isLocalVarPar= true; + isVarParEnumerator= true; + break; case CRefactory.ARGUMENT_FILE_LOCAL_VAR: case CRefactory.ARGUMENT_GLOBAL_VAR: case CRefactory.ARGUMENT_FIELD: @@ -1396,11 +1386,10 @@ public class ASTManager { String space = " \n"; //$NON-NLS-1$ String formatted = message + space + message1 + space + message2 + space + message3; RefactoringStatusEntry[] entries= status.getEntries(); - for (int j = 0; (conflict.getName() != null || msg != null || what != null) - && j<entries.length; j++) { - RefactoringStatusEntry entry = entries[j]; + for (RefactoringStatusEntry entry : entries) { if (formatted.equals(entry.getMessage())) { formatted= null; + break; } } if (formatted != null) { @@ -1423,10 +1412,9 @@ public class ASTManager { String name= fArgument.getName(); IBinding[] newBindingsAboverOrEqual= null; IScope oldBindingsScope= null; - for (Iterator iter= fKnownBindings.entrySet().iterator(); iter.hasNext();) { - Map.Entry entry= (Map.Entry) iter.next(); - IBinding oldBinding= (IBinding) entry.getKey(); - Integer value= (Integer) entry.getValue(); + for (Map.Entry<IBinding, Integer> entry : fKnownBindings.entrySet()) { + IBinding oldBinding= entry.getKey(); + Integer value= entry.getValue(); if (value.intValue() == TRUE && oldBinding.getName().equals(name)) { try { oldBindingsScope = oldBinding.getScope(); @@ -1447,8 +1435,7 @@ public class ASTManager { } // check conflicting bindings for being from above or equal level. - for (Iterator<IBinding> iter = fConflictingBinding.iterator(); iter.hasNext();) { - IBinding conflictingBinding= iter.next(); + for (IBinding conflictingBinding : fConflictingBinding) { if (conflictingBinding != null) { boolean isAboveOrEqual= false; for (int i = 0; !isAboveOrEqual && i<newBindingsAboverOrEqual.length; i++) { @@ -1468,8 +1455,7 @@ public class ASTManager { } // find bindings on same level - for (int i = 0; i<newBindingsAboverOrEqual.length; i++) { - IBinding aboveBinding = newBindingsAboverOrEqual[i]; + for (IBinding aboveBinding : newBindingsAboverOrEqual) { IScope aboveScope; try { aboveScope = aboveBinding.getScope(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java index fdbe50748b3..7caeed00aee 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java @@ -95,17 +95,17 @@ public class CRefactoringMatchStore { } public CRefactoringMatch findMatch(IPath path, int nodeOffset) { - Map map= fPathToMatches.get(path); + Map<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.get(path); if (map != null) { - return (CRefactoringMatch) map.get(new CRefactoringMatch(null, nodeOffset, 0, 0)); + return map.get(new CRefactoringMatch(null, nodeOffset, 0, 0)); } return null; } public void removePath(IPath path) { - Map map= fPathToMatches.remove(path); + Map<CRefactoringMatch, CRefactoringMatch> map= fPathToMatches.remove(path); if (map != null && !map.isEmpty()) { - IFile file= ((CRefactoringMatch) map.values().iterator().next()).getFile(); + IFile file= (map.values().iterator().next()).getFile(); fFileToPathMap.remove(file); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java index da1d8fee30c..efb1354ebad 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactory.java @@ -130,8 +130,7 @@ public class CRefactory { public String[] getCCppPatterns() { IContentType[] cts= Platform.getContentTypeManager().getAllContentTypes(); HashSet<String> all= new HashSet<String>(); - for (int i= 0; i < cts.length; i++) { - IContentType type= cts[i]; + for (IContentType type : cts) { boolean useit= false; while (!useit && type != null) { String id= type.getId(); @@ -152,9 +151,9 @@ public class CRefactory { } } String[] result= new String[all.size()]; - Iterator it= all.iterator(); + Iterator<String> it= all.iterator(); for (int i= 0; i < result.length; i++) { - result[i]= "*." + (String) it.next(); //$NON-NLS-1$ + result[i]= "*." + it.next(); //$NON-NLS-1$ } return result; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java index 9a74e883722..03169ebbfc4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameLocalProcessor.java @@ -74,8 +74,8 @@ public class CRenameLocalProcessor extends CRenameProcessorDelegate { } } int[] range= result; - for (Iterator iter = matches.iterator(); iter.hasNext();) { - CRefactoringMatch m = (CRefactoringMatch) iter.next(); + for (Iterator<CRefactoringMatch> iter = matches.iterator(); iter.hasNext();) { + CRefactoringMatch m = iter.next(); int off= m.getOffset(); if (off < range[0] || off > range[1]) { iter.remove(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java index fb6be0784d0..0439105c3d2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameMacroProcessor.java @@ -11,7 +11,6 @@ package org.eclipse.cdt.internal.ui.refactoring.rename; import java.util.ArrayList; -import java.util.Iterator; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.ltk.core.refactoring.RefactoringStatus; @@ -38,8 +37,7 @@ public class CRenameMacroProcessor extends CRenameGlobalProcessor { @Override protected void analyzeTextMatches(ArrayList<CRefactoringMatch> matches, IProgressMonitor monitor, RefactoringStatus status) { - for (Iterator iter = matches.iterator(); iter.hasNext();) { - CRefactoringMatch m = (CRefactoringMatch) iter.next(); + for (CRefactoringMatch m : matches) { if ((m.getLocation() & CRefactory.OPTION_IN_PREPROCESSOR_DIRECTIVE) != 0) { m.setASTInformation(CRefactoringMatch.AST_REFERENCE); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java index cd77fb13daf..2ae3a57473f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java @@ -274,8 +274,7 @@ public abstract class CRenameProcessorDelegate { IFile file= null; TextFileChange fileChange= null; MultiTextEdit fileEdit= null; - for (Iterator<CRefactoringMatch> iter = fMatches.iterator(); iter.hasNext();) { - CRefactoringMatch match= iter.next(); + for (CRefactoringMatch match : fMatches) { switch(match.getAstInformation()) { case CRefactoringMatch.AST_REFERENCE_OTHER: continue; @@ -287,7 +286,7 @@ public abstract class CRenameProcessorDelegate { } if (match.getAstInformation() != CRefactoringMatch.AST_REFERENCE_OTHER) { IFile mfile= match.getFile(); - if (file==null || !file.equals(mfile)) { + if (file==null || !file.equals(mfile) || fileEdit == null || fileChange == null) { file= mfile; fileEdit= new MultiTextEdit(); fileChange = new CTextFileChange(file.getName(), file); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java index 8734d11b436..cb9a24c6e42 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java @@ -32,6 +32,7 @@ import org.eclipse.ui.IWorkingSetManager; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.IWorkingSetSelectionDialog; +import org.eclipse.cdt.core.CConventions; import org.eclipse.cdt.ui.CUIPlugin; @@ -454,7 +455,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { setErrorMessage(null); setPageComplete(false); } - else if (!isValidIdentifier(txt)) { + else if (!CConventions.isValidIdentifier(txt)) { setErrorMessage(NLS.bind(Messages.getString("CRenameRefactoringInputPage.errorInvalidIdentifier"), txt)); //$NON-NLS-1$ setPageComplete(false); } @@ -464,77 +465,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { } } - private boolean isValidIdentifier(String txt) { - if (txt.length() < 1) { - return false; - } - char[] chars= txt.toCharArray(); - for (int i = 0; i < chars.length; i++) { - final char c = chars[i]; - switch(c) { - case '?': - // check for trigraph for backslash - if (i+2 >= chars.length) { - return false; - } - if (chars[++i] != '?') { - return false; - } - if (chars[++i] != '/') { - return false; - } - // no break, continue with check for universal character name - case '\\': - // check for universal character name - if (++i >= chars.length) { - return false; - } - int hexdigits= 0; - switch(chars[i]) { - case 'u': - hexdigits= 4; - break; - case 'U': - hexdigits= 8; - break; - default: - return false; - } - while (hexdigits > 0) { - if (++i >= chars.length) { - return false; - } - if (!isHexDigit(chars[i])) { - return false; - } - hexdigits--; - } - break; - case '_': - break; - default: - if (i==0) { - if (!Character.isLetter(c)) { - return false; - } - } - else { - if (!Character.isLetterOrDigit(c)) { - return false; - } - } - } - } - return true; - } - - private boolean isHexDigit(char c) { - return ( c >= '0' && c <= '9' ) - || ( c >= 'A' && c <= 'F' ) - || ( c >= 'a' && c <= 'f' ); - } - - protected void updateEnablement() { + protected void updateEnablement() { boolean enable= fEnableScopeOptions==-1 || (computeSelectedOptions() & fEnableScopeOptions) != 0; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java index bf278901b40..25022043eec 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/EclipseObjects.java @@ -70,8 +70,8 @@ public class EclipseObjects { static public IEditorPart getEditorForFile(IFile file) { IWorkbenchPage page = getActivePage(); IEditorReference[] editors = page.getEditorReferences(); - for (int i = 0; i < editors.length; i++) { - IEditorPart editor = editors[i].getEditor(false); + for (IEditorReference editor2 : editors) { + IEditorPart editor = editor2.getEditor(false); if (editor instanceof CEditor) { CEditor edi = ((CEditor)editor); IResource resource = edi.getInputCElement().getResource(); @@ -136,9 +136,8 @@ public class EclipseObjects { if (selection instanceof IStructuredSelection && !selection.isEmpty()) { IFile file = getFile((IStructuredSelection)selection); return file; - } else { - return EclipseObjects.getActiveFile(); } + return EclipseObjects.getActiveFile(); } static private IFile getFile(IStructuredSelection selection) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierHelper.java index ff8691426ce..e2ba0a48985 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierHelper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/IdentifierHelper.java @@ -12,12 +12,11 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.utils; +import java.text.MessageFormat; import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; -import java.text.MessageFormat; - import org.eclipse.cdt.core.parser.KeywordSetKey; import org.eclipse.cdt.core.parser.ParserLanguage; @@ -44,9 +43,7 @@ public class IdentifierHelper { if(isKeyword(identifier)){ return new IdentifierResult(IdentifierResult.KEYWORD, MessageFormat.format(Messages.IdentifierHelper_isKeyword, new Object[] {identifier})); } - else{ - return new IdentifierResult(IdentifierResult.VALID, MessageFormat.format(Messages.IdentifierHelper_isValid, new Object[] {identifier})); - } + return new IdentifierResult(IdentifierResult.VALID, MessageFormat.format(Messages.IdentifierHelper_isValid, new Object[] {identifier})); } else if(isLeadingADigit(identifier)){ return new IdentifierResult(IdentifierResult.DIGIT_FIRST, MessageFormat.format(Messages.IdentifierHelper_leadingDigit, new Object[] {identifier})); } else if(identifier.length() == 0){ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalCategory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalCategory.java index 40af3f6596c..8c85e268911 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalCategory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalCategory.java @@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist; import java.net.URL; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.eclipse.core.runtime.FileLocator; @@ -27,6 +26,8 @@ import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.jface.action.LegacyActionTools; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.eclipse.jface.text.contentassist.IContextInformation; import org.osgi.framework.Bundle; import org.eclipse.cdt.ui.CUIPlugin; @@ -200,9 +201,8 @@ public final class CompletionProposalCategory { * otherwise */ public boolean hasComputers() { - List descriptors= fRegistry.getProposalComputerDescriptors(); - for (Iterator it= descriptors.iterator(); it.hasNext();) { - CompletionProposalComputerDescriptor desc= (CompletionProposalComputerDescriptor) it.next(); + List<CompletionProposalComputerDescriptor> descriptors= fRegistry.getProposalComputerDescriptors(); + for (CompletionProposalComputerDescriptor desc : descriptors) { if (desc.getCategory() == this) return true; } @@ -218,9 +218,8 @@ public final class CompletionProposalCategory { * otherwise */ public boolean hasComputers(String partition) { - List descriptors= fRegistry.getProposalComputerDescriptors(partition); - for (Iterator it= descriptors.iterator(); it.hasNext();) { - CompletionProposalComputerDescriptor desc= (CompletionProposalComputerDescriptor) it.next(); + List<CompletionProposalComputerDescriptor> descriptors= fRegistry.getProposalComputerDescriptors(partition); + for (CompletionProposalComputerDescriptor desc : descriptors) { if (desc.getCategory() == this) return true; } @@ -252,12 +251,11 @@ public final class CompletionProposalCategory { * @return the list of computed completion proposals (element type: * {@link org.eclipse.jface.text.contentassist.ICompletionProposal}) */ - public List computeCompletionProposals(ContentAssistInvocationContext context, String partition, SubProgressMonitor monitor) { + public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, String partition, SubProgressMonitor monitor) { fLastError= null; - List result= new ArrayList(); - List descriptors= new ArrayList(fRegistry.getProposalComputerDescriptors(partition)); - for (Iterator it= descriptors.iterator(); it.hasNext();) { - CompletionProposalComputerDescriptor desc= (CompletionProposalComputerDescriptor) it.next(); + List<ICompletionProposal> result= new ArrayList<ICompletionProposal>(); + List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors(partition)); + for (CompletionProposalComputerDescriptor desc : descriptors) { if (desc.getCategory() == this) result.addAll(desc.computeCompletionProposals(context, monitor)); if (fLastError == null) @@ -277,12 +275,11 @@ public final class CompletionProposalCategory { * @return the list of computed context information objects (element type: * {@link org.eclipse.jface.text.contentassist.IContextInformation}) */ - public List computeContextInformation(ContentAssistInvocationContext context, String partition, SubProgressMonitor monitor) { + public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, String partition, SubProgressMonitor monitor) { fLastError= null; - List result= new ArrayList(); - List descriptors= new ArrayList(fRegistry.getProposalComputerDescriptors(partition)); - for (Iterator it= descriptors.iterator(); it.hasNext();) { - CompletionProposalComputerDescriptor desc= (CompletionProposalComputerDescriptor) it.next(); + List<IContextInformation> result= new ArrayList<IContextInformation>(); + List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors(partition)); + for (CompletionProposalComputerDescriptor desc : descriptors) { if (desc.getCategory() == this) result.addAll(desc.computeContextInformation(context, monitor)); if (fLastError == null) @@ -304,9 +301,8 @@ public final class CompletionProposalCategory { * Notifies the computers in this category of a proposal computation session start. */ public void sessionStarted() { - List descriptors= new ArrayList(fRegistry.getProposalComputerDescriptors()); - for (Iterator it= descriptors.iterator(); it.hasNext();) { - CompletionProposalComputerDescriptor desc= (CompletionProposalComputerDescriptor) it.next(); + List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors()); + for (CompletionProposalComputerDescriptor desc : descriptors) { if (desc.getCategory() == this) desc.sessionStarted(); if (fLastError == null) @@ -318,9 +314,8 @@ public final class CompletionProposalCategory { * Notifies the computers in this category of a proposal computation session end. */ public void sessionEnded() { - List descriptors= new ArrayList(fRegistry.getProposalComputerDescriptors()); - for (Iterator it= descriptors.iterator(); it.hasNext();) { - CompletionProposalComputerDescriptor desc= (CompletionProposalComputerDescriptor) it.next(); + List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors()); + for (CompletionProposalComputerDescriptor desc : descriptors) { if (desc.getCategory() == this) desc.sessionEnded(); if (fLastError == null) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java index 9e0e2d4452d..987e8976c10 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerDescriptor.java @@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Set; @@ -29,9 +28,9 @@ import org.eclipse.core.runtime.InvalidRegistryObjectException; import org.eclipse.core.runtime.PerformanceStats; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; - import org.eclipse.jface.text.IDocument; - +import org.eclipse.jface.text.contentassist.ICompletionProposal; +import org.eclipse.jface.text.contentassist.IContextInformation; import org.osgi.framework.Bundle; import org.eclipse.cdt.ui.CUIPlugin; @@ -63,7 +62,7 @@ final class CompletionProposalComputerDescriptor { /** The extension schema name of the partition child elements. */ private static final String PARTITION= "partition"; //$NON-NLS-1$ /** Set of Java partition types. */ - private static final Set PARTITION_SET; + private static final Set<String> PARTITION_SET; /** The name of the performance event used to trace extensions. */ private static final String PERFORMANCE_EVENT= CUIPlugin.getPluginId() + "/perf/content_assist/extensions"; //$NON-NLS-1$ /** @@ -86,7 +85,7 @@ final class CompletionProposalComputerDescriptor { private static final String SESSION_ENDED= "sessionEnded()"; //$NON-NLS-1$ static { - Set partitions= new HashSet(); + Set<String> partitions= new HashSet<String>(); partitions.add(IDocument.DEFAULT_CONTENT_TYPE); partitions.addAll(Arrays.asList(ICPartitions.ALL_CPARTITIONS)); @@ -102,7 +101,7 @@ final class CompletionProposalComputerDescriptor { /** The activate attribute value. */ private final boolean fActivate; /** The partition of the extension (element type: {@link String}). */ - private final Set fPartitions; + private final Set<String> fPartitions; /** The configuration element of this extension. */ private final IConfigurationElement fElement; /** The registry we are registered with. */ @@ -128,7 +127,8 @@ final class CompletionProposalComputerDescriptor { * @param element the configuration element to read * @param registry the computer registry creating this descriptor */ - CompletionProposalComputerDescriptor(IConfigurationElement element, CompletionProposalComputerRegistry registry, List categories) throws InvalidRegistryObjectException { + @SuppressWarnings("null") + CompletionProposalComputerDescriptor(IConfigurationElement element, CompletionProposalComputerRegistry registry, List<CompletionProposalCategory> categories) throws InvalidRegistryObjectException { Assert.isLegal(registry != null); Assert.isLegal(element != null); @@ -144,13 +144,13 @@ final class CompletionProposalComputerDescriptor { else fName= name; - Set partitions= new HashSet(); + Set<String> partitions= new HashSet<String>(); IConfigurationElement[] children= element.getChildren(PARTITION); if (children.length == 0) { fPartitions= PARTITION_SET; // add to all partition types if no partition is configured } else { - for (int i= 0; i < children.length; i++) { - String type= children[i].getAttribute(TYPE); + for (IConfigurationElement element2 : children) { + String type= element2.getAttribute(TYPE); checkNotNull(type, TYPE); partitions.add(type); } @@ -167,8 +167,7 @@ final class CompletionProposalComputerDescriptor { if (categoryId == null) categoryId= DEFAULT_CATEGORY_ID; CompletionProposalCategory category= null; - for (Iterator it= categories.iterator(); it.hasNext();) { - CompletionProposalCategory cat= (CompletionProposalCategory) it.next(); + for (CompletionProposalCategory cat : categories) { if (cat.getId().equals(categoryId)) { category= cat; break; @@ -222,7 +221,7 @@ final class CompletionProposalComputerDescriptor { * * @return the set of partition types (element type: {@link String}) */ - public Set getPartitions() { + public Set<String> getPartitions() { return fPartitions; } @@ -283,19 +282,19 @@ final class CompletionProposalComputerDescriptor { * @return the list of computed completion proposals (element type: * {@link org.eclipse.jface.text.contentassist.ICompletionProposal}) */ - public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) { + public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) { if (!isEnabled()) - return Collections.EMPTY_LIST; + return Collections.emptyList(); IStatus status; try { ICompletionProposalComputer computer= getComputer(); if (computer == null) // not active yet - return Collections.EMPTY_LIST; + return Collections.emptyList(); try { PerformanceStats stats= startMeter(context, computer); - List proposals= computer.computeCompletionProposals(context, monitor); + List<ICompletionProposal> proposals= computer.computeCompletionProposals(context, monitor); stopMeter(stats, COMPUTE_COMPLETION_PROPOSALS); if (proposals != null) { @@ -318,7 +317,7 @@ final class CompletionProposalComputerDescriptor { fRegistry.informUser(this, status); - return Collections.EMPTY_LIST; + return Collections.emptyList(); } /** @@ -331,18 +330,18 @@ final class CompletionProposalComputerDescriptor { * @return the list of computed context information objects (element type: * {@link org.eclipse.jface.text.contentassist.IContextInformation}) */ - public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) { + public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) { if (!isEnabled()) - return Collections.EMPTY_LIST; + return Collections.emptyList(); IStatus status; try { ICompletionProposalComputer computer= getComputer(); if (computer == null) // not active yet - return Collections.EMPTY_LIST; + return Collections.emptyList(); PerformanceStats stats= startMeter(context, computer); - List proposals= computer.computeContextInformation(context, monitor); + List<IContextInformation> proposals= computer.computeContextInformation(context, monitor); stopMeter(stats, COMPUTE_CONTEXT_INFORMATION); if (proposals != null) { @@ -363,7 +362,7 @@ final class CompletionProposalComputerDescriptor { fRegistry.informUser(this, status); - return Collections.EMPTY_LIST; + return Collections.emptyList(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java index 3b329b8d091..3ff5ff9c663 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CompletionProposalComputerRegistry.java @@ -30,7 +30,9 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.InvalidRegistryObjectException; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Status; - +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -38,11 +40,6 @@ import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Link; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.MessageDialog; -import org.eclipse.jface.preference.IPreferenceStore; - import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.cdt.ui.CUIPlugin; @@ -85,26 +82,26 @@ public final class CompletionProposalComputerRegistry { * {@link String}, value type: * {@linkplain List List<CompletionProposalComputerDescriptor>}). */ - private final Map fDescriptorsByPartition= new HashMap(); + private final Map<String, List<CompletionProposalComputerDescriptor>> fDescriptorsByPartition= new HashMap<String, List<CompletionProposalComputerDescriptor>>(); /** * Unmodifiable versions of the sets stored in * <code>fDescriptorsByPartition</code> (key type: {@link String}, * value type: * {@linkplain List List<CompletionProposalComputerDescriptor>}). */ - private final Map fPublicDescriptorsByPartition= new HashMap(); + private final Map<String, List<CompletionProposalComputerDescriptor>> fPublicDescriptorsByPartition= new HashMap<String, List<CompletionProposalComputerDescriptor>>(); /** * All descriptors (element type: * {@link CompletionProposalComputerDescriptor}). */ - private final List fDescriptors= new ArrayList(); + private final List<CompletionProposalComputerDescriptor> fDescriptors= new ArrayList<CompletionProposalComputerDescriptor>(); /** * Unmodifiable view of <code>fDescriptors</code> */ - private final List fPublicDescriptors= Collections.unmodifiableList(fDescriptors); + private final List<CompletionProposalComputerDescriptor> fPublicDescriptors= Collections.unmodifiableList(fDescriptors); - private final List fCategories= new ArrayList(); - private final List fPublicCategories= Collections.unmodifiableList(fCategories); + private final List<CompletionProposalCategory> fCategories= new ArrayList<CompletionProposalCategory>(); + private final List<CompletionProposalCategory> fPublicCategories= Collections.unmodifiableList(fCategories); /** * <code>true</code> if this registry has been loaded. */ @@ -140,10 +137,12 @@ public final class CompletionProposalComputerRegistry { * @return the list of extensions to the <code>completionProposalComputer</code> extension * point (element type: {@link CompletionProposalComputerDescriptor}) */ - List getProposalComputerDescriptors(String partition) { + List<CompletionProposalComputerDescriptor> getProposalComputerDescriptors(String partition) { ensureExtensionPointRead(); - List result= (List) fPublicDescriptorsByPartition.get(partition); - return result != null ? result : Collections.EMPTY_LIST; + List<CompletionProposalComputerDescriptor> result= fPublicDescriptorsByPartition.get(partition); + if (result == null) + return Collections.emptyList(); + return result; } /** @@ -161,7 +160,7 @@ public final class CompletionProposalComputerRegistry { * @return the list of extensions to the <code>completionProposalComputer</code> extension * point (element type: {@link CompletionProposalComputerDescriptor}) */ - List getProposalComputerDescriptors() { + List<CompletionProposalComputerDescriptor> getProposalComputerDescriptors() { ensureExtensionPointRead(); return fPublicDescriptors; } @@ -180,7 +179,7 @@ public final class CompletionProposalComputerRegistry { * <code>completionProposalComputer</code> extension point (element type: * {@link CompletionProposalCategory}) */ - public List getProposalCategories() { + public List<CompletionProposalCategory> getProposalCategories() { ensureExtensionPointRead(); return fPublicCategories; } @@ -208,22 +207,21 @@ public final class CompletionProposalComputerRegistry { */ public void reload() { IExtensionRegistry registry= Platform.getExtensionRegistry(); - List elements= new ArrayList(Arrays.asList(registry.getConfigurationElementsFor(CUIPlugin.getPluginId(), EXTENSION_POINT))); + List<IConfigurationElement> elements= new ArrayList<IConfigurationElement>(Arrays.asList(registry.getConfigurationElementsFor(CUIPlugin.getPluginId(), EXTENSION_POINT))); - Map map= new HashMap(); - List all= new ArrayList(); + Map<String, List<CompletionProposalComputerDescriptor>> map= new HashMap<String, List<CompletionProposalComputerDescriptor>>(); + List<CompletionProposalComputerDescriptor> all= new ArrayList<CompletionProposalComputerDescriptor>(); - List categories= getCategories(elements); - for (Iterator iter= elements.iterator(); iter.hasNext();) { - IConfigurationElement element= (IConfigurationElement) iter.next(); + List<CompletionProposalCategory> categories= getCategories(elements); + for (IConfigurationElement element : elements) { try { CompletionProposalComputerDescriptor desc= new CompletionProposalComputerDescriptor(element, this, categories); - Set partitions= desc.getPartitions(); - for (Iterator it= partitions.iterator(); it.hasNext();) { - String partition= (String) it.next(); - List list= (List) map.get(partition); + Set<String> partitions= desc.getPartitions(); + for (Object element2 : partitions) { + String partition= (String) element2; + List<CompletionProposalComputerDescriptor> list= map.get(partition); if (list == null) { - list= new ArrayList(); + list= new ArrayList<CompletionProposalComputerDescriptor>(); map.put(partition, list); } list.add(desc); @@ -247,13 +245,12 @@ public final class CompletionProposalComputerRegistry { fCategories.clear(); fCategories.addAll(categories); - Set partitions= map.keySet(); + Set<String> partitions= map.keySet(); fDescriptorsByPartition.keySet().retainAll(partitions); fPublicDescriptorsByPartition.keySet().retainAll(partitions); - for (Iterator it= partitions.iterator(); it.hasNext();) { - String partition= (String) it.next(); - List old= (List) fDescriptorsByPartition.get(partition); - List current= (List) map.get(partition); + for (String partition : partitions) { + List<CompletionProposalComputerDescriptor> old= fDescriptorsByPartition.get(partition); + List<CompletionProposalComputerDescriptor> current= map.get(partition); if (old != null) { old.clear(); old.addAll(current); @@ -268,14 +265,14 @@ public final class CompletionProposalComputerRegistry { } } - private List getCategories(List elements) { + private List<CompletionProposalCategory> getCategories(List<IConfigurationElement> elements) { IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); String preference= store.getString(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES); - Set disabled= new HashSet(); + Set<String> disabled= new HashSet<String>(); StringTokenizer tok= new StringTokenizer(preference, "\0"); //$NON-NLS-1$ while (tok.hasMoreTokens()) disabled.add(tok.nextToken()); - Map ordered= new HashMap(); + Map<String, Integer> ordered= new HashMap<String, Integer>(); preference= store.getString(PreferenceConstants.CODEASSIST_CATEGORY_ORDER); tok= new StringTokenizer(preference, "\0"); //$NON-NLS-1$ while (tok.hasMoreTokens()) { @@ -285,9 +282,9 @@ public final class CompletionProposalComputerRegistry { ordered.put(id, new Integer(rank)); } - List categories= new ArrayList(); - for (Iterator iter= elements.iterator(); iter.hasNext();) { - IConfigurationElement element= (IConfigurationElement) iter.next(); + List<CompletionProposalCategory> categories= new ArrayList<CompletionProposalCategory>(); + for (Iterator<IConfigurationElement> iter= elements.iterator(); iter.hasNext();) { + IConfigurationElement element= iter.next(); try { if (element.getName().equals("proposalCategory")) { //$NON-NLS-1$ iter.remove(); // remove from list to leave only computers @@ -295,7 +292,7 @@ public final class CompletionProposalComputerRegistry { CompletionProposalCategory category= new CompletionProposalCategory(element, this); categories.add(category); category.setIncluded(!disabled.contains(category.getId())); - Integer rank= (Integer) ordered.get(category.getId()); + Integer rank= ordered.get(category.getId()); if (rank != null) { int r= rank.intValue(); boolean separate= r < 0xffff; @@ -329,7 +326,7 @@ public final class CompletionProposalComputerRegistry { String title= ContentAssistMessages.CompletionProposalComputerRegistry_error_dialog_title; CompletionProposalCategory category= descriptor.getCategory(); IContributor culprit= descriptor.getContributor(); - Set affectedPlugins= getAffectedContributors(category, culprit); + Set<String> affectedPlugins= getAffectedContributors(category, culprit); final String avoidHint; final String culpritName= culprit == null ? null : culprit.getName(); @@ -371,10 +368,9 @@ public final class CompletionProposalComputerRegistry { * @param culprit the culprit plug-in, which is not included in the returned list * @return the names of the contributors other than <code>culprit</code> that contribute to <code>category</code> (element type: {@link String}) */ - private Set getAffectedContributors(CompletionProposalCategory category, IContributor culprit) { - Set affectedPlugins= new HashSet(); - for (Iterator it= getProposalComputerDescriptors().iterator(); it.hasNext();) { - CompletionProposalComputerDescriptor desc= (CompletionProposalComputerDescriptor) it.next(); + private Set<String> getAffectedContributors(CompletionProposalCategory category, IContributor culprit) { + Set<String> affectedPlugins= new HashSet<String>(); + for (CompletionProposalComputerDescriptor desc : getProposalComputerDescriptors()) { CompletionProposalCategory cat= desc.getCategory(); if (cat.equals(category)) { IContributor contributor= desc.getContributor(); @@ -385,7 +381,7 @@ public final class CompletionProposalComputerRegistry { return affectedPlugins; } - private Object toString(Collection collection) { + private Object toString(Collection<String> collection) { // strip brackets off AbstractCollection.toString() String string= collection.toString(); return string.substring(1, string.length() - 1); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java index 4b6aca30064..2b261982151 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckEngine.java @@ -53,7 +53,7 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe /** * Caches the locales of installed dictionaries. */ - private static Set fgLocalesWithInstalledDictionaries; + private static Set<Locale> fgLocalesWithInstalledDictionaries; /** @@ -62,7 +62,7 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe * * @return The available locales for this engine */ - public static Set getLocalesWithInstalledDictionaries() { + public static Set<Locale> getLocalesWithInstalledDictionaries() { if (fgLocalesWithInstalledDictionaries != null) return fgLocalesWithInstalledDictionaries; @@ -70,10 +70,10 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe try { location= getDictionaryLocation(); if (location == null) - return fgLocalesWithInstalledDictionaries= Collections.EMPTY_SET; + return fgLocalesWithInstalledDictionaries= Collections.emptySet(); } catch (MalformedURLException ex) { CUIPlugin.log(ex); - return fgLocalesWithInstalledDictionaries= Collections.EMPTY_SET; + return fgLocalesWithInstalledDictionaries= Collections.emptySet(); } String[] fileNames; @@ -81,16 +81,16 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe URL url= FileLocator.toFileURL(location); File file= new File(url.getFile()); if (!file.isDirectory()) - return fgLocalesWithInstalledDictionaries= Collections.EMPTY_SET; + return fgLocalesWithInstalledDictionaries= Collections.emptySet(); fileNames= file.list(); if (fileNames == null) - return fgLocalesWithInstalledDictionaries= Collections.EMPTY_SET; + return fgLocalesWithInstalledDictionaries= Collections.emptySet(); } catch (IOException ex) { CUIPlugin.log(ex); - return fgLocalesWithInstalledDictionaries= Collections.EMPTY_SET; + return fgLocalesWithInstalledDictionaries= Collections.emptySet(); } - fgLocalesWithInstalledDictionaries= new HashSet(); + fgLocalesWithInstalledDictionaries= new HashSet<Locale>(); int fileNameCount= fileNames.length; for (int i= 0; i < fileNameCount; i++) { String fileName= fileNames[i]; @@ -127,18 +127,18 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe * @return the dictionary or <code>null</code> if none is suitable */ public ISpellDictionary findDictionary(Locale locale) { - ISpellDictionary dictionary= (ISpellDictionary)fLocaleDictionaries.get(locale); + ISpellDictionary dictionary= fLocaleDictionaries.get(locale); if (dictionary != null) return dictionary; // Try same language String language= locale.getLanguage(); - Iterator iter= fLocaleDictionaries.entrySet().iterator(); + Iterator<Map.Entry<Locale, ISpellDictionary>> iter= fLocaleDictionaries.entrySet().iterator(); while (iter.hasNext()) { - Entry entry= (Entry)iter.next(); - Locale dictLocale= (Locale)entry.getKey(); + Entry<Locale, ISpellDictionary> entry= iter.next(); + Locale dictLocale= entry.getKey(); if (dictLocale.getLanguage().equals(language)) - return (ISpellDictionary)entry.getValue(); + return entry.getValue(); } return null; @@ -156,9 +156,9 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe // Try same language String language= locale.getLanguage(); - Iterator iter= getLocalesWithInstalledDictionaries().iterator(); + Iterator<Locale> iter= getLocalesWithInstalledDictionaries().iterator(); while (iter.hasNext()) { - Locale dictLocale= (Locale)iter.next(); + Locale dictLocale= iter.next(); if (dictLocale.getLanguage().equals(language)) return dictLocale; } @@ -215,13 +215,13 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe } /** The registered locale insensitive dictionaries */ - private Set fGlobalDictionaries= new HashSet(); + private Set<ISpellDictionary> fGlobalDictionaries= new HashSet<ISpellDictionary>(); /** The spell checker for fLocale */ private ISpellChecker fChecker= null; /** The registered locale sensitive dictionaries */ - private Map fLocaleDictionaries= new HashMap(); + private Map<Locale, ISpellDictionary> fLocaleDictionaries= new HashMap<Locale, ISpellDictionary>(); /** The user dictionary */ private ISpellDictionary fUserDictionary= null; @@ -233,11 +233,9 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe fGlobalDictionaries.add(new TaskTagDictionary()); try { - Locale locale= null; final URL location= getDictionaryLocation(); - for (final Iterator iterator= getLocalesWithInstalledDictionaries().iterator(); iterator.hasNext();) { - locale= (Locale)iterator.next(); + for (Locale locale : getLocalesWithInstalledDictionaries()) { fLocaleDictionaries.put(locale, new LocaleSensitiveSpellDictionary(locale, location)); } } catch (MalformedURLException exception) { @@ -267,8 +265,7 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe fChecker= new DefaultSpellChecker(store, locale); resetUserDictionary(); - for (Iterator iterator= fGlobalDictionaries.iterator(); iterator.hasNext();) { - ISpellDictionary dictionary= (ISpellDictionary)iterator.next(); + for (ISpellDictionary dictionary : fGlobalDictionaries) { fChecker.addDictionary(dictionary); } @@ -392,14 +389,14 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe SpellingPreferences.removePropertyChangeListener(this); ISpellDictionary dictionary= null; - for (final Iterator iterator= fGlobalDictionaries.iterator(); iterator.hasNext();) { - dictionary= (ISpellDictionary)iterator.next(); + for (final Iterator<ISpellDictionary> iterator= fGlobalDictionaries.iterator(); iterator.hasNext();) { + dictionary= iterator.next(); dictionary.unload(); } fGlobalDictionaries= null; - for (final Iterator iterator= fLocaleDictionaries.values().iterator(); iterator.hasNext();) { - dictionary= (ISpellDictionary)iterator.next(); + for (Object element : fLocaleDictionaries.values()) { + dictionary= (ISpellDictionary)element; dictionary.unload(); } fLocaleDictionaries= null; @@ -410,7 +407,7 @@ public class SpellCheckEngine implements ISpellCheckEngine, IPropertyChangeListe private synchronized void resetSpellChecker() { if (fChecker != null) { - ISpellDictionary dictionary= (ISpellDictionary)fLocaleDictionaries.get(fChecker.getLocale()); + ISpellDictionary dictionary= fLocaleDictionaries.get(fChecker.getLocale()); if (dictionary != null) dictionary.unload(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java index 47131ded3f3..c9f56d86a58 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/IListAdapter.java @@ -13,21 +13,21 @@ package org.eclipse.cdt.internal.ui.wizards.dialogfields; /** * Change listener used by <code>ListDialogField</code> and <code>CheckedListDialogField</code> */ -public interface IListAdapter { +public interface IListAdapter<T> { /** * A button from the button bar has been pressed. */ - void customButtonPressed(ListDialogField field, int index); + void customButtonPressed(ListDialogField<T> field, int index); /** * The selection of the list has changed. */ - void selectionChanged(ListDialogField field); + void selectionChanged(ListDialogField<T> field); /** * En entry in the list has been double clicked */ - void doubleClicked(ListDialogField field); + void doubleClicked(ListDialogField<T> field); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java index 62c68c349cf..0919c3b2c3a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/ListDialogField.java @@ -14,21 +14,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableColumn; - import org.eclipse.core.runtime.Assert; import org.eclipse.jface.viewers.ColumnLayoutData; import org.eclipse.jface.viewers.ColumnWeightData; @@ -45,6 +30,20 @@ import org.eclipse.jface.viewers.TableLayout; import org.eclipse.jface.viewers.TableViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerComparator; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; import org.eclipse.cdt.internal.ui.util.PixelConverter; import org.eclipse.cdt.internal.ui.util.SWTUtil; @@ -56,7 +55,7 @@ import org.eclipse.cdt.internal.ui.util.TableLayoutComposite; * List model is independend of widget creation. * DialogFields controls are: Label, List and Composite containing buttons. */ -public class ListDialogField extends DialogField { +public class ListDialogField<T> extends DialogField { public static class ColumnsDescription { protected ColumnLayoutData[] columns; @@ -89,7 +88,7 @@ public class ListDialogField extends DialogField { protected TableViewer fTable; protected IBaseLabelProvider fLabelProvider; protected ListViewerAdapter fListViewerAdapter; - protected List fElements; + protected List<T> fElements; protected ViewerComparator fViewerComparator; protected String[] fButtonLabels; @@ -107,7 +106,7 @@ public class ListDialogField extends DialogField { private Composite fButtonsControl; private ISelection fSelectionWhenEnabled; - private IListAdapter fListAdapter; + private IListAdapter<T> fListAdapter; private Object fParentElement; @@ -122,7 +121,7 @@ public class ListDialogField extends DialogField { * marks a separator. * @param lprovider The label provider to render the table entries */ - public ListDialogField(IListAdapter adapter, String[] buttonLabels, IBaseLabelProvider lprovider) { + public ListDialogField(IListAdapter<T> adapter, String[] buttonLabels, IBaseLabelProvider lprovider) { super(); fListAdapter= adapter; @@ -130,7 +129,7 @@ public class ListDialogField extends DialogField { fListViewerAdapter= new ListViewerAdapter(); fParentElement= this; - fElements= new ArrayList(10); + fElements= new ArrayList<T>(10); fButtonLabels= buttonLabels; if (fButtonLabels != null) { @@ -542,8 +541,8 @@ public class ListDialogField extends DialogField { /** * Sets the elements shown in the list. */ - public void setElements(List elements) { - fElements= new ArrayList(elements); + public void setElements(List<? extends T> elements) { + fElements= new ArrayList<T>(elements); if (fTable != null) { fTable.refresh(); } @@ -554,14 +553,14 @@ public class ListDialogField extends DialogField { * Gets the elements shown in the list. * The list returned is a copy, so it can be modified by the user. */ - public List getElements() { - return new ArrayList(fElements); + public List<T> getElements() { + return new ArrayList<T>(fElements); } /** * Gets the elements shown at the given index. */ - public Object getElement(int index) { + public T getElement(int index) { return fElements.get(index); } @@ -575,12 +574,12 @@ public class ListDialogField extends DialogField { /** * Replace an element. */ - public void replaceElement(Object oldElement, Object newElement) throws IllegalArgumentException { + public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException { int idx= fElements.indexOf(oldElement); if (idx != -1) { fElements.set(idx, newElement); if (fTable != null) { - List selected= getSelectedElements(); + List<T> selected= getSelectedElements(); if (selected.remove(oldElement)) { selected.add(newElement); } @@ -596,7 +595,7 @@ public class ListDialogField extends DialogField { /** * Adds an element at the end of the list. */ - public void addElement(Object element) { + public void addElement(T element) { if (fElements.contains(element)) { return; } @@ -610,15 +609,15 @@ public class ListDialogField extends DialogField { /** * Adds elements at the end of the list. */ - public void addElements(List elements) { + public void addElements(List<? extends T> elements) { int nElements= elements.size(); if (nElements > 0) { // filter duplicated - ArrayList elementsToAdd= new ArrayList(nElements); + ArrayList<T> elementsToAdd= new ArrayList<T>(nElements); for (int i= 0; i < nElements; i++) { - Object elem= elements.get(i); + T elem= elements.get(i); if (!fElements.contains(elem)) { elementsToAdd.add(elem); } @@ -634,7 +633,7 @@ public class ListDialogField extends DialogField { /** * Adds an element at a position. */ - public void insertElementAt(Object element, int index) { + public void insertElementAt(T element, int index) { if (fElements.contains(element)) { return; } @@ -677,7 +676,7 @@ public class ListDialogField extends DialogField { /** * Removes elements from the list. */ - public void removeElements(List elements) { + public void removeElements(List<? extends T> elements) { if (elements.size() > 0) { fElements.removeAll(elements); if (fTable != null) { @@ -745,12 +744,12 @@ public class ListDialogField extends DialogField { // ------- list maintenance - private List moveUp(List elements, List move) { + private List<T> moveUp(List<? extends T> elements, List<? extends T> move) { int nElements= elements.size(); - List res= new ArrayList(nElements); - Object floating= null; + List<T> res= new ArrayList<T>(nElements); + T floating= null; for (int i= 0; i < nElements; i++) { - Object curr= elements.get(i); + T curr= elements.get(i); if (move.contains(curr)) { res.add(curr); } else { @@ -766,22 +765,22 @@ public class ListDialogField extends DialogField { return res; } - private void moveUp(List toMoveUp) { + private void moveUp(List<? extends T> toMoveUp) { if (toMoveUp.size() > 0) { setElements(moveUp(fElements, toMoveUp)); fTable.reveal(toMoveUp.get(0)); } } - private void moveDown(List toMoveDown) { + private void moveDown(List<? extends T> toMoveDown) { if (toMoveDown.size() > 0) { setElements(reverse(moveUp(reverse(fElements), toMoveDown))); fTable.reveal(toMoveDown.get(toMoveDown.size() - 1)); } } - private List reverse(List p) { - List reverse= new ArrayList(p.size()); + private List<T> reverse(List<? extends T> p) { + List<T> reverse= new ArrayList<T>(p.size()); for (int i= p.size()-1; i >= 0; i--) { reverse.add(p.get(i)); } @@ -829,12 +828,13 @@ public class ListDialogField extends DialogField { /** * Returns the selected elements. */ - public List getSelectedElements() { - List result= new ArrayList(); + public List<T> getSelectedElements() { + List<T> result= new ArrayList<T>(); if (fTable != null) { ISelection selection= fTable.getSelection(); if (selection instanceof IStructuredSelection) { - Iterator iter= ((IStructuredSelection)selection).iterator(); + @SuppressWarnings("unchecked") + Iterator<T> iter= ((IStructuredSelection)selection).iterator(); while (iter.hasNext()) { result.add(iter.next()); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java index 7a0695a9a76..60b53a82a8f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/TreeListDialogField.java @@ -15,20 +15,6 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.KeyAdapter; -import org.eclipse.swt.events.KeyEvent; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Tree; - import org.eclipse.core.runtime.Assert; import org.eclipse.jface.viewers.DoubleClickEvent; import org.eclipse.jface.viewers.IDoubleClickListener; @@ -43,6 +29,19 @@ import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Tree; import org.eclipse.cdt.internal.ui.util.PixelConverter; import org.eclipse.cdt.internal.ui.util.SWTUtil; @@ -57,7 +56,7 @@ public class TreeListDialogField extends DialogField { protected TreeViewer fTree; protected ILabelProvider fLabelProvider; protected TreeViewerAdapter fTreeViewerAdapter; - protected List fElements; + protected List<Object> fElements; protected ViewerComparator fViewerComparator; protected String[] fButtonLabels; @@ -92,7 +91,7 @@ public class TreeListDialogField extends DialogField { fTreeViewerAdapter = new TreeViewerAdapter(); fParentElement = this; - fElements = new ArrayList(10); + fElements = new ArrayList<Object>(10); fButtonLabels = buttonLabels; if (fButtonLabels != null) { @@ -452,7 +451,7 @@ public class TreeListDialogField extends DialogField { } } - protected boolean containsAttributes(List selected) { + protected boolean containsAttributes(List<Object> selected) { for (int i = 0; i < selected.size(); i++) { if (!fElements.contains(selected.get(i))) { return true; @@ -462,7 +461,7 @@ public class TreeListDialogField extends DialogField { } protected boolean getManagedButtonState(ISelection sel, int index) { - List selected = getSelectedElements(); + List<Object> selected = getSelectedElements(); boolean hasAttributes = containsAttributes(selected); if (index == fRemoveButtonIndex) { return !selected.isEmpty() && !hasAttributes; @@ -515,8 +514,8 @@ public class TreeListDialogField extends DialogField { /** * Sets the elements shown in the list. */ - public void setElements(List elements) { - fElements = new ArrayList(elements); + public void setElements(List<Object> elements) { + fElements = new ArrayList<Object>(elements); refresh(); if (fTree != null) { fTree.expandToLevel(fTreeExpandLevel); @@ -528,8 +527,8 @@ public class TreeListDialogField extends DialogField { * Gets the elements shown in the list. The list returned is a copy, so it * can be modified by the user. */ - public List getElements() { - return new ArrayList(fElements); + public List<Object> getElements() { + return new ArrayList<Object>(fElements); } /** @@ -554,7 +553,7 @@ public class TreeListDialogField extends DialogField { if (idx != -1) { fElements.set(idx, newElement); if (fTree != null) { - List selected = getSelectedElements(); + List<Object> selected = getSelectedElements(); if (selected.remove(oldElement)) { selected.add(newElement); } @@ -590,12 +589,12 @@ public class TreeListDialogField extends DialogField { /** * Adds elements at the end of the tree list. */ - public void addElements(List elements) { + public void addElements(List<Object> elements) { int nElements = elements.size(); if (nElements > 0) { // filter duplicated - ArrayList elementsToAdd = new ArrayList(nElements); + ArrayList<Object> elementsToAdd = new ArrayList<Object>(nElements); for (int i = 0; i < nElements; i++) { Object elem = elements.get(i); @@ -660,7 +659,7 @@ public class TreeListDialogField extends DialogField { /** * Removes elements from the list. */ - public void removeElements(List elements) { + public void removeElements(List<Object> elements) { if (elements.size() > 0) { fElements.removeAll(elements); if (fTree != null) { @@ -736,9 +735,9 @@ public class TreeListDialogField extends DialogField { // ------- list maintenance - private List moveUp(List elements, List move) { + private List<Object> moveUp(List<Object> elements, List<Object> move) { int nElements = elements.size(); - List res = new ArrayList(nElements); + List<Object> res = new ArrayList<Object>(nElements); Object floating = null; for (int i = 0; i < nElements; i++) { Object curr = elements.get(i); @@ -757,22 +756,22 @@ public class TreeListDialogField extends DialogField { return res; } - private void moveUp(List toMoveUp) { + private void moveUp(List<Object> toMoveUp) { if (toMoveUp.size() > 0) { setElements(moveUp(fElements, toMoveUp)); fTree.reveal(toMoveUp.get(0)); } } - private void moveDown(List toMoveDown) { + private void moveDown(List<Object> toMoveDown) { if (toMoveDown.size() > 0) { setElements(reverse(moveUp(reverse(fElements), toMoveDown))); fTree.reveal(toMoveDown.get(toMoveDown.size() - 1)); } } - private List reverse(List p) { - List reverse = new ArrayList(p.size()); + private List<Object> reverse(List<Object> p) { + List<Object> reverse = new ArrayList<Object>(p.size()); for (int i = p.size() - 1; i >= 0; i--) { reverse.add(p.get(i)); } @@ -791,7 +790,7 @@ public class TreeListDialogField extends DialogField { moveDown(getSelectedElements()); } - private boolean canMoveUp(List selectedElements) { + private boolean canMoveUp(List<Object> selectedElements) { if (isOkToUse(fTreeControl)) { int nSelected = selectedElements.size(); int nElements = fElements.size(); @@ -805,7 +804,7 @@ public class TreeListDialogField extends DialogField { return false; } - private boolean canMoveDown(List selectedElements) { + private boolean canMoveDown(List<Object> selectedElements) { if (isOkToUse(fTreeControl)) { int nSelected = selectedElements.size(); for (int i = fElements.size() - 1; i >= 0 && nSelected > 0; i--) { @@ -821,12 +820,13 @@ public class TreeListDialogField extends DialogField { /** * Returns the selected elements. */ - public List getSelectedElements() { - ArrayList result = new ArrayList(); + public List<Object> getSelectedElements() { + ArrayList<Object> result = new ArrayList<Object>(); if (fTree != null) { ISelection selection = fTree.getSelection(); if (selection instanceof IStructuredSelection) { - Iterator iter = ((IStructuredSelection) selection).iterator(); + @SuppressWarnings("unchecked") + Iterator<Object> iter = ((IStructuredSelection) selection).iterator(); while (iter.hasNext()) { result.add(iter.next()); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java index 5ac07cfaa08..d8a0405fc92 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionContributor.java @@ -37,6 +37,7 @@ public interface ICompletionContributor { * @param proposals the current list of proposals. This method should add any additional * proposals to this list. */ + @SuppressWarnings("unchecked") // no need to change, it's deprecated void contributeCompletionProposals(ITextViewer viewer, int offset, IWorkingCopy workingCopy, diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionProposalComputer.java index a54ca6ef9ed..8460efd38db 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionProposalComputer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/contentassist/ICompletionProposalComputer.java @@ -14,7 +14,6 @@ package org.eclipse.cdt.ui.text.contentassist; import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; - import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContextInformation; @@ -43,7 +42,7 @@ public interface ICompletionProposalComputer { * invocation, i.e. there is no need for the receiver to spawn a sub monitor. * @return a list of completion proposals (element type: {@link ICompletionProposal}) */ - List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor); + List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor); /** * Returns context information objects valid at the given invocation context. @@ -53,7 +52,7 @@ public interface ICompletionProposalComputer { * invocation, i.e. there is no need for the receiver to spawn a sub monitor. * @return a list of context information objects (element type: {@link IContextInformation}) */ - List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor); + List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor); /** * Returns the reason why this computer was unable to produce any completion proposals or |