1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-09 18:56:02 +02:00

Fix warnings.

This commit is contained in:
Markus Schorn 2008-04-11 09:27:01 +00:00
parent 026c8371f8
commit b681d5978e
59 changed files with 608 additions and 637 deletions

View file

@ -65,7 +65,6 @@ public class DefaultCodeFormatterConstants {
* </pre> * </pre>
* @see #FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST * @see #FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST
* @see #FORMATTER_BRACE_POSITION_FOR_BLOCK * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
* @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
* @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
* @see #FORMATTER_BRACE_POSITION_FOR_SWITCH * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
* @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
@ -2063,7 +2062,6 @@ public class DefaultCodeFormatterConstants {
* </pre> * </pre>
* @see #FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST * @see #FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST
* @see #FORMATTER_BRACE_POSITION_FOR_BLOCK * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
* @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
* @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
* @see #FORMATTER_BRACE_POSITION_FOR_SWITCH * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
* @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
@ -2076,7 +2074,6 @@ public class DefaultCodeFormatterConstants {
* </pre> * </pre>
* @see #FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST * @see #FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST
* @see #FORMATTER_BRACE_POSITION_FOR_BLOCK * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
* @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
* @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
* @see #FORMATTER_BRACE_POSITION_FOR_SWITCH * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
* @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
@ -2089,7 +2086,6 @@ public class DefaultCodeFormatterConstants {
* </pre> * </pre>
* @see #FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST * @see #FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST
* @see #FORMATTER_BRACE_POSITION_FOR_BLOCK * @see #FORMATTER_BRACE_POSITION_FOR_BLOCK
* @see #FORMATTER_BRACE_POSITION_FOR_CONSTRUCTOR_DECLARATION
* @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION * @see #FORMATTER_BRACE_POSITION_FOR_METHOD_DECLARATION
* @see #FORMATTER_BRACE_POSITION_FOR_SWITCH * @see #FORMATTER_BRACE_POSITION_FOR_SWITCH
* @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION * @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
@ -2194,7 +2190,7 @@ public class DefaultCodeFormatterConstants {
* *
* @return the default settings * @return the default settings
*/ */
public static Map getDefaultSettings() { public static Map<String,String> getDefaultSettings() {
return DefaultCodeFormatterOptions.getDefaultSettings().getMap(); return DefaultCodeFormatterOptions.getDefaultSettings().getMap();
} }
@ -2203,7 +2199,7 @@ public class DefaultCodeFormatterConstants {
* *
* @return the K&R settings * @return the K&R settings
*/ */
public static Map getKandRSettings() { public static Map<String,String> getKandRSettings() {
return DefaultCodeFormatterOptions.getKandRSettings().getMap(); return DefaultCodeFormatterOptions.getKandRSettings().getMap();
} }
@ -2212,7 +2208,7 @@ public class DefaultCodeFormatterConstants {
* *
* @return the Allman settings * @return the Allman settings
*/ */
public static Map getAllmanSettings() { public static Map<String,String> getAllmanSettings() {
return DefaultCodeFormatterOptions.getAllmanSettings().getMap(); return DefaultCodeFormatterOptions.getAllmanSettings().getMap();
} }
@ -2221,7 +2217,7 @@ public class DefaultCodeFormatterConstants {
* *
* @return the GNU settings * @return the GNU settings
*/ */
public static Map getGNUSettings() { public static Map<String,String> getGNUSettings() {
return DefaultCodeFormatterOptions.getGNUSettings().getMap(); return DefaultCodeFormatterOptions.getGNUSettings().getMap();
} }
@ -2230,7 +2226,7 @@ public class DefaultCodeFormatterConstants {
* *
* @return the Whitesmiths settings * @return the Whitesmiths settings
*/ */
public static Map getWhitesmithsSettings() { public static Map<String,String> getWhitesmithsSettings() {
return DefaultCodeFormatterOptions.getWhitesmithsSettings().getMap(); return DefaultCodeFormatterOptions.getWhitesmithsSettings().getMap();
} }

View file

@ -15,8 +15,8 @@ package org.eclipse.cdt.internal.formatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.cdt.internal.formatter.align.Alignment; import org.eclipse.cdt.internal.formatter.align.Alignment;
@ -246,7 +246,7 @@ public class DefaultCodeFormatterOptions {
// cannot be instantiated // cannot be instantiated
} }
public DefaultCodeFormatterOptions(Map settings) { public DefaultCodeFormatterOptions(Map<String,String> settings) {
setDefaultSettings(); setDefaultSettings();
if (settings == null) return; if (settings == null) return;
set(settings); set(settings);
@ -256,8 +256,8 @@ public class DefaultCodeFormatterOptions {
return Integer.toString(alignment); return Integer.toString(alignment);
} }
public Map getMap() { public Map<String,String> getMap() {
Map options = new HashMap(); Map<String,String> options = new HashMap<String,String>();
// options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION, getAlignment(this.alignment_for_arguments_in_allocation_expression)); // options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION, getAlignment(this.alignment_for_arguments_in_allocation_expression));
options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, getAlignment(this.alignment_for_arguments_in_method_invocation)); options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_METHOD_INVOCATION, getAlignment(this.alignment_for_arguments_in_method_invocation));
// options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, getAlignment(this.alignment_for_assignment)); // options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, getAlignment(this.alignment_for_assignment));
@ -449,7 +449,7 @@ public class DefaultCodeFormatterOptions {
return options; return options;
} }
public void set(Map settings) { public void set(Map<String,String> settings) {
// final Object alignmentForArgumentsInAllocationExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION); // final Object alignmentForArgumentsInAllocationExpressionOption = settings.get(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ARGUMENTS_IN_ALLOCATION_EXPRESSION);
// if (alignmentForArgumentsInAllocationExpressionOption != null) { // if (alignmentForArgumentsInAllocationExpressionOption != null) {
// try { // try {
@ -1571,7 +1571,7 @@ public class DefaultCodeFormatterOptions {
* } * }
* } * }
* </pre> * </pre>
* @see http://en.wikipedia.org/wiki/Indent_style * @see "http://en.wikipedia.org/wiki/Indent_style"
*/ */
public void setKandRSettings() { public void setKandRSettings() {
setDefaultSettings(); setDefaultSettings();
@ -1595,7 +1595,7 @@ public class DefaultCodeFormatterOptions {
* } * }
* } * }
* </pre> * </pre>
* @see http://en.wikipedia.org/wiki/Indent_style * @see "http://en.wikipedia.org/wiki/Indent_style"
*/ */
public void setAllmanSettings() { public void setAllmanSettings() {
setDefaultSettings(); setDefaultSettings();
@ -1661,7 +1661,7 @@ public class DefaultCodeFormatterOptions {
* } * }
* } * }
* </pre> * </pre>
* @see http://en.wikipedia.org/wiki/Indent_style * @see "http://en.wikipedia.org/wiki/Indent_style"
*/ */
public void setGNUSettings() { public void setGNUSettings() {
setDefaultSettings(); setDefaultSettings();
@ -1732,7 +1732,7 @@ public class DefaultCodeFormatterOptions {
* } * }
* } * }
* </pre> * </pre>
* @see http://en.wikipedia.org/wiki/Indent_style * @see "http://en.wikipedia.org/wiki/Indent_style"
*/ */
public void setWhitesmitsSettings() { public void setWhitesmitsSettings() {
setDefaultSettings(); setDefaultSettings();

View file

@ -20,9 +20,9 @@ import org.eclipse.jface.text.source.IAnnotationModel;
/** /**
* Filters problems based on their types. * Filters problems based on their types.
*/ */
public class CAnnotationIterator implements Iterator { public class CAnnotationIterator implements Iterator<Annotation> {
private Iterator fIterator; private Iterator<Annotation> fIterator;
private Annotation fNext; private Annotation fNext;
private boolean fSkipIrrelevants; private boolean fSkipIrrelevants;
private boolean fReturnAllAnnotations; private boolean fReturnAllAnnotations;
@ -40,6 +40,7 @@ public class CAnnotationIterator implements Iterator {
* @param skipIrrelevants whether to skip irrelevant annotations * @param skipIrrelevants whether to skip irrelevant annotations
* @param returnAllAnnotations Whether to return non IJavaAnnotations as well * @param returnAllAnnotations Whether to return non IJavaAnnotations as well
*/ */
@SuppressWarnings("unchecked") // using api without generics
public CAnnotationIterator(IAnnotationModel model, boolean skipIrrelevants, boolean returnAllAnnotations) { public CAnnotationIterator(IAnnotationModel model, boolean skipIrrelevants, boolean returnAllAnnotations) {
fReturnAllAnnotations= returnAllAnnotations; fReturnAllAnnotations= returnAllAnnotations;
if (model != null) if (model != null)
@ -52,7 +53,7 @@ public class CAnnotationIterator implements Iterator {
private void skip() { private void skip() {
while (fIterator.hasNext()) { while (fIterator.hasNext()) {
Annotation next= (Annotation) fIterator.next(); Annotation next= fIterator.next();
if (next instanceof ICAnnotation) { if (next instanceof ICAnnotation) {
if (fSkipIrrelevants) { if (fSkipIrrelevants) {
if (!next.isMarkedDeleted()) { if (!next.isMarkedDeleted()) {
@ -81,7 +82,7 @@ public class CAnnotationIterator implements Iterator {
/* /*
* @see Iterator#next() * @see Iterator#next()
*/ */
public Object next() { public Annotation next() {
try { try {
return fNext; return fNext;
} finally { } finally {

View file

@ -212,7 +212,7 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
protected ISelection updateSelection(ISelection sel) { protected ISelection updateSelection(ISelection sel) {
final ArrayList<ICElement> newSelection = new ArrayList<ICElement>(); final ArrayList<ICElement> newSelection = new ArrayList<ICElement>();
if (sel instanceof IStructuredSelection) { if (sel instanceof IStructuredSelection) {
final Iterator iter = ((IStructuredSelection) sel).iterator(); final Iterator<?> iter = ((IStructuredSelection) sel).iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
final Object o = iter.next(); final Object o = iter.next();
if (o instanceof ICElement) { if (o instanceof ICElement) {
@ -307,8 +307,8 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
return null; return null;
} }
for (int i = 0; i < children.length; i++) { for (ICElementDelta element2 : children) {
final ICElementDelta d = findElement(unit, children[i]); final ICElementDelta d = findElement(unit, element2);
if (d != null) { if (d != null) {
return d; return d;
} }

View file

@ -580,9 +580,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
private void overlayMarkers(Position position, ProblemAnnotation problemAnnotation) { private void overlayMarkers(Position position, ProblemAnnotation problemAnnotation) {
Object value= getAnnotations(position); Object value= getAnnotations(position);
if (value instanceof List) { if (value instanceof List) {
List list= (List) value; List<?> list= (List<?>) value;
for (Iterator e = list.iterator(); e.hasNext();) for (Object element : list)
setOverlay(e.next(), problemAnnotation); setOverlay(element, problemAnnotation);
} else { } else {
setOverlay(value, problemAnnotation); setOverlay(value, problemAnnotation);
} }
@ -681,7 +681,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
synchronized (getLockObject()) { synchronized (getLockObject()) {
Object cached= fReverseMap.get(position); Object cached= fReverseMap.get(position);
if (cached instanceof List) { if (cached instanceof List) {
List list= (List) cached; List<?> list= (List<?>) cached;
list.remove(annotation); list.remove(annotation);
if (list.size() == 1) { if (list.size() == 1) {
fReverseMap.put(position, list.get(0)); fReverseMap.put(position, list.get(0));
@ -708,8 +708,8 @@ public class CDocumentProvider extends TextFileDocumentProvider {
*/ */
public void modelChanged(IAnnotationModel model) { public void modelChanged(IAnnotationModel model) {
Object[] listeners= fListenerList.getListeners(); Object[] listeners= fListenerList.getListeners();
for (int i= 0; i < listeners.length; i++) { for (Object listener : listeners) {
((IAnnotationModelListener) listeners[i]).modelChanged(model); ((IAnnotationModelListener) listener).modelChanged(model);
} }
} }
@ -718,8 +718,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
*/ */
public void modelChanged(AnnotationModelEvent event) { public void modelChanged(AnnotationModelEvent event) {
Object[] listeners= fListenerList.getListeners(); Object[] listeners= fListenerList.getListeners();
for (int i= 0; i < listeners.length; i++) { for (Object curr : listeners) {
Object curr= listeners[i];
if (curr instanceof IAnnotationModelListenerExtension) { if (curr instanceof IAnnotationModelListenerExtension) {
((IAnnotationModelListenerExtension) curr).modelChanged(event); ((IAnnotationModelListenerExtension) curr).modelChanged(event);
} }
@ -1034,7 +1033,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
*/ */
protected void enableHandlingTemporaryProblems() { protected void enableHandlingTemporaryProblems() {
boolean enable= isHandlingTemporaryProblems(); boolean enable= isHandlingTemporaryProblems();
for (Iterator iter= getFileInfosIterator(); iter.hasNext();) { for (Iterator<?> iter= getFileInfosIterator(); iter.hasNext();) {
FileInfo info= (FileInfo) iter.next(); FileInfo info= (FileInfo) iter.next();
if (info.fModel instanceof IProblemRequestorExtension) { if (info.fModel instanceof IProblemRequestorExtension) {
IProblemRequestorExtension extension= (IProblemRequestorExtension) info.fModel; IProblemRequestorExtension extension= (IProblemRequestorExtension) info.fModel;
@ -1062,7 +1061,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
public void shutdown() { public void shutdown() {
// CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyListener); // CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyListener);
Iterator e = getConnectedElementsIterator(); Iterator<?> e = getConnectedElementsIterator();
while (e.hasNext()) while (e.hasNext())
disconnect(e.next()); disconnect(e.next());
} }

View file

@ -189,12 +189,12 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.ICHelpContextIds;
import org.eclipse.cdt.internal.ui.IContextMenuConstants; import org.eclipse.cdt.internal.ui.IContextMenuConstants;
import org.eclipse.cdt.internal.ui.actions.AddBlockCommentAction; import org.eclipse.cdt.internal.ui.actions.AddBlockCommentAction;
import org.eclipse.cdt.internal.ui.actions.FindWordAction;
import org.eclipse.cdt.internal.ui.actions.FoldingActionGroup; import org.eclipse.cdt.internal.ui.actions.FoldingActionGroup;
import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction; import org.eclipse.cdt.internal.ui.actions.GoToNextPreviousMemberAction;
import org.eclipse.cdt.internal.ui.actions.GotoNextBookmarkAction; import org.eclipse.cdt.internal.ui.actions.GotoNextBookmarkAction;
import org.eclipse.cdt.internal.ui.actions.IndentAction; import org.eclipse.cdt.internal.ui.actions.IndentAction;
import org.eclipse.cdt.internal.ui.actions.RemoveBlockCommentAction; import org.eclipse.cdt.internal.ui.actions.RemoveBlockCommentAction;
import org.eclipse.cdt.internal.ui.actions.FindWordAction;
import org.eclipse.cdt.internal.ui.actions.SelectionConverter; import org.eclipse.cdt.internal.ui.actions.SelectionConverter;
import org.eclipse.cdt.internal.ui.dnd.TextEditorDropAdapter; import org.eclipse.cdt.internal.ui.dnd.TextEditorDropAdapter;
import org.eclipse.cdt.internal.ui.dnd.TextViewerDragAdapter; import org.eclipse.cdt.internal.ui.dnd.TextViewerDragAdapter;
@ -1389,6 +1389,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
/** /**
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class) * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/ */
@SuppressWarnings("unchecked")
@Override @Override
public Object getAdapter(Class required) { public Object getAdapter(Class required) {
if (IContentOutlinePage.class.equals(required)) { if (IContentOutlinePage.class.equals(required)) {
@ -1410,7 +1411,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
ce = null; ce = null;
} }
} catch (CModelException ex) { } catch (CModelException ex) {
ce= null;
} }
final ISelection selection= ce != null ? new StructuredSelection(ce) : null; final ISelection selection= ce != null ? new StructuredSelection(ce) : null;
return new IShowInSource() { return new IShowInSource() {
@ -1582,9 +1582,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
SourceViewerConfiguration configuration= getSourceViewerConfiguration(); SourceViewerConfiguration configuration= getSourceViewerConfiguration();
String[] types= configuration.getConfiguredContentTypes(getSourceViewer()); String[] types= configuration.getConfiguredContentTypes(getSourceViewer());
for (int i= 0; i < types.length; i++) { for (String t : types) {
String t= types[i];
ISourceViewer sourceViewer= getSourceViewer(); ISourceViewer sourceViewer= getSourceViewer();
if (sourceViewer instanceof ITextViewerExtension2) { if (sourceViewer instanceof ITextViewerExtension2) {
@ -1594,8 +1592,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
int[] stateMasks= configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t); int[] stateMasks= configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t);
if (stateMasks != null) { if (stateMasks != null) {
for (int j= 0; j < stateMasks.length; j++) { for (int stateMask : stateMasks) {
int stateMask= stateMasks[j];
ITextHover textHover= configuration.getTextHover(sourceViewer, t, stateMask); ITextHover textHover= configuration.getTextHover(sourceViewer, t, stateMask);
((ITextViewerExtension2)sourceViewer).setTextHover(textHover, t, stateMask); ((ITextViewerExtension2)sourceViewer).setTextHover(textHover, t, stateMask);
} }
@ -2413,9 +2410,9 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
*/ */
private Annotation getAnnotation(int offset, int length) { private Annotation getAnnotation(int offset, int length) {
IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput()); IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
Iterator e = new CAnnotationIterator(model, true, true); Iterator<Annotation> e = new CAnnotationIterator(model, true, true);
while (e.hasNext()) { while (e.hasNext()) {
Annotation a = (Annotation) e.next(); Annotation a = e.next();
if (!isNavigationTarget(a)) if (!isNavigationTarget(a))
continue; continue;
@ -2994,10 +2991,10 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, annotationMap); ((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, annotationMap);
} else { } else {
removeOccurrenceAnnotations(); removeOccurrenceAnnotations();
Iterator iter= annotationMap.entrySet().iterator(); Iterator<Map.Entry<Annotation, Position>> iter= annotationMap.entrySet().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
Map.Entry mapEntry= (Map.Entry)iter.next(); Map.Entry<Annotation, Position> mapEntry= iter.next();
annotationModel.addAnnotation((Annotation)mapEntry.getKey(), (Position)mapEntry.getValue()); annotationModel.addAnnotation(mapEntry.getKey(), mapEntry.getValue());
} }
} }
fOccurrenceAnnotations= annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]); fOccurrenceAnnotations= annotationMap.keySet().toArray(new Annotation[annotationMap.keySet().size()]);
@ -3230,8 +3227,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
if (annotationModel instanceof IAnnotationModelExtension) { if (annotationModel instanceof IAnnotationModelExtension) {
((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null); ((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null);
} else { } else {
for (int i= 0, length= fOccurrenceAnnotations.length; i < length; i++) for (Annotation occurrenceAnnotation : fOccurrenceAnnotations)
annotationModel.removeAnnotation(fOccurrenceAnnotations[i]); annotationModel.removeAnnotation(occurrenceAnnotation);
} }
fOccurrenceAnnotations= null; fOccurrenceAnnotations= null;
} }

View file

@ -154,7 +154,7 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
/* /*
* @see ICAnnotation#getOverlaidIterator() * @see ICAnnotation#getOverlaidIterator()
*/ */
public Iterator getOverlaidIterator() { public Iterator<ICAnnotation> getOverlaidIterator() {
// not supported // not supported
return null; return null;
} }

View file

@ -14,6 +14,7 @@
package org.eclipse.cdt.internal.ui.editor; package org.eclipse.cdt.internal.ui.editor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.preference.IPreferenceStore;
@ -409,11 +410,14 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
public void prependTextPresentationListener(ITextPresentationListener listener) { public void prependTextPresentationListener(ITextPresentationListener listener) {
Assert.isNotNull(listener); Assert.isNotNull(listener);
if (fTextPresentationListeners == null) @SuppressWarnings("unchecked") // using list from base class
fTextPresentationListeners= new ArrayList<ITextPresentationListener>(); List<ITextPresentationListener> textPresentationListeners= fTextPresentationListeners;
fTextPresentationListeners.remove(listener); if (textPresentationListeners == null)
fTextPresentationListeners.add(0, listener); fTextPresentationListeners= textPresentationListeners= new ArrayList<ITextPresentationListener>();
textPresentationListeners.remove(listener);
textPresentationListeners.add(0, listener);
} }
/** /**

View file

@ -178,9 +178,9 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
private DocumentSetCommand fSetCmd= new DocumentSetCommand(); private DocumentSetCommand fSetCmd= new DocumentSetCommand();
private DocumentReplaceCommand fReplaceCmd= new DocumentReplaceCommand(); private DocumentReplaceCommand fReplaceCmd= new DocumentReplaceCommand();
private Set fLegalLineDelimiters; private Set<String> fLegalLineDelimiters;
private List fBufferListeners= new ArrayList(3); private List<IBufferChangedListener> fBufferListeners= new ArrayList<IBufferChangedListener>(3);
private IStatus fStatus; private IStatus fStatus;
final private IPath fLocation; final private IPath fLocation;
@ -451,7 +451,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
if (fLegalLineDelimiters == null) { if (fLegalLineDelimiters == null) {
// collect all line delimiters in the document // collect all line delimiters in the document
HashSet existingDelimiters= new HashSet(); HashSet<String> existingDelimiters= new HashSet<String>();
for (int i= fDocument.getNumberOfLines() - 1; i >= 0; i-- ) { for (int i= fDocument.getNumberOfLines() - 1; i >= 0; i-- ) {
try { try {
@ -509,9 +509,9 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
private void fireBufferChanged(BufferChangedEvent event) { private void fireBufferChanged(BufferChangedEvent event) {
if (fBufferListeners != null && fBufferListeners.size() > 0) { if (fBufferListeners != null && fBufferListeners.size() > 0) {
Iterator e= new ArrayList(fBufferListeners).iterator(); Iterator<IBufferChangedListener> e= new ArrayList<IBufferChangedListener>(fBufferListeners).iterator();
while (e.hasNext()) while (e.hasNext())
((IBufferChangedListener) e.next()).bufferChanged(event); e.next().bufferChanged(event);
} }
} }

View file

@ -85,14 +85,11 @@ public class ExternalSearchDocumentProvider extends TextFileDocumentProvider {
IStorage storage = new EFSFileStorage(uri); IStorage storage = new EFSFileStorage(uri);
return createExternalSearchAnnotationModel(storage, null); return createExternalSearchAnnotationModel(storage, null);
} }
else { ILocationProvider provider = (ILocationProvider) adaptable.getAdapter(ILocationProvider.class);
ILocationProvider provider = (ILocationProvider) adaptable if (provider != null) {
.getAdapter(ILocationProvider.class); IPath path = provider.getPath(element);
if (provider != null) { IStorage storage = new FileStorage(path);
IPath path = provider.getPath(element); return createExternalSearchAnnotationModel(storage, null);
IStorage storage = new FileStorage(path);
return createExternalSearchAnnotationModel(storage, null);
}
} }
} }
return null; return null;

View file

@ -64,9 +64,9 @@ public interface ICAnnotation {
* Returns an iterator for iterating over the * Returns an iterator for iterating over the
* annotation which are overlaid by this annotation. * annotation which are overlaid by this annotation.
* *
* @return an iterator over the overlaid annotaions * @return an iterator over the overlaid annotations
*/ */
Iterator getOverlaidIterator(); Iterator<ICAnnotation> getOverlaidIterator();
/** /**
* Adds the given annotation to the list of * Adds the given annotation to the list of

View file

@ -26,6 +26,7 @@ import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextInputListener; import org.eclipse.jface.text.ITextInputListener;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.TypedPosition; import org.eclipse.jface.text.TypedPosition;
import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Display;
@ -84,7 +85,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
/** The editor this is installed on */ /** The editor this is installed on */
private CEditor fEditor; private CEditor fEditor;
/** The list of currently highlighted positions */ /** The list of currently highlighted positions */
private List fInactiveCodePositions= Collections.EMPTY_LIST; private List<Position> fInactiveCodePositions= Collections.emptyList();
private IDocument fDocument; private IDocument fDocument;
/** /**
@ -161,7 +162,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
} }
if (fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) { if (fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
fLineBackgroundPainter.removeHighlightPositions(fInactiveCodePositions); fLineBackgroundPainter.removeHighlightPositions(fInactiveCodePositions);
fInactiveCodePositions= Collections.EMPTY_LIST; fInactiveCodePositions= Collections.emptyList();
fLineBackgroundPainter= null; fLineBackgroundPainter= null;
} }
if (fEditor != null) { if (fEditor != null) {
@ -195,7 +196,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
if (progressMonitor != null && progressMonitor.isCanceled()) { if (progressMonitor != null && progressMonitor.isCanceled()) {
return; return;
} }
final List newInactiveCodePositions= collectInactiveCodePositions(ast); final List<Position> newInactiveCodePositions= collectInactiveCodePositions(ast);
Runnable updater = new Runnable() { Runnable updater = new Runnable() {
public void run() { public void run() {
if (fEditor != null && fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) { if (fEditor != null && fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
@ -216,23 +217,22 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
* @param translationUnit the {@link IASTTranslationUnit}, may be <code>null</code> * @param translationUnit the {@link IASTTranslationUnit}, may be <code>null</code>
* @return a {@link List} of {@link IRegion}s * @return a {@link List} of {@link IRegion}s
*/ */
private List collectInactiveCodePositions(IASTTranslationUnit translationUnit) { private List<Position> collectInactiveCodePositions(IASTTranslationUnit translationUnit) {
if (translationUnit == null) { if (translationUnit == null) {
return Collections.EMPTY_LIST; return Collections.emptyList();
} }
String fileName = translationUnit.getFilePath(); String fileName = translationUnit.getFilePath();
if (fileName == null) { if (fileName == null) {
return Collections.EMPTY_LIST; return Collections.emptyList();
} }
List positions = new ArrayList(); List<Position> positions = new ArrayList<Position>();
int inactiveCodeStart = -1; int inactiveCodeStart = -1;
boolean inInactiveCode = false; boolean inInactiveCode = false;
Stack inactiveCodeStack = new Stack(); Stack<Boolean> inactiveCodeStack = new Stack<Boolean>();
IASTPreprocessorStatement[] preprocStmts = translationUnit.getAllPreprocessorStatements(); IASTPreprocessorStatement[] preprocStmts = translationUnit.getAllPreprocessorStatements();
for (int i = 0; i < preprocStmts.length; i++) { for (IASTPreprocessorStatement statement : preprocStmts) {
IASTPreprocessorStatement statement = preprocStmts[i];
IASTFileLocation floc= statement.getFileLocation(); IASTFileLocation floc= statement.getFileLocation();
if (floc == null || !fileName.equals(floc.getFileName())) { if (floc == null || !fileName.equals(floc.getFileName())) {
// preprocessor directive is from a different file // preprocessor directive is from a different file
@ -287,7 +287,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
} }
} else if (statement instanceof IASTPreprocessorEndifStatement) { } else if (statement instanceof IASTPreprocessorEndifStatement) {
try { try {
boolean wasInInactiveCode = ((Boolean)inactiveCodeStack.pop()).booleanValue(); boolean wasInInactiveCode = inactiveCodeStack.pop().booleanValue();
if (inInactiveCode && !wasInInactiveCode) { if (inInactiveCode && !wasInInactiveCode) {
int inactiveCodeEnd = floc.getNodeOffset() + floc.getNodeLength(); int inactiveCodeEnd = floc.getNodeOffset() + floc.getNodeLength();
positions.add(createHighlightPosition(inactiveCodeStart, inactiveCodeEnd, true, fHighlightKey)); positions.add(createHighlightPosition(inactiveCodeStart, inactiveCodeEnd, true, fHighlightKey));
@ -337,7 +337,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
if (fEditor != null && fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) { if (fEditor != null && fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
fLineBackgroundPainter.removeHighlightPositions(fInactiveCodePositions); fLineBackgroundPainter.removeHighlightPositions(fInactiveCodePositions);
fInactiveCodePositions= Collections.EMPTY_LIST; fInactiveCodePositions= Collections.emptyList();
} }
} }

View file

@ -330,8 +330,7 @@ public final class IndentUtil {
private static int computeVisualLength(char ch, int tabSize) { private static int computeVisualLength(char ch, int tabSize) {
if (ch == '\t') if (ch == '\t')
return tabSize; return tabSize;
else return 1;
return 1;
} }
/** /**

View file

@ -87,7 +87,7 @@ public class OpenIncludeAction extends Action {
try { try {
IResource res = include.getUnderlyingResource(); IResource res = include.getUnderlyingResource();
ArrayList/*<IPath>*/ filesFound = new ArrayList(4); ArrayList<IPath> filesFound = new ArrayList<IPath>(4);
String fullFileName= include.getFullFileName(); String fullFileName= include.getFullFileName();
if (fullFileName != null) { if (fullFileName != null) {
IPath fullPath= new Path(fullFileName); IPath fullPath= new Path(fullFileName);
@ -144,7 +144,7 @@ public class OpenIncludeAction extends Action {
noElementsFound(); noElementsFound();
fileToOpen= null; fileToOpen= null;
} else if (nElementsFound == 1) { } else if (nElementsFound == 1) {
fileToOpen= (IPath) filesFound.get(0); fileToOpen= filesFound.get(0);
} else { } else {
fileToOpen= chooseFile(filesFound); fileToOpen= chooseFile(filesFound);
} }
@ -198,7 +198,7 @@ public class OpenIncludeAction extends Action {
return ResourcesPlugin.getWorkspace().getRoot(); return ResourcesPlugin.getWorkspace().getRoot();
} }
private void findFile(String[] includePaths, String name, ArrayList list) private void findFile(String[] includePaths, String name, ArrayList<IPath> list)
throws CoreException { throws CoreException {
// in case it is an absolute path // in case it is an absolute path
IPath includeFile= new Path(name); IPath includeFile= new Path(name);
@ -209,14 +209,13 @@ public class OpenIncludeAction extends Action {
return; return;
} }
} }
HashSet foundSet = new HashSet(); HashSet<IPath> foundSet = new HashSet<IPath>();
for (int i = 0; i < includePaths.length; i++) { for (String includePath : includePaths) {
IPath path = PathUtil.getCanonicalPath(new Path(includePaths[i]).append(includeFile)); IPath path = PathUtil.getCanonicalPath(new Path(includePath).append(includeFile));
File file = path.toFile(); File file = path.toFile();
if (file.exists()) { if (file.exists()) {
IPath[] paths = resolveIncludeLink(path); IPath[] paths = resolveIncludeLink(path);
for (int j = 0; j < paths.length; j++) { for (IPath p : paths) {
IPath p = paths[j];
if (foundSet.add(p)) { if (foundSet.add(p)) {
list.add(p); list.add(p);
} }
@ -232,7 +231,7 @@ public class OpenIncludeAction extends Action {
* @param list * @param list
* @throws CoreException * @throws CoreException
*/ */
private void findFile(IContainer parent, final IPath name, final ArrayList list) throws CoreException { private void findFile(IContainer parent, final IPath name, final ArrayList<IPath> list) throws CoreException {
parent.accept(new IResourceProxyVisitor() { parent.accept(new IResourceProxyVisitor() {
public boolean visit(IResourceProxy proxy) throws CoreException { public boolean visit(IResourceProxy proxy) throws CoreException {
@ -254,7 +253,7 @@ public class OpenIncludeAction extends Action {
} }
private IPath chooseFile(ArrayList filesFound) { private IPath chooseFile(ArrayList<IPath> filesFound) {
ILabelProvider renderer= new LabelProvider() { ILabelProvider renderer= new LabelProvider() {
@Override @Override
public String getText(Object element) { public String getText(Object element) {
@ -280,7 +279,7 @@ public class OpenIncludeAction extends Action {
private static IInclude getIncludeStatement(ISelection sel) { private static IInclude getIncludeStatement(ISelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) { if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
List list= ((IStructuredSelection)sel).toList(); List<?> list= ((IStructuredSelection)sel).toList();
if (list.size() == 1) { if (list.size() == 1) {
Object element= list.get(0); Object element= list.get(0);
if (element instanceof IInclude) { if (element instanceof IInclude) {

View file

@ -12,15 +12,16 @@
package org.eclipse.cdt.internal.ui.editor; package org.eclipse.cdt.internal.ui.editor;
import java.util.Iterator; import java.util.Iterator;
import org.eclipse.jface.text.source.IAnnotationModel; import org.eclipse.jface.text.source.IAnnotationModel;
/** /**
* Filters problems based on their types. * Filters problems based on their types.
*/ */
public class ProblemAnnotationIterator implements Iterator { public class ProblemAnnotationIterator implements Iterator<IProblemAnnotation> {
private Iterator fIterator; private Iterator<?> fIterator;
private IProblemAnnotation fNext; private IProblemAnnotation fNext;
public ProblemAnnotationIterator(IAnnotationModel model) { public ProblemAnnotationIterator(IAnnotationModel model) {
@ -49,7 +50,7 @@ public class ProblemAnnotationIterator implements Iterator {
/* /*
* @see Iterator#next() * @see Iterator#next()
*/ */
public Object next() { public IProblemAnnotation next() {
try { try {
return fNext; return fNext;
} finally { } finally {

View file

@ -349,7 +349,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
* @return the hard-coded positions * @return the hard-coded positions
*/ */
private HighlightedPosition[] createHardcodedPositions() { private HighlightedPosition[] createHardcodedPositions() {
List positions= new ArrayList(); List<HighlightedPosition> positions= new ArrayList<HighlightedPosition>();
for (int i= 0; i < fHardcodedRanges.length; i++) { for (int i= 0; i < fHardcodedRanges.length; i++) {
HighlightedRange range= null; HighlightedRange range= null;
HighlightingStyle hl= null; HighlightingStyle hl= null;
@ -364,7 +364,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
if (range != null) if (range != null)
positions.add(fPresenter.createHighlightedPosition(range.getOffset(), range.getLength(), hl)); positions.add(fPresenter.createHighlightedPosition(range.getOffset(), range.getLength(), hl));
} }
return (HighlightedPosition[]) positions.toArray(new HighlightedPosition[positions.size()]); return positions.toArray(new HighlightedPosition[positions.size()]);
} }
/** /**

View file

@ -236,7 +236,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
private CPresentationReconciler fPresentationReconciler; private CPresentationReconciler fPresentationReconciler;
/** UI's current highlighted positions - can contain <code>null</code> elements */ /** UI's current highlighted positions - can contain <code>null</code> elements */
private List fPositions= new ArrayList(); private List<HighlightedPosition> fPositions= new ArrayList<HighlightedPosition>();
/** UI position lock */ /** UI position lock */
private Object fPositionLock= new Object(); private Object fPositionLock= new Object();
@ -267,7 +267,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* *
* @param list The list * @param list The list
*/ */
public void addAllPositions(List list) { public void addAllPositions(List<? super HighlightedPosition> list) {
synchronized (fPositionLock) { synchronized (fPositionLock) {
list.addAll(fPositions); list.addAll(fPositions);
} }
@ -283,7 +283,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param removedPositions the removed positions * @param removedPositions the removed positions
* @return the text presentation or <code>null</code>, if reconciliation should be canceled * @return the text presentation or <code>null</code>, if reconciliation should be canceled
*/ */
public TextPresentation createPresentation(List addedPositions, List removedPositions) { public TextPresentation createPresentation(List<? extends Position> addedPositions, List<? extends Position> removedPositions) {
CSourceViewer sourceViewer= fSourceViewer; CSourceViewer sourceViewer= fSourceViewer;
CPresentationReconciler presentationReconciler= fPresentationReconciler; CPresentationReconciler presentationReconciler= fPresentationReconciler;
if (sourceViewer == null || presentationReconciler == null) if (sourceViewer == null || presentationReconciler == null)
@ -299,13 +299,13 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
int minStart= Integer.MAX_VALUE; int minStart= Integer.MAX_VALUE;
int maxEnd= Integer.MIN_VALUE; int maxEnd= Integer.MIN_VALUE;
for (int i= 0, n= removedPositions.size(); i < n; i++) { for (int i= 0, n= removedPositions.size(); i < n; i++) {
Position position= (Position) removedPositions.get(i); Position position= removedPositions.get(i);
int offset= position.getOffset(); int offset= position.getOffset();
minStart= Math.min(minStart, offset); minStart= Math.min(minStart, offset);
maxEnd= Math.max(maxEnd, offset + position.getLength()); maxEnd= Math.max(maxEnd, offset + position.getLength());
} }
for (int i= 0, n= addedPositions.size(); i < n; i++) { for (int i= 0, n= addedPositions.size(); i < n; i++) {
Position position= (Position) addedPositions.get(i); Position position= addedPositions.get(i);
int offset= position.getOffset(); int offset= position.getOffset();
minStart= Math.min(minStart, offset); minStart= Math.min(minStart, offset);
maxEnd= Math.max(maxEnd, offset + position.getLength()); maxEnd= Math.max(maxEnd, offset + position.getLength());
@ -331,15 +331,13 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param removedPositions the removed positions * @param removedPositions the removed positions
* @return the runnable or <code>null</code>, if reconciliation should be canceled * @return the runnable or <code>null</code>, if reconciliation should be canceled
*/ */
public Runnable createUpdateRunnable(final TextPresentation textPresentation, List addedPositions, List removedPositions) { public Runnable createUpdateRunnable(final TextPresentation textPresentation, List<HighlightedPosition> addedPositions, List<HighlightedPosition> removedPositions) {
if (fSourceViewer == null || textPresentation == null) if (fSourceViewer == null || textPresentation == null)
return null; return null;
// TODO: do clustering of positions and post multiple fast runnables // TODO: do clustering of positions and post multiple fast runnables
final HighlightedPosition[] added= new SemanticHighlightingManager.HighlightedPosition[addedPositions.size()]; final HighlightedPosition[] added= addedPositions.toArray(new HighlightedPosition[addedPositions.size()]);
addedPositions.toArray(added); final HighlightedPosition[] removed= removedPositions.toArray(new HighlightedPosition[removedPositions.size()]);
final SemanticHighlightingManager.HighlightedPosition[] removed= new SemanticHighlightingManager.HighlightedPosition[removedPositions.size()];
removedPositions.toArray(removed);
if (isCanceled()) if (isCanceled())
return null; return null;
@ -381,11 +379,11 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
String positionCategory= getPositionCategory(); String positionCategory= getPositionCategory();
List removedPositionsList= Arrays.asList(removedPositions); List<HighlightedPosition> removedPositionsList= Arrays.asList(removedPositions);
try { try {
synchronized (fPositionLock) { synchronized (fPositionLock) {
List oldPositions= fPositions; List<HighlightedPosition> oldPositions= fPositions;
int newSize= Math.max(fPositions.size() + addedPositions.length - removedPositions.length, 10); int newSize= Math.max(fPositions.size() + addedPositions.length - removedPositions.length, 10);
/* /*
@ -395,15 +393,15 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* removed on the fly. The second of two is the list of added positions. The result * removed on the fly. The second of two is the list of added positions. The result
* is stored in newPositions. * is stored in newPositions.
*/ */
List newPositions= new ArrayList(newSize); List<HighlightedPosition> newPositions= new ArrayList<HighlightedPosition>(newSize);
Position position= null; HighlightedPosition position= null;
Position addedPosition= null; HighlightedPosition addedPosition= null;
for (int i= 0, j= 0, n= oldPositions.size(), m= addedPositions.length; i < n || position != null || j < m || addedPosition != null;) { for (int i= 0, j= 0, n= oldPositions.size(), m= addedPositions.length; i < n || position != null || j < m || addedPosition != null;) {
// loop variant: i + j < old(i + j) // loop variant: i + j < old(i + j)
// a) find the next non-deleted Position from the old list // a) find the next non-deleted Position from the old list
while (position == null && i < n) { while (position == null && i < n) {
position= (Position) oldPositions.get(i++); position= oldPositions.get(i++);
if (position.isDeleted() || contain(removedPositionsList, position)) { if (position.isDeleted() || contain(removedPositionsList, position)) {
document.removePosition(positionCategory, position); document.removePosition(positionCategory, position);
position= null; position= null;
@ -467,7 +465,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param position the position * @param position the position
* @return <code>true</code> iff the positions contain the position * @return <code>true</code> iff the positions contain the position
*/ */
private boolean contain(List positions, Position position) { private boolean contain(List<? extends Position> positions, Position position) {
return indexOf(positions, position) != -1; return indexOf(positions, position) != -1;
} }
@ -477,7 +475,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param position the position * @param position the position
* @return the index * @return the index
*/ */
private int indexOf(List positions, Position position) { private int indexOf(List<? extends Position> positions, Position position) {
int index= computeIndexAtOffset(positions, position.getOffset()); int index= computeIndexAtOffset(positions, position.getOffset());
int size= positions.size(); int size= positions.size();
while (index < size) { while (index < size) {
@ -493,7 +491,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* *
* @param position The position for insertion * @param position The position for insertion
*/ */
private void insertPosition(Position position) { private void insertPosition(HighlightedPosition position) {
int i= computeIndexAfterOffset(fPositions, position.getOffset()); int i= computeIndexAfterOffset(fPositions, position.getOffset());
fPositions.add(i, position); fPositions.add(i, position);
} }
@ -505,12 +503,12 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param offset the offset * @param offset the offset
* @return the index of the last position with an offset greater than the given offset * @return the index of the last position with an offset greater than the given offset
*/ */
private int computeIndexAfterOffset(List positions, int offset) { private int computeIndexAfterOffset(List<? extends Position> positions, int offset) {
int i= -1; int i= -1;
int j= positions.size(); int j= positions.size();
while (j - i > 1) { while (j - i > 1) {
int k= (i + j) >> 1; int k= (i + j) >> 1;
Position position= (Position) positions.get(k); Position position= positions.get(k);
if (position.getOffset() > offset) if (position.getOffset() > offset)
j= k; j= k;
else else
@ -526,12 +524,12 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param offset the offset * @param offset the offset
* @return the index of the last position with an offset equal or greater than the given offset * @return the index of the last position with an offset equal or greater than the given offset
*/ */
private int computeIndexAtOffset(List positions, int offset) { private int computeIndexAtOffset(List<? extends Position> positions, int offset) {
int i= -1; int i= -1;
int j= positions.size(); int j= positions.size();
while (j - i > 1) { while (j - i > 1) {
int k= (i + j) >> 1; int k= (i + j) >> 1;
Position position= (Position) positions.get(k); Position position= positions.get(k);
if (position.getOffset() >= offset) if (position.getOffset() >= offset)
j= k; j= k;
else else
@ -547,18 +545,18 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
IRegion region= textPresentation.getExtent(); IRegion region= textPresentation.getExtent();
int i= computeIndexAtOffset(fPositions, region.getOffset()), n= computeIndexAtOffset(fPositions, region.getOffset() + region.getLength()); int i= computeIndexAtOffset(fPositions, region.getOffset()), n= computeIndexAtOffset(fPositions, region.getOffset() + region.getLength());
if (n - i > 2) { if (n - i > 2) {
List ranges= new ArrayList(n - i); List<StyleRange> ranges= new ArrayList<StyleRange>(n - i);
for (; i < n; i++) { for (; i < n; i++) {
HighlightedPosition position= (HighlightedPosition) fPositions.get(i); HighlightedPosition position= fPositions.get(i);
if (!position.isDeleted()) if (!position.isDeleted())
ranges.add(position.createStyleRange()); ranges.add(position.createStyleRange());
} }
StyleRange[] array= new StyleRange[ranges.size()]; StyleRange[] array= new StyleRange[ranges.size()];
array= (StyleRange[]) ranges.toArray(array); array= ranges.toArray(array);
textPresentation.replaceStyleRanges(array); textPresentation.replaceStyleRanges(array);
} else { } else {
for (; i < n; i++) { for (; i < n; i++) {
HighlightedPosition position= (HighlightedPosition) fPositions.get(i); HighlightedPosition position= fPositions.get(i);
if (!position.isDeleted()) if (!position.isDeleted())
textPresentation.replaceStyleRange(position.createStyleRange()); textPresentation.replaceStyleRange(position.createStyleRange());
} }
@ -682,7 +680,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
*/ */
public void highlightingStyleChanged(HighlightingStyle highlighting) { public void highlightingStyleChanged(HighlightingStyle highlighting) {
for (int i= 0, n= fPositions.size(); i < n; i++) { for (int i= 0, n= fPositions.size(); i < n; i++) {
HighlightedPosition position= (HighlightedPosition) fPositions.get(i); HighlightedPosition position= fPositions.get(i);
if (position.getHighlighting() == highlighting) if (position.getHighlighting() == highlighting)
fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength()); fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength());
} }
@ -696,7 +694,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
fSourceViewer.invalidateTextPresentation(); fSourceViewer.invalidateTextPresentation();
} else { } else {
for (int i= 0, n= fPositions.size(); i < n; i++) { for (int i= 0, n= fPositions.size(); i < n; i++) {
Position position= (Position) fPositions.get(i); Position position= fPositions.get(i);
fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength()); fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength());
} }
} }
@ -711,7 +709,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
* @param highlighting * @param highlighting
*/ */
private void addPositionFromUI(int offset, int length, HighlightingStyle highlighting) { private void addPositionFromUI(int offset, int length, HighlightingStyle highlighting) {
Position position= createHighlightedPosition(offset, length, highlighting); HighlightedPosition position= createHighlightedPosition(offset, length, highlighting);
synchronized (fPositionLock) { synchronized (fPositionLock) {
insertPosition(position); insertPosition(position);
} }

View file

@ -95,8 +95,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
// visit macro definitions // visit macro definitions
IASTPreprocessorMacroDefinition[] macroDefs= tu.getMacroDefinitions(); IASTPreprocessorMacroDefinition[] macroDefs= tu.getMacroDefinitions();
for (int i= 0; i < macroDefs.length; i++) { for (IASTPreprocessorMacroDefinition macroDef : macroDefs) {
IASTPreprocessorMacroDefinition macroDef= macroDefs[i];
if (macroDef.isPartOfTranslationUnitFile()) { if (macroDef.isPartOfTranslationUnitFile()) {
visitNode(macroDef.getName()); visitNode(macroDef.getName());
} }
@ -105,14 +104,12 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
// visit macro expansions // visit macro expansions
IASTPreprocessorMacroExpansion[] macroExps= tu.getMacroExpansions(); IASTPreprocessorMacroExpansion[] macroExps= tu.getMacroExpansions();
for (int i= 0; i < macroExps.length; i++) { for (IASTPreprocessorMacroExpansion macroExp : macroExps) {
IASTPreprocessorMacroExpansion macroExp= macroExps[i];
if (macroExp.isPartOfTranslationUnitFile()) { if (macroExp.isPartOfTranslationUnitFile()) {
IASTName macroRef= macroExp.getMacroReference(); IASTName macroRef= macroExp.getMacroReference();
visitNode(macroRef); visitNode(macroRef);
IASTName[] nestedMacroRefs= macroExp.getNestedMacroReferences(); IASTName[] nestedMacroRefs= macroExp.getNestedMacroReferences();
for (int j= 0; j < nestedMacroRefs.length; j++) { for (IASTName nestedMacroRef : nestedMacroRefs) {
IASTName nestedMacroRef= nestedMacroRefs[j];
visitNode(nestedMacroRef); visitNode(nestedMacroRef);
} }
} }
@ -144,8 +141,8 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
IASTFunctionDefinition functionDef= (IASTFunctionDefinition) declaration; IASTFunctionDefinition functionDef= (IASTFunctionDefinition) declaration;
ICPPASTFunctionTryBlockDeclarator declarator= (ICPPASTFunctionTryBlockDeclarator) functionDef.getDeclarator(); ICPPASTFunctionTryBlockDeclarator declarator= (ICPPASTFunctionTryBlockDeclarator) functionDef.getDeclarator();
ICPPASTCatchHandler[] catchHandlers= declarator.getCatchHandlers(); ICPPASTCatchHandler[] catchHandlers= declarator.getCatchHandlers();
for (int i = 0; i < catchHandlers.length; i++) { for (ICPPASTCatchHandler catchHandler : catchHandlers) {
catchHandlers[i].accept(this); catchHandler.accept(this);
} }
} }
return PROCESS_CONTINUE; return PROCESS_CONTINUE;
@ -273,7 +270,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
boolean isExisting= false; boolean isExisting= false;
// TODO: use binary search // TODO: use binary search
for (int i= 0, n= fRemovedPositions.size(); i < n; i++) { for (int i= 0, n= fRemovedPositions.size(); i < n; i++) {
HighlightedPosition position= (HighlightedPosition) fRemovedPositions.get(i); HighlightedPosition position= fRemovedPositions.get(i);
if (position == null) if (position == null)
continue; continue;
if (position.isEqual(offset, length, highlighting)) { if (position.isEqual(offset, length, highlighting)) {
@ -285,7 +282,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
} }
if (!isExisting) { if (!isExisting) {
Position position= fJobPresenter.createHighlightedPosition(offset, length, highlighting); HighlightedPosition position= fJobPresenter.createHighlightedPosition(offset, length, highlighting);
fAddedPositions.add(position); fAddedPositions.add(position);
} }
} }
@ -302,9 +299,9 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
private HighlightingStyle[] fHighlightings; private HighlightingStyle[] fHighlightings;
/** Background job's added highlighted positions */ /** Background job's added highlighted positions */
private List<Position> fAddedPositions= new ArrayList<Position>(); private List<HighlightedPosition> fAddedPositions= new ArrayList<HighlightedPosition>();
/** Background job's removed highlighted positions */ /** Background job's removed highlighted positions */
private List<Object> fRemovedPositions= new ArrayList<Object>(); private List<HighlightedPosition> fRemovedPositions= new ArrayList<HighlightedPosition>();
/** Number of removed positions */ /** Number of removed positions */
private int fNOfRemovedPositions; private int fNOfRemovedPositions;
@ -342,8 +339,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
synchronized (fReconcileLock) { synchronized (fReconcileLock) {
if (fIsReconciling) if (fIsReconciling)
return; return;
else fIsReconciling= true;
fIsReconciling= true;
} }
fJobPresenter= fPresenter; fJobPresenter= fPresenter;
fJobSemanticHighlightings= fSemanticHighlightings; fJobSemanticHighlightings= fSemanticHighlightings;
@ -399,10 +395,10 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
*/ */
private void reconcilePositions(IASTTranslationUnit ast, PositionCollector visitor) { private void reconcilePositions(IASTTranslationUnit ast, PositionCollector visitor) {
ast.accept(visitor); ast.accept(visitor);
List<Object> oldPositions= fRemovedPositions; List<HighlightedPosition> oldPositions= fRemovedPositions;
List<Object> newPositions= new ArrayList<Object>(fNOfRemovedPositions); List<HighlightedPosition> newPositions= new ArrayList<HighlightedPosition>(fNOfRemovedPositions);
for (int i= 0, n= oldPositions.size(); i < n; i ++) { for (int i= 0, n= oldPositions.size(); i < n; i ++) {
Object current= oldPositions.get(i); HighlightedPosition current= oldPositions.get(i);
if (current != null) if (current != null)
newPositions.add(current); newPositions.add(current);
} }
@ -421,7 +417,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
* @param addedPositions the added positions * @param addedPositions the added positions
* @param removedPositions the removed positions * @param removedPositions the removed positions
*/ */
private void updatePresentation(TextPresentation textPresentation, List<Position> addedPositions, List<Object> removedPositions) { private void updatePresentation(TextPresentation textPresentation, List<HighlightedPosition> addedPositions, List<HighlightedPosition> removedPositions) {
Runnable runnable= fJobPresenter.createUpdateRunnable(textPresentation, addedPositions, removedPositions); Runnable runnable= fJobPresenter.createUpdateRunnable(textPresentation, addedPositions, removedPositions);
if (runnable == null) if (runnable == null)
return; return;

View file

@ -659,20 +659,19 @@ public class SemanticHighlightings {
// try to derive from AST // try to derive from AST
if (name instanceof ICPPASTQualifiedName) { if (name instanceof ICPPASTQualifiedName) {
return false; return false;
} else { }
node= name.getParent(); node= name.getParent();
while (node instanceof IASTName) { while (node instanceof IASTName) {
node= node.getParent();
}
if (node instanceof IASTFunctionDeclarator) {
while (node != token.getRoot() && !(node.getParent() instanceof IASTDeclSpecifier)) {
node= node.getParent(); node= node.getParent();
} }
if (node instanceof IASTFunctionDeclarator) { if (node instanceof ICPPASTCompositeTypeSpecifier) {
while (node != token.getRoot() && !(node.getParent() instanceof IASTDeclSpecifier)) { return false;
node= node.getParent();
}
if (node instanceof ICPPASTCompositeTypeSpecifier) {
return false;
}
return true;
} }
return true;
} }
} }
} }
@ -1892,8 +1891,8 @@ public class SemanticHighlightings {
return false; return false;
} }
IIndexName[] decls= index.findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACCROSS_LANGUAGE_BOUNDARIES); IIndexName[] decls= index.findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACCROSS_LANGUAGE_BOUNDARIES);
for (int i = 0; i < decls.length; i++) { for (IIndexName decl : decls) {
IIndexFile indexFile= decls[i].getFile(); IIndexFile indexFile= decl.getFile();
if (indexFile != null && indexFile.getLocation().getFullPath() != null) { if (indexFile != null && indexFile.getLocation().getFullPath() != null) {
return false; return false;
} }
@ -2010,8 +2009,7 @@ public class SemanticHighlightings {
store.setDefault(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED, true); store.setDefault(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED, true);
SemanticHighlighting[] semanticHighlightings= getSemanticHighlightings(); SemanticHighlighting[] semanticHighlightings= getSemanticHighlightings();
for (int i= 0, n= semanticHighlightings.length; i < n; i++) { for (SemanticHighlighting semanticHighlighting : semanticHighlightings) {
SemanticHighlighting semanticHighlighting= semanticHighlightings[i];
store.setDefault(SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting), DEBUG || semanticHighlighting.isEnabledByDefault()); store.setDefault(SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting), DEBUG || semanticHighlighting.isEnabledByDefault());
PreferenceConverter.setDefault(store, SemanticHighlightings.getColorPreferenceKey(semanticHighlighting), semanticHighlighting.getDefaultTextColor()); PreferenceConverter.setDefault(store, SemanticHighlightings.getColorPreferenceKey(semanticHighlighting), semanticHighlighting.getDefaultTextColor());
store.setDefault(SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting), semanticHighlighting.isBoldByDefault()); store.setDefault(SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting), semanticHighlighting.isBoldByDefault());
@ -2036,8 +2034,8 @@ public class SemanticHighlightings {
} }
String relevantKey= null; String relevantKey= null;
SemanticHighlighting[] highlightings= getSemanticHighlightings(); SemanticHighlighting[] highlightings= getSemanticHighlightings();
for (int i= 0; i < highlightings.length; i++) { for (SemanticHighlighting highlighting : highlightings) {
if (event.getProperty().equals(getEnabledPreferenceKey(highlightings[i]))) { if (event.getProperty().equals(getEnabledPreferenceKey(highlighting))) {
relevantKey= event.getProperty(); relevantKey= event.getProperty();
break; break;
} }
@ -2045,8 +2043,8 @@ public class SemanticHighlightings {
if (relevantKey == null) if (relevantKey == null)
return false; return false;
for (int i= 0; i < highlightings.length; i++) { for (SemanticHighlighting highlighting : highlightings) {
String key= getEnabledPreferenceKey(highlightings[i]); String key= getEnabledPreferenceKey(highlighting);
if (key.equals(relevantKey)) if (key.equals(relevantKey))
continue; continue;
if (store.getBoolean(key)) if (store.getBoolean(key))
@ -2070,8 +2068,8 @@ public class SemanticHighlightings {
} }
SemanticHighlighting[] highlightings= getSemanticHighlightings(); SemanticHighlighting[] highlightings= getSemanticHighlightings();
boolean enable= false; boolean enable= false;
for (int i= 0; i < highlightings.length; i++) { for (SemanticHighlighting highlighting : highlightings) {
String enabledKey= getEnabledPreferenceKey(highlightings[i]); String enabledKey= getEnabledPreferenceKey(highlighting);
if (store.getBoolean(enabledKey)) { if (store.getBoolean(enabledKey)) {
enable= true; enable= true;
break; break;

View file

@ -50,12 +50,12 @@ public final class SpecificContentAssistExecutor {
* @param categoryId the id of the proposal category to show proposals for * @param categoryId the id of the proposal category to show proposals for
*/ */
public void invokeContentAssist(final ITextEditor editor, String categoryId) { public void invokeContentAssist(final ITextEditor editor, String categoryId) {
Collection categories= fRegistry.getProposalCategories(); Collection<CompletionProposalCategory> categories= fRegistry.getProposalCategories();
boolean[] inclusionState= new boolean[categories.size()]; boolean[] inclusionState= new boolean[categories.size()];
boolean[] separateState= new boolean[categories.size()]; boolean[] separateState= new boolean[categories.size()];
int i= 0; int i= 0;
for (Iterator it= categories.iterator(); it.hasNext(); i++) { for (Iterator<CompletionProposalCategory> it= categories.iterator(); it.hasNext(); i++) {
CompletionProposalCategory cat= (CompletionProposalCategory) it.next(); CompletionProposalCategory cat= it.next();
inclusionState[i]= cat.isIncluded(); inclusionState[i]= cat.isIncluded();
cat.setIncluded(cat.getId().equals(categoryId)); cat.setIncluded(cat.getId().equals(categoryId));
separateState[i]= cat.isSeparateCommand(); separateState[i]= cat.isSeparateCommand();
@ -68,8 +68,8 @@ public final class SpecificContentAssistExecutor {
target.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS); target.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
} finally { } finally {
i= 0; i= 0;
for (Iterator it= categories.iterator(); it.hasNext(); i++) { for (Iterator<CompletionProposalCategory> it= categories.iterator(); it.hasNext(); i++) {
CompletionProposalCategory cat= (CompletionProposalCategory) it.next(); CompletionProposalCategory cat= it.next();
cat.setIncluded(inclusionState[i]); cat.setIncluded(inclusionState[i]);
cat.setSeparateCommand(separateState[i]); cat.setSeparateCommand(separateState[i]);
} }

View file

@ -48,7 +48,7 @@ public final class ToggleCommentAction extends TextEditorAction {
/** The document partitioning */ /** The document partitioning */
private String fDocumentPartitioning; private String fDocumentPartitioning;
/** The comment prefixes */ /** The comment prefixes */
private Map fPrefixesMap; private Map<String, String[]> fPrefixesMap;
/** /**
* Creates and initializes the action for the given text editor. The action * Creates and initializes the action for the given text editor. The action
@ -154,7 +154,7 @@ public final class ToggleCommentAction extends TextEditorAction {
// Perform the check // Perform the check
for (int i = 0, j = 0; i < regions.length; i++, j += 2) { for (int i = 0, j = 0; i < regions.length; i++, j += 2) {
String[] prefixes= (String[]) fPrefixesMap.get(regions[i].getType()); String[] prefixes= fPrefixesMap.get(regions[i].getType());
if (prefixes != null && prefixes.length > 0 && lines[j] >= 0 && lines[j + 1] >= 0) if (prefixes != null && prefixes.length > 0 && lines[j] >= 0 && lines[j + 1] >= 0)
if (!isBlockCommented(lines[j], lines[j + 1], prefixes, document)) if (!isBlockCommented(lines[j], lines[j + 1], prefixes, document))
return false; return false;
@ -308,7 +308,7 @@ public final class ToggleCommentAction extends TextEditorAction {
fPrefixesMap= null; fPrefixesMap= null;
String[] types= configuration.getConfiguredContentTypes(sourceViewer); String[] types= configuration.getConfiguredContentTypes(sourceViewer);
Map prefixesMap= new HashMap(types.length); Map<String, String[]> prefixesMap= new HashMap<String, String[]>(types.length);
for (int i= 0; i < types.length; i++) { for (int i= 0; i < types.length; i++) {
String type= types[i]; String type= types[i];
String[] prefixes= configuration.getDefaultPrefixes(sourceViewer, type); String[] prefixes= configuration.getDefaultPrefixes(sourceViewer, type);

View file

@ -93,7 +93,7 @@ public class ToggleSourceAndHeaderAction extends TextEditorAction {
private IIndex fIndex; private IIndex fIndex;
private IPath fFilePath; private IPath fFilePath;
private Map fMap; private Map<IPath, Counter> fMap;
/** The confidence level == number of hits */ /** The confidence level == number of hits */
private int fConfidence; private int fConfidence;
/** Suspect level == number of no index matches */ /** Suspect level == number of no index matches */
@ -108,7 +108,7 @@ public class ToggleSourceAndHeaderAction extends TextEditorAction {
if (ast != null) { if (ast != null) {
fIndex= ast.getIndex(); fIndex= ast.getIndex();
fFilePath= Path.fromOSString(ast.getFilePath()); fFilePath= Path.fromOSString(ast.getFilePath());
fMap= new HashMap(); fMap= new HashMap<IPath, Counter>();
if (fIndex != null) { if (fIndex != null) {
ast.accept(this); ast.accept(this);
} }
@ -168,7 +168,7 @@ public class ToggleSourceAndHeaderAction extends TextEditorAction {
} }
private void addPotentialPartnerFileLocation(IPath partnerFileLocation) { private void addPotentialPartnerFileLocation(IPath partnerFileLocation) {
Counter counter= (Counter)fMap.get(partnerFileLocation); Counter counter= fMap.get(partnerFileLocation);
if (counter == null) { if (counter == null) {
counter= new Counter(); counter= new Counter();
fMap.put(partnerFileLocation, counter); fMap.put(partnerFileLocation, counter);
@ -291,7 +291,7 @@ public class ToggleSourceAndHeaderAction extends TextEditorAction {
} }
IPath partnerBasePath= sourceFileLocation.removeFileExtension(); IPath partnerBasePath= sourceFileLocation.removeFileExtension();
IContentType[] contentTypes= getPartnerContentTypes(tUnit.getContentTypeId()); IContentType[] contentTypes= getPartnerContentTypes(tUnit.getContentTypeId());
HashSet extensionsTried= new HashSet(); HashSet<String> extensionsTried= new HashSet<String>();
for (int j = 0; j < contentTypes.length; j++) { for (int j = 0; j < contentTypes.length; j++) {
IContentType contentType= contentTypes[j]; IContentType contentType= contentTypes[j];
String[] partnerExtensions; String[] partnerExtensions;

View file

@ -30,7 +30,7 @@ import org.eclipse.ui.IEditorInput;
public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyManagerExtension { public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyManagerExtension {
private CDocumentProvider fDocumentProvider; private CDocumentProvider fDocumentProvider;
private Map fMap; private Map<IEditorInput, IWorkingCopy> fMap;
private boolean fIsShuttingDown; private boolean fIsShuttingDown;
/** /**
@ -80,7 +80,7 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
* @see org.eclipse.cdt.ui.IWorkingCopyManager#getWorkingCopy(org.eclipse.ui.IEditorInput) * @see org.eclipse.cdt.ui.IWorkingCopyManager#getWorkingCopy(org.eclipse.ui.IEditorInput)
*/ */
public IWorkingCopy getWorkingCopy(IEditorInput input) { public IWorkingCopy getWorkingCopy(IEditorInput input) {
IWorkingCopy unit= fMap == null ? null : (IWorkingCopy) fMap.get(input); IWorkingCopy unit= fMap == null ? null : fMap.get(input);
return unit != null ? unit : fDocumentProvider.getWorkingCopy(input); return unit != null ? unit : fDocumentProvider.getWorkingCopy(input);
} }
@ -90,7 +90,7 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
public void setWorkingCopy(IEditorInput input, IWorkingCopy workingCopy) { public void setWorkingCopy(IEditorInput input, IWorkingCopy workingCopy) {
if (fDocumentProvider.getDocument(input) != null) { if (fDocumentProvider.getDocument(input) != null) {
if (fMap == null) if (fMap == null)
fMap= new HashMap(); fMap= new HashMap<IEditorInput, IWorkingCopy>();
fMap.put(input, workingCopy); fMap.put(input, workingCopy);
} }
} }

View file

@ -122,6 +122,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
/* /*
* @see org.eclipse.ui.editors.text.TextEditor#getAdapter(java.lang.Class) * @see org.eclipse.ui.editors.text.TextEditor#getAdapter(java.lang.Class)
*/ */
@SuppressWarnings("unchecked")
@Override @Override
public Object getAdapter(Class adapter) { public Object getAdapter(Class adapter) {
if (IContentOutlinePage.class.equals(adapter)) { if (IContentOutlinePage.class.equals(adapter)) {
@ -268,9 +269,9 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
*/ */
private Annotation getAnnotation(int offset, int length) { private Annotation getAnnotation(int offset, int length) {
IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput()); IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
Iterator e = new CAnnotationIterator(model, true, true); Iterator<Annotation> e = new CAnnotationIterator(model, true, true);
while (e.hasNext()) { while (e.hasNext()) {
Annotation a = (Annotation) e.next(); Annotation a = e.next();
if (!isNavigationTarget(a)) if (!isNavigationTarget(a))
continue; continue;

View file

@ -116,7 +116,7 @@ public class BracesTabPage extends FormatterTabPage {
* @param modifyDialog * @param modifyDialog
* @param workingValues * @param workingValues
*/ */
public BracesTabPage(ModifyDialog modifyDialog, Map workingValues) { public BracesTabPage(ModifyDialog modifyDialog, Map<String,String> workingValues) {
super(modifyDialog, workingValues); super(modifyDialog, workingValues);
} }

View file

@ -96,7 +96,7 @@ public abstract class CPreview {
protected final MarginPainter fMarginPainter; protected final MarginPainter fMarginPainter;
protected Map fWorkingValues; protected Map<String, String> fWorkingValues;
private int fTabSize= 0; private int fTabSize= 0;
private WhitespaceCharacterPainter fWhitespaceCharacterPainter; private WhitespaceCharacterPainter fWhitespaceCharacterPainter;
@ -106,7 +106,7 @@ public abstract class CPreview {
* @param workingValues * @param workingValues
* @param parent * @param parent
*/ */
public CPreview(Map workingValues, Composite parent) { public CPreview(Map<String, String> workingValues, Composite parent) {
CTextTools tools= CUIPlugin.getDefault().getTextTools(); CTextTools tools= CUIPlugin.getDefault().getTextTools();
fPreviewDocument= new Document(); fPreviewDocument= new Document();
fWorkingValues= workingValues; fWorkingValues= workingValues;
@ -141,12 +141,12 @@ public abstract class CPreview {
} }
// update the print margin // update the print margin
final String value= (String)fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT); final String value= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_LINE_SPLIT);
final int lineWidth= getPositiveIntValue(value, 0); final int lineWidth= getPositiveIntValue(value, 0);
fMarginPainter.setMarginRulerColumn(lineWidth); fMarginPainter.setMarginRulerColumn(lineWidth);
// update the tab size // update the tab size
final int tabSize= getPositiveIntValue((String) fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE), 0); final int tabSize= getPositiveIntValue(fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE), 0);
if (tabSize != fTabSize) fSourceViewer.getTextWidget().setTabs(tabSize); if (tabSize != fTabSize) fSourceViewer.getTextWidget().setTabs(tabSize);
fTabSize= tabSize; fTabSize= tabSize;
@ -192,12 +192,12 @@ public abstract class CPreview {
public Map getWorkingValues() { public Map<String, String> getWorkingValues() {
return fWorkingValues; return fWorkingValues;
} }
public void setWorkingValues(Map workingValues) { public void setWorkingValues(Map<String, String> workingValues) {
fWorkingValues= workingValues; fWorkingValues= workingValues;
} }

View file

@ -112,7 +112,7 @@ public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock {
} }
@Override @Override
protected ProfileManager createProfileManager(List profiles, IScopeContext context, PreferencesAccess access, IProfileVersioner profileVersioner) { protected ProfileManager createProfileManager(List<Profile> profiles, IScopeContext context, PreferencesAccess access, IProfileVersioner profileVersioner) {
return new FormatterProfileManager(profiles, context, access, profileVersioner); return new FormatterProfileManager(profiles, context, access, profileVersioner);
} }

View file

@ -78,7 +78,7 @@ public class ControlStatementsTabPage extends FormatterTabPage {
protected CheckboxPreference fThenStatementPref, fSimpleIfPref; protected CheckboxPreference fThenStatementPref, fSimpleIfPref;
public ControlStatementsTabPage(ModifyDialog modifyDialog, Map workingValues) { public ControlStatementsTabPage(ModifyDialog modifyDialog, Map<String, String> workingValues) {
super(modifyDialog, workingValues); super(modifyDialog, workingValues);
} }

View file

@ -17,7 +17,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.cdt.internal.ui.preferences.formatter.IProfileVersioner;
import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.dialogs.StatusDialog; import org.eclipse.jface.dialogs.StatusDialog;
@ -58,7 +57,7 @@ public class CreateProfileDialog extends StatusDialog {
private final static StatusInfo fDuplicate= new StatusInfo(IStatus.ERROR, FormatterMessages.CreateProfileDialog_status_message_profile_with_this_name_already_exists); private final static StatusInfo fDuplicate= new StatusInfo(IStatus.ERROR, FormatterMessages.CreateProfileDialog_status_message_profile_with_this_name_already_exists);
private final ProfileManager fProfileManager; private final ProfileManager fProfileManager;
private final List fSortedProfiles; private final List<Profile> fSortedProfiles;
private final String [] fSortedNames; private final String [] fSortedNames;
private CustomProfile fCreatedProfile; private CustomProfile fCreatedProfile;
@ -187,7 +186,7 @@ public class CreateProfileDialog extends StatusDialog {
CUIPlugin.getDefault().getDialogSettings().put(PREF_OPEN_EDIT_DIALOG, fOpenEditDialog); CUIPlugin.getDefault().getDialogSettings().put(PREF_OPEN_EDIT_DIALOG, fOpenEditDialog);
final Map baseSettings= new HashMap(((Profile)fSortedProfiles.get(fProfileCombo.getSelectionIndex())).getSettings()); final Map<String, String> baseSettings= new HashMap<String, String>((fSortedProfiles.get(fProfileCombo.getSelectionIndex())).getSettings());
final String profileName= fNameText.getText(); final String profileName= fNameText.getText();
fCreatedProfile= new CustomProfile(profileName, baseSettings, fProfileVersioner.getCurrentVersion(), fProfileVersioner.getProfileKind()); fCreatedProfile= new CustomProfile(profileName, baseSettings, fProfileVersioner.getCurrentVersion(), fProfileVersioner.getProfileKind());

View file

@ -105,12 +105,12 @@ public class CustomCodeFormatterBlock extends Observable {
} }
fFormatterCombo.clearSelection(); fFormatterCombo.clearSelection();
fFormatterCombo.setText(DEFAULT); fFormatterCombo.setText(DEFAULT);
Iterator iterator = idMap.entrySet().iterator(); Iterator<Map.Entry<String,String>> iterator = idMap.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry)iterator.next(); Map.Entry<String,String> entry = iterator.next();
String val = (String)entry.getValue(); String val = entry.getValue();
if (val != null && val.equals(fDefaultFormatterId)) { if (val != null && val.equals(fDefaultFormatterId)) {
fFormatterCombo.setText((String)entry.getKey()); fFormatterCombo.setText(entry.getKey());
} }
} }
handleFormatterChanged(); handleFormatterChanged();
@ -175,12 +175,12 @@ public class CustomCodeFormatterBlock extends Observable {
boolean init = false; boolean init = false;
String formatterID= fPrefs.get(CCorePreferenceConstants.CODE_FORMATTER, fDefaultFormatterId); String formatterID= fPrefs.get(CCorePreferenceConstants.CODE_FORMATTER, fDefaultFormatterId);
if (formatterID != null) { if (formatterID != null) {
Iterator iterator = idMap.entrySet().iterator(); Iterator<Map.Entry<String,String>> iterator = idMap.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
Map.Entry entry = (Map.Entry)iterator.next(); Map.Entry<String, String> entry = iterator.next();
String val = (String)entry.getValue(); String val = entry.getValue();
if (val != null && val.equals(formatterID)) { if (val != null && val.equals(formatterID)) {
fFormatterCombo.setText((String)entry.getKey()); fFormatterCombo.setText(entry.getKey());
init = true; init = true;
} }
} }
@ -197,8 +197,8 @@ public class CustomCodeFormatterBlock extends Observable {
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.FORMATTER_EXTPOINT_ID); IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.FORMATTER_EXTPOINT_ID);
if (point != null) { if (point != null) {
IExtension[] exts = point.getExtensions(); IExtension[] exts = point.getExtensions();
for (int i = 0; i < exts.length; i++) { for (IExtension ext : exts) {
IConfigurationElement[] elements = exts[i].getConfigurationElements(); IConfigurationElement[] elements = ext.getConfigurationElements();
for (int j = 0; j < elements.length; ++j) { for (int j = 0; j < elements.length; ++j) {
String name = elements[j].getAttribute(ATTR_NAME); String name = elements[j].getAttribute(ATTR_NAME);
String id= elements[j].getAttribute(ATTR_ID); String id= elements[j].getAttribute(ATTR_ID);

View file

@ -24,7 +24,7 @@ public class FormatterModifyDialog extends ModifyDialog {
} }
@Override @Override
protected void addPages(Map values) { protected void addPages(Map<String, String> values) {
addTabPage(FormatterMessages.ModifyDialog_tabpage_indentation_title, new IndentationTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_indentation_title, new IndentationTabPage(this, values));
addTabPage(FormatterMessages.ModifyDialog_tabpage_braces_title, new BracesTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_braces_title, new BracesTabPage(this, values));
addTabPage(FormatterMessages.ModifyDialog_tabpage_whitespace_title, new WhiteSpaceTabPage(this, values)); addTabPage(FormatterMessages.ModifyDialog_tabpage_whitespace_title, new WhiteSpaceTabPage(this, values));

View file

@ -28,6 +28,8 @@ import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess;
public class FormatterProfileManager extends ProfileManager { public class FormatterProfileManager extends ProfileManager {
private static final List<String> EMPTY_LIST = Collections.emptyList();
public final static String KANDR_PROFILE= "org.eclipse.cdt.ui.default.kandr_profile"; //$NON-NLS-1$ public final static String KANDR_PROFILE= "org.eclipse.cdt.ui.default.kandr_profile"; //$NON-NLS-1$
public final static String ALLMAN_PROFILE= "org.eclipse.cdt.ui.default.allman_profile"; //$NON-NLS-1$ public final static String ALLMAN_PROFILE= "org.eclipse.cdt.ui.default.allman_profile"; //$NON-NLS-1$
public final static String GNU_PROFILE= "org.eclipse.cdt.ui.default.gnu_profile"; //$NON-NLS-1$ public final static String GNU_PROFILE= "org.eclipse.cdt.ui.default.gnu_profile"; //$NON-NLS-1$
@ -36,18 +38,18 @@ public class FormatterProfileManager extends ProfileManager {
public final static String DEFAULT_PROFILE= KANDR_PROFILE; public final static String DEFAULT_PROFILE= KANDR_PROFILE;
private final static KeySet[] KEY_SETS= new KeySet[] { private final static KeySet[] KEY_SETS= new KeySet[] {
new KeySet(CCorePlugin.PLUGIN_ID, new ArrayList(DefaultCodeFormatterConstants.getDefaultSettings().keySet())), new KeySet(CCorePlugin.PLUGIN_ID, new ArrayList<String>(DefaultCodeFormatterConstants.getDefaultSettings().keySet())),
new KeySet(CUIPlugin.PLUGIN_ID, Collections.EMPTY_LIST) new KeySet(CUIPlugin.PLUGIN_ID, EMPTY_LIST)
}; };
private final static String PROFILE_KEY= PreferenceConstants.FORMATTER_PROFILE; private final static String PROFILE_KEY= PreferenceConstants.FORMATTER_PROFILE;
private final static String FORMATTER_SETTINGS_VERSION= "formatter_settings_version"; //$NON-NLS-1$ private final static String FORMATTER_SETTINGS_VERSION= "formatter_settings_version"; //$NON-NLS-1$
public FormatterProfileManager(List profiles, IScopeContext context, PreferencesAccess preferencesAccess, IProfileVersioner profileVersioner) { public FormatterProfileManager(List<Profile> profiles, IScopeContext context, PreferencesAccess preferencesAccess, IProfileVersioner profileVersioner) {
super(addBuiltinProfiles(profiles, profileVersioner), context, preferencesAccess, profileVersioner, KEY_SETS, PROFILE_KEY, FORMATTER_SETTINGS_VERSION); super(addBuiltinProfiles(profiles, profileVersioner), context, preferencesAccess, profileVersioner, KEY_SETS, PROFILE_KEY, FORMATTER_SETTINGS_VERSION);
} }
private static List addBuiltinProfiles(List profiles, IProfileVersioner profileVersioner) { private static List<Profile> addBuiltinProfiles(List<Profile> profiles, IProfileVersioner profileVersioner) {
final Profile kandrProfile= new BuiltInProfile(KANDR_PROFILE, FormatterMessages.ProfileManager_kandr_profile_name, getKandRSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); final Profile kandrProfile= new BuiltInProfile(KANDR_PROFILE, FormatterMessages.ProfileManager_kandr_profile_name, getKandRSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind());
profiles.add(kandrProfile); profiles.add(kandrProfile);
final Profile allmanProfile= new BuiltInProfile(ALLMAN_PROFILE, FormatterMessages.ProfileManager_allman_profile_name, getAllmanSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind()); final Profile allmanProfile= new BuiltInProfile(ALLMAN_PROFILE, FormatterMessages.ProfileManager_allman_profile_name, getAllmanSettings(), 2, profileVersioner.getCurrentVersion(), profileVersioner.getProfileKind());
@ -62,35 +64,35 @@ public class FormatterProfileManager extends ProfileManager {
/** /**
* @return Returns the default settings. * @return Returns the default settings.
*/ */
public static Map getDefaultSettings() { public static Map<String, String> getDefaultSettings() {
return DefaultCodeFormatterConstants.getDefaultSettings(); return DefaultCodeFormatterConstants.getDefaultSettings();
} }
/** /**
* @return Returns the K&R settings. * @return Returns the K&R settings.
*/ */
public static Map getKandRSettings() { public static Map<String, String> getKandRSettings() {
return DefaultCodeFormatterConstants.getKandRSettings(); return DefaultCodeFormatterConstants.getKandRSettings();
} }
/** /**
* @return Returns the ANSI settings. * @return Returns the ANSI settings.
*/ */
public static Map getAllmanSettings() { public static Map<String, String> getAllmanSettings() {
return DefaultCodeFormatterConstants.getAllmanSettings(); return DefaultCodeFormatterConstants.getAllmanSettings();
} }
/** /**
* @return Returns the GNU settings. * @return Returns the GNU settings.
*/ */
public static Map getGNUSettings() { public static Map<String, String> getGNUSettings() {
return DefaultCodeFormatterConstants.getGNUSettings(); return DefaultCodeFormatterConstants.getGNUSettings();
} }
/** /**
* @return Returns the Whitesmiths settings. * @return Returns the Whitesmiths settings.
*/ */
public static Map getWhitesmithsSettings() { public static Map<String, String> getWhitesmithsSettings() {
return DefaultCodeFormatterConstants.getWhitesmithsSettings(); return DefaultCodeFormatterConstants.getWhitesmithsSettings();
} }

View file

@ -21,6 +21,8 @@ import org.osgi.service.prefs.BackingStoreException;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
public class FormatterProfileStore extends ProfileStore { public class FormatterProfileStore extends ProfileStore {
@ -38,7 +40,7 @@ public class FormatterProfileStore extends ProfileStore {
* {@inheritDoc} * {@inheritDoc}
*/ */
@Override @Override
public List readProfiles(IScopeContext scope) throws CoreException { public List<Profile> readProfiles(IScopeContext scope) throws CoreException {
final IEclipsePreferences node= scope.getNode(CUIPlugin.PLUGIN_ID); final IEclipsePreferences node= scope.getNode(CUIPlugin.PLUGIN_ID);
final String profilesValue= node.get(PREF_FORMATTER_PROFILES_OLD, null); final String profilesValue= node.get(PREF_FORMATTER_PROFILES_OLD, null);
if (profilesValue != null) { if (profilesValue != null) {

View file

@ -31,7 +31,7 @@ public abstract class FormatterTabPage extends ModifyDialogTabPage {
private final IDialogSettings fDialogSettings; private final IDialogSettings fDialogSettings;
private Button fShowInvisibleButton; private Button fShowInvisibleButton;
public FormatterTabPage(IModifyDialogTabPage.IModificationListener modifyListener, Map workingValues) { public FormatterTabPage(IModifyDialogTabPage.IModificationListener modifyListener, Map<String, String> workingValues) {
super(modifyListener, workingValues); super(modifyListener, workingValues);
fDialogSettings= CUIPlugin.getDefault().getDialogSettings(); fDialogSettings= CUIPlugin.getDefault().getDialogSettings();

View file

@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.preferences.formatter;
import java.util.Map; import java.util.Map;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Composite;
/** /**
@ -36,7 +35,7 @@ public interface IModifyDialogTabPage {
* *
* @param workingValues the values to work with * @param workingValues the values to work with
*/ */
public void setWorkingValues(Map workingValues); public void setWorkingValues(Map<String, String> workingValues);
/** /**
* A modify listener which must be informed whenever * A modify listener which must be informed whenever

View file

@ -87,7 +87,7 @@ public class IndentationTabPage extends FormatterTabPage {
private TranslationUnitPreview fPreview; private TranslationUnitPreview fPreview;
private String fOldTabChar= null; private String fOldTabChar= null;
public IndentationTabPage(ModifyDialog modifyDialog, Map workingValues) { public IndentationTabPage(ModifyDialog modifyDialog, Map<String,String> workingValues) {
super(modifyDialog, workingValues); super(modifyDialog, workingValues);
} }
@ -110,7 +110,7 @@ public class IndentationTabPage extends FormatterTabPage {
final NumberPreference indentSize= createNumberPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_indent_size, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32); final NumberPreference indentSize= createNumberPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_indent_size, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32);
final NumberPreference tabSize= createNumberPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_tab_size, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32); final NumberPreference tabSize= createNumberPref(generalGroup, numColumns, FormatterMessages.IndentationTabPage_general_group_option_tab_size, DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, 0, 32);
String tabchar= (String) fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR); String tabchar= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR);
updateTabPreferences(tabchar, tabSize, indentSize, onlyForLeading); updateTabPreferences(tabchar, tabSize, indentSize, onlyForLeading);
tabPolicy.addObserver(new Observer() { tabPolicy.addObserver(new Observer() {
public void update(Observable o, Object arg) { public void update(Observable o, Object arg) {
@ -208,8 +208,8 @@ public class IndentationTabPage extends FormatterTabPage {
} }
private void swapTabValues() { private void swapTabValues() {
Object tabSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE); String tabSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
Object indentSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE); String indentSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
fWorkingValues.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, indentSize); fWorkingValues.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, indentSize);
fWorkingValues.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, tabSize); fWorkingValues.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, tabSize);
} }

View file

@ -62,7 +62,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
public final String key; public final String key;
public final String name; public final String name;
public final String previewText; public final String previewText;
public final List children; public final List<Category> children;
public int index; public int index;
@ -70,7 +70,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
this.key= _key; this.key= _key;
this.name= _name; this.name= _name;
this.previewText= _previewText != null ? createPreviewHeader(_name) + _previewText : null; this.previewText= _previewText != null ? createPreviewHeader(_name) + _previewText : null;
children= new ArrayList(); children= new ArrayList<Category>();
} }
/** /**
@ -92,18 +92,18 @@ public class LineWrappingTabPage extends FormatterTabPage {
private final class CategoryListener implements ISelectionChangedListener, IDoubleClickListener { private final class CategoryListener implements ISelectionChangedListener, IDoubleClickListener {
private final List fCategoriesList; private final List<Category> fCategoriesList;
private int fIndex= 0; private int fIndex= 0;
public CategoryListener(List categoriesTree) { public CategoryListener(List<Category> categoriesTree) {
fCategoriesList= new ArrayList(); fCategoriesList= new ArrayList<Category>();
flatten(fCategoriesList, categoriesTree); flatten(fCategoriesList, categoriesTree);
} }
private void flatten(List categoriesList, List categoriesTree) { private void flatten(List<Category> categoriesList, List<Category> categoriesTree) {
for (final Iterator iter= categoriesTree.iterator(); iter.hasNext(); ) { for (Category category2 : categoriesTree) {
final Category category= (Category) iter.next(); final Category category= category2;
category.index= fIndex++; category.index= fIndex++;
categoriesList.add(category); categoriesList.add(category);
flatten(categoriesList, category.children); flatten(categoriesList, category.children);
@ -166,7 +166,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
if (index < 0 || index > fCategoriesList.size() - 1) { if (index < 0 || index > fCategoriesList.size() - 1) {
index= 1; // In order to select a category with preview initially index= 1; // In order to select a category with preview initially
} }
final Category category= (Category)fCategoriesList.get(index); final Category category= fCategoriesList.get(index);
fCategoriesViewer.setSelection(new StructuredSelection(new Category[] {category})); fCategoriesViewer.setSelection(new StructuredSelection(new Category[] {category}));
} }
@ -180,12 +180,12 @@ public class LineWrappingTabPage extends FormatterTabPage {
} }
private class SelectionState { private class SelectionState {
private List fElements= new ArrayList(); private List<Category> fElements= new ArrayList<Category>();
public void refreshState(IStructuredSelection selection) { public void refreshState(IStructuredSelection selection) {
Map wrappingStyleMap= new HashMap(); Map<Object, Integer> wrappingStyleMap= new HashMap<Object, Integer>();
Map indentStyleMap= new HashMap(); Map<Object, Integer> indentStyleMap= new HashMap<Object, Integer>();
Map forceWrappingMap= new HashMap(); Map<Object, Integer> forceWrappingMap= new HashMap<Object, Integer>();
fElements.clear(); fElements.clear();
evaluateElements(selection.iterator()); evaluateElements(selection.iterator());
evaluateMaps(wrappingStyleMap, indentStyleMap, forceWrappingMap); evaluateMaps(wrappingStyleMap, indentStyleMap, forceWrappingMap);
@ -193,45 +193,48 @@ public class LineWrappingTabPage extends FormatterTabPage {
refreshControls(wrappingStyleMap, indentStyleMap, forceWrappingMap); refreshControls(wrappingStyleMap, indentStyleMap, forceWrappingMap);
} }
public List getElements() { public List<Category> getElements() {
return fElements; return fElements;
} }
private void evaluateElements(Iterator iterator) { private void evaluateElements(Iterator<?> iterator) {
Category category; Category category;
String value; String value;
while (iterator.hasNext()) { while (iterator.hasNext()) {
category= (Category) iterator.next(); Object next= iterator.next();
value= (String)fWorkingValues.get(category.key); if (next instanceof Category) {
if (value != null) { category= (Category) next;
if (!fElements.contains(category)) value= fWorkingValues.get(category.key);
fElements.add(category); if (value != null) {
} if (!fElements.contains(category))
else { fElements.add(category);
evaluateElements(category.children.iterator()); }
} else {
evaluateElements(category.children.iterator());
}
}
} }
} }
private void evaluateMaps(Map wrappingStyleMap, Map indentStyleMap, Map forceWrappingMap) { private void evaluateMaps(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap, Map<Object, Integer> forceWrappingMap) {
Iterator iterator= fElements.iterator(); Iterator<Category> iterator= fElements.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
insertIntoMap(wrappingStyleMap, indentStyleMap, forceWrappingMap, (Category)iterator.next()); insertIntoMap(wrappingStyleMap, indentStyleMap, forceWrappingMap, iterator.next());
} }
} }
private String getPreviewText(Map wrappingMap, Map indentMap, Map forceMap) { private String getPreviewText(Map<Object, Integer> wrappingMap, Map<Object, Integer> indentMap, Map<Object, Integer> forceMap) {
Iterator iterator= fElements.iterator(); Iterator<Category> iterator= fElements.iterator();
String previewText= ""; //$NON-NLS-1$ String previewText= ""; //$NON-NLS-1$
while (iterator.hasNext()) { while (iterator.hasNext()) {
Category category= (Category)iterator.next(); Category category= iterator.next();
previewText= previewText + category.previewText + "\n\n"; //$NON-NLS-1$ previewText= previewText + category.previewText + "\n\n"; //$NON-NLS-1$
} }
return previewText; return previewText;
} }
private void insertIntoMap(Map wrappingMap, Map indentMap, Map forceMap, Category category) { private void insertIntoMap(Map<Object, Integer> wrappingMap, Map<Object, Integer> indentMap, Map<Object, Integer> forceMap, Category category) {
final String value= (String)fWorkingValues.get(category.key); final String value= fWorkingValues.get(category.key);
Integer wrappingStyle; Integer wrappingStyle;
Integer indentStyle; Integer indentStyle;
Boolean forceWrapping; Boolean forceWrapping;
@ -251,28 +254,28 @@ public class LineWrappingTabPage extends FormatterTabPage {
increaseMapEntry(forceMap, forceWrapping); increaseMapEntry(forceMap, forceWrapping);
} }
private void increaseMapEntry(Map map, Object type) { private void increaseMapEntry(Map<Object, Integer> map, Object type) {
Integer count= (Integer)map.get(type); Integer count= map.get(type);
if (count == null) // not in map yet -> count == 0 if (count == null) // not in map yet -> count == 0
map.put(type, new Integer(1)); map.put(type, new Integer(1));
else else
map.put(type, new Integer(count.intValue() + 1)); map.put(type, new Integer(count.intValue() + 1));
} }
private void refreshControls(Map wrappingStyleMap, Map indentStyleMap, Map forceWrappingMap) { private void refreshControls(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap, Map<Object, Integer> forceWrappingMap) {
updateCombos(wrappingStyleMap, indentStyleMap); updateCombos(wrappingStyleMap, indentStyleMap);
updateButton(forceWrappingMap); updateButton(forceWrappingMap);
Integer wrappingStyleMax= getWrappingStyleMax(wrappingStyleMap); Integer wrappingStyleMax= getWrappingStyleMax(wrappingStyleMap);
boolean isInhomogeneous= (fElements.size() != ((Integer)wrappingStyleMap.get(wrappingStyleMax)).intValue()); boolean isInhomogeneous= (fElements.size() != wrappingStyleMap.get(wrappingStyleMax).intValue());
updateControlEnablement(isInhomogeneous, wrappingStyleMax.intValue()); updateControlEnablement(isInhomogeneous, wrappingStyleMax.intValue());
doUpdatePreview(); doUpdatePreview();
notifyValuesModified(); notifyValuesModified();
} }
private Integer getWrappingStyleMax(Map wrappingStyleMap) { private Integer getWrappingStyleMax(Map<Object, Integer> wrappingStyleMap) {
int maxCount= 0, maxStyle= 0; int maxCount= 0, maxStyle= 0;
for (int i=0; i<WRAPPING_NAMES.length; i++) { for (int i=0; i<WRAPPING_NAMES.length; i++) {
Integer count= (Integer)wrappingStyleMap.get(new Integer(i)); Integer count= wrappingStyleMap.get(new Integer(i));
if (count == null) if (count == null)
continue; continue;
if (count.intValue() > maxCount) { if (count.intValue() > maxCount) {
@ -283,9 +286,9 @@ public class LineWrappingTabPage extends FormatterTabPage {
return new Integer(maxStyle); return new Integer(maxStyle);
} }
private void updateButton(Map forceWrappingMap) { private void updateButton(Map<Object, Integer> forceWrappingMap) {
Integer nrOfTrue= (Integer)forceWrappingMap.get(Boolean.TRUE); Integer nrOfTrue= forceWrappingMap.get(Boolean.TRUE);
Integer nrOfFalse= (Integer)forceWrappingMap.get(Boolean.FALSE); Integer nrOfFalse= forceWrappingMap.get(Boolean.FALSE);
if (nrOfTrue == null || nrOfFalse == null) if (nrOfTrue == null || nrOfFalse == null)
fForceSplit.setSelection(nrOfTrue != null); fForceSplit.setSelection(nrOfTrue != null);
@ -313,17 +316,17 @@ public class LineWrappingTabPage extends FormatterTabPage {
return nrOfFalse.intValue(); return nrOfFalse.intValue();
} }
private void updateCombos(Map wrappingStyleMap, Map indentStyleMap) { private void updateCombos(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap) {
updateCombo(fWrappingStyleCombo, wrappingStyleMap, WRAPPING_NAMES); updateCombo(fWrappingStyleCombo, wrappingStyleMap, WRAPPING_NAMES);
updateCombo(fIndentStyleCombo, indentStyleMap, INDENT_NAMES); updateCombo(fIndentStyleCombo, indentStyleMap, INDENT_NAMES);
} }
private void updateCombo(Combo combo, Map map, final String[] items) { private void updateCombo(Combo combo, Map<Object, Integer> map, final String[] items) {
String[] newItems= new String[items.length]; String[] newItems= new String[items.length];
int maxCount= 0, maxStyle= 0; int maxCount= 0, maxStyle= 0;
for(int i = 0; i < items.length; i++) { for(int i = 0; i < items.length; i++) {
Integer count= (Integer) map.get(new Integer(i)); Integer count= map.get(new Integer(i));
int val= (count == null) ? 0 : count.intValue(); int val= (count == null) ? 0 : count.intValue();
if (val > maxCount) { if (val > maxCount) {
maxCount= val; maxCount= val;
@ -504,7 +507,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
* A collection containing the categories tree. This is used as model for the tree viewer. * A collection containing the categories tree. This is used as model for the tree viewer.
* @see TreeViewer * @see TreeViewer
*/ */
private final List fCategories; private final List<Category> fCategories;
/** /**
* The category listener which makes the selection persistent. * The category listener which makes the selection persistent.
@ -524,7 +527,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
/** /**
* A special options store wherein the preview line width is kept. * A special options store wherein the preview line width is kept.
*/ */
protected final Map fPreviewPreferences; protected final Map<String,String> fPreviewPreferences;
/** /**
* The key for the preview line width. * The key for the preview line width.
@ -536,14 +539,14 @@ public class LineWrappingTabPage extends FormatterTabPage {
* @param modifyDialog * @param modifyDialog
* @param workingValues * @param workingValues
*/ */
public LineWrappingTabPage(ModifyDialog modifyDialog, Map workingValues) { public LineWrappingTabPage(ModifyDialog modifyDialog, Map<String,String> workingValues) {
super(modifyDialog, workingValues); super(modifyDialog, workingValues);
fDialogSettings= CUIPlugin.getDefault().getDialogSettings(); fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
final String previewLineWidth= fDialogSettings.get(PREF_PREVIEW_LINE_WIDTH); final String previewLineWidth= fDialogSettings.get(PREF_PREVIEW_LINE_WIDTH);
fPreviewPreferences= new HashMap(); fPreviewPreferences= new HashMap<String, String>();
fPreviewPreferences.put(LINE_SPLIT, previewLineWidth != null ? previewLineWidth : Integer.toString(DEFAULT_PREVIEW_WINDOW_LINE_WIDTH)); fPreviewPreferences.put(LINE_SPLIT, previewLineWidth != null ? previewLineWidth : Integer.toString(DEFAULT_PREVIEW_WINDOW_LINE_WIDTH));
fCategories= createCategories(); fCategories= createCategories();
@ -553,7 +556,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
/** /**
* @return Create the categories tree. * @return Create the categories tree.
*/ */
protected List createCategories() { protected List<Category> createCategories() {
final Category classDeclarations= new Category(FormatterMessages.LineWrappingTabPage_class_decls); final Category classDeclarations= new Category(FormatterMessages.LineWrappingTabPage_class_decls);
classDeclarations.children.add(fTypeDeclarationBaseClauseCategory); classDeclarations.children.add(fTypeDeclarationBaseClauseCategory);
@ -587,7 +590,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
// final Category statements= new Category(FormatterMessages.LineWrappingTabPage_statements); // final Category statements= new Category(FormatterMessages.LineWrappingTabPage_statements);
// statements.children.add(fCompactIfCategory); // statements.children.add(fCompactIfCategory);
final List root= new ArrayList(); final List<Category> root= new ArrayList<Category>();
root.add(classDeclarations); root.add(classDeclarations);
// root.add(constructorDeclarations); // root.add(constructorDeclarations);
root.add(methodDeclarations); root.add(methodDeclarations);
@ -614,7 +617,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
fCategoriesViewer= new TreeViewer(composite /*categoryGroup*/, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL ); fCategoriesViewer= new TreeViewer(composite /*categoryGroup*/, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL );
fCategoriesViewer.setContentProvider(new ITreeContentProvider() { fCategoriesViewer.setContentProvider(new ITreeContentProvider() {
public Object[] getElements(Object inputElement) { public Object[] getElements(Object inputElement) {
return ((Collection)inputElement).toArray(); return ((Collection<?>)inputElement).toArray();
} }
public Object[] getChildren(Object parentElement) { public Object[] getChildren(Object parentElement) {
return ((Category)parentElement).children.toArray(); return ((Category)parentElement).children.toArray();
@ -676,7 +679,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
previewLineWidth.addObserver(fUpdater); previewLineWidth.addObserver(fUpdater);
previewLineWidth.addObserver(new Observer() { previewLineWidth.addObserver(new Observer() {
public void update(Observable o, Object arg) { public void update(Observable o, Object arg) {
fDialogSettings.put(PREF_PREVIEW_LINE_WIDTH, (String)fPreviewPreferences.get(LINE_SPLIT)); fDialogSettings.put(PREF_PREVIEW_LINE_WIDTH, fPreviewPreferences.get(LINE_SPLIT));
} }
}); });
@ -734,24 +737,24 @@ public class LineWrappingTabPage extends FormatterTabPage {
*/ */
@Override @Override
protected void doUpdatePreview() { protected void doUpdatePreview() {
final Object normalSetting= fWorkingValues.get(LINE_SPLIT); final String normalSetting= fWorkingValues.get(LINE_SPLIT);
fWorkingValues.put(LINE_SPLIT, fPreviewPreferences.get(LINE_SPLIT)); fWorkingValues.put(LINE_SPLIT, fPreviewPreferences.get(LINE_SPLIT));
fPreview.update(); fPreview.update();
fWorkingValues.put(LINE_SPLIT, normalSetting); fWorkingValues.put(LINE_SPLIT, normalSetting);
} }
protected void setPreviewText(String text) { protected void setPreviewText(String text) {
final Object normalSetting= fWorkingValues.get(LINE_SPLIT); final String normalSetting= fWorkingValues.get(LINE_SPLIT);
fWorkingValues.put(LINE_SPLIT, fPreviewPreferences.get(LINE_SPLIT)); fWorkingValues.put(LINE_SPLIT, fPreviewPreferences.get(LINE_SPLIT));
fPreview.setPreviewText(text); fPreview.setPreviewText(text);
fWorkingValues.put(LINE_SPLIT, normalSetting); fWorkingValues.put(LINE_SPLIT, normalSetting);
} }
protected void forceSplitChanged(boolean forceSplit) { protected void forceSplitChanged(boolean forceSplit) {
Iterator iterator= fSelectionState.fElements.iterator(); Iterator<Category> iterator= fSelectionState.fElements.iterator();
String currentKey; String currentKey;
while (iterator.hasNext()) { while (iterator.hasNext()) {
currentKey= ((Category)iterator.next()).key; currentKey= (iterator.next()).key;
try { try {
changeForceSplit(currentKey, forceSplit); changeForceSplit(currentKey, forceSplit);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@ -764,7 +767,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
} }
private void changeForceSplit(String currentKey, boolean forceSplit) throws IllegalArgumentException{ private void changeForceSplit(String currentKey, boolean forceSplit) throws IllegalArgumentException{
String value= (String)fWorkingValues.get(currentKey); String value= fWorkingValues.get(currentKey);
value= DefaultCodeFormatterConstants.setForceWrapping(value, forceSplit); value= DefaultCodeFormatterConstants.setForceWrapping(value, forceSplit);
if (value == null) if (value == null)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@ -772,10 +775,10 @@ public class LineWrappingTabPage extends FormatterTabPage {
} }
protected void wrappingStyleChanged(int wrappingStyle) { protected void wrappingStyleChanged(int wrappingStyle) {
Iterator iterator= fSelectionState.fElements.iterator(); Iterator<Category> iterator= fSelectionState.fElements.iterator();
String currentKey; String currentKey;
while (iterator.hasNext()) { while (iterator.hasNext()) {
currentKey= ((Category)iterator.next()).key; currentKey= (iterator.next()).key;
try { try {
changeWrappingStyle(currentKey, wrappingStyle); changeWrappingStyle(currentKey, wrappingStyle);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@ -788,7 +791,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
} }
private void changeWrappingStyle(String currentKey, int wrappingStyle) throws IllegalArgumentException { private void changeWrappingStyle(String currentKey, int wrappingStyle) throws IllegalArgumentException {
String value= (String)fWorkingValues.get(currentKey); String value= fWorkingValues.get(currentKey);
value= DefaultCodeFormatterConstants.setWrappingStyle(value, wrappingStyle); value= DefaultCodeFormatterConstants.setWrappingStyle(value, wrappingStyle);
if (value == null) if (value == null)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@ -796,10 +799,10 @@ public class LineWrappingTabPage extends FormatterTabPage {
} }
protected void indentStyleChanged(int indentStyle) { protected void indentStyleChanged(int indentStyle) {
Iterator iterator= fSelectionState.fElements.iterator(); Iterator<Category> iterator= fSelectionState.fElements.iterator();
String currentKey; String currentKey;
while (iterator.hasNext()) { while (iterator.hasNext()) {
currentKey= ((Category)iterator.next()).key; currentKey= iterator.next().key;
try { try {
changeIndentStyle(currentKey, indentStyle); changeIndentStyle(currentKey, indentStyle);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
@ -812,7 +815,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
} }
private void changeIndentStyle(String currentKey, int indentStyle) throws IllegalArgumentException{ private void changeIndentStyle(String currentKey, int indentStyle) throws IllegalArgumentException{
String value= (String)fWorkingValues.get(currentKey); String value= fWorkingValues.get(currentKey);
value= DefaultCodeFormatterConstants.setIndentStyle(value, indentStyle); value= DefaultCodeFormatterConstants.setIndentStyle(value, indentStyle);
if (value == null) if (value == null)
throw new IllegalArgumentException(); throw new IllegalArgumentException();

View file

@ -85,8 +85,8 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
private final ProfileStore fProfileStore; private final ProfileStore fProfileStore;
private final boolean fNewProfile; private final boolean fNewProfile;
private Profile fProfile; private Profile fProfile;
private final Map fWorkingValues; private final Map<String, String> fWorkingValues;
private final List fTabPages; private final List<IModifyDialogTabPage> fTabPages;
private final IDialogSettings fDialogSettings; private final IDialogSettings fDialogSettings;
private TabFolder fTabFolder; private TabFolder fTabFolder;
private final ProfileManager fProfileManager; private final ProfileManager fProfileManager;
@ -112,13 +112,13 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
fProfile= profile; fProfile= profile;
setTitle(Messages.format(FormatterMessages.ModifyDialog_dialog_title, profile.getName())); setTitle(Messages.format(FormatterMessages.ModifyDialog_dialog_title, profile.getName()));
fWorkingValues= new HashMap(fProfile.getSettings()); fWorkingValues= new HashMap<String, String>(fProfile.getSettings());
setStatusLineAboveButtons(false); setStatusLineAboveButtons(false);
fTabPages= new ArrayList(); fTabPages= new ArrayList<IModifyDialogTabPage>();
fDialogSettings= CUIPlugin.getDefault().getDialogSettings(); fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
} }
protected abstract void addPages(Map values); protected abstract void addPages(Map<String, String> values);
@Override @Override
public void create() { public void create() {
@ -261,13 +261,13 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
if (!fProfile.getName().equals(fProfileNameField.getText())) { if (!fProfile.getName().equals(fProfileNameField.getText())) {
fProfile= fProfile.rename(fProfileNameField.getText(), fProfileManager); fProfile= fProfile.rename(fProfileNameField.getText(), fProfileManager);
} }
fProfile.setSettings(new HashMap(fWorkingValues)); fProfile.setSettings(new HashMap<String, String>(fWorkingValues));
fProfileManager.setSelected(fProfile); fProfileManager.setSelected(fProfile);
doValidate(); doValidate();
} }
private void saveButtonPressed() { private void saveButtonPressed() {
Profile selected= new CustomProfile(fProfileNameField.getText(), new HashMap(fWorkingValues), fProfile.getVersion(), fProfileManager.getProfileVersioner().getProfileKind()); Profile selected= new CustomProfile(fProfileNameField.getText(), new HashMap<String, String>(fWorkingValues), fProfile.getVersion(), fProfileManager.getProfileVersioner().getProfileKind());
final FileDialog dialog= new FileDialog(getShell(), SWT.SAVE); final FileDialog dialog= new FileDialog(getShell(), SWT.SAVE);
dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_save_profile_dialog_title); dialog.setText(FormatterMessages.CodingStyleConfigurationBlock_save_profile_dialog_title);
@ -291,7 +291,7 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
final IContentType type= Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.xml"); //$NON-NLS-1$ final IContentType type= Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.xml"); //$NON-NLS-1$
if (type != null) if (type != null)
encoding= type.getDefaultCharset(); encoding= type.getDefaultCharset();
final Collection profiles= new ArrayList(); final Collection<Profile> profiles= new ArrayList<Profile>();
profiles.add(selected); profiles.add(selected);
try { try {
fProfileStore.writeProfilesToFile(profiles, file, encoding); fProfileStore.writeProfilesToFile(profiles, file, encoding);
@ -393,9 +393,9 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
if (!fProfileNameField.getText().trim().equals(fProfile.getName())) if (!fProfileNameField.getText().trim().equals(fProfile.getName()))
return true; return true;
Iterator iter= fProfile.getSettings().entrySet().iterator(); Iterator<Map.Entry<String, String>> iter= fProfile.getSettings().entrySet().iterator();
for (;iter.hasNext();) { for (;iter.hasNext();) {
Map.Entry curr= (Map.Entry) iter.next(); Map.Entry<String, String> curr= iter.next();
if (!fWorkingValues.get(curr.getKey()).equals(curr.getValue())) { if (!fWorkingValues.get(curr.getKey()).equals(curr.getValue())) {
return true; return true;
} }

View file

@ -73,7 +73,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
* On each change, the new value is written to the map and the listeners are notified. * On each change, the new value is written to the map and the listeners are notified.
*/ */
protected abstract class Preference extends Observable { protected abstract class Preference extends Observable {
private final Map fPreferences; private final Map<String, String> fPreferences;
private boolean fEnabled; private boolean fEnabled;
private String fKey; private String fKey;
@ -82,7 +82,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
* @param preferences The map where the value is written. * @param preferences The map where the value is written.
* @param key The key for which a value is managed. * @param key The key for which a value is managed.
*/ */
public Preference(Map preferences, String key) { public Preference(Map<String, String> preferences, String key) {
fPreferences= preferences; fPreferences= preferences;
fEnabled= true; fEnabled= true;
fKey= key; fKey= key;
@ -90,7 +90,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
/** /**
* @return Gets the map of this Preference. * @return Gets the map of this Preference.
*/ */
protected final Map getPreferences() { protected final Map<String, String> getPreferences() {
return fPreferences; return fPreferences;
} }
@ -160,7 +160,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
* @param style SWT style flag for the button * @param style SWT style flag for the button
*/ */
public ButtonPreference(Composite composite, int numColumns, public ButtonPreference(Composite composite, int numColumns,
Map preferences, String key, Map<String, String> preferences, String key,
String [] values, String text, int style) { String [] values, String text, int style) {
super(preferences, key); super(preferences, key);
if (values == null || text == null) if (values == null || text == null)
@ -216,13 +216,13 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
} }
protected final class CheckboxPreference extends ButtonPreference { protected final class CheckboxPreference extends ButtonPreference {
public CheckboxPreference(Composite composite, int numColumns, Map preferences, String key, String[] values, String text) { public CheckboxPreference(Composite composite, int numColumns, Map<String,String> preferences, String key, String[] values, String text) {
super(composite, numColumns, preferences, key, values, text, SWT.CHECK); super(composite, numColumns, preferences, key, values, text, SWT.CHECK);
} }
} }
protected final class RadioPreference extends ButtonPreference { protected final class RadioPreference extends ButtonPreference {
public RadioPreference(Composite composite, int numColumns, Map preferences, String key, String[] values, String text) { public RadioPreference(Composite composite, int numColumns, Map<String,String> preferences, String key, String[] values, String text) {
super(composite, numColumns, preferences, key, values, text, SWT.RADIO); super(composite, numColumns, preferences, key, values, text, SWT.RADIO);
} }
} }
@ -246,7 +246,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
* @param items An array of n elements indicating the text to be written in the combo box. * @param items An array of n elements indicating the text to be written in the combo box.
*/ */
public ComboPreference(Composite composite, int numColumns, public ComboPreference(Composite composite, int numColumns,
Map preferences, String key, Map<String, String> preferences, String key,
String [] values, String text, String [] items) { String [] values, String text, String [] items) {
super(preferences, key); super(preferences, key);
if (values == null || items == null || text == null) if (values == null || items == null || text == null)
@ -259,8 +259,8 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
fCombo.setItems(items); fCombo.setItems(items);
int max= 0; int max= 0;
for (int i= 0; i < items.length; i++) for (String item : items)
if (items[i].length() > max) max= items[i].length(); if (item.length() > max) max= item.length();
fCombo.setLayoutData(createGridData(1, GridData.HORIZONTAL_ALIGN_FILL, fCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x)); fCombo.setLayoutData(createGridData(1, GridData.HORIZONTAL_ALIGN_FILL, fCombo.computeSize(SWT.DEFAULT, SWT.DEFAULT).x));
@ -292,7 +292,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
} }
public String getSelectedItem() { public String getSelectedItem() {
final String selected= (String)getPreferences().get(getKey()); final String selected= getPreferences().get(getKey());
for (int i= 0; i < fValues.length; i++) { for (int i= 0; i < fValues.length; i++) {
if (fValues[i].equals(selected)) { if (fValues[i].equals(selected)) {
return fItems[i]; return fItems[i];
@ -335,7 +335,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
* @param text The label text for this Preference. * @param text The label text for this Preference.
*/ */
public NumberPreference(Composite composite, int numColumns, public NumberPreference(Composite composite, int numColumns,
Map preferences, String key, Map<String, String> preferences, String key,
int minValue, int maxValue, String text) { int minValue, int maxValue, String text) {
super(preferences, key); super(preferences, key);
@ -433,7 +433,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
fNumberText.setEnabled(hasKey && getEnabled()); fNumberText.setEnabled(hasKey && getEnabled());
if (hasKey) { if (hasKey) {
String s= (String)getPreferences().get(getKey()); String s= getPreferences().get(getKey());
try { try {
fSelected= Integer.parseInt(s); fSelected= Integer.parseInt(s);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
@ -470,21 +470,21 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
private final IDialogSettings fDialogSettings; private final IDialogSettings fDialogSettings;
private final Map fItemMap; private final Map<Control, Integer> fItemMap;
private final List fItemList; private final List<Control> fItemList;
private int fIndex; private int fIndex;
public DefaultFocusManager() { public DefaultFocusManager() {
fDialogSettings= CUIPlugin.getDefault().getDialogSettings(); fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
fItemMap= new HashMap(); fItemMap= new HashMap<Control, Integer>();
fItemList= new ArrayList(); fItemList= new ArrayList<Control>();
fIndex= 0; fIndex= 0;
} }
@Override @Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
fDialogSettings.put(PREF_LAST_FOCUS_INDEX, ((Integer)fItemMap.get(e.widget)).intValue()); fDialogSettings.put(PREF_LAST_FOCUS_INDEX, fItemMap.get(e.widget).intValue());
} }
public void add(Control control) { public void add(Control control) {
@ -509,7 +509,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
index= fDialogSettings.getInt(PREF_LAST_FOCUS_INDEX); index= fDialogSettings.getInt(PREF_LAST_FOCUS_INDEX);
// make sure the value is within the range // make sure the value is within the range
if ((index >= 0) && (index <= fItemList.size() - 1)) { if ((index >= 0) && (index <= fItemList.size() - 1)) {
((Control)fItemList.get(index)).setFocus(); fItemList.get(index).setFocus();
} }
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
// this is the first time // this is the first time
@ -546,8 +546,8 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
int x = fMinimalWidth; int x = fMinimalWidth;
int y = fMinimalHight; int y = fMinimalHight;
Control[] children = composite.getChildren(); Control[] children = composite.getChildren();
for (int i = 0; i < children.length; i++) { for (Control element : children) {
Point size = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, force); Point size = element.computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
x = Math.max(x, size.x); x = Math.max(x, size.x);
y = Math.max(y, size.y); y = Math.max(y, size.y);
} }
@ -579,8 +579,8 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
public void layout(Composite composite, boolean force) { public void layout(Composite composite, boolean force) {
Rectangle rect = composite.getClientArea(); Rectangle rect = composite.getClientArea();
Control[] children = composite.getChildren(); Control[] children = composite.getChildren();
for (int i = 0; i < children.length; i++) { for (Control element : children) {
children[i].setSize(rect.width, rect.height); element.setSize(rect.width, rect.height);
} }
} }
} }
@ -606,7 +606,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
/** /**
* The map where the current settings are stored. * The map where the current settings are stored.
*/ */
protected Map fWorkingValues; protected Map<String,String> fWorkingValues;
/** /**
* The modify dialog where we can display status messages. * The modify dialog where we can display status messages.
@ -617,7 +617,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
/* /*
* Create a new <code>ModifyDialogTabPage</code> * Create a new <code>ModifyDialogTabPage</code>
*/ */
public ModifyDialogTabPage(IModifyDialogTabPage.IModificationListener modifyListener, Map workingValues) { public ModifyDialogTabPage(IModifyDialogTabPage.IModificationListener modifyListener, Map<String,String> workingValues) {
fWorkingValues= workingValues; fWorkingValues= workingValues;
fModifyListener= modifyListener; fModifyListener= modifyListener;
fDefaultFocusManager= new DefaultFocusManager(); fDefaultFocusManager= new DefaultFocusManager();
@ -630,7 +630,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */
public void setWorkingValues(Map workingValues) { public void setWorkingValues(Map<String,String> workingValues) {
fWorkingValues= workingValues; fWorkingValues= workingValues;
} }

View file

@ -89,7 +89,7 @@ public abstract class ProfileConfigurationBlock {
class ProfileComboController implements Observer, SelectionListener { class ProfileComboController implements Observer, SelectionListener {
private final List fSortedProfiles; private final List<Profile> fSortedProfiles;
public ProfileComboController() { public ProfileComboController() {
fSortedProfiles= fProfileManager.getSortedProfiles(); fSortedProfiles= fProfileManager.getSortedProfiles();
@ -101,7 +101,7 @@ public abstract class ProfileConfigurationBlock {
public void widgetSelected(SelectionEvent e) { public void widgetSelected(SelectionEvent e) {
final int index= fProfileCombo.getSelectionIndex(); final int index= fProfileCombo.getSelectionIndex();
fProfileManager.setSelected((Profile)fSortedProfiles.get(index)); fProfileManager.setSelected(fSortedProfiles.get(index));
} }
public void widgetDefaultSelected(SelectionEvent e) {} public void widgetDefaultSelected(SelectionEvent e) {}
@ -201,7 +201,7 @@ public abstract class ProfileConfigurationBlock {
CUIPlugin.getDefault().getDialogSettings().put(fLastSaveLoadPathKey + ".loadpath", dialog.getFilterPath()); //$NON-NLS-1$ CUIPlugin.getDefault().getDialogSettings().put(fLastSaveLoadPathKey + ".loadpath", dialog.getFilterPath()); //$NON-NLS-1$
final File file= new File(path); final File file= new File(path);
Collection profiles= null; Collection<Profile> profiles= null;
try { try {
profiles= fProfileStore.readProfilesFromFile(file); profiles= fProfileStore.readProfilesFromFile(file);
} catch (CoreException e) { } catch (CoreException e) {
@ -275,7 +275,7 @@ public abstract class ProfileConfigurationBlock {
fCurrContext= fInstanceScope; fCurrContext= fInstanceScope;
} }
List profiles= null; List<Profile> profiles= null;
try { try {
profiles= fProfileStore.readProfiles(fInstanceScope); profiles= fProfileStore.readProfiles(fInstanceScope);
} catch (CoreException e) { } catch (CoreException e) {
@ -291,7 +291,7 @@ public abstract class ProfileConfigurationBlock {
} }
if (profiles == null) if (profiles == null)
profiles= new ArrayList(); profiles= new ArrayList<Profile>();
fProfileManager= createProfileManager(profiles, fCurrContext, access, fProfileVersioner); fProfileManager= createProfileManager(profiles, fCurrContext, access, fProfileVersioner);
@ -317,7 +317,7 @@ public abstract class ProfileConfigurationBlock {
protected abstract ProfileStore createProfileStore(IProfileVersioner versioner); protected abstract ProfileStore createProfileStore(IProfileVersioner versioner);
protected abstract ProfileManager createProfileManager(List profiles, IScopeContext context, PreferencesAccess access, IProfileVersioner profileVersioner); protected abstract ProfileManager createProfileManager(List<Profile> profiles, IScopeContext context, PreferencesAccess access, IProfileVersioner profileVersioner);
protected abstract ModifyDialog createModifyDialog(Shell shell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile); protected abstract ModifyDialog createModifyDialog(Shell shell, Profile profile, ProfileManager profileManager, ProfileStore profileStore, boolean newProfile);

View file

@ -16,7 +16,6 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Observable; import java.util.Observable;
@ -29,8 +28,6 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext; import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.osgi.util.TextProcessor; import org.eclipse.osgi.util.TextProcessor;
import org.eclipse.cdt.internal.ui.preferences.formatter.IProfileVersioner;
import org.osgi.service.prefs.BackingStoreException; import org.osgi.service.prefs.BackingStoreException;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
@ -43,13 +40,14 @@ import org.eclipse.cdt.internal.ui.util.Messages;
* The model for the set of profiles which are available in the workbench. * The model for the set of profiles which are available in the workbench.
*/ */
public abstract class ProfileManager extends Observable { public abstract class ProfileManager extends Observable {
private static final Map<String, String> EMPTY_MAP = Collections.emptyMap();
public static final class KeySet { public static final class KeySet {
private final List fKeys; private final List<String> fKeys;
private final String fNodeName; private final String fNodeName;
public KeySet(String nodeName, List keys) { public KeySet(String nodeName, List<String> keys) {
fNodeName= nodeName; fNodeName= nodeName;
fKeys= keys; fKeys= keys;
} }
@ -58,7 +56,7 @@ public abstract class ProfileManager extends Observable {
return fNodeName; return fNodeName;
} }
public List getKeys() { public List<String> getKeys() {
return fKeys; return fKeys;
} }
} }
@ -73,20 +71,20 @@ public abstract class ProfileManager extends Observable {
* Represents a profile with a unique ID, a name and a map * Represents a profile with a unique ID, a name and a map
* containing the code formatter settings. * containing the code formatter settings.
*/ */
public static abstract class Profile implements Comparable { public static abstract class Profile implements Comparable<Profile> {
public abstract String getName(); public abstract String getName();
public abstract Profile rename(String name, ProfileManager manager); public abstract Profile rename(String name, ProfileManager manager);
public abstract Map getSettings(); public abstract Map<String,String> getSettings();
public abstract void setSettings(Map settings); public abstract void setSettings(Map<String,String> settings);
public abstract int getVersion(); public abstract int getVersion();
public boolean hasEqualSettings(Map otherMap, Collection allKeys) { public boolean hasEqualSettings(Map<String,String> otherMap, Collection<String> allKeys) {
Map settings= getSettings(); Map<String,String> settings= getSettings();
for (Iterator iter= allKeys.iterator(); iter.hasNext(); ){ for (Object element : allKeys) {
String key= (String) iter.next(); String key= (String) element;
Object other= otherMap.get(key); Object other= otherMap.get(key);
Object curr= settings.get(key); Object curr= settings.get(key);
if (other == null) { if (other == null) {
@ -120,12 +118,12 @@ public abstract class ProfileManager extends Observable {
public final static class BuiltInProfile extends Profile { public final static class BuiltInProfile extends Profile {
private final String fName; private final String fName;
private final String fID; private final String fID;
private final Map fSettings; private final Map<String,String> fSettings;
private final int fOrder; private final int fOrder;
private final int fCurrentVersion; private final int fCurrentVersion;
private final String fProfileKind; private final String fProfileKind;
protected BuiltInProfile(String ID, String name, Map settings, int order, int currentVersion, String profileKind) { protected BuiltInProfile(String ID, String name, Map<String,String> settings, int order, int currentVersion, String profileKind) {
fName= TextProcessor.process(name); fName= TextProcessor.process(name);
fID= ID; fID= ID;
fSettings= settings; fSettings= settings;
@ -148,12 +146,12 @@ public abstract class ProfileManager extends Observable {
} }
@Override @Override
public Map getSettings() { public Map<String,String> getSettings() {
return fSettings; return fSettings;
} }
@Override @Override
public void setSettings(Map settings) { public void setSettings(Map<String,String> settings) {
} }
@Override @Override
@ -161,7 +159,7 @@ public abstract class ProfileManager extends Observable {
return fID; return fID;
} }
public final int compareTo(Object o) { public final int compareTo(Profile o) {
if (o instanceof BuiltInProfile) { if (o instanceof BuiltInProfile) {
return fOrder - ((BuiltInProfile)o).fOrder; return fOrder - ((BuiltInProfile)o).fOrder;
} }
@ -190,12 +188,12 @@ public abstract class ProfileManager extends Observable {
*/ */
public static class CustomProfile extends Profile { public static class CustomProfile extends Profile {
private String fName; private String fName;
private Map fSettings; private Map<String,String> fSettings;
protected ProfileManager fManager; protected ProfileManager fManager;
private int fVersion; private int fVersion;
private final String fKind; private final String fKind;
public CustomProfile(String name, Map settings, int version, String kind) { public CustomProfile(String name, Map<String,String> settings, int version, String kind) {
fName= name; fName= name;
fSettings= settings; fSettings= settings;
fVersion= version; fVersion= version;
@ -221,12 +219,12 @@ public abstract class ProfileManager extends Observable {
} }
@Override @Override
public Map getSettings() { public Map<String,String> getSettings() {
return fSettings; return fSettings;
} }
@Override @Override
public void setSettings(Map settings) { public void setSettings(Map<String,String> settings) {
if (settings == null) if (settings == null)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
fSettings= settings; fSettings= settings;
@ -257,12 +255,12 @@ public abstract class ProfileManager extends Observable {
fVersion= version; fVersion= version;
} }
public int compareTo(Object o) { public int compareTo(Profile o) {
if (o instanceof SharedProfile) { if (o instanceof SharedProfile) {
return -1; return -1;
} }
if (o instanceof CustomProfile) { if (o instanceof CustomProfile) {
return getName().compareToIgnoreCase(((Profile)o).getName()); return getName().compareToIgnoreCase((o).getName());
} }
return 1; return 1;
} }
@ -280,7 +278,7 @@ public abstract class ProfileManager extends Observable {
public final static class SharedProfile extends CustomProfile { public final static class SharedProfile extends CustomProfile {
public SharedProfile(String oldName, Map options, int version, String profileKind) { public SharedProfile(String oldName, Map<String,String> options, int version, String profileKind) {
super(oldName, options, version, profileKind); super(oldName, options, version, profileKind);
} }
@ -298,7 +296,7 @@ public abstract class ProfileManager extends Observable {
} }
@Override @Override
public final int compareTo(Object o) { public final int compareTo(Profile o) {
return 1; return 1;
} }
@ -339,12 +337,12 @@ public abstract class ProfileManager extends Observable {
/** /**
* A map containing the available profiles, using the IDs as keys. * A map containing the available profiles, using the IDs as keys.
*/ */
private final Map fProfiles; private final Map<String,Profile> fProfiles;
/** /**
* The available profiles, sorted by name. * The available profiles, sorted by name.
*/ */
private final List fProfilesByName; private final List<Profile> fProfilesByName;
/** /**
* The currently selected profile. * The currently selected profile.
@ -365,7 +363,7 @@ public abstract class ProfileManager extends Observable {
* @param profileVersioner * @param profileVersioner
*/ */
public ProfileManager( public ProfileManager(
List profiles, List<Profile> profiles,
IScopeContext context, IScopeContext context,
PreferencesAccess preferencesAccess, PreferencesAccess preferencesAccess,
IProfileVersioner profileVersioner, IProfileVersioner profileVersioner,
@ -379,11 +377,11 @@ public abstract class ProfileManager extends Observable {
fProfileKey= profileKey; fProfileKey= profileKey;
fProfileVersionKey= profileVersionKey; fProfileVersionKey= profileVersionKey;
fProfiles= new HashMap(); fProfiles= new HashMap<String, Profile>();
fProfilesByName= new ArrayList(); fProfilesByName= new ArrayList<Profile>();
for (final Iterator iter = profiles.iterator(); iter.hasNext();) { for (Object element : profiles) {
final Profile profile= (Profile) iter.next(); final Profile profile= (Profile) element;
if (profile instanceof CustomProfile) { if (profile instanceof CustomProfile) {
((CustomProfile)profile).setManager(this); ((CustomProfile)profile).setManager(this);
} }
@ -395,19 +393,19 @@ public abstract class ProfileManager extends Observable {
String profileId= getSelectedProfileId(fPreferencesAccess.getInstanceScope()); String profileId= getSelectedProfileId(fPreferencesAccess.getInstanceScope());
Profile profile= (Profile) fProfiles.get(profileId); Profile profile= fProfiles.get(profileId);
if (profile == null) { if (profile == null) {
profile= getDefaultProfile(); profile= getDefaultProfile();
} }
fSelected= profile; fSelected= profile;
if (context.getName() == ProjectScope.SCOPE && hasProjectSpecificSettings(context)) { if (context.getName() == ProjectScope.SCOPE && hasProjectSpecificSettings(context)) {
Map map= readFromPreferenceStore(context, profile); Map<String, String> map= readFromPreferenceStore(context, profile);
if (map != null) { if (map != null) {
List allKeys= new ArrayList(); List<String> allKeys= new ArrayList<String>();
for (int i= 0; i < fKeySets.length; i++) { for (KeySet keySet : fKeySets) {
allKeys.addAll(fKeySets[i].getKeys()); allKeys.addAll(keySet.getKeys());
} }
Collections.sort(allKeys); Collections.sort(allKeys);
@ -415,14 +413,14 @@ public abstract class ProfileManager extends Observable {
String projProfileId= context.getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null); String projProfileId= context.getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null);
if (projProfileId != null) { if (projProfileId != null) {
Profile curr= (Profile) fProfiles.get(projProfileId); Profile curr= fProfiles.get(projProfileId);
if (curr != null && (curr.isBuiltInProfile() || curr.hasEqualSettings(map, allKeys))) { if (curr != null && (curr.isBuiltInProfile() || curr.hasEqualSettings(map, allKeys))) {
matching= curr; matching= curr;
} }
} else { } else {
// old version: look for similar // old version: look for similar
for (final Iterator iter = fProfilesByName.iterator(); iter.hasNext();) { for (Object element : fProfilesByName) {
Profile curr= (Profile) iter.next(); Profile curr= (Profile) element;
if (curr.hasEqualSettings(map, allKeys)) { if (curr.hasEqualSettings(map, allKeys)) {
matching= curr; matching= curr;
break; break;
@ -473,11 +471,10 @@ public abstract class ProfileManager extends Observable {
} }
public static boolean hasProjectSpecificSettings(IScopeContext context, KeySet[] keySets) { public static boolean hasProjectSpecificSettings(IScopeContext context, KeySet[] keySets) {
for (int i= 0; i < keySets.length; i++) { for (KeySet keySet : keySets) {
KeySet keySet= keySets[i];
IEclipsePreferences preferences= context.getNode(keySet.getNodeName()); IEclipsePreferences preferences= context.getNode(keySet.getNodeName());
for (final Iterator keyIter= keySet.getKeys().iterator(); keyIter.hasNext();) { for (Object element : keySet.getKeys()) {
final String key= (String)keyIter.next(); final String key= (String)element;
Object val= preferences.get(key, null); Object val= preferences.get(key, null);
if (val != null) { if (val != null) {
return true; return true;
@ -495,15 +492,15 @@ public abstract class ProfileManager extends Observable {
* Only to read project specific settings to find out to what profile it matches. * Only to read project specific settings to find out to what profile it matches.
* @param context The project context * @param context The project context
*/ */
public Map readFromPreferenceStore(IScopeContext context, Profile workspaceProfile) { public Map<String, String> readFromPreferenceStore(IScopeContext context, Profile workspaceProfile) {
final Map profileOptions= new HashMap(); final Map<String, String> profileOptions= new HashMap<String, String>();
IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID); IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
int version= uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion()); int version= uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion());
if (version != fProfileVersioner.getCurrentVersion()) { if (version != fProfileVersioner.getCurrentVersion()) {
Map allOptions= new HashMap(); Map<String, String> allOptions= new HashMap<String, String>();
for (int i= 0; i < fKeySets.length; i++) { for (KeySet keySet : fKeySets) {
addAll(context.getNode(fKeySets[i].getNodeName()), allOptions); addAll(context.getNode(keySet.getNodeName()), allOptions);
} }
CustomProfile profile= new CustomProfile("tmp", allOptions, version, fProfileVersioner.getProfileKind()); //$NON-NLS-1$ CustomProfile profile= new CustomProfile("tmp", allOptions, version, fProfileVersioner.getProfileKind()); //$NON-NLS-1$
fProfileVersioner.update(profile); fProfileVersioner.update(profile);
@ -511,12 +508,11 @@ public abstract class ProfileManager extends Observable {
} }
boolean hasValues= false; boolean hasValues= false;
for (int i= 0; i < fKeySets.length; i++) { for (KeySet keySet : fKeySets) {
KeySet keySet= fKeySets[i];
IEclipsePreferences preferences= context.getNode(keySet.getNodeName()); IEclipsePreferences preferences= context.getNode(keySet.getNodeName());
for (final Iterator keyIter = keySet.getKeys().iterator(); keyIter.hasNext(); ) { for (Object element : keySet.getKeys()) {
final String key= (String) keyIter.next(); final String key= (String) element;
Object val= preferences.get(key, null); String val= preferences.get(key, null);
if (val != null) { if (val != null) {
hasValues= true; hasValues= true;
} else { } else {
@ -537,11 +533,10 @@ public abstract class ProfileManager extends Observable {
* @param uiPrefs * @param uiPrefs
* @param allOptions * @param allOptions
*/ */
private void addAll(IEclipsePreferences uiPrefs, Map allOptions) { private void addAll(IEclipsePreferences uiPrefs, Map<String,String> allOptions) {
try { try {
String[] keys= uiPrefs.keys(); String[] keys= uiPrefs.keys();
for (int i= 0; i < keys.length; i++) { for (String key : keys) {
String key= keys[i];
String val= uiPrefs.get(key, null); String val= uiPrefs.get(key, null);
if (val != null) { if (val != null) {
allOptions.put(key, val); allOptions.put(key, val);
@ -553,12 +548,12 @@ public abstract class ProfileManager extends Observable {
} }
private boolean updatePreferences(IEclipsePreferences prefs, List keys, Map profileOptions) { private boolean updatePreferences(IEclipsePreferences prefs, List<String> keys, Map<String,String> profileOptions) {
boolean hasChanges= false; boolean hasChanges= false;
for (final Iterator keyIter = keys.iterator(); keyIter.hasNext(); ) { for (Object element : keys) {
final String key= (String) keyIter.next(); final String key= (String) element;
final String oldVal= prefs.get(key, null); final String oldVal= prefs.get(key, null);
final String val= (String) profileOptions.get(key); final String val= profileOptions.get(key);
if (val == null) { if (val == null) {
if (oldVal != null) { if (oldVal != null) {
prefs.remove(key); prefs.remove(key);
@ -578,10 +573,10 @@ public abstract class ProfileManager extends Observable {
* @param profile The profile to write to the preference store * @param profile The profile to write to the preference store
*/ */
private void writeToPreferenceStore(Profile profile, IScopeContext context) { private void writeToPreferenceStore(Profile profile, IScopeContext context) {
final Map profileOptions= profile.getSettings(); final Map<String,String> profileOptions= profile.getSettings();
for (int i= 0; i < fKeySets.length; i++) { for (KeySet keySet : fKeySets) {
updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), profileOptions); updatePreferences(context.getNode(keySet.getNodeName()), keySet.getKeys(), profileOptions);
} }
final IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID); final IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
@ -604,7 +599,7 @@ public abstract class ProfileManager extends Observable {
* *
* @see #getSortedDisplayNames() * @see #getSortedDisplayNames()
*/ */
public List getSortedProfiles() { public List<Profile> getSortedProfiles() {
return Collections.unmodifiableList(fProfilesByName); return Collections.unmodifiableList(fProfilesByName);
} }
@ -618,8 +613,8 @@ public abstract class ProfileManager extends Observable {
public String[] getSortedDisplayNames() { public String[] getSortedDisplayNames() {
final String[] sortedNames= new String[fProfilesByName.size()]; final String[] sortedNames= new String[fProfilesByName.size()];
int i= 0; int i= 0;
for (final Iterator iter = fProfilesByName.iterator(); iter.hasNext();) { for (Object element : fProfilesByName) {
Profile curr= (Profile) iter.next(); Profile curr= (Profile) element;
sortedNames[i++]= curr.getName(); sortedNames[i++]= curr.getName();
} }
return sortedNames; return sortedNames;
@ -631,7 +626,7 @@ public abstract class ProfileManager extends Observable {
* @return The profile with the given ID or <code>null</code> * @return The profile with the given ID or <code>null</code>
*/ */
public Profile getProfile(String ID) { public Profile getProfile(String ID) {
return (Profile)fProfiles.get(ID); return fProfiles.get(ID);
} }
/** /**
@ -645,8 +640,8 @@ public abstract class ProfileManager extends Observable {
} }
public void clearAllSettings(IScopeContext context) { public void clearAllSettings(IScopeContext context) {
for (int i= 0; i < fKeySets.length; i++) { for (KeySet keySet : fKeySets) {
updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), Collections.EMPTY_MAP); updatePreferences(context.getNode(keySet.getNodeName()), keySet.getKeys(), EMPTY_MAP);
} }
final IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID); final IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
@ -666,7 +661,7 @@ public abstract class ProfileManager extends Observable {
* @param profile The profile to select * @param profile The profile to select
*/ */
public void setSelected(Profile profile) { public void setSelected(Profile profile) {
final Profile newSelected= (Profile)fProfiles.get(profile.getID()); final Profile newSelected= fProfiles.get(profile.getID());
if (newSelected != null && !newSelected.equals(fSelected)) { if (newSelected != null && !newSelected.equals(fSelected)) {
fSelected= newSelected; fSelected= newSelected;
notifyObservers(SELECTION_CHANGED_EVENT); notifyObservers(SELECTION_CHANGED_EVENT);
@ -680,8 +675,8 @@ public abstract class ProfileManager extends Observable {
* @return Returns <code>true</code> if a profile with the given name exists * @return Returns <code>true</code> if a profile with the given name exists
*/ */
public boolean containsName(String name) { public boolean containsName(String name) {
for (final Iterator iter = fProfilesByName.iterator(); iter.hasNext();) { for (Object element : fProfilesByName) {
Profile curr= (Profile) iter.next(); Profile curr= (Profile) element;
if (name.equals(curr.getName())) { if (name.equals(curr.getName())) {
return true; return true;
} }
@ -730,7 +725,7 @@ public abstract class ProfileManager extends Observable {
if (index >= fProfilesByName.size()) if (index >= fProfilesByName.size())
index--; index--;
fSelected= (Profile) fProfilesByName.get(index); fSelected= fProfilesByName.get(index);
if (!profile.isSharedProfile()) { if (!profile.isSharedProfile()) {
updateProfilesWithName(profile.getID(), null, false); updateProfilesWithName(profile.getID(), null, false);
@ -779,8 +774,8 @@ public abstract class ProfileManager extends Observable {
private void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) { private void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) {
IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects(); IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i= 0; i < projects.length; i++) { for (IProject project : projects) {
IScopeContext projectScope= fPreferencesAccess.getProjectScope(projects[i]); IScopeContext projectScope= fPreferencesAccess.getProjectScope(project);
IEclipsePreferences node= projectScope.getNode(CUIPlugin.PLUGIN_ID); IEclipsePreferences node= projectScope.getNode(CUIPlugin.PLUGIN_ID);
String profileId= node.get(fProfileKey, null); String profileId= node.get(fProfileKey, null);
if (oldName.equals(profileId)) { if (oldName.equals(profileId)) {

View file

@ -44,7 +44,6 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext; import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Element; import org.w3c.dom.Element;
import org.xml.sax.Attributes; import org.xml.sax.Attributes;
@ -73,11 +72,11 @@ public class ProfileStore {
*/ */
private final static class ProfileDefaultHandler extends DefaultHandler { private final static class ProfileDefaultHandler extends DefaultHandler {
private List fProfiles; private List<Profile> fProfiles;
private int fVersion; private int fVersion;
private String fName; private String fName;
private Map fSettings; private Map<String, String> fSettings;
private String fKind; private String fKind;
@Override @Override
@ -96,12 +95,12 @@ public class ProfileStore {
if (fKind == null) //Can only be an CodeFormatterProfile created pre 20061106 if (fKind == null) //Can only be an CodeFormatterProfile created pre 20061106
fKind= ProfileVersioner.CODE_FORMATTER_PROFILE_KIND; fKind= ProfileVersioner.CODE_FORMATTER_PROFILE_KIND;
fSettings= new HashMap(200); fSettings= new HashMap<String, String>(200);
} }
else if (qName.equals(XML_NODE_ROOT)) { else if (qName.equals(XML_NODE_ROOT)) {
fProfiles= new ArrayList(); fProfiles= new ArrayList<Profile>();
try { try {
fVersion= Integer.parseInt(attributes.getValue(XML_ATTRIBUTE_VERSION)); fVersion= Integer.parseInt(attributes.getValue(XML_ATTRIBUTE_VERSION));
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
@ -121,7 +120,7 @@ public class ProfileStore {
} }
} }
public List getProfiles() { public List<Profile> getProfiles() {
return fProfiles; return fProfiles;
} }
@ -157,11 +156,11 @@ public class ProfileStore {
* and are all updated to the latest version. * and are all updated to the latest version.
* @throws CoreException * @throws CoreException
*/ */
public List readProfiles(IScopeContext scope) throws CoreException { public List<Profile> readProfiles(IScopeContext scope) throws CoreException {
return readProfilesFromString(scope.getNode(CUIPlugin.PLUGIN_ID).get(fProfilesKey, null)); return readProfilesFromString(scope.getNode(CUIPlugin.PLUGIN_ID).get(fProfilesKey, null));
} }
public void writeProfiles(Collection profiles, IScopeContext instanceScope) throws CoreException { public void writeProfiles(Collection<Profile> profiles, IScopeContext instanceScope) throws CoreException {
ByteArrayOutputStream stream= new ByteArrayOutputStream(2000); ByteArrayOutputStream stream= new ByteArrayOutputStream(2000);
try { try {
writeProfilesToStream(profiles, stream, ENCODING, fProfileVersioner); writeProfilesToStream(profiles, stream, ENCODING, fProfileVersioner);
@ -179,7 +178,7 @@ public class ProfileStore {
} }
} }
public List readProfilesFromString(String profiles) throws CoreException { public List<Profile> readProfilesFromString(String profiles) throws CoreException {
if (profiles != null && profiles.length() > 0) { if (profiles != null && profiles.length() > 0) {
byte[] bytes; byte[] bytes;
try { try {
@ -189,7 +188,7 @@ public class ProfileStore {
} }
InputStream is= new ByteArrayInputStream(bytes); InputStream is= new ByteArrayInputStream(bytes);
try { try {
List res= readProfilesFromStream(new InputSource(is)); List<Profile> res= readProfilesFromStream(new InputSource(is));
if (res != null) { if (res != null) {
for (int i= 0; i < res.size(); i++) { for (int i= 0; i < res.size(); i++) {
fProfileVersioner.update((CustomProfile) res.get(i)); fProfileVersioner.update((CustomProfile) res.get(i));
@ -210,7 +209,7 @@ public class ProfileStore {
* @return returns a list of <code>CustomProfile</code> or <code>null</code> * @return returns a list of <code>CustomProfile</code> or <code>null</code>
* @throws CoreException * @throws CoreException
*/ */
public List readProfilesFromFile(File file) throws CoreException { public List<Profile> readProfilesFromFile(File file) throws CoreException {
try { try {
final FileInputStream reader= new FileInputStream(file); final FileInputStream reader= new FileInputStream(file);
try { try {
@ -229,7 +228,7 @@ public class ProfileStore {
* @return returns a list of <code>CustomProfile</code> or <code>null</code> * @return returns a list of <code>CustomProfile</code> or <code>null</code>
* @throws CoreException * @throws CoreException
*/ */
protected static List readProfilesFromStream(InputSource inputSource) throws CoreException { protected static List<Profile> readProfilesFromStream(InputSource inputSource) throws CoreException {
final ProfileDefaultHandler handler= new ProfileDefaultHandler(); final ProfileDefaultHandler handler= new ProfileDefaultHandler();
try { try {
@ -253,7 +252,7 @@ public class ProfileStore {
* @param encoding the encoding to use * @param encoding the encoding to use
* @throws CoreException * @throws CoreException
*/ */
public void writeProfilesToFile(Collection profiles, File file, String encoding) throws CoreException { public void writeProfilesToFile(Collection<Profile> profiles, File file, String encoding) throws CoreException {
final OutputStream stream; final OutputStream stream;
try { try {
stream= new FileOutputStream(file); stream= new FileOutputStream(file);
@ -274,7 +273,7 @@ public class ProfileStore {
* @param encoding the encoding to use * @param encoding the encoding to use
* @throws CoreException * @throws CoreException
*/ */
private static void writeProfilesToStream(Collection profiles, OutputStream stream, String encoding, IProfileVersioner profileVersioner) throws CoreException { private static void writeProfilesToStream(Collection<Profile> profiles, OutputStream stream, String encoding, IProfileVersioner profileVersioner) throws CoreException {
try { try {
@ -287,8 +286,8 @@ public class ProfileStore {
document.appendChild(rootElement); document.appendChild(rootElement);
for(final Iterator iter= profiles.iterator(); iter.hasNext();) { for (Object element : profiles) {
final Profile profile= (Profile)iter.next(); final Profile profile= (Profile)element;
if (profile.isProfileToSave()) { if (profile.isProfileToSave()) {
final Element profileElement= createProfileElement(profile, document, profileVersioner); final Element profileElement= createProfileElement(profile, document, profileVersioner);
rootElement.appendChild(profileElement); rootElement.appendChild(profileElement);
@ -318,11 +317,11 @@ public class ProfileStore {
element.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profile.getVersion())); element.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profile.getVersion()));
element.setAttribute(XML_ATTRIBUTE_PROFILE_KIND, profileVersioner.getProfileKind()); element.setAttribute(XML_ATTRIBUTE_PROFILE_KIND, profileVersioner.getProfileKind());
final Iterator keyIter= profile.getSettings().keySet().iterator(); final Iterator<String> keyIter= profile.getSettings().keySet().iterator();
while (keyIter.hasNext()) { while (keyIter.hasNext()) {
final String key= (String)keyIter.next(); final String key= keyIter.next();
final String value= (String)profile.getSettings().get(key); final String value= profile.getSettings().get(key);
if (value != null) { if (value != null) {
final Element setting= document.createElement(XML_NODE_SETTING); final Element setting= document.createElement(XML_NODE_SETTING);
setting.setAttribute(XML_ATTRIBUTE_ID, key); setting.setAttribute(XML_ATTRIBUTE_ID, key);

View file

@ -12,7 +12,6 @@
package org.eclipse.cdt.internal.ui.preferences.formatter; package org.eclipse.cdt.internal.ui.preferences.formatter;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile; import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
@ -43,8 +42,8 @@ public class ProfileVersioner implements IProfileVersioner {
} }
public void update(CustomProfile profile) { public void update(CustomProfile profile) {
final Map oldSettings= profile.getSettings(); final Map<String, String> oldSettings= profile.getSettings();
Map newSettings= updateAndComplete(oldSettings, profile.getVersion()); Map<String, String> newSettings= updateAndComplete(oldSettings, profile.getVersion());
profile.setVersion(CURRENT_VERSION); profile.setVersion(CURRENT_VERSION);
profile.setSettings(newSettings); profile.setSettings(newSettings);
} }
@ -60,28 +59,28 @@ public class ProfileVersioner implements IProfileVersioner {
} }
public static void updateAndComplete(CustomProfile profile) { public static void updateAndComplete(CustomProfile profile) {
final Map oldSettings= profile.getSettings(); final Map<String, String> oldSettings= profile.getSettings();
Map newSettings= updateAndComplete(oldSettings, profile.getVersion()); Map<String, String> newSettings= updateAndComplete(oldSettings, profile.getVersion());
profile.setVersion(CURRENT_VERSION); profile.setVersion(CURRENT_VERSION);
profile.setSettings(newSettings); profile.setSettings(newSettings);
} }
public static Map updateAndComplete(Map oldSettings, int version) { public static Map<String, String> updateAndComplete(Map<String, String> oldSettings, int version) {
final Map newSettings= FormatterProfileManager.getDefaultSettings(); final Map<String, String> newSettings= FormatterProfileManager.getDefaultSettings();
switch (version) { switch (version) {
default: default:
for (final Iterator iter= oldSettings.keySet().iterator(); iter.hasNext(); ) { for (Object element : oldSettings.keySet()) {
final String key= (String)iter.next(); final String key= (String)element;
if (!newSettings.containsKey(key)) if (!newSettings.containsKey(key))
continue; continue;
final String value= (String)oldSettings.get(key); final String value= oldSettings.get(key);
if (value != null) { if (value != null) {
newSettings.put(key, value); newSettings.put(key, value);
} }
} }
} }
return newSettings; return newSettings;
} }

View file

@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.preferences.formatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator;
import java.util.Map; import java.util.Map;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
@ -44,11 +43,11 @@ public class SnippetPreview extends CPreview {
} }
} }
private ArrayList fSnippets; private ArrayList<PreviewSnippet> fSnippets;
public SnippetPreview(Map workingValues, Composite parent) { public SnippetPreview(Map<String,String> workingValues, Composite parent) {
super(workingValues, parent); super(workingValues, parent);
fSnippets= new ArrayList(); fSnippets= new ArrayList<PreviewSnippet>();
} }
@Override @Override
@ -62,8 +61,7 @@ public class SnippetPreview extends CPreview {
final String delimiter= "\n"; //$NON-NLS-1$ final String delimiter= "\n"; //$NON-NLS-1$
final StringBuffer buffer= new StringBuffer(); final StringBuffer buffer= new StringBuffer();
for (final Iterator iter= fSnippets.iterator(); iter.hasNext();) { for (PreviewSnippet snippet: fSnippets) {
final PreviewSnippet snippet= (PreviewSnippet) iter.next();
String formattedSource; String formattedSource;
try { try {
TextEdit edit= CodeFormatterUtil.format(snippet.kind, snippet.source, 0, delimiter, fWorkingValues); TextEdit edit= CodeFormatterUtil.format(snippet.kind, snippet.source, 0, delimiter, fWorkingValues);
@ -98,7 +96,7 @@ public class SnippetPreview extends CPreview {
fSnippets.remove(snippet); fSnippets.remove(snippet);
} }
public void addAll(Collection snippets) { public void addAll(Collection<PreviewSnippet> snippets) {
fSnippets.addAll(snippets); fSnippets.addAll(snippets);
} }

View file

@ -41,7 +41,7 @@ public class TranslationUnitPreview extends CPreview {
* @param workingValues * @param workingValues
* @param parent * @param parent
*/ */
public TranslationUnitPreview(Map workingValues, Composite parent) { public TranslationUnitPreview(Map<String, String> workingValues, Composite parent) {
super(workingValues, parent); super(workingValues, parent);
} }
@ -59,9 +59,9 @@ public class TranslationUnitPreview extends CPreview {
final IContentFormatter formatter = fViewerConfiguration.getContentFormatter(fSourceViewer); final IContentFormatter formatter = fViewerConfiguration.getContentFormatter(fSourceViewer);
if (formatter instanceof IContentFormatterExtension) { if (formatter instanceof IContentFormatterExtension) {
final IContentFormatterExtension extension = (IContentFormatterExtension) formatter; final IContentFormatterExtension extension = (IContentFormatterExtension) formatter;
Map prefs= fWorkingValues; Map<String, String> prefs= fWorkingValues;
if (fFormatterId != null) { if (fFormatterId != null) {
prefs= new HashMap(fWorkingValues); prefs= new HashMap<String, String>(fWorkingValues);
prefs.put(CCorePreferenceConstants.CODE_FORMATTER, fFormatterId); prefs.put(CCorePreferenceConstants.CODE_FORMATTER, fFormatterId);
} }
context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, prefs); context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, prefs);

View file

@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.preferences.formatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -40,16 +39,16 @@ public final class WhiteSpaceOptions {
public int index; public int index;
protected final Map fWorkingValues; protected final Map<String,String> fWorkingValues;
protected final ArrayList fChildren; protected final ArrayList<Node> fChildren;
public Node(InnerNode parent, Map workingValues, String message) { public Node(InnerNode parent, Map<String,String> workingValues, String message) {
if (workingValues == null || message == null) if (workingValues == null || message == null)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
fParent= parent; fParent= parent;
fWorkingValues= workingValues; fWorkingValues= workingValues;
fName= message; fName= message;
fChildren= new ArrayList(); fChildren= new ArrayList<Node>();
if (fParent != null) if (fParent != null)
fParent.add(this); fParent.add(this);
} }
@ -60,7 +59,7 @@ public final class WhiteSpaceOptions {
return !fChildren.isEmpty(); return !fChildren.isEmpty();
} }
public List getChildren() { public List<Node> getChildren() {
return Collections.unmodifiableList(fChildren); return Collections.unmodifiableList(fChildren);
} }
@ -73,9 +72,9 @@ public final class WhiteSpaceOptions {
return fName; return fName;
} }
public abstract List getSnippets(); public abstract List<PreviewSnippet> getSnippets();
public abstract void getCheckedLeafs(List list); public abstract void getCheckedLeafs(List<OptionNode> list);
} }
/** /**
@ -83,14 +82,14 @@ public final class WhiteSpaceOptions {
*/ */
public static class InnerNode extends Node { public static class InnerNode extends Node {
public InnerNode(InnerNode parent, Map workingValues, String messageKey) { public InnerNode(InnerNode parent, Map<String,String> workingValues, String messageKey) {
super(parent, workingValues, messageKey); super(parent, workingValues, messageKey);
} }
@Override @Override
public void setChecked(boolean checked) { public void setChecked(boolean checked) {
for (final Iterator iter = fChildren.iterator(); iter.hasNext();) for (Object element : fChildren)
((Node)iter.next()).setChecked(checked); ((Node)element).setChecked(checked);
} }
public void add(Node child) { public void add(Node child) {
@ -98,12 +97,11 @@ public final class WhiteSpaceOptions {
} }
@Override @Override
public List getSnippets() { public List<PreviewSnippet> getSnippets() {
final ArrayList snippets= new ArrayList(fChildren.size()); final ArrayList<PreviewSnippet> snippets= new ArrayList<PreviewSnippet>(fChildren.size());
for (Iterator iter= fChildren.iterator(); iter.hasNext();) { for (Object element : fChildren) {
final List childSnippets= ((Node)iter.next()).getSnippets(); final List<PreviewSnippet> childSnippets= ((Node)element).getSnippets();
for (final Iterator chIter= childSnippets.iterator(); chIter.hasNext(); ) { for (PreviewSnippet snippet : childSnippets) {
final Object snippet= chIter.next();
if (!snippets.contains(snippet)) if (!snippets.contains(snippet))
snippets.add(snippet); snippets.add(snippet);
} }
@ -112,9 +110,9 @@ public final class WhiteSpaceOptions {
} }
@Override @Override
public void getCheckedLeafs(List list) { public void getCheckedLeafs(List<OptionNode> list) {
for (Iterator iter= fChildren.iterator(); iter.hasNext();) { for (Node element : fChildren) {
((Node)iter.next()).getCheckedLeafs(list); element.getCheckedLeafs(list);
} }
} }
} }
@ -125,12 +123,12 @@ public final class WhiteSpaceOptions {
*/ */
public static class OptionNode extends Node { public static class OptionNode extends Node {
private final String fKey; private final String fKey;
private final ArrayList fSnippets; private final ArrayList<PreviewSnippet> fSnippets;
public OptionNode(InnerNode parent, Map workingValues, String messageKey, String key, PreviewSnippet snippet) { public OptionNode(InnerNode parent, Map<String, String> workingValues, String messageKey, String key, PreviewSnippet snippet) {
super(parent, workingValues, messageKey); super(parent, workingValues, messageKey);
fKey= key; fKey= key;
fSnippets= new ArrayList(1); fSnippets= new ArrayList<PreviewSnippet>(1);
fSnippets.add(snippet); fSnippets.add(snippet);
} }
@ -144,12 +142,12 @@ public final class WhiteSpaceOptions {
} }
@Override @Override
public List getSnippets() { public List<PreviewSnippet> getSnippets() {
return fSnippets; return fSnippets;
} }
@Override @Override
public void getCheckedLeafs(List list) { public void getCheckedLeafs(List<OptionNode> list) {
if (getChecked()) if (getChecked())
list.add(this); list.add(this);
} }
@ -255,8 +253,8 @@ public final class WhiteSpaceOptions {
* @param workingValues * @param workingValues
* @return returns roots (type <code>Node</code>) * @return returns roots (type <code>Node</code>)
*/ */
public List createTreeBySyntaxElem(Map workingValues) { public List<InnerNode> createTreeBySyntaxElem(Map<String, String> workingValues) {
final ArrayList roots= new ArrayList(); final ArrayList<InnerNode> roots= new ArrayList<InnerNode>();
InnerNode element; InnerNode element;
@ -335,9 +333,9 @@ public final class WhiteSpaceOptions {
* @param workingValues * @param workingValues
* @return returns roots (type <code>Node</code>) * @return returns roots (type <code>Node</code>)
*/ */
public List createAltTree(Map workingValues) { public List<InnerNode> createAltTree(Map<String, String> workingValues) {
final ArrayList roots= new ArrayList(); final ArrayList<InnerNode> roots= new ArrayList<InnerNode>();
InnerNode parent; InnerNode parent;
@ -435,13 +433,13 @@ public final class WhiteSpaceOptions {
return roots; return roots;
} }
private InnerNode createParentNode(List roots, Map workingValues, String text) { private InnerNode createParentNode(List<InnerNode> roots, Map<String, String> workingValues, String text) {
final InnerNode parent= new InnerNode(null, workingValues, text); final InnerNode parent= new InnerNode(null, workingValues, text);
roots.add(parent); roots.add(parent);
return parent; return parent;
} }
public ArrayList createTreeByJavaElement(Map workingValues) { public ArrayList<InnerNode> createTreeByJavaElement(Map<String, String> workingValues) {
final InnerNode declarations= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_declarations); final InnerNode declarations= new InnerNode(null, workingValues, FormatterMessages.WhiteSpaceTabPage_declarations);
createClassTree(workingValues, declarations); createClassTree(workingValues, declarations);
@ -478,7 +476,7 @@ public final class WhiteSpaceOptions {
createTemplateArgumentTree(workingValues, templates); createTemplateArgumentTree(workingValues, templates);
createTemplateParameterTree(workingValues, templates); createTemplateParameterTree(workingValues, templates);
final ArrayList roots= new ArrayList(); final ArrayList<InnerNode> roots= new ArrayList<InnerNode>();
roots.add(declarations); roots.add(declarations);
roots.add(statements); roots.add(statements);
roots.add(expressions); roots.add(expressions);
@ -487,16 +485,16 @@ public final class WhiteSpaceOptions {
return roots; return roots;
} }
private void createBeforeQuestionTree(Map workingValues, final InnerNode parent) { private void createBeforeQuestionTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
} }
private void createBeforeSemicolonTree(Map workingValues, final InnerNode parent) { private void createBeforeSemicolonTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, FOR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON_IN_FOR, FOR_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_statements, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_SEMICOLON, SEMICOLON_PREVIEW);
} }
private void createBeforeColonTree(Map workingValues, final InnerNode parent) { private void createBeforeColonTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_label, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_label, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_base_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_base_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW);
@ -506,7 +504,7 @@ public final class WhiteSpaceOptions {
createOption(switchStatement, workingValues, FormatterMessages.WhiteSpaceOptions_default, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, SWITCH_PREVIEW); createOption(switchStatement, workingValues, FormatterMessages.WhiteSpaceOptions_default, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_DEFAULT, SWITCH_PREVIEW);
} }
private void createBeforeCommaTree(Map workingValues, final InnerNode parent) { private void createBeforeCommaTree(Map<String, String> workingValues, final InnerNode parent) {
// final InnerNode forStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for); // final InnerNode forStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for);
// createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_initialization, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW); // createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_initialization, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_FOR_INITS, FOR_PREVIEW);
@ -533,7 +531,7 @@ public final class WhiteSpaceOptions {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
} }
private void createBeforeOperatorTree(Map workingValues, final InnerNode parent) { private void createBeforeOperatorTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_unary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, OPERATOR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_unary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_UNARY_OPERATOR, OPERATOR_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_binary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_binary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW);
@ -541,30 +539,30 @@ public final class WhiteSpaceOptions {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_postfix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_postfix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
} }
private void createBeforeClosingBracketTree(Map workingValues, final InnerNode parent) { private void createBeforeClosingBracketTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET, ARRAY_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET, ARRAY_PREVIEW);
} }
private void createBeforeClosingAngleBracketTree(Map workingValues, final InnerNode parent) { private void createBeforeClosingAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
} }
private void createBeforeOpenBracketTree(Map workingValues, final InnerNode parent) { private void createBeforeOpenBracketTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET, ARRAY_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET, ARRAY_PREVIEW);
} }
private void createBeforeOpenAngleBracketTree(Map workingValues, final InnerNode parent) { private void createBeforeOpenAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
} }
private void createBeforeClosingBraceTree(Map workingValues, final InnerNode parent) { private void createBeforeClosingBraceTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_INITIALIZER_LIST, CLASS_DECL_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACE_IN_INITIALIZER_LIST, CLASS_DECL_PREVIEW);
} }
private void createBeforeOpenBraceTree(Map workingValues, final InnerNode parent) { private void createBeforeOpenBraceTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_class_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, CLASS_DECL_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_class_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, CLASS_DECL_PREVIEW);
@ -578,7 +576,7 @@ public final class WhiteSpaceOptions {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, SWITCH_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_switch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_SWITCH, SWITCH_PREVIEW);
} }
private void createBeforeClosingParenTree(Map workingValues, final InnerNode parent) { private void createBeforeClosingParenTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_FOR, FOR_PREVIEW);
@ -596,7 +594,7 @@ public final class WhiteSpaceOptions {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
} }
private void createBeforeOpenParenTree(Map workingValues, final InnerNode parent) { private void createBeforeOpenParenTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
@ -614,7 +612,7 @@ public final class WhiteSpaceOptions {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
} }
private void createAfterQuestionTree(Map workingValues, final InnerNode parent) { private void createAfterQuestionTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
} }
@ -626,17 +624,17 @@ public final class WhiteSpaceOptions {
// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_vararg_parameter, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, VARARG_PARAMETER_PREVIEW); // createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_vararg_parameter, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ELLIPSIS, VARARG_PARAMETER_PREVIEW);
// } // }
private void createAfterSemicolonTree(Map workingValues, final InnerNode parent) { private void createAfterSemicolonTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_SEMICOLON_IN_FOR, FOR_PREVIEW);
} }
private void createAfterColonTree(Map workingValues, final InnerNode parent) { private void createAfterColonTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_conditional, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_label, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_label, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_base_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_base_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW);
} }
private void createAfterCommaTree(Map workingValues, final InnerNode parent) { private void createAfterCommaTree(Map<String, String> workingValues, final InnerNode parent) {
// final InnerNode forStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for); { // final InnerNode forStatement= createChild(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for); {
// createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_initialization, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW); // createOption(forStatement, workingValues, FormatterMessages.WhiteSpaceOptions_initialization, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_FOR_INITS, FOR_PREVIEW);
@ -664,7 +662,7 @@ public final class WhiteSpaceOptions {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
} }
private void createAfterOperatorTree(Map workingValues, final InnerNode parent) { private void createAfterOperatorTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_unary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, OPERATOR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_unary_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_UNARY_OPERATOR, OPERATOR_PREVIEW);
@ -673,38 +671,38 @@ public final class WhiteSpaceOptions {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_postfix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_postfix_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_POSTFIX_OPERATOR, OPERATOR_PREVIEW);
} }
private void createAfterOpenBracketTree(Map workingValues, final InnerNode parent) { private void createAfterOpenBracketTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET, ARRAY_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET, ARRAY_PREVIEW);
} }
private void createAfterOpenAngleBracketTree(Map workingValues, final InnerNode parent) { private void createAfterOpenAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
} }
private void createAfterOpenBraceTree(Map workingValues, final InnerNode parent) { private void createAfterOpenBraceTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACE_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW);
} }
private void createAfterCloseBraceTree(Map workingValues, final InnerNode parent) { private void createAfterCloseBraceTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_block, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, BLOCK_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_block, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_BRACE_IN_BLOCK, BLOCK_PREVIEW);
} }
private void createAfterCloseParenTree(Map workingValues, final InnerNode parent) { private void createAfterCloseParenTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, CAST_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_type_cast, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_PAREN_IN_CAST, CAST_PREVIEW);
} }
private void createAfterClosingAngleBracketTree(Map workingValues, final InnerNode parent) { private void createAfterClosingAngleBracketTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_parameters, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
//createOption(parent, workingValues, "WhiteSpaceOptions.parameterized_type", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, TYPE_ARGUMENTS_PREVIEW); //$NON-NLS-1$ //createOption(parent, workingValues, "WhiteSpaceOptions.parameterized_type", DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_PARAMETERIZED_TYPE_REFERENCE, TYPE_ARGUMENTS_PREVIEW); //$NON-NLS-1$
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_template_arguments, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_CLOSING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
} }
private void createAfterOpenParenTree(Map workingValues, final InnerNode parent) { private void createAfterOpenParenTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_catch, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_for, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_if, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_IF, IF_PREVIEW);
@ -720,24 +718,24 @@ public final class WhiteSpaceOptions {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_paren_expr, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
} }
private void createBetweenEmptyParenTree(Map workingValues, final InnerNode parent) { private void createBetweenEmptyParenTree(Map<String, String> workingValues, final InnerNode parent) {
// createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_constructor_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW); // createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_constructor_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_CONSTRUCTOR_DECLARATION, CONSTRUCTOR_DECL_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_method_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_method_decl, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_method_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_method_call, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_PARENS_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
} }
private void createBetweenEmptyBracketsTree(Map workingValues, final InnerNode parent) { private void createBetweenEmptyBracketsTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS, ARRAY_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_arrays, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACKETS, ARRAY_PREVIEW);
} }
private void createBetweenEmptyBracesTree(Map workingValues, final InnerNode parent) { private void createBetweenEmptyBracesTree(Map<String, String> workingValues, final InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceOptions_initializer_list, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BETWEEN_EMPTY_BRACES_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW);
} }
// syntax element tree // syntax element tree
private InnerNode createClassTree(Map workingValues, InnerNode parent) { private InnerNode createClassTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_classes); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_classes);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_opening_brace_of_a_class, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, CLASS_DECL_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_opening_brace_of_a_class, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_TYPE_DECLARATION, CLASS_DECL_PREVIEW);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_colon_of_base_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_classes_before_colon_of_base_clause, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_BASE_CLAUSE, CLASS_DECL_PREVIEW);
@ -747,14 +745,14 @@ public final class WhiteSpaceOptions {
return root; return root;
} }
private InnerNode createAssignmentTree(Map workingValues, InnerNode parent) { private InnerNode createAssignmentTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments_before_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments_before_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments_after_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_assignments_after_assignment_operator, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_ASSIGNMENT_OPERATOR, OPERATOR_PREVIEW);
return root; return root;
} }
private InnerNode createOperatorTree(Map workingValues, InnerNode parent) { private InnerNode createOperatorTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_operators); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_operators);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_binary_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_operators_before_binary_operators, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_BINARY_OPERATOR, OPERATOR_PREVIEW);
@ -768,7 +766,7 @@ public final class WhiteSpaceOptions {
return root; return root;
} }
private InnerNode createMethodDeclTree(Map workingValues, InnerNode parent) { private InnerNode createMethodDeclTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_methods); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_methods);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_DECLARATION, METHOD_DECL_PREVIEW);
@ -803,7 +801,7 @@ public final class WhiteSpaceOptions {
// return root; // return root;
// } // }
private InnerNode createDeclaratorListTree(Map workingValues, InnerNode parent) { private InnerNode createDeclaratorListTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_declarator_list); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_declarator_list);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_declarator_list_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_DECLARATOR_LIST, DECLARATOR_LIST_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_declarator_list_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_DECLARATOR_LIST, DECLARATOR_LIST_PREVIEW);
@ -811,14 +809,14 @@ public final class WhiteSpaceOptions {
return root; return root;
} }
private InnerNode createExpressionListTree(Map workingValues, InnerNode parent) { private InnerNode createExpressionListTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_expression_list); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_expression_list);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_expression_list_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPRESSION_LIST, EXPRESSION_LIST_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_expression_list_before_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COMMA_IN_EXPRESSION_LIST, EXPRESSION_LIST_PREVIEW);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_expression_list_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPRESSION_LIST, EXPRESSION_LIST_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_expression_list_after_comma, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COMMA_IN_EXPRESSION_LIST, EXPRESSION_LIST_PREVIEW);
return root; return root;
} }
private InnerNode createInitializerListTree(Map workingValues, InnerNode parent) { private InnerNode createInitializerListTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_initializer_list); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_initializer_list);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_INITIALIZER_LIST, INITIALIZER_LIST_PREVIEW);
@ -830,7 +828,7 @@ public final class WhiteSpaceOptions {
return root; return root;
} }
private InnerNode createArrayTree(Map workingValues, InnerNode parent) { private InnerNode createArrayTree(Map<String, String> workingValues, InnerNode parent) {
createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET, ARRAY_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACKET, ARRAY_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET, ARRAY_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_BRACKET, ARRAY_PREVIEW);
createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET, ARRAY_PREVIEW); createOption(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_BRACKET, ARRAY_PREVIEW);
@ -838,7 +836,7 @@ public final class WhiteSpaceOptions {
return parent; return parent;
} }
private InnerNode createFunctionCallTree(Map workingValues, InnerNode parent) { private InnerNode createFunctionCallTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_calls); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_calls);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_METHOD_INVOCATION, METHOD_CALL_PREVIEW);
@ -852,7 +850,7 @@ public final class WhiteSpaceOptions {
return root; return root;
} }
private InnerNode createBlockTree(Map workingValues, InnerNode parent) { private InnerNode createBlockTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_blocks); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_blocks);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, BLOCK_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_brace, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_BRACE_IN_BLOCK, BLOCK_PREVIEW);
@ -860,7 +858,7 @@ public final class WhiteSpaceOptions {
return root; return root;
} }
private InnerNode createSwitchStatementTree(Map workingValues, InnerNode parent) { private InnerNode createSwitchStatementTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_switch); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_switch);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_switch_before_case_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, SWITCH_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_switch_before_case_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_CASE, SWITCH_PREVIEW);
@ -872,7 +870,7 @@ public final class WhiteSpaceOptions {
return root; return root;
} }
private InnerNode createDoWhileTree(Map workingValues, InnerNode parent) { private InnerNode createDoWhileTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_do); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_do);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_WHILE, WHILE_PREVIEW);
@ -882,7 +880,7 @@ public final class WhiteSpaceOptions {
return root; return root;
} }
private InnerNode createTryStatementTree(Map workingValues, InnerNode parent) { private InnerNode createTryStatementTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_try); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_try);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_CATCH, CATCH_PREVIEW);
@ -890,7 +888,7 @@ public final class WhiteSpaceOptions {
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_closing_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_CLOSING_PAREN_IN_CATCH, CATCH_PREVIEW);
return root; return root;
} }
private InnerNode createIfStatementTree(Map workingValues, InnerNode parent) { private InnerNode createIfStatementTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_if); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_if);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_IF, IF_PREVIEW);
@ -899,7 +897,7 @@ public final class WhiteSpaceOptions {
return root; return root;
} }
private InnerNode createForStatementTree(Map workingValues, InnerNode parent) { private InnerNode createForStatementTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_for); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_for);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_FOR, FOR_PREVIEW);
@ -927,14 +925,14 @@ public final class WhiteSpaceOptions {
// return root; // return root;
// } // }
private InnerNode createLabelTree(Map workingValues, InnerNode parent) { private InnerNode createLabelTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_labels); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_labels);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_colon, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_COLON_IN_LABELED_STATEMENT, LABEL_PREVIEW);
return root; return root;
} }
private InnerNode createTemplateArgumentTree(Map workingValues, InnerNode parent) { private InnerNode createTemplateArgumentTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_template_arguments); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_template_arguments);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_ARGUMENTS, TEMPLATES_PREVIEW);
@ -945,7 +943,7 @@ public final class WhiteSpaceOptions {
return root; return root;
} }
private InnerNode createTemplateParameterTree(Map workingValues, InnerNode parent) { private InnerNode createTemplateParameterTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_template_parameters); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_template_parameters);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_angle_bracket, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_ANGLE_BRACKET_IN_TEMPLATE_PARAMETERS, TEMPLATES_PREVIEW);
@ -956,7 +954,7 @@ public final class WhiteSpaceOptions {
return root; return root;
} }
private InnerNode createConditionalTree(Map workingValues, InnerNode parent) { private InnerNode createConditionalTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_conditionals); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_conditionals);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_question, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_question, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_QUESTION_IN_CONDITIONAL, CONDITIONAL_PREVIEW);
@ -967,7 +965,7 @@ public final class WhiteSpaceOptions {
} }
private InnerNode createTypecastTree(Map workingValues, InnerNode parent) { private InnerNode createTypecastTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_typecasts); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_typecasts);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_after_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_AFTER_OPENING_PAREN_IN_CAST, CAST_PREVIEW);
@ -977,7 +975,7 @@ public final class WhiteSpaceOptions {
} }
private InnerNode createParenthesizedExpressionTree(Map workingValues, InnerNode parent) { private InnerNode createParenthesizedExpressionTree(Map<String, String> workingValues, InnerNode parent) {
final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_parenexpr); final InnerNode root= new InnerNode(parent, workingValues, FormatterMessages.WhiteSpaceTabPage_parenexpr);
createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW); createOption(root, workingValues, FormatterMessages.WhiteSpaceTabPage_before_opening_paren, DefaultCodeFormatterConstants.FORMATTER_INSERT_SPACE_BEFORE_OPENING_PAREN_IN_PARENTHESIZED_EXPRESSION, PAREN_EXPR_PREVIEW);
@ -988,17 +986,16 @@ public final class WhiteSpaceOptions {
private static InnerNode createChild(InnerNode root, Map workingValues, String message) { private static InnerNode createChild(InnerNode root, Map<String, String> workingValues, String message) {
return new InnerNode(root, workingValues, message); return new InnerNode(root, workingValues, message);
} }
private static OptionNode createOption(InnerNode root, Map workingValues, String message, String key, PreviewSnippet snippet) { private static OptionNode createOption(InnerNode root, Map<String, String> workingValues, String message, String key, PreviewSnippet snippet) {
return new OptionNode(root, workingValues, message, key, snippet); return new OptionNode(root, workingValues, message, key, snippet);
} }
public static void makeIndexForNodes(List tree, List flatList) { public static void makeIndexForNodes(List<? extends Node> tree, List<Node> flatList) {
for (final Iterator iter= tree.iterator(); iter.hasNext();) { for (Node node : tree) {
final Node node= (Node) iter.next();
node.index= flatList.size(); node.index= flatList.size();
flatList.add(node); flatList.add(node);
makeIndexForNodes(node.getChildren(), flatList); makeIndexForNodes(node.getChildren(), flatList);

View file

@ -13,19 +13,9 @@ package org.eclipse.cdt.internal.ui.preferences.formatter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.jface.dialogs.IDialogSettings; import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.viewers.ArrayContentProvider; import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.CheckStateChangedEvent; import org.eclipse.jface.viewers.CheckStateChangedEvent;
@ -42,7 +32,14 @@ import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer; import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer;
import org.eclipse.ui.part.PageBook; import org.eclipse.ui.part.PageBook;
@ -65,8 +62,8 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
private final String PREF_NODE_KEY= CUIPlugin.PLUGIN_ID + "formatter_page.white_space_tab_page.node"; //$NON-NLS-1$ private final String PREF_NODE_KEY= CUIPlugin.PLUGIN_ID + "formatter_page.white_space_tab_page.node"; //$NON-NLS-1$
private final List fIndexedNodeList; private final List<Node> fIndexedNodeList;
private final List fTree; private final List<? extends Node> fTree;
private ContainerCheckedTreeViewer fTreeViewer; private ContainerCheckedTreeViewer fTreeViewer;
private Composite fComposite; private Composite fComposite;
@ -74,7 +71,7 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
private Node fLastSelected= null; private Node fLastSelected= null;
public SyntaxComponent() { public SyntaxComponent() {
fIndexedNodeList= new ArrayList(); fIndexedNodeList= new ArrayList<Node>();
fTree= new WhiteSpaceOptions().createAltTree(fWorkingValues); fTree= new WhiteSpaceOptions().createAltTree(fWorkingValues);
WhiteSpaceOptions.makeIndexForNodes(fTree, fIndexedNodeList); WhiteSpaceOptions.makeIndexForNodes(fTree, fIndexedNodeList);
} }
@ -89,7 +86,7 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
fTreeViewer= new ContainerCheckedTreeViewer(fComposite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL); fTreeViewer= new ContainerCheckedTreeViewer(fComposite, SWT.SINGLE | SWT.BORDER | SWT.V_SCROLL);
fTreeViewer.setContentProvider(new ITreeContentProvider() { fTreeViewer.setContentProvider(new ITreeContentProvider() {
public Object[] getElements(Object inputElement) { public Object[] getElements(Object inputElement) {
return ((Collection)inputElement).toArray(); return ((Collection<?>)inputElement).toArray();
} }
public Object[] getChildren(Object parentElement) { public Object[] getChildren(Object parentElement) {
return ((Node)parentElement).getChildren().toArray(); return ((Node)parentElement).getChildren().toArray();
@ -118,9 +115,9 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
} }
public void refreshState() { public void refreshState() {
final ArrayList checked= new ArrayList(100); final ArrayList<OptionNode> checked= new ArrayList<OptionNode>(100);
for (Iterator iter= fTree.iterator(); iter.hasNext();) for (Node node : fTree)
((Node) iter.next()).getCheckedLeafs(checked); (node).getCheckedLeafs(checked);
fTreeViewer.setGrayedElements(new Object[0]); fTreeViewer.setGrayedElements(new Object[0]);
fTreeViewer.setCheckedElements(checked.toArray()); fTreeViewer.setCheckedElements(checked.toArray());
fPreview.clear(); fPreview.clear();
@ -161,7 +158,7 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
if (index < 0 || index > fIndexedNodeList.size() - 1) { if (index < 0 || index > fIndexedNodeList.size() - 1) {
index= 0; index= 0;
} }
final Node node= (Node)fIndexedNodeList.get(index); final Node node= fIndexedNodeList.get(index);
if (node != null) { if (node != null) {
fTreeViewer.expandToLevel(node, 0); fTreeViewer.expandToLevel(node, 0);
fTreeViewer.setSelection(new StructuredSelection(new Node [] {node})); fTreeViewer.setSelection(new StructuredSelection(new Node [] {node}));
@ -189,8 +186,8 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
private final String PREF_INNER_INDEX= CUIPlugin.PLUGIN_ID + "formatter_page.white_space.java_view.inner"; //$NON-NLS-1$ private final String PREF_INNER_INDEX= CUIPlugin.PLUGIN_ID + "formatter_page.white_space.java_view.inner"; //$NON-NLS-1$
private final String PREF_OPTION_INDEX= CUIPlugin.PLUGIN_ID + "formatter_page.white_space.java_view.option"; //$NON-NLS-1$ private final String PREF_OPTION_INDEX= CUIPlugin.PLUGIN_ID + "formatter_page.white_space.java_view.option"; //$NON-NLS-1$
private final ArrayList fIndexedNodeList; private final ArrayList<Node> fIndexedNodeList;
private final ArrayList fTree; private final ArrayList<InnerNode> fTree;
private InnerNode fLastSelected; private InnerNode fLastSelected;
@ -200,7 +197,7 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
private Composite fComposite; private Composite fComposite;
public JavaElementComponent() { public JavaElementComponent() {
fIndexedNodeList= new ArrayList(); fIndexedNodeList= new ArrayList<Node>();
fTree= new WhiteSpaceOptions().createTreeByJavaElement(fWorkingValues); fTree= new WhiteSpaceOptions().createTreeByJavaElement(fWorkingValues);
WhiteSpaceOptions.makeIndexForNodes(fTree, fIndexedNodeList); WhiteSpaceOptions.makeIndexForNodes(fTree, fIndexedNodeList);
} }
@ -220,13 +217,12 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
fInnerViewer.setContentProvider(new ITreeContentProvider() { fInnerViewer.setContentProvider(new ITreeContentProvider() {
public Object[] getElements(Object inputElement) { public Object[] getElements(Object inputElement) {
return ((Collection)inputElement).toArray(); return ((Collection<?>)inputElement).toArray();
} }
public Object[] getChildren(Object parentElement) { public Object[] getChildren(Object parentElement) {
final List children= ((Node)parentElement).getChildren(); final List<Node> children= ((Node)parentElement).getChildren();
final ArrayList innerChildren= new ArrayList(); final ArrayList<Object> innerChildren= new ArrayList<Object>();
for (final Iterator iter= children.iterator(); iter.hasNext();) { for (Object o : children) {
final Object o= iter.next();
if (o instanceof InnerNode) innerChildren.add(o); if (o instanceof InnerNode) innerChildren.add(o);
} }
return innerChildren.toArray(); return innerChildren.toArray();
@ -237,9 +233,9 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
return null; return null;
} }
public boolean hasChildren(Object element) { public boolean hasChildren(Object element) {
final List children= ((Node)element).getChildren(); final List<?> children= ((Node)element).getChildren();
for (final Iterator iter= children.iterator(); iter.hasNext();) for (Object child : children)
if (iter.next() instanceof InnerNode) return true; if (child instanceof InnerNode) return true;
return false; return false;
} }
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
@ -283,7 +279,7 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
private void restoreSelections() { private void restoreSelections() {
Node node; Node node;
final int innerIndex= getValidatedIndex(PREF_INNER_INDEX); final int innerIndex= getValidatedIndex(PREF_INNER_INDEX);
node= (Node)fIndexedNodeList.get(innerIndex); node= fIndexedNodeList.get(innerIndex);
if (node instanceof InnerNode) { if (node instanceof InnerNode) {
fInnerViewer.expandToLevel(node, 0); fInnerViewer.expandToLevel(node, 0);
fInnerViewer.setSelection(new StructuredSelection(new Object[] {node})); fInnerViewer.setSelection(new StructuredSelection(new Object[] {node}));
@ -291,7 +287,7 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
} }
final int optionIndex= getValidatedIndex(PREF_OPTION_INDEX); final int optionIndex= getValidatedIndex(PREF_OPTION_INDEX);
node= (Node)fIndexedNodeList.get(optionIndex); node= fIndexedNodeList.get(optionIndex);
if (node instanceof OptionNode) { if (node instanceof OptionNode) {
fOptionsViewer.setSelection(new StructuredSelection(new Object[] {node})); fOptionsViewer.setSelection(new StructuredSelection(new Object[] {node}));
} }
@ -338,19 +334,17 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
private void innerViewerChanged(InnerNode selectedNode) { private void innerViewerChanged(InnerNode selectedNode) {
final List children= selectedNode.getChildren(); final List<Node> children= selectedNode.getChildren();
final ArrayList optionsChildren= new ArrayList(); final ArrayList<OptionNode> optionsChildren= new ArrayList<OptionNode>();
for (final Iterator iter= children.iterator(); iter.hasNext();) { for (Object o : children) {
final Object o= iter.next(); if (o instanceof OptionNode) optionsChildren.add((OptionNode) o);
if (o instanceof OptionNode) optionsChildren.add(o);
} }
fOptionsViewer.setInput(optionsChildren.toArray()); fOptionsViewer.setInput(optionsChildren.toArray());
for (final Iterator iter= optionsChildren.iterator(); iter.hasNext();) { for (OptionNode child : optionsChildren) {
final OptionNode child= (OptionNode)iter.next(); fOptionsViewer.setChecked(child, child.getChecked());
fOptionsViewer.setChecked(child, child.getChecked());
} }
fPreview.clear(); fPreview.clear();
@ -454,7 +448,7 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
* @param modifyDialog * @param modifyDialog
* @param workingValues * @param workingValues
*/ */
public WhiteSpaceTabPage(ModifyDialog modifyDialog, Map workingValues) { public WhiteSpaceTabPage(ModifyDialog modifyDialog, Map<String,String> workingValues) {
super(modifyDialog, workingValues); super(modifyDialog, workingValues);
fDialogSettings= CUIPlugin.getDefault().getDialogSettings(); fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
fSwitchComponent= new SwitchComponent(); fSwitchComponent= new SwitchComponent();

View file

@ -13,11 +13,12 @@
*/ */
package org.eclipse.cdt.internal.ui.search; package org.eclipse.cdt.internal.ui.search;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkingSet; import org.eclipse.ui.IWorkingSet;
import org.eclipse.cdt.core.model.ICElement;
/** /**
* @author aniefer * @author aniefer
* *
@ -54,7 +55,7 @@ public class CSearchUtil {
} }
public static String toString(IWorkingSet[] workingSets) { public static String toString(IWorkingSet[] workingSets) {
if( workingSets != null & workingSets.length > 0 ){ if( workingSets != null && workingSets.length > 0 ){
String string = new String(); String string = new String();
for( int i = 0; i < workingSets.length; i++ ){ for( int i = 0; i < workingSets.length; i++ ){
if( i > 0 ) if( i > 0 )

View file

@ -35,11 +35,11 @@ import org.eclipse.ui.PlatformUI;
*/ */
public class LRUWorkingSets { public class LRUWorkingSets {
ArrayList workingSetsCache = null; ArrayList<IWorkingSet[]> workingSetsCache = null;
int size=0; int size=0;
public LRUWorkingSets(int size){ public LRUWorkingSets(int size){
workingSetsCache = new ArrayList(size); workingSetsCache = new ArrayList<IWorkingSet[]>(size);
this.size = size; this.size = size;
} }
@ -54,12 +54,12 @@ public class LRUWorkingSets {
workingSetsCache.add(0, workingSet); workingSetsCache.add(0, workingSet);
} }
private IWorkingSet[] find(ArrayList list, IWorkingSet[] workingSet) { private IWorkingSet[] find(ArrayList<IWorkingSet[]> list, IWorkingSet[] workingSet) {
Set workingSetList= new HashSet(Arrays.asList(workingSet)); Set<IWorkingSet> workingSetList= new HashSet<IWorkingSet>(Arrays.asList(workingSet));
Iterator iter= list.iterator(); Iterator<IWorkingSet[]> iter= list.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
IWorkingSet[] lruWorkingSets= (IWorkingSet[])iter.next(); IWorkingSet[] lruWorkingSets= iter.next();
Set lruWorkingSetList= new HashSet(Arrays.asList(lruWorkingSets)); Set<IWorkingSet> lruWorkingSetList= new HashSet<IWorkingSet>(Arrays.asList(lruWorkingSets));
if (lruWorkingSetList.equals(workingSetList)) if (lruWorkingSetList.equals(workingSetList))
return lruWorkingSets; return lruWorkingSets;
} }
@ -68,9 +68,9 @@ public class LRUWorkingSets {
private void cleanUpCache(){ private void cleanUpCache(){
//Remove any previously deleted entries //Remove any previously deleted entries
Iterator iter = workingSetsCache.iterator(); Iterator<IWorkingSet[]> iter = workingSetsCache.iterator();
while (iter.hasNext()){ while (iter.hasNext()){
IWorkingSet[] workingSet = (IWorkingSet []) iter.next(); IWorkingSet[] workingSet = iter.next();
for (int i= 0; i < workingSet.length; i++) { for (int i= 0; i < workingSet.length; i++) {
if (PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSet[i].getName()) == null) { if (PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSet[i].getName()) == null) {
workingSetsCache.remove(workingSet); workingSetsCache.remove(workingSet);
@ -80,7 +80,7 @@ public class LRUWorkingSets {
} }
} }
public Iterator iterator() { public Iterator<IWorkingSet[]> iterator() {
return workingSetsCache.iterator(); return workingSetsCache.iterator();
} }
} }

View file

@ -57,7 +57,6 @@ public class PDOMSearchElementQuery extends PDOMSearchQuery {
public String getLabel() { public String getLabel() {
if (element instanceof ICElement) if (element instanceof ICElement)
return super.getLabel() + " " + ((ICElement)element).getElementName(); //$NON-NLS-1$ return super.getLabel() + " " + ((ICElement)element).getElementName(); //$NON-NLS-1$
else return super.getLabel() + " something."; //$NON-NLS-1$
return super.getLabel() + " something."; //$NON-NLS-1$
} }
} }

View file

@ -42,12 +42,12 @@ public class PDOMSearchListContentProvider implements
private PDOMSearchResult result; private PDOMSearchResult result;
public Object[] getElements(Object inputElement) { public Object[] getElements(Object inputElement) {
Set uncoveredProjects = new HashSet(); Set<String> uncoveredProjects = new HashSet<String>();
PDOMSearchResult result = (PDOMSearchResult) inputElement; PDOMSearchResult result = (PDOMSearchResult) inputElement;
Object[] results = result.getElements(); Object[] results = result.getElements();
List resultList = new ArrayList(Arrays.asList(results)); List<Object> resultList = new ArrayList<Object>(Arrays.asList(results));
// see if indexer was busy // see if indexer was busy
if (result.wasIndexerBusy()) { if (result.wasIndexerBusy()) {

View file

@ -178,13 +178,13 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
} }
// get the list of elements for the scope // get the list of elements for the scope
List elements = new ArrayList(); List<Object> elements = new ArrayList<Object>();
String scopeDescription = ""; //$NON-NLS-1$ String scopeDescription = ""; //$NON-NLS-1$
switch (getContainer().getSelectedScope()) { switch (getContainer().getSelectedScope()) {
case ISearchPageContainer.SELECTED_PROJECTS_SCOPE: case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
if (structuredSelection != null) { if (structuredSelection != null) {
scopeDescription = CSearchMessages.ProjectScope; scopeDescription = CSearchMessages.ProjectScope;
for (Iterator i = structuredSelection.iterator(); i.hasNext();) { for (Iterator<?> i = structuredSelection.iterator(); i.hasNext();) {
ICProject project = getProject(i.next()); ICProject project = getProject(i.next());
if (project != null) if (project != null)
elements.add(project); elements.add(project);
@ -194,7 +194,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
case ISearchPageContainer.SELECTION_SCOPE: case ISearchPageContainer.SELECTION_SCOPE:
if( structuredSelection != null) { if( structuredSelection != null) {
scopeDescription = CSearchMessages.SelectionScope; scopeDescription = CSearchMessages.SelectionScope;
for (Iterator i = structuredSelection.iterator(); i.hasNext();) { for (Iterator<?> i = structuredSelection.iterator(); i.hasNext();) {
Object obj = i.next(); Object obj = i.next();
if (obj instanceof IResource) if (obj instanceof IResource)
elements.add(CoreModel.getDefault().create((IResource)obj)); elements.add(CoreModel.getDefault().create((IResource)obj));
@ -225,7 +225,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
ICElement[] scope ICElement[] scope
= elements.isEmpty() = elements.isEmpty()
? null ? null
: (ICElement[])elements.toArray(new ICElement[elements.size()]); : elements.toArray(new ICElement[elements.size()]);
try { try {
PDOMSearchPatternQuery job = new PDOMSearchPatternQuery(scope, scopeDescription, patternStr, PDOMSearchPatternQuery job = new PDOMSearchPatternQuery(scope, scopeDescription, patternStr,

View file

@ -49,17 +49,17 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
private Map<Object, Set<Object>> tree = new HashMap<Object, Set<Object>>(); private Map<Object, Set<Object>> tree = new HashMap<Object, Set<Object>>();
public Object[] getChildren(Object parentElement) { public Object[] getChildren(Object parentElement) {
Set children = tree.get(parentElement); Set<Object> children = tree.get(parentElement);
if (children == null) if (children == null)
return new Object[0]; return new Object[0];
return children.toArray(); return children.toArray();
} }
public Object getParent(Object element) { public Object getParent(Object element) {
Iterator p = tree.keySet().iterator(); Iterator<Object> p = tree.keySet().iterator();
while (p.hasNext()) { while (p.hasNext()) {
Object parent = p.next(); Object parent = p.next();
Set children = tree.get(parent); Set<Object> children = tree.get(parent);
if (children.contains(element)) if (children.contains(element))
return parent; return parent;
} }
@ -236,7 +236,7 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
// reached the search result // reached the search result
return; return;
Set siblings = tree.get(parent); Set<Object> siblings = tree.get(parent);
siblings.remove(element); siblings.remove(element);
if (siblings.isEmpty()) { if (siblings.isEmpty()) {

View file

@ -88,17 +88,17 @@ public class DeclarationsSearchGroup extends ActionGroup {
incomingMenu.add(fFindDeclarationsProjectAction); incomingMenu.add(fFindDeclarationsProjectAction);
incomingMenu.add(fFindDeclarationsInWorkingSetAction); incomingMenu.add(fFindDeclarationsInWorkingSetAction);
for (int i=0; i<actions.length; i++){ for (FindAction action : actions) {
incomingMenu.add(actions[i]); incomingMenu.add(action);
} }
} }
private FindAction[] getWorkingSetActions() { private FindAction[] getWorkingSetActions() {
ArrayList actions= new ArrayList(CSearchUtil.LRU_WORKINGSET_LIST_SIZE); ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
Iterator iter= CSearchUtil.getLRUWorkingSets().iterator(); Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
IWorkingSet[] workingSets= (IWorkingSet[])iter.next(); IWorkingSet[] workingSets= iter.next();
FindAction action; FindAction action;
if (fEditor != null) if (fEditor != null)
action= new WorkingSetFindAction(fEditor, new FindDeclarationsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets)); action= new WorkingSetFindAction(fEditor, new FindDeclarationsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
@ -108,19 +108,18 @@ public class DeclarationsSearchGroup extends ActionGroup {
actions.add(action); actions.add(action);
} }
return (FindAction[])actions.toArray(new FindAction[actions.size()]); return actions.toArray(new FindAction[actions.size()]);
} }
public static boolean canActionBeAdded(ISelection selection) { public static boolean canActionBeAdded(ISelection selection) {
if(selection instanceof ITextSelection) { if(selection instanceof ITextSelection) {
return (((ITextSelection)selection).getLength() > 0); return (((ITextSelection)selection).getLength() > 0);
} else {
return getElement(selection) != null;
} }
return getElement(selection) != null;
} }
private static ICElement getElement(ISelection sel) { private static ICElement getElement(ISelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) { if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
List list= ((IStructuredSelection)sel).toList(); List<?> list= ((IStructuredSelection)sel).toList();
if (list.size() == 1) { if (list.size() == 1) {
Object element= list.get(0); Object element= list.get(0);
if (element instanceof ICElement) { if (element instanceof ICElement) {

View file

@ -70,7 +70,7 @@ public abstract class FindInWorkingSetAction extends FindAction {
if (fWorkingSets == null) { if (fWorkingSets == null) {
return new ICElement[0]; return new ICElement[0];
} }
List scope = new ArrayList(); List<ICElement> scope = new ArrayList<ICElement>();
for (int i = 0; i < fWorkingSets.length; ++i) { for (int i = 0; i < fWorkingSets.length; ++i) {
IAdaptable[] elements = fWorkingSets[i].getElements(); IAdaptable[] elements = fWorkingSets[i].getElements();
for (int j = 0; j < elements.length; ++j) { for (int j = 0; j < elements.length; ++j) {
@ -80,7 +80,7 @@ public abstract class FindInWorkingSetAction extends FindAction {
} }
} }
return (ICElement[])scope.toArray(new ICElement[scope.size()]); return scope.toArray(new ICElement[scope.size()]);
} }
private IWorkingSet[] askForWorkingSets() { private IWorkingSet[] askForWorkingSets() {

View file

@ -45,7 +45,7 @@ public class FindUnresolvedIncludesProjectAction implements IObjectActionDelegat
public void run(IAction action) { public void run(IAction action) {
List<ICProject> projects= new ArrayList<ICProject>(); List<ICProject> projects= new ArrayList<ICProject>();
IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection); IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection);
for (Iterator i = cElements.iterator(); i.hasNext();) { for (Iterator<?> i = cElements.iterator(); i.hasNext();) {
Object elem = i.next(); Object elem = i.next();
if (elem instanceof ICProject) { if (elem instanceof ICProject) {
projects.add((ICProject) elem); projects.add((ICProject) elem);

View file

@ -203,13 +203,11 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
return Status.OK_STATUS; return Status.OK_STATUS;
} }
// Check if we're in an include statement // no enclosing name, check if we're in an include statement
if (searchName == null) { IASTNode node= nodeSelector.findEnclosingNode(selectionStart, selectionLength);
IASTNode node= nodeSelector.findEnclosingNode(selectionStart, selectionLength); if (node instanceof IASTPreprocessorIncludeStatement) {
if (node instanceof IASTPreprocessorIncludeStatement) { openInclude(((IASTPreprocessorIncludeStatement) node));
openInclude(((IASTPreprocessorIncludeStatement) node)); return Status.OK_STATUS;
return Status.OK_STATUS;
}
} }
if (!navigationFallBack(ast)) { if (!navigationFallBack(ast)) {
reportSelectionMatchFailure(); reportSelectionMatchFailure();
@ -267,8 +265,8 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
} }
private boolean navigateOneLocation(IName[] declNames) { private boolean navigateOneLocation(IName[] declNames) {
for (int i = 0; i < declNames.length; i++) { for (IName declName : declNames) {
IASTFileLocation fileloc = declNames[i].getFileLocation(); IASTFileLocation fileloc = declName.getFileLocation();
if (fileloc != null) { if (fileloc != null) {
final IPath path = new Path(fileloc.getFileName()); final IPath path = new Path(fileloc.getFileName());
@ -298,9 +296,9 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
private void convertToCElements(ICProject project, IIndex index, IName[] declNames, List<ICElement> elements) { private void convertToCElements(ICProject project, IIndex index, IName[] declNames, List<ICElement> elements) {
for (int i = 0; i < declNames.length; i++) { for (IName declName : declNames) {
try { try {
ICElement elem = getCElementForName(project, index, declNames[i]); ICElement elem = getCElementForName(project, index, declName);
if (elem instanceof ISourceReference) { if (elem instanceof ISourceReference) {
elements.add(elem); elements.add(elem);
} }

View file

@ -82,18 +82,18 @@ public class ReferencesSearchGroup extends ActionGroup {
incomingMenu.add(fFindRefsProjectAction); incomingMenu.add(fFindRefsProjectAction);
incomingMenu.add(fFindRefsInWorkingSetAction); incomingMenu.add(fFindRefsInWorkingSetAction);
for (int i=0; i<actions.length; i++){ for (FindAction action : actions) {
incomingMenu.add(actions[i]); incomingMenu.add(action);
} }
} }
private FindAction[] getWorkingSetActions() { private FindAction[] getWorkingSetActions() {
ArrayList actions= new ArrayList(CSearchUtil.LRU_WORKINGSET_LIST_SIZE); ArrayList<FindAction> actions= new ArrayList<FindAction>(CSearchUtil.LRU_WORKINGSET_LIST_SIZE);
Iterator iter= CSearchUtil.getLRUWorkingSets().iterator(); Iterator<IWorkingSet[]> iter= CSearchUtil.getLRUWorkingSets().iterator();
while (iter.hasNext()) { while (iter.hasNext()) {
IWorkingSet[] workingSets= (IWorkingSet[])iter.next(); IWorkingSet[] workingSets= iter.next();
FindAction action; FindAction action;
if (fEditor != null) if (fEditor != null)
action= new WorkingSetFindAction(fEditor, new FindRefsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets)); action= new WorkingSetFindAction(fEditor, new FindRefsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
@ -103,7 +103,7 @@ public class ReferencesSearchGroup extends ActionGroup {
actions.add(action); actions.add(action);
} }
return (FindAction[])actions.toArray(new FindAction[actions.size()]); return actions.toArray(new FindAction[actions.size()]);
} }
/* /*

View file

@ -12,8 +12,6 @@ package org.eclipse.cdt.internal.ui.search.actions;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
@ -22,6 +20,10 @@ import org.eclipse.ui.IWorkbenchSite;
import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.part.Page; import org.eclipse.ui.part.Page;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.internal.ui.editor.CEditor;
public class SelectionSearchGroup extends ActionGroup { public class SelectionSearchGroup extends ActionGroup {
private CEditor fEditor; private CEditor fEditor;
@ -63,14 +65,13 @@ public class SelectionSearchGroup extends ActionGroup {
public static boolean canActionBeAdded(ISelection selection) { public static boolean canActionBeAdded(ISelection selection) {
if(selection instanceof ITextSelection) { if(selection instanceof ITextSelection) {
return (((ITextSelection)selection).getLength() > 0); return (((ITextSelection)selection).getLength() > 0);
} else {
return getElement(selection) != null;
} }
return getElement(selection) != null;
} }
private static ICElement getElement(ISelection sel) { private static ICElement getElement(ISelection sel) {
if (!sel.isEmpty() && sel instanceof IStructuredSelection) { if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
List list= ((IStructuredSelection)sel).toList(); List<?> list= ((IStructuredSelection)sel).toList();
if (list.size() == 1) { if (list.size() == 1) {
Object element= list.get(0); Object element= list.get(0);
if (element instanceof ICElement) { if (element instanceof ICElement) {