mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
Fix warnings.
This commit is contained in:
parent
026c8371f8
commit
b681d5978e
59 changed files with 608 additions and 637 deletions
|
@ -65,7 +65,6 @@ public class DefaultCodeFormatterConstants {
|
|||
* </pre>
|
||||
* @see #FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST
|
||||
* @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_SWITCH
|
||||
* @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
|
||||
|
@ -2063,7 +2062,6 @@ public class DefaultCodeFormatterConstants {
|
|||
* </pre>
|
||||
* @see #FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST
|
||||
* @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_SWITCH
|
||||
* @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
|
||||
|
@ -2076,7 +2074,6 @@ public class DefaultCodeFormatterConstants {
|
|||
* </pre>
|
||||
* @see #FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST
|
||||
* @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_SWITCH
|
||||
* @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
|
||||
|
@ -2089,7 +2086,6 @@ public class DefaultCodeFormatterConstants {
|
|||
* </pre>
|
||||
* @see #FORMATTER_BRACE_POSITION_FOR_INITIALIZER_LIST
|
||||
* @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_SWITCH
|
||||
* @see #FORMATTER_BRACE_POSITION_FOR_TYPE_DECLARATION
|
||||
|
@ -2194,7 +2190,7 @@ public class DefaultCodeFormatterConstants {
|
|||
*
|
||||
* @return the default settings
|
||||
*/
|
||||
public static Map getDefaultSettings() {
|
||||
public static Map<String,String> getDefaultSettings() {
|
||||
return DefaultCodeFormatterOptions.getDefaultSettings().getMap();
|
||||
}
|
||||
|
||||
|
@ -2203,7 +2199,7 @@ public class DefaultCodeFormatterConstants {
|
|||
*
|
||||
* @return the K&R settings
|
||||
*/
|
||||
public static Map getKandRSettings() {
|
||||
public static Map<String,String> getKandRSettings() {
|
||||
return DefaultCodeFormatterOptions.getKandRSettings().getMap();
|
||||
}
|
||||
|
||||
|
@ -2212,7 +2208,7 @@ public class DefaultCodeFormatterConstants {
|
|||
*
|
||||
* @return the Allman settings
|
||||
*/
|
||||
public static Map getAllmanSettings() {
|
||||
public static Map<String,String> getAllmanSettings() {
|
||||
return DefaultCodeFormatterOptions.getAllmanSettings().getMap();
|
||||
}
|
||||
|
||||
|
@ -2221,7 +2217,7 @@ public class DefaultCodeFormatterConstants {
|
|||
*
|
||||
* @return the GNU settings
|
||||
*/
|
||||
public static Map getGNUSettings() {
|
||||
public static Map<String,String> getGNUSettings() {
|
||||
return DefaultCodeFormatterOptions.getGNUSettings().getMap();
|
||||
}
|
||||
|
||||
|
@ -2230,7 +2226,7 @@ public class DefaultCodeFormatterConstants {
|
|||
*
|
||||
* @return the Whitesmiths settings
|
||||
*/
|
||||
public static Map getWhitesmithsSettings() {
|
||||
public static Map<String,String> getWhitesmithsSettings() {
|
||||
return DefaultCodeFormatterOptions.getWhitesmithsSettings().getMap();
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@ package org.eclipse.cdt.internal.formatter;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
|
||||
import org.eclipse.cdt.internal.formatter.align.Alignment;
|
||||
|
||||
|
||||
|
@ -246,7 +246,7 @@ public class DefaultCodeFormatterOptions {
|
|||
// cannot be instantiated
|
||||
}
|
||||
|
||||
public DefaultCodeFormatterOptions(Map settings) {
|
||||
public DefaultCodeFormatterOptions(Map<String,String> settings) {
|
||||
setDefaultSettings();
|
||||
if (settings == null) return;
|
||||
set(settings);
|
||||
|
@ -256,8 +256,8 @@ public class DefaultCodeFormatterOptions {
|
|||
return Integer.toString(alignment);
|
||||
}
|
||||
|
||||
public Map getMap() {
|
||||
Map options = new HashMap();
|
||||
public Map<String,String> getMap() {
|
||||
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_METHOD_INVOCATION, getAlignment(this.alignment_for_arguments_in_method_invocation));
|
||||
// options.put(DefaultCodeFormatterConstants.FORMATTER_ALIGNMENT_FOR_ASSIGNMENT, getAlignment(this.alignment_for_assignment));
|
||||
|
@ -449,7 +449,7 @@ public class DefaultCodeFormatterOptions {
|
|||
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);
|
||||
// if (alignmentForArgumentsInAllocationExpressionOption != null) {
|
||||
// try {
|
||||
|
@ -1571,7 +1571,7 @@ public class DefaultCodeFormatterOptions {
|
|||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* @see http://en.wikipedia.org/wiki/Indent_style
|
||||
* @see "http://en.wikipedia.org/wiki/Indent_style"
|
||||
*/
|
||||
public void setKandRSettings() {
|
||||
setDefaultSettings();
|
||||
|
@ -1595,7 +1595,7 @@ public class DefaultCodeFormatterOptions {
|
|||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* @see http://en.wikipedia.org/wiki/Indent_style
|
||||
* @see "http://en.wikipedia.org/wiki/Indent_style"
|
||||
*/
|
||||
public void setAllmanSettings() {
|
||||
setDefaultSettings();
|
||||
|
@ -1661,7 +1661,7 @@ public class DefaultCodeFormatterOptions {
|
|||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* @see http://en.wikipedia.org/wiki/Indent_style
|
||||
* @see "http://en.wikipedia.org/wiki/Indent_style"
|
||||
*/
|
||||
public void setGNUSettings() {
|
||||
setDefaultSettings();
|
||||
|
@ -1732,7 +1732,7 @@ public class DefaultCodeFormatterOptions {
|
|||
* }
|
||||
* }
|
||||
* </pre>
|
||||
* @see http://en.wikipedia.org/wiki/Indent_style
|
||||
* @see "http://en.wikipedia.org/wiki/Indent_style"
|
||||
*/
|
||||
public void setWhitesmitsSettings() {
|
||||
setDefaultSettings();
|
||||
|
|
|
@ -20,9 +20,9 @@ import org.eclipse.jface.text.source.IAnnotationModel;
|
|||
/**
|
||||
* 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 boolean fSkipIrrelevants;
|
||||
private boolean fReturnAllAnnotations;
|
||||
|
@ -40,6 +40,7 @@ public class CAnnotationIterator implements Iterator {
|
|||
* @param skipIrrelevants whether to skip irrelevant annotations
|
||||
* @param returnAllAnnotations Whether to return non IJavaAnnotations as well
|
||||
*/
|
||||
@SuppressWarnings("unchecked") // using api without generics
|
||||
public CAnnotationIterator(IAnnotationModel model, boolean skipIrrelevants, boolean returnAllAnnotations) {
|
||||
fReturnAllAnnotations= returnAllAnnotations;
|
||||
if (model != null)
|
||||
|
@ -52,7 +53,7 @@ public class CAnnotationIterator implements Iterator {
|
|||
|
||||
private void skip() {
|
||||
while (fIterator.hasNext()) {
|
||||
Annotation next= (Annotation) fIterator.next();
|
||||
Annotation next= fIterator.next();
|
||||
if (next instanceof ICAnnotation) {
|
||||
if (fSkipIrrelevants) {
|
||||
if (!next.isMarkedDeleted()) {
|
||||
|
@ -81,7 +82,7 @@ public class CAnnotationIterator implements Iterator {
|
|||
/*
|
||||
* @see Iterator#next()
|
||||
*/
|
||||
public Object next() {
|
||||
public Annotation next() {
|
||||
try {
|
||||
return fNext;
|
||||
} finally {
|
||||
|
|
|
@ -212,7 +212,7 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
|
|||
protected ISelection updateSelection(ISelection sel) {
|
||||
final ArrayList<ICElement> newSelection = new ArrayList<ICElement>();
|
||||
if (sel instanceof IStructuredSelection) {
|
||||
final Iterator iter = ((IStructuredSelection) sel).iterator();
|
||||
final Iterator<?> iter = ((IStructuredSelection) sel).iterator();
|
||||
while (iter.hasNext()) {
|
||||
final Object o = iter.next();
|
||||
if (o instanceof ICElement) {
|
||||
|
@ -307,8 +307,8 @@ public class CContentOutlinerProvider extends BaseCElementContentProvider {
|
|||
return null;
|
||||
}
|
||||
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
final ICElementDelta d = findElement(unit, children[i]);
|
||||
for (ICElementDelta element2 : children) {
|
||||
final ICElementDelta d = findElement(unit, element2);
|
||||
if (d != null) {
|
||||
return d;
|
||||
}
|
||||
|
|
|
@ -580,9 +580,9 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
private void overlayMarkers(Position position, ProblemAnnotation problemAnnotation) {
|
||||
Object value= getAnnotations(position);
|
||||
if (value instanceof List) {
|
||||
List list= (List) value;
|
||||
for (Iterator e = list.iterator(); e.hasNext();)
|
||||
setOverlay(e.next(), problemAnnotation);
|
||||
List<?> list= (List<?>) value;
|
||||
for (Object element : list)
|
||||
setOverlay(element, problemAnnotation);
|
||||
} else {
|
||||
setOverlay(value, problemAnnotation);
|
||||
}
|
||||
|
@ -681,7 +681,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
synchronized (getLockObject()) {
|
||||
Object cached= fReverseMap.get(position);
|
||||
if (cached instanceof List) {
|
||||
List list= (List) cached;
|
||||
List<?> list= (List<?>) cached;
|
||||
list.remove(annotation);
|
||||
if (list.size() == 1) {
|
||||
fReverseMap.put(position, list.get(0));
|
||||
|
@ -708,8 +708,8 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
*/
|
||||
public void modelChanged(IAnnotationModel model) {
|
||||
Object[] listeners= fListenerList.getListeners();
|
||||
for (int i= 0; i < listeners.length; i++) {
|
||||
((IAnnotationModelListener) listeners[i]).modelChanged(model);
|
||||
for (Object listener : listeners) {
|
||||
((IAnnotationModelListener) listener).modelChanged(model);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -718,8 +718,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
*/
|
||||
public void modelChanged(AnnotationModelEvent event) {
|
||||
Object[] listeners= fListenerList.getListeners();
|
||||
for (int i= 0; i < listeners.length; i++) {
|
||||
Object curr= listeners[i];
|
||||
for (Object curr : listeners) {
|
||||
if (curr instanceof IAnnotationModelListenerExtension) {
|
||||
((IAnnotationModelListenerExtension) curr).modelChanged(event);
|
||||
}
|
||||
|
@ -1034,7 +1033,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
*/
|
||||
protected void enableHandlingTemporaryProblems() {
|
||||
boolean enable= isHandlingTemporaryProblems();
|
||||
for (Iterator iter= getFileInfosIterator(); iter.hasNext();) {
|
||||
for (Iterator<?> iter= getFileInfosIterator(); iter.hasNext();) {
|
||||
FileInfo info= (FileInfo) iter.next();
|
||||
if (info.fModel instanceof IProblemRequestorExtension) {
|
||||
IProblemRequestorExtension extension= (IProblemRequestorExtension) info.fModel;
|
||||
|
@ -1062,7 +1061,7 @@ public class CDocumentProvider extends TextFileDocumentProvider {
|
|||
|
||||
public void shutdown() {
|
||||
// CUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(fPropertyListener);
|
||||
Iterator e = getConnectedElementsIterator();
|
||||
Iterator<?> e = getConnectedElementsIterator();
|
||||
while (e.hasNext())
|
||||
disconnect(e.next());
|
||||
}
|
||||
|
|
|
@ -189,12 +189,12 @@ import org.eclipse.cdt.internal.ui.CPluginImages;
|
|||
import org.eclipse.cdt.internal.ui.ICHelpContextIds;
|
||||
import org.eclipse.cdt.internal.ui.IContextMenuConstants;
|
||||
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.GoToNextPreviousMemberAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.GotoNextBookmarkAction;
|
||||
import org.eclipse.cdt.internal.ui.actions.IndentAction;
|
||||
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.dnd.TextEditorDropAdapter;
|
||||
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)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getAdapter(Class required) {
|
||||
if (IContentOutlinePage.class.equals(required)) {
|
||||
|
@ -1410,7 +1411,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
ce = null;
|
||||
}
|
||||
} catch (CModelException ex) {
|
||||
ce= null;
|
||||
}
|
||||
final ISelection selection= ce != null ? new StructuredSelection(ce) : null;
|
||||
return new IShowInSource() {
|
||||
|
@ -1582,9 +1582,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
SourceViewerConfiguration configuration= getSourceViewerConfiguration();
|
||||
String[] types= configuration.getConfiguredContentTypes(getSourceViewer());
|
||||
|
||||
for (int i= 0; i < types.length; i++) {
|
||||
|
||||
String t= types[i];
|
||||
for (String t : types) {
|
||||
|
||||
ISourceViewer sourceViewer= getSourceViewer();
|
||||
if (sourceViewer instanceof ITextViewerExtension2) {
|
||||
|
@ -1594,8 +1592,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
int[] stateMasks= configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t);
|
||||
|
||||
if (stateMasks != null) {
|
||||
for (int j= 0; j < stateMasks.length; j++) {
|
||||
int stateMask= stateMasks[j];
|
||||
for (int stateMask : stateMasks) {
|
||||
ITextHover textHover= configuration.getTextHover(sourceViewer, 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) {
|
||||
IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
|
||||
Iterator e = new CAnnotationIterator(model, true, true);
|
||||
Iterator<Annotation> e = new CAnnotationIterator(model, true, true);
|
||||
while (e.hasNext()) {
|
||||
Annotation a = (Annotation) e.next();
|
||||
Annotation a = e.next();
|
||||
if (!isNavigationTarget(a))
|
||||
continue;
|
||||
|
||||
|
@ -2994,10 +2991,10 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC
|
|||
((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, annotationMap);
|
||||
} else {
|
||||
removeOccurrenceAnnotations();
|
||||
Iterator iter= annotationMap.entrySet().iterator();
|
||||
Iterator<Map.Entry<Annotation, Position>> iter= annotationMap.entrySet().iterator();
|
||||
while (iter.hasNext()) {
|
||||
Map.Entry mapEntry= (Map.Entry)iter.next();
|
||||
annotationModel.addAnnotation((Annotation)mapEntry.getKey(), (Position)mapEntry.getValue());
|
||||
Map.Entry<Annotation, Position> mapEntry= iter.next();
|
||||
annotationModel.addAnnotation(mapEntry.getKey(), mapEntry.getValue());
|
||||
}
|
||||
}
|
||||
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) {
|
||||
((IAnnotationModelExtension)annotationModel).replaceAnnotations(fOccurrenceAnnotations, null);
|
||||
} else {
|
||||
for (int i= 0, length= fOccurrenceAnnotations.length; i < length; i++)
|
||||
annotationModel.removeAnnotation(fOccurrenceAnnotations[i]);
|
||||
for (Annotation occurrenceAnnotation : fOccurrenceAnnotations)
|
||||
annotationModel.removeAnnotation(occurrenceAnnotation);
|
||||
}
|
||||
fOccurrenceAnnotations= null;
|
||||
}
|
||||
|
|
|
@ -154,7 +154,7 @@ public class CMarkerAnnotation extends MarkerAnnotation implements IProblemAnnot
|
|||
/*
|
||||
* @see ICAnnotation#getOverlaidIterator()
|
||||
*/
|
||||
public Iterator getOverlaidIterator() {
|
||||
public Iterator<ICAnnotation> getOverlaidIterator() {
|
||||
// not supported
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.core.runtime.Assert;
|
||||
import org.eclipse.jface.preference.IPreferenceStore;
|
||||
|
@ -409,11 +410,14 @@ public class CSourceViewer extends ProjectionViewer implements IPropertyChangeLi
|
|||
public void prependTextPresentationListener(ITextPresentationListener listener) {
|
||||
Assert.isNotNull(listener);
|
||||
|
||||
if (fTextPresentationListeners == null)
|
||||
fTextPresentationListeners= new ArrayList<ITextPresentationListener>();
|
||||
@SuppressWarnings("unchecked") // using list from base class
|
||||
List<ITextPresentationListener> textPresentationListeners= fTextPresentationListeners;
|
||||
|
||||
if (textPresentationListeners == null)
|
||||
fTextPresentationListeners= textPresentationListeners= new ArrayList<ITextPresentationListener>();
|
||||
|
||||
fTextPresentationListeners.remove(listener);
|
||||
fTextPresentationListeners.add(0, listener);
|
||||
textPresentationListeners.remove(listener);
|
||||
textPresentationListeners.add(0, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -178,9 +178,9 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
|
|||
private DocumentSetCommand fSetCmd= new DocumentSetCommand();
|
||||
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;
|
||||
|
||||
final private IPath fLocation;
|
||||
|
@ -451,7 +451,7 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
|
|||
|
||||
if (fLegalLineDelimiters == null) {
|
||||
// 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-- ) {
|
||||
try {
|
||||
|
@ -509,9 +509,9 @@ public class DocumentAdapter implements IBuffer, IDocumentListener {
|
|||
|
||||
private void fireBufferChanged(BufferChangedEvent event) {
|
||||
if (fBufferListeners != null && fBufferListeners.size() > 0) {
|
||||
Iterator e= new ArrayList(fBufferListeners).iterator();
|
||||
Iterator<IBufferChangedListener> e= new ArrayList<IBufferChangedListener>(fBufferListeners).iterator();
|
||||
while (e.hasNext())
|
||||
((IBufferChangedListener) e.next()).bufferChanged(event);
|
||||
e.next().bufferChanged(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -85,14 +85,11 @@ public class ExternalSearchDocumentProvider extends TextFileDocumentProvider {
|
|||
IStorage storage = new EFSFileStorage(uri);
|
||||
return createExternalSearchAnnotationModel(storage, null);
|
||||
}
|
||||
else {
|
||||
ILocationProvider provider = (ILocationProvider) adaptable
|
||||
.getAdapter(ILocationProvider.class);
|
||||
if (provider != null) {
|
||||
IPath path = provider.getPath(element);
|
||||
IStorage storage = new FileStorage(path);
|
||||
return createExternalSearchAnnotationModel(storage, null);
|
||||
}
|
||||
ILocationProvider provider = (ILocationProvider) adaptable.getAdapter(ILocationProvider.class);
|
||||
if (provider != null) {
|
||||
IPath path = provider.getPath(element);
|
||||
IStorage storage = new FileStorage(path);
|
||||
return createExternalSearchAnnotationModel(storage, null);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -64,9 +64,9 @@ public interface ICAnnotation {
|
|||
* Returns an iterator for iterating over the
|
||||
* 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
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.eclipse.jface.text.BadLocationException;
|
|||
import org.eclipse.jface.text.IDocument;
|
||||
import org.eclipse.jface.text.IRegion;
|
||||
import org.eclipse.jface.text.ITextInputListener;
|
||||
import org.eclipse.jface.text.Position;
|
||||
import org.eclipse.jface.text.TypedPosition;
|
||||
import org.eclipse.swt.widgets.Display;
|
||||
|
||||
|
@ -84,7 +85,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
|
|||
/** The editor this is installed on */
|
||||
private CEditor fEditor;
|
||||
/** The list of currently highlighted positions */
|
||||
private List fInactiveCodePositions= Collections.EMPTY_LIST;
|
||||
private List<Position> fInactiveCodePositions= Collections.emptyList();
|
||||
private IDocument fDocument;
|
||||
|
||||
/**
|
||||
|
@ -161,7 +162,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
|
|||
}
|
||||
if (fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
|
||||
fLineBackgroundPainter.removeHighlightPositions(fInactiveCodePositions);
|
||||
fInactiveCodePositions= Collections.EMPTY_LIST;
|
||||
fInactiveCodePositions= Collections.emptyList();
|
||||
fLineBackgroundPainter= null;
|
||||
}
|
||||
if (fEditor != null) {
|
||||
|
@ -195,7 +196,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
|
|||
if (progressMonitor != null && progressMonitor.isCanceled()) {
|
||||
return;
|
||||
}
|
||||
final List newInactiveCodePositions= collectInactiveCodePositions(ast);
|
||||
final List<Position> newInactiveCodePositions= collectInactiveCodePositions(ast);
|
||||
Runnable updater = new Runnable() {
|
||||
public void run() {
|
||||
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>
|
||||
* @return a {@link List} of {@link IRegion}s
|
||||
*/
|
||||
private List collectInactiveCodePositions(IASTTranslationUnit translationUnit) {
|
||||
private List<Position> collectInactiveCodePositions(IASTTranslationUnit translationUnit) {
|
||||
if (translationUnit == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
String fileName = translationUnit.getFilePath();
|
||||
if (fileName == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List positions = new ArrayList();
|
||||
List<Position> positions = new ArrayList<Position>();
|
||||
int inactiveCodeStart = -1;
|
||||
boolean inInactiveCode = false;
|
||||
Stack inactiveCodeStack = new Stack();
|
||||
Stack<Boolean> inactiveCodeStack = new Stack<Boolean>();
|
||||
|
||||
IASTPreprocessorStatement[] preprocStmts = translationUnit.getAllPreprocessorStatements();
|
||||
|
||||
for (int i = 0; i < preprocStmts.length; i++) {
|
||||
IASTPreprocessorStatement statement = preprocStmts[i];
|
||||
for (IASTPreprocessorStatement statement : preprocStmts) {
|
||||
IASTFileLocation floc= statement.getFileLocation();
|
||||
if (floc == null || !fileName.equals(floc.getFileName())) {
|
||||
// preprocessor directive is from a different file
|
||||
|
@ -287,7 +287,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
|
|||
}
|
||||
} else if (statement instanceof IASTPreprocessorEndifStatement) {
|
||||
try {
|
||||
boolean wasInInactiveCode = ((Boolean)inactiveCodeStack.pop()).booleanValue();
|
||||
boolean wasInInactiveCode = inactiveCodeStack.pop().booleanValue();
|
||||
if (inInactiveCode && !wasInInactiveCode) {
|
||||
int inactiveCodeEnd = floc.getNodeOffset() + floc.getNodeLength();
|
||||
positions.add(createHighlightPosition(inactiveCodeStart, inactiveCodeEnd, true, fHighlightKey));
|
||||
|
@ -337,7 +337,7 @@ public class InactiveCodeHighlighting implements ICReconcilingListener, ITextInp
|
|||
public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
|
||||
if (fEditor != null && fLineBackgroundPainter != null && !fLineBackgroundPainter.isDisposed()) {
|
||||
fLineBackgroundPainter.removeHighlightPositions(fInactiveCodePositions);
|
||||
fInactiveCodePositions= Collections.EMPTY_LIST;
|
||||
fInactiveCodePositions= Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -330,8 +330,7 @@ public final class IndentUtil {
|
|||
private static int computeVisualLength(char ch, int tabSize) {
|
||||
if (ch == '\t')
|
||||
return tabSize;
|
||||
else
|
||||
return 1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -87,7 +87,7 @@ public class OpenIncludeAction extends Action {
|
|||
|
||||
try {
|
||||
IResource res = include.getUnderlyingResource();
|
||||
ArrayList/*<IPath>*/ filesFound = new ArrayList(4);
|
||||
ArrayList<IPath> filesFound = new ArrayList<IPath>(4);
|
||||
String fullFileName= include.getFullFileName();
|
||||
if (fullFileName != null) {
|
||||
IPath fullPath= new Path(fullFileName);
|
||||
|
@ -144,7 +144,7 @@ public class OpenIncludeAction extends Action {
|
|||
noElementsFound();
|
||||
fileToOpen= null;
|
||||
} else if (nElementsFound == 1) {
|
||||
fileToOpen= (IPath) filesFound.get(0);
|
||||
fileToOpen= filesFound.get(0);
|
||||
} else {
|
||||
fileToOpen= chooseFile(filesFound);
|
||||
}
|
||||
|
@ -198,7 +198,7 @@ public class OpenIncludeAction extends Action {
|
|||
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 {
|
||||
// in case it is an absolute path
|
||||
IPath includeFile= new Path(name);
|
||||
|
@ -209,14 +209,13 @@ public class OpenIncludeAction extends Action {
|
|||
return;
|
||||
}
|
||||
}
|
||||
HashSet foundSet = new HashSet();
|
||||
for (int i = 0; i < includePaths.length; i++) {
|
||||
IPath path = PathUtil.getCanonicalPath(new Path(includePaths[i]).append(includeFile));
|
||||
HashSet<IPath> foundSet = new HashSet<IPath>();
|
||||
for (String includePath : includePaths) {
|
||||
IPath path = PathUtil.getCanonicalPath(new Path(includePath).append(includeFile));
|
||||
File file = path.toFile();
|
||||
if (file.exists()) {
|
||||
IPath[] paths = resolveIncludeLink(path);
|
||||
for (int j = 0; j < paths.length; j++) {
|
||||
IPath p = paths[j];
|
||||
for (IPath p : paths) {
|
||||
if (foundSet.add(p)) {
|
||||
list.add(p);
|
||||
}
|
||||
|
@ -232,7 +231,7 @@ public class OpenIncludeAction extends Action {
|
|||
* @param list
|
||||
* @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() {
|
||||
|
||||
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() {
|
||||
@Override
|
||||
public String getText(Object element) {
|
||||
|
@ -280,7 +279,7 @@ public class OpenIncludeAction extends Action {
|
|||
|
||||
private static IInclude getIncludeStatement(ISelection sel) {
|
||||
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||
List list= ((IStructuredSelection)sel).toList();
|
||||
List<?> list= ((IStructuredSelection)sel).toList();
|
||||
if (list.size() == 1) {
|
||||
Object element= list.get(0);
|
||||
if (element instanceof IInclude) {
|
||||
|
|
|
@ -12,15 +12,16 @@
|
|||
package org.eclipse.cdt.internal.ui.editor;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import org.eclipse.jface.text.source.IAnnotationModel;
|
||||
|
||||
|
||||
/**
|
||||
* 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;
|
||||
|
||||
public ProblemAnnotationIterator(IAnnotationModel model) {
|
||||
|
@ -49,7 +50,7 @@ public class ProblemAnnotationIterator implements Iterator {
|
|||
/*
|
||||
* @see Iterator#next()
|
||||
*/
|
||||
public Object next() {
|
||||
public IProblemAnnotation next() {
|
||||
try {
|
||||
return fNext;
|
||||
} finally {
|
||||
|
|
|
@ -349,7 +349,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
|
|||
* @return the hard-coded positions
|
||||
*/
|
||||
private HighlightedPosition[] createHardcodedPositions() {
|
||||
List positions= new ArrayList();
|
||||
List<HighlightedPosition> positions= new ArrayList<HighlightedPosition>();
|
||||
for (int i= 0; i < fHardcodedRanges.length; i++) {
|
||||
HighlightedRange range= null;
|
||||
HighlightingStyle hl= null;
|
||||
|
@ -364,7 +364,7 @@ public class SemanticHighlightingManager implements IPropertyChangeListener {
|
|||
if (range != null)
|
||||
positions.add(fPresenter.createHighlightedPosition(range.getOffset(), range.getLength(), hl));
|
||||
}
|
||||
return (HighlightedPosition[]) positions.toArray(new HighlightedPosition[positions.size()]);
|
||||
return positions.toArray(new HighlightedPosition[positions.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -236,7 +236,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
private CPresentationReconciler fPresentationReconciler;
|
||||
|
||||
/** 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 */
|
||||
private Object fPositionLock= new Object();
|
||||
|
||||
|
@ -267,7 +267,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
*
|
||||
* @param list The list
|
||||
*/
|
||||
public void addAllPositions(List list) {
|
||||
public void addAllPositions(List<? super HighlightedPosition> list) {
|
||||
synchronized (fPositionLock) {
|
||||
list.addAll(fPositions);
|
||||
}
|
||||
|
@ -283,7 +283,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
* @param removedPositions the removed positions
|
||||
* @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;
|
||||
CPresentationReconciler presentationReconciler= fPresentationReconciler;
|
||||
if (sourceViewer == null || presentationReconciler == null)
|
||||
|
@ -299,13 +299,13 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
int minStart= Integer.MAX_VALUE;
|
||||
int maxEnd= Integer.MIN_VALUE;
|
||||
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();
|
||||
minStart= Math.min(minStart, offset);
|
||||
maxEnd= Math.max(maxEnd, offset + position.getLength());
|
||||
}
|
||||
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();
|
||||
minStart= Math.min(minStart, offset);
|
||||
maxEnd= Math.max(maxEnd, offset + position.getLength());
|
||||
|
@ -331,15 +331,13 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
* @param removedPositions the removed positions
|
||||
* @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)
|
||||
return null;
|
||||
|
||||
// TODO: do clustering of positions and post multiple fast runnables
|
||||
final HighlightedPosition[] added= new SemanticHighlightingManager.HighlightedPosition[addedPositions.size()];
|
||||
addedPositions.toArray(added);
|
||||
final SemanticHighlightingManager.HighlightedPosition[] removed= new SemanticHighlightingManager.HighlightedPosition[removedPositions.size()];
|
||||
removedPositions.toArray(removed);
|
||||
final HighlightedPosition[] added= addedPositions.toArray(new HighlightedPosition[addedPositions.size()]);
|
||||
final HighlightedPosition[] removed= removedPositions.toArray(new HighlightedPosition[removedPositions.size()]);
|
||||
|
||||
if (isCanceled())
|
||||
return null;
|
||||
|
@ -381,11 +379,11 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
|
||||
String positionCategory= getPositionCategory();
|
||||
|
||||
List removedPositionsList= Arrays.asList(removedPositions);
|
||||
List<HighlightedPosition> removedPositionsList= Arrays.asList(removedPositions);
|
||||
|
||||
try {
|
||||
synchronized (fPositionLock) {
|
||||
List oldPositions= fPositions;
|
||||
List<HighlightedPosition> oldPositions= fPositions;
|
||||
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
|
||||
* is stored in newPositions.
|
||||
*/
|
||||
List newPositions= new ArrayList(newSize);
|
||||
Position position= null;
|
||||
Position addedPosition= null;
|
||||
List<HighlightedPosition> newPositions= new ArrayList<HighlightedPosition>(newSize);
|
||||
HighlightedPosition position= null;
|
||||
HighlightedPosition 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)
|
||||
|
||||
// a) find the next non-deleted Position from the old list
|
||||
while (position == null && i < n) {
|
||||
position= (Position) oldPositions.get(i++);
|
||||
position= oldPositions.get(i++);
|
||||
if (position.isDeleted() || contain(removedPositionsList, position)) {
|
||||
document.removePosition(positionCategory, position);
|
||||
position= null;
|
||||
|
@ -467,7 +465,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
* @param position 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;
|
||||
}
|
||||
|
||||
|
@ -477,7 +475,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
* @param position the position
|
||||
* @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 size= positions.size();
|
||||
while (index < size) {
|
||||
|
@ -493,7 +491,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
*
|
||||
* @param position The position for insertion
|
||||
*/
|
||||
private void insertPosition(Position position) {
|
||||
private void insertPosition(HighlightedPosition position) {
|
||||
int i= computeIndexAfterOffset(fPositions, position.getOffset());
|
||||
fPositions.add(i, position);
|
||||
}
|
||||
|
@ -505,12 +503,12 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
* @param offset the 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 j= positions.size();
|
||||
while (j - i > 1) {
|
||||
int k= (i + j) >> 1;
|
||||
Position position= (Position) positions.get(k);
|
||||
Position position= positions.get(k);
|
||||
if (position.getOffset() > offset)
|
||||
j= k;
|
||||
else
|
||||
|
@ -526,12 +524,12 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
* @param offset the 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 j= positions.size();
|
||||
while (j - i > 1) {
|
||||
int k= (i + j) >> 1;
|
||||
Position position= (Position) positions.get(k);
|
||||
Position position= positions.get(k);
|
||||
if (position.getOffset() >= offset)
|
||||
j= k;
|
||||
else
|
||||
|
@ -547,18 +545,18 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
IRegion region= textPresentation.getExtent();
|
||||
int i= computeIndexAtOffset(fPositions, region.getOffset()), n= computeIndexAtOffset(fPositions, region.getOffset() + region.getLength());
|
||||
if (n - i > 2) {
|
||||
List ranges= new ArrayList(n - i);
|
||||
List<StyleRange> ranges= new ArrayList<StyleRange>(n - i);
|
||||
for (; i < n; i++) {
|
||||
HighlightedPosition position= (HighlightedPosition) fPositions.get(i);
|
||||
HighlightedPosition position= fPositions.get(i);
|
||||
if (!position.isDeleted())
|
||||
ranges.add(position.createStyleRange());
|
||||
}
|
||||
StyleRange[] array= new StyleRange[ranges.size()];
|
||||
array= (StyleRange[]) ranges.toArray(array);
|
||||
array= ranges.toArray(array);
|
||||
textPresentation.replaceStyleRanges(array);
|
||||
} else {
|
||||
for (; i < n; i++) {
|
||||
HighlightedPosition position= (HighlightedPosition) fPositions.get(i);
|
||||
HighlightedPosition position= fPositions.get(i);
|
||||
if (!position.isDeleted())
|
||||
textPresentation.replaceStyleRange(position.createStyleRange());
|
||||
}
|
||||
|
@ -682,7 +680,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
*/
|
||||
public void highlightingStyleChanged(HighlightingStyle highlighting) {
|
||||
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)
|
||||
fSourceViewer.invalidateTextPresentation(position.getOffset(), position.getLength());
|
||||
}
|
||||
|
@ -696,7 +694,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
fSourceViewer.invalidateTextPresentation();
|
||||
} else {
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
@ -711,7 +709,7 @@ public class SemanticHighlightingPresenter implements ITextPresentationListener,
|
|||
* @param highlighting
|
||||
*/
|
||||
private void addPositionFromUI(int offset, int length, HighlightingStyle highlighting) {
|
||||
Position position= createHighlightedPosition(offset, length, highlighting);
|
||||
HighlightedPosition position= createHighlightedPosition(offset, length, highlighting);
|
||||
synchronized (fPositionLock) {
|
||||
insertPosition(position);
|
||||
}
|
||||
|
|
|
@ -95,8 +95,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
|
||||
// visit macro definitions
|
||||
IASTPreprocessorMacroDefinition[] macroDefs= tu.getMacroDefinitions();
|
||||
for (int i= 0; i < macroDefs.length; i++) {
|
||||
IASTPreprocessorMacroDefinition macroDef= macroDefs[i];
|
||||
for (IASTPreprocessorMacroDefinition macroDef : macroDefs) {
|
||||
if (macroDef.isPartOfTranslationUnitFile()) {
|
||||
visitNode(macroDef.getName());
|
||||
}
|
||||
|
@ -105,14 +104,12 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
|
||||
// visit macro expansions
|
||||
IASTPreprocessorMacroExpansion[] macroExps= tu.getMacroExpansions();
|
||||
for (int i= 0; i < macroExps.length; i++) {
|
||||
IASTPreprocessorMacroExpansion macroExp= macroExps[i];
|
||||
for (IASTPreprocessorMacroExpansion macroExp : macroExps) {
|
||||
if (macroExp.isPartOfTranslationUnitFile()) {
|
||||
IASTName macroRef= macroExp.getMacroReference();
|
||||
visitNode(macroRef);
|
||||
IASTName[] nestedMacroRefs= macroExp.getNestedMacroReferences();
|
||||
for (int j= 0; j < nestedMacroRefs.length; j++) {
|
||||
IASTName nestedMacroRef= nestedMacroRefs[j];
|
||||
for (IASTName nestedMacroRef : nestedMacroRefs) {
|
||||
visitNode(nestedMacroRef);
|
||||
}
|
||||
}
|
||||
|
@ -144,8 +141,8 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
IASTFunctionDefinition functionDef= (IASTFunctionDefinition) declaration;
|
||||
ICPPASTFunctionTryBlockDeclarator declarator= (ICPPASTFunctionTryBlockDeclarator) functionDef.getDeclarator();
|
||||
ICPPASTCatchHandler[] catchHandlers= declarator.getCatchHandlers();
|
||||
for (int i = 0; i < catchHandlers.length; i++) {
|
||||
catchHandlers[i].accept(this);
|
||||
for (ICPPASTCatchHandler catchHandler : catchHandlers) {
|
||||
catchHandler.accept(this);
|
||||
}
|
||||
}
|
||||
return PROCESS_CONTINUE;
|
||||
|
@ -273,7 +270,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
boolean isExisting= false;
|
||||
// TODO: use binary search
|
||||
for (int i= 0, n= fRemovedPositions.size(); i < n; i++) {
|
||||
HighlightedPosition position= (HighlightedPosition) fRemovedPositions.get(i);
|
||||
HighlightedPosition position= fRemovedPositions.get(i);
|
||||
if (position == null)
|
||||
continue;
|
||||
if (position.isEqual(offset, length, highlighting)) {
|
||||
|
@ -285,7 +282,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
}
|
||||
|
||||
if (!isExisting) {
|
||||
Position position= fJobPresenter.createHighlightedPosition(offset, length, highlighting);
|
||||
HighlightedPosition position= fJobPresenter.createHighlightedPosition(offset, length, highlighting);
|
||||
fAddedPositions.add(position);
|
||||
}
|
||||
}
|
||||
|
@ -302,9 +299,9 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
private HighlightingStyle[] fHighlightings;
|
||||
|
||||
/** 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 */
|
||||
private List<Object> fRemovedPositions= new ArrayList<Object>();
|
||||
private List<HighlightedPosition> fRemovedPositions= new ArrayList<HighlightedPosition>();
|
||||
/** Number of removed positions */
|
||||
private int fNOfRemovedPositions;
|
||||
|
||||
|
@ -342,8 +339,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
synchronized (fReconcileLock) {
|
||||
if (fIsReconciling)
|
||||
return;
|
||||
else
|
||||
fIsReconciling= true;
|
||||
fIsReconciling= true;
|
||||
}
|
||||
fJobPresenter= fPresenter;
|
||||
fJobSemanticHighlightings= fSemanticHighlightings;
|
||||
|
@ -399,10 +395,10 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
*/
|
||||
private void reconcilePositions(IASTTranslationUnit ast, PositionCollector visitor) {
|
||||
ast.accept(visitor);
|
||||
List<Object> oldPositions= fRemovedPositions;
|
||||
List<Object> newPositions= new ArrayList<Object>(fNOfRemovedPositions);
|
||||
List<HighlightedPosition> oldPositions= fRemovedPositions;
|
||||
List<HighlightedPosition> newPositions= new ArrayList<HighlightedPosition>(fNOfRemovedPositions);
|
||||
for (int i= 0, n= oldPositions.size(); i < n; i ++) {
|
||||
Object current= oldPositions.get(i);
|
||||
HighlightedPosition current= oldPositions.get(i);
|
||||
if (current != null)
|
||||
newPositions.add(current);
|
||||
}
|
||||
|
@ -421,7 +417,7 @@ public class SemanticHighlightingReconciler implements ICReconcilingListener {
|
|||
* @param addedPositions the added 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);
|
||||
if (runnable == null)
|
||||
return;
|
||||
|
|
|
@ -659,20 +659,19 @@ public class SemanticHighlightings {
|
|||
// try to derive from AST
|
||||
if (name instanceof ICPPASTQualifiedName) {
|
||||
return false;
|
||||
} else {
|
||||
node= name.getParent();
|
||||
while (node instanceof IASTName) {
|
||||
}
|
||||
node= name.getParent();
|
||||
while (node instanceof IASTName) {
|
||||
node= node.getParent();
|
||||
}
|
||||
if (node instanceof IASTFunctionDeclarator) {
|
||||
while (node != token.getRoot() && !(node.getParent() instanceof IASTDeclSpecifier)) {
|
||||
node= node.getParent();
|
||||
}
|
||||
if (node instanceof IASTFunctionDeclarator) {
|
||||
while (node != token.getRoot() && !(node.getParent() instanceof IASTDeclSpecifier)) {
|
||||
node= node.getParent();
|
||||
}
|
||||
if (node instanceof ICPPASTCompositeTypeSpecifier) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
if (node instanceof ICPPASTCompositeTypeSpecifier) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1892,8 +1891,8 @@ public class SemanticHighlightings {
|
|||
return false;
|
||||
}
|
||||
IIndexName[] decls= index.findNames(binding, IIndex.FIND_DECLARATIONS | IIndex.SEARCH_ACCROSS_LANGUAGE_BOUNDARIES);
|
||||
for (int i = 0; i < decls.length; i++) {
|
||||
IIndexFile indexFile= decls[i].getFile();
|
||||
for (IIndexName decl : decls) {
|
||||
IIndexFile indexFile= decl.getFile();
|
||||
if (indexFile != null && indexFile.getLocation().getFullPath() != null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -2010,8 +2009,7 @@ public class SemanticHighlightings {
|
|||
store.setDefault(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED, true);
|
||||
|
||||
SemanticHighlighting[] semanticHighlightings= getSemanticHighlightings();
|
||||
for (int i= 0, n= semanticHighlightings.length; i < n; i++) {
|
||||
SemanticHighlighting semanticHighlighting= semanticHighlightings[i];
|
||||
for (SemanticHighlighting semanticHighlighting : semanticHighlightings) {
|
||||
store.setDefault(SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting), DEBUG || semanticHighlighting.isEnabledByDefault());
|
||||
PreferenceConverter.setDefault(store, SemanticHighlightings.getColorPreferenceKey(semanticHighlighting), semanticHighlighting.getDefaultTextColor());
|
||||
store.setDefault(SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting), semanticHighlighting.isBoldByDefault());
|
||||
|
@ -2036,8 +2034,8 @@ public class SemanticHighlightings {
|
|||
}
|
||||
String relevantKey= null;
|
||||
SemanticHighlighting[] highlightings= getSemanticHighlightings();
|
||||
for (int i= 0; i < highlightings.length; i++) {
|
||||
if (event.getProperty().equals(getEnabledPreferenceKey(highlightings[i]))) {
|
||||
for (SemanticHighlighting highlighting : highlightings) {
|
||||
if (event.getProperty().equals(getEnabledPreferenceKey(highlighting))) {
|
||||
relevantKey= event.getProperty();
|
||||
break;
|
||||
}
|
||||
|
@ -2045,8 +2043,8 @@ public class SemanticHighlightings {
|
|||
if (relevantKey == null)
|
||||
return false;
|
||||
|
||||
for (int i= 0; i < highlightings.length; i++) {
|
||||
String key= getEnabledPreferenceKey(highlightings[i]);
|
||||
for (SemanticHighlighting highlighting : highlightings) {
|
||||
String key= getEnabledPreferenceKey(highlighting);
|
||||
if (key.equals(relevantKey))
|
||||
continue;
|
||||
if (store.getBoolean(key))
|
||||
|
@ -2070,8 +2068,8 @@ public class SemanticHighlightings {
|
|||
}
|
||||
SemanticHighlighting[] highlightings= getSemanticHighlightings();
|
||||
boolean enable= false;
|
||||
for (int i= 0; i < highlightings.length; i++) {
|
||||
String enabledKey= getEnabledPreferenceKey(highlightings[i]);
|
||||
for (SemanticHighlighting highlighting : highlightings) {
|
||||
String enabledKey= getEnabledPreferenceKey(highlighting);
|
||||
if (store.getBoolean(enabledKey)) {
|
||||
enable= true;
|
||||
break;
|
||||
|
|
|
@ -50,12 +50,12 @@ public final class SpecificContentAssistExecutor {
|
|||
* @param categoryId the id of the proposal category to show proposals for
|
||||
*/
|
||||
public void invokeContentAssist(final ITextEditor editor, String categoryId) {
|
||||
Collection categories= fRegistry.getProposalCategories();
|
||||
Collection<CompletionProposalCategory> categories= fRegistry.getProposalCategories();
|
||||
boolean[] inclusionState= new boolean[categories.size()];
|
||||
boolean[] separateState= new boolean[categories.size()];
|
||||
int i= 0;
|
||||
for (Iterator it= categories.iterator(); it.hasNext(); i++) {
|
||||
CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
|
||||
for (Iterator<CompletionProposalCategory> it= categories.iterator(); it.hasNext(); i++) {
|
||||
CompletionProposalCategory cat= it.next();
|
||||
inclusionState[i]= cat.isIncluded();
|
||||
cat.setIncluded(cat.getId().equals(categoryId));
|
||||
separateState[i]= cat.isSeparateCommand();
|
||||
|
@ -68,8 +68,8 @@ public final class SpecificContentAssistExecutor {
|
|||
target.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
|
||||
} finally {
|
||||
i= 0;
|
||||
for (Iterator it= categories.iterator(); it.hasNext(); i++) {
|
||||
CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
|
||||
for (Iterator<CompletionProposalCategory> it= categories.iterator(); it.hasNext(); i++) {
|
||||
CompletionProposalCategory cat= it.next();
|
||||
cat.setIncluded(inclusionState[i]);
|
||||
cat.setSeparateCommand(separateState[i]);
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public final class ToggleCommentAction extends TextEditorAction {
|
|||
/** The document partitioning */
|
||||
private String fDocumentPartitioning;
|
||||
/** The comment prefixes */
|
||||
private Map fPrefixesMap;
|
||||
private Map<String, String[]> fPrefixesMap;
|
||||
|
||||
/**
|
||||
* 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
|
||||
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 (!isBlockCommented(lines[j], lines[j + 1], prefixes, document))
|
||||
return false;
|
||||
|
@ -308,7 +308,7 @@ public final class ToggleCommentAction extends TextEditorAction {
|
|||
fPrefixesMap= null;
|
||||
|
||||
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++) {
|
||||
String type= types[i];
|
||||
String[] prefixes= configuration.getDefaultPrefixes(sourceViewer, type);
|
||||
|
|
|
@ -93,7 +93,7 @@ public class ToggleSourceAndHeaderAction extends TextEditorAction {
|
|||
|
||||
private IIndex fIndex;
|
||||
private IPath fFilePath;
|
||||
private Map fMap;
|
||||
private Map<IPath, Counter> fMap;
|
||||
/** The confidence level == number of hits */
|
||||
private int fConfidence;
|
||||
/** Suspect level == number of no index matches */
|
||||
|
@ -108,7 +108,7 @@ public class ToggleSourceAndHeaderAction extends TextEditorAction {
|
|||
if (ast != null) {
|
||||
fIndex= ast.getIndex();
|
||||
fFilePath= Path.fromOSString(ast.getFilePath());
|
||||
fMap= new HashMap();
|
||||
fMap= new HashMap<IPath, Counter>();
|
||||
if (fIndex != null) {
|
||||
ast.accept(this);
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ public class ToggleSourceAndHeaderAction extends TextEditorAction {
|
|||
}
|
||||
|
||||
private void addPotentialPartnerFileLocation(IPath partnerFileLocation) {
|
||||
Counter counter= (Counter)fMap.get(partnerFileLocation);
|
||||
Counter counter= fMap.get(partnerFileLocation);
|
||||
if (counter == null) {
|
||||
counter= new Counter();
|
||||
fMap.put(partnerFileLocation, counter);
|
||||
|
@ -291,7 +291,7 @@ public class ToggleSourceAndHeaderAction extends TextEditorAction {
|
|||
}
|
||||
IPath partnerBasePath= sourceFileLocation.removeFileExtension();
|
||||
IContentType[] contentTypes= getPartnerContentTypes(tUnit.getContentTypeId());
|
||||
HashSet extensionsTried= new HashSet();
|
||||
HashSet<String> extensionsTried= new HashSet<String>();
|
||||
for (int j = 0; j < contentTypes.length; j++) {
|
||||
IContentType contentType= contentTypes[j];
|
||||
String[] partnerExtensions;
|
||||
|
|
|
@ -30,7 +30,7 @@ import org.eclipse.ui.IEditorInput;
|
|||
public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyManagerExtension {
|
||||
|
||||
private CDocumentProvider fDocumentProvider;
|
||||
private Map fMap;
|
||||
private Map<IEditorInput, IWorkingCopy> fMap;
|
||||
private boolean fIsShuttingDown;
|
||||
|
||||
/**
|
||||
|
@ -80,7 +80,7 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
|
|||
* @see org.eclipse.cdt.ui.IWorkingCopyManager#getWorkingCopy(org.eclipse.ui.IEditorInput)
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public class WorkingCopyManager implements IWorkingCopyManager, IWorkingCopyMana
|
|||
public void setWorkingCopy(IEditorInput input, IWorkingCopy workingCopy) {
|
||||
if (fDocumentProvider.getDocument(input) != null) {
|
||||
if (fMap == null)
|
||||
fMap= new HashMap();
|
||||
fMap= new HashMap<IEditorInput, IWorkingCopy>();
|
||||
fMap.put(input, workingCopy);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -122,6 +122,7 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
|
|||
/*
|
||||
* @see org.eclipse.ui.editors.text.TextEditor#getAdapter(java.lang.Class)
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (IContentOutlinePage.class.equals(adapter)) {
|
||||
|
@ -268,9 +269,9 @@ public class AsmTextEditor extends TextEditor implements ISelectionChangedListen
|
|||
*/
|
||||
private Annotation getAnnotation(int offset, int length) {
|
||||
IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
|
||||
Iterator e = new CAnnotationIterator(model, true, true);
|
||||
Iterator<Annotation> e = new CAnnotationIterator(model, true, true);
|
||||
while (e.hasNext()) {
|
||||
Annotation a = (Annotation) e.next();
|
||||
Annotation a = e.next();
|
||||
if (!isNavigationTarget(a))
|
||||
continue;
|
||||
|
||||
|
|
|
@ -116,7 +116,7 @@ public class BracesTabPage extends FormatterTabPage {
|
|||
* @param modifyDialog
|
||||
* @param workingValues
|
||||
*/
|
||||
public BracesTabPage(ModifyDialog modifyDialog, Map workingValues) {
|
||||
public BracesTabPage(ModifyDialog modifyDialog, Map<String,String> workingValues) {
|
||||
super(modifyDialog, workingValues);
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ public abstract class CPreview {
|
|||
|
||||
protected final MarginPainter fMarginPainter;
|
||||
|
||||
protected Map fWorkingValues;
|
||||
protected Map<String, String> fWorkingValues;
|
||||
|
||||
private int fTabSize= 0;
|
||||
private WhitespaceCharacterPainter fWhitespaceCharacterPainter;
|
||||
|
@ -106,7 +106,7 @@ public abstract class CPreview {
|
|||
* @param workingValues
|
||||
* @param parent
|
||||
*/
|
||||
public CPreview(Map workingValues, Composite parent) {
|
||||
public CPreview(Map<String, String> workingValues, Composite parent) {
|
||||
CTextTools tools= CUIPlugin.getDefault().getTextTools();
|
||||
fPreviewDocument= new Document();
|
||||
fWorkingValues= workingValues;
|
||||
|
@ -141,12 +141,12 @@ public abstract class CPreview {
|
|||
}
|
||||
|
||||
// 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);
|
||||
fMarginPainter.setMarginRulerColumn(lineWidth);
|
||||
|
||||
// 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);
|
||||
fTabSize= tabSize;
|
||||
|
||||
|
@ -192,12 +192,12 @@ public abstract class CPreview {
|
|||
|
||||
|
||||
|
||||
public Map getWorkingValues() {
|
||||
public Map<String, String> getWorkingValues() {
|
||||
return fWorkingValues;
|
||||
}
|
||||
|
||||
|
||||
public void setWorkingValues(Map workingValues) {
|
||||
public void setWorkingValues(Map<String, String> workingValues) {
|
||||
fWorkingValues= workingValues;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ public class CodeFormatterConfigurationBlock extends ProfileConfigurationBlock {
|
|||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ public class ControlStatementsTabPage extends FormatterTabPage {
|
|||
protected CheckboxPreference fThenStatementPref, fSimpleIfPref;
|
||||
|
||||
|
||||
public ControlStatementsTabPage(ModifyDialog modifyDialog, Map workingValues) {
|
||||
public ControlStatementsTabPage(ModifyDialog modifyDialog, Map<String, String> workingValues) {
|
||||
super(modifyDialog, workingValues);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
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.IDialogSettings;
|
||||
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 ProfileManager fProfileManager;
|
||||
private final List fSortedProfiles;
|
||||
private final List<Profile> fSortedProfiles;
|
||||
private final String [] fSortedNames;
|
||||
|
||||
private CustomProfile fCreatedProfile;
|
||||
|
@ -187,7 +186,7 @@ public class CreateProfileDialog extends StatusDialog {
|
|||
|
||||
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();
|
||||
|
||||
fCreatedProfile= new CustomProfile(profileName, baseSettings, fProfileVersioner.getCurrentVersion(), fProfileVersioner.getProfileKind());
|
||||
|
|
|
@ -105,12 +105,12 @@ public class CustomCodeFormatterBlock extends Observable {
|
|||
}
|
||||
fFormatterCombo.clearSelection();
|
||||
fFormatterCombo.setText(DEFAULT);
|
||||
Iterator iterator = idMap.entrySet().iterator();
|
||||
Iterator<Map.Entry<String,String>> iterator = idMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry)iterator.next();
|
||||
String val = (String)entry.getValue();
|
||||
Map.Entry<String,String> entry = iterator.next();
|
||||
String val = entry.getValue();
|
||||
if (val != null && val.equals(fDefaultFormatterId)) {
|
||||
fFormatterCombo.setText((String)entry.getKey());
|
||||
fFormatterCombo.setText(entry.getKey());
|
||||
}
|
||||
}
|
||||
handleFormatterChanged();
|
||||
|
@ -175,12 +175,12 @@ public class CustomCodeFormatterBlock extends Observable {
|
|||
boolean init = false;
|
||||
String formatterID= fPrefs.get(CCorePreferenceConstants.CODE_FORMATTER, fDefaultFormatterId);
|
||||
if (formatterID != null) {
|
||||
Iterator iterator = idMap.entrySet().iterator();
|
||||
Iterator<Map.Entry<String,String>> iterator = idMap.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry entry = (Map.Entry)iterator.next();
|
||||
String val = (String)entry.getValue();
|
||||
Map.Entry<String, String> entry = iterator.next();
|
||||
String val = entry.getValue();
|
||||
if (val != null && val.equals(formatterID)) {
|
||||
fFormatterCombo.setText((String)entry.getKey());
|
||||
fFormatterCombo.setText(entry.getKey());
|
||||
init = true;
|
||||
}
|
||||
}
|
||||
|
@ -197,8 +197,8 @@ public class CustomCodeFormatterBlock extends Observable {
|
|||
IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(CCorePlugin.PLUGIN_ID, CCorePlugin.FORMATTER_EXTPOINT_ID);
|
||||
if (point != null) {
|
||||
IExtension[] exts = point.getExtensions();
|
||||
for (int i = 0; i < exts.length; i++) {
|
||||
IConfigurationElement[] elements = exts[i].getConfigurationElements();
|
||||
for (IExtension ext : exts) {
|
||||
IConfigurationElement[] elements = ext.getConfigurationElements();
|
||||
for (int j = 0; j < elements.length; ++j) {
|
||||
String name = elements[j].getAttribute(ATTR_NAME);
|
||||
String id= elements[j].getAttribute(ATTR_ID);
|
||||
|
|
|
@ -24,7 +24,7 @@ public class FormatterModifyDialog extends ModifyDialog {
|
|||
}
|
||||
|
||||
@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_braces_title, new BracesTabPage(this, values));
|
||||
addTabPage(FormatterMessages.ModifyDialog_tabpage_whitespace_title, new WhiteSpaceTabPage(this, values));
|
||||
|
|
|
@ -28,6 +28,8 @@ import org.eclipse.cdt.internal.ui.preferences.PreferencesAccess;
|
|||
|
||||
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 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$
|
||||
|
@ -36,18 +38,18 @@ public class FormatterProfileManager extends ProfileManager {
|
|||
public final static String DEFAULT_PROFILE= KANDR_PROFILE;
|
||||
|
||||
private final static KeySet[] KEY_SETS= new KeySet[] {
|
||||
new KeySet(CCorePlugin.PLUGIN_ID, new ArrayList(DefaultCodeFormatterConstants.getDefaultSettings().keySet())),
|
||||
new KeySet(CUIPlugin.PLUGIN_ID, Collections.EMPTY_LIST)
|
||||
new KeySet(CCorePlugin.PLUGIN_ID, new ArrayList<String>(DefaultCodeFormatterConstants.getDefaultSettings().keySet())),
|
||||
new KeySet(CUIPlugin.PLUGIN_ID, EMPTY_LIST)
|
||||
};
|
||||
|
||||
private final static String PROFILE_KEY= PreferenceConstants.FORMATTER_PROFILE;
|
||||
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);
|
||||
}
|
||||
|
||||
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());
|
||||
profiles.add(kandrProfile);
|
||||
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.
|
||||
*/
|
||||
public static Map getDefaultSettings() {
|
||||
public static Map<String, String> getDefaultSettings() {
|
||||
return DefaultCodeFormatterConstants.getDefaultSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the K&R settings.
|
||||
*/
|
||||
public static Map getKandRSettings() {
|
||||
public static Map<String, String> getKandRSettings() {
|
||||
return DefaultCodeFormatterConstants.getKandRSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the ANSI settings.
|
||||
*/
|
||||
public static Map getAllmanSettings() {
|
||||
public static Map<String, String> getAllmanSettings() {
|
||||
return DefaultCodeFormatterConstants.getAllmanSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the GNU settings.
|
||||
*/
|
||||
public static Map getGNUSettings() {
|
||||
public static Map<String, String> getGNUSettings() {
|
||||
return DefaultCodeFormatterConstants.getGNUSettings();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the Whitesmiths settings.
|
||||
*/
|
||||
public static Map getWhitesmithsSettings() {
|
||||
public static Map<String, String> getWhitesmithsSettings() {
|
||||
return DefaultCodeFormatterConstants.getWhitesmithsSettings();
|
||||
}
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@ import org.osgi.service.prefs.BackingStoreException;
|
|||
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.Profile;
|
||||
|
||||
|
||||
public class FormatterProfileStore extends ProfileStore {
|
||||
|
||||
|
@ -38,7 +40,7 @@ public class FormatterProfileStore extends ProfileStore {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@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 String profilesValue= node.get(PREF_FORMATTER_PROFILES_OLD, null);
|
||||
if (profilesValue != null) {
|
||||
|
|
|
@ -31,7 +31,7 @@ public abstract class FormatterTabPage extends ModifyDialogTabPage {
|
|||
private final IDialogSettings fDialogSettings;
|
||||
private Button fShowInvisibleButton;
|
||||
|
||||
public FormatterTabPage(IModifyDialogTabPage.IModificationListener modifyListener, Map workingValues) {
|
||||
public FormatterTabPage(IModifyDialogTabPage.IModificationListener modifyListener, Map<String, String> workingValues) {
|
||||
super(modifyListener, workingValues);
|
||||
|
||||
fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
|
||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.preferences.formatter;
|
|||
import java.util.Map;
|
||||
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
|
||||
/**
|
||||
|
@ -36,7 +35,7 @@ public interface IModifyDialogTabPage {
|
|||
*
|
||||
* @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
|
||||
|
|
|
@ -87,7 +87,7 @@ public class IndentationTabPage extends FormatterTabPage {
|
|||
private TranslationUnitPreview fPreview;
|
||||
private String fOldTabChar= null;
|
||||
|
||||
public IndentationTabPage(ModifyDialog modifyDialog, Map workingValues) {
|
||||
public IndentationTabPage(ModifyDialog modifyDialog, Map<String,String> 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 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);
|
||||
tabPolicy.addObserver(new Observer() {
|
||||
public void update(Observable o, Object arg) {
|
||||
|
@ -208,8 +208,8 @@ public class IndentationTabPage extends FormatterTabPage {
|
|||
}
|
||||
|
||||
private void swapTabValues() {
|
||||
Object tabSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
|
||||
Object indentSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
|
||||
String tabSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE);
|
||||
String indentSize= fWorkingValues.get(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE);
|
||||
fWorkingValues.put(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE, indentSize);
|
||||
fWorkingValues.put(DefaultCodeFormatterConstants.FORMATTER_INDENTATION_SIZE, tabSize);
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
public final String key;
|
||||
public final String name;
|
||||
public final String previewText;
|
||||
public final List children;
|
||||
public final List<Category> children;
|
||||
|
||||
public int index;
|
||||
|
||||
|
@ -70,7 +70,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
this.key= _key;
|
||||
this.name= _name;
|
||||
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 List fCategoriesList;
|
||||
private final List<Category> fCategoriesList;
|
||||
|
||||
private int fIndex= 0;
|
||||
|
||||
public CategoryListener(List categoriesTree) {
|
||||
fCategoriesList= new ArrayList();
|
||||
public CategoryListener(List<Category> categoriesTree) {
|
||||
fCategoriesList= new ArrayList<Category>();
|
||||
flatten(fCategoriesList, categoriesTree);
|
||||
}
|
||||
|
||||
private void flatten(List categoriesList, List categoriesTree) {
|
||||
for (final Iterator iter= categoriesTree.iterator(); iter.hasNext(); ) {
|
||||
final Category category= (Category) iter.next();
|
||||
private void flatten(List<Category> categoriesList, List<Category> categoriesTree) {
|
||||
for (Category category2 : categoriesTree) {
|
||||
final Category category= category2;
|
||||
category.index= fIndex++;
|
||||
categoriesList.add(category);
|
||||
flatten(categoriesList, category.children);
|
||||
|
@ -166,7 +166,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
if (index < 0 || index > fCategoriesList.size() - 1) {
|
||||
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}));
|
||||
}
|
||||
|
||||
|
@ -180,12 +180,12 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
}
|
||||
|
||||
private class SelectionState {
|
||||
private List fElements= new ArrayList();
|
||||
private List<Category> fElements= new ArrayList<Category>();
|
||||
|
||||
public void refreshState(IStructuredSelection selection) {
|
||||
Map wrappingStyleMap= new HashMap();
|
||||
Map indentStyleMap= new HashMap();
|
||||
Map forceWrappingMap= new HashMap();
|
||||
Map<Object, Integer> wrappingStyleMap= new HashMap<Object, Integer>();
|
||||
Map<Object, Integer> indentStyleMap= new HashMap<Object, Integer>();
|
||||
Map<Object, Integer> forceWrappingMap= new HashMap<Object, Integer>();
|
||||
fElements.clear();
|
||||
evaluateElements(selection.iterator());
|
||||
evaluateMaps(wrappingStyleMap, indentStyleMap, forceWrappingMap);
|
||||
|
@ -193,45 +193,48 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
refreshControls(wrappingStyleMap, indentStyleMap, forceWrappingMap);
|
||||
}
|
||||
|
||||
public List getElements() {
|
||||
public List<Category> getElements() {
|
||||
return fElements;
|
||||
}
|
||||
|
||||
private void evaluateElements(Iterator iterator) {
|
||||
private void evaluateElements(Iterator<?> iterator) {
|
||||
Category category;
|
||||
String value;
|
||||
while (iterator.hasNext()) {
|
||||
category= (Category) iterator.next();
|
||||
value= (String)fWorkingValues.get(category.key);
|
||||
if (value != null) {
|
||||
if (!fElements.contains(category))
|
||||
fElements.add(category);
|
||||
}
|
||||
else {
|
||||
evaluateElements(category.children.iterator());
|
||||
}
|
||||
Object next= iterator.next();
|
||||
if (next instanceof Category) {
|
||||
category= (Category) next;
|
||||
value= fWorkingValues.get(category.key);
|
||||
if (value != null) {
|
||||
if (!fElements.contains(category))
|
||||
fElements.add(category);
|
||||
}
|
||||
else {
|
||||
evaluateElements(category.children.iterator());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateMaps(Map wrappingStyleMap, Map indentStyleMap, Map forceWrappingMap) {
|
||||
Iterator iterator= fElements.iterator();
|
||||
private void evaluateMaps(Map<Object, Integer> wrappingStyleMap, Map<Object, Integer> indentStyleMap, Map<Object, Integer> forceWrappingMap) {
|
||||
Iterator<Category> iterator= fElements.iterator();
|
||||
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) {
|
||||
Iterator iterator= fElements.iterator();
|
||||
private String getPreviewText(Map<Object, Integer> wrappingMap, Map<Object, Integer> indentMap, Map<Object, Integer> forceMap) {
|
||||
Iterator<Category> iterator= fElements.iterator();
|
||||
String previewText= ""; //$NON-NLS-1$
|
||||
while (iterator.hasNext()) {
|
||||
Category category= (Category)iterator.next();
|
||||
Category category= iterator.next();
|
||||
previewText= previewText + category.previewText + "\n\n"; //$NON-NLS-1$
|
||||
}
|
||||
return previewText;
|
||||
}
|
||||
|
||||
private void insertIntoMap(Map wrappingMap, Map indentMap, Map forceMap, Category category) {
|
||||
final String value= (String)fWorkingValues.get(category.key);
|
||||
private void insertIntoMap(Map<Object, Integer> wrappingMap, Map<Object, Integer> indentMap, Map<Object, Integer> forceMap, Category category) {
|
||||
final String value= fWorkingValues.get(category.key);
|
||||
Integer wrappingStyle;
|
||||
Integer indentStyle;
|
||||
Boolean forceWrapping;
|
||||
|
@ -251,28 +254,28 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
increaseMapEntry(forceMap, forceWrapping);
|
||||
}
|
||||
|
||||
private void increaseMapEntry(Map map, Object type) {
|
||||
Integer count= (Integer)map.get(type);
|
||||
private void increaseMapEntry(Map<Object, Integer> map, Object type) {
|
||||
Integer count= map.get(type);
|
||||
if (count == null) // not in map yet -> count == 0
|
||||
map.put(type, new Integer(1));
|
||||
else
|
||||
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);
|
||||
updateButton(forceWrappingMap);
|
||||
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());
|
||||
doUpdatePreview();
|
||||
notifyValuesModified();
|
||||
}
|
||||
|
||||
private Integer getWrappingStyleMax(Map wrappingStyleMap) {
|
||||
private Integer getWrappingStyleMax(Map<Object, Integer> wrappingStyleMap) {
|
||||
int maxCount= 0, maxStyle= 0;
|
||||
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)
|
||||
continue;
|
||||
if (count.intValue() > maxCount) {
|
||||
|
@ -283,9 +286,9 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
return new Integer(maxStyle);
|
||||
}
|
||||
|
||||
private void updateButton(Map forceWrappingMap) {
|
||||
Integer nrOfTrue= (Integer)forceWrappingMap.get(Boolean.TRUE);
|
||||
Integer nrOfFalse= (Integer)forceWrappingMap.get(Boolean.FALSE);
|
||||
private void updateButton(Map<Object, Integer> forceWrappingMap) {
|
||||
Integer nrOfTrue= forceWrappingMap.get(Boolean.TRUE);
|
||||
Integer nrOfFalse= forceWrappingMap.get(Boolean.FALSE);
|
||||
|
||||
if (nrOfTrue == null || nrOfFalse == null)
|
||||
fForceSplit.setSelection(nrOfTrue != null);
|
||||
|
@ -313,17 +316,17 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
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(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];
|
||||
int maxCount= 0, maxStyle= 0;
|
||||
|
||||
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();
|
||||
if (val > maxCount) {
|
||||
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.
|
||||
* @see TreeViewer
|
||||
*/
|
||||
private final List fCategories;
|
||||
private final List<Category> fCategories;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
protected final Map fPreviewPreferences;
|
||||
protected final Map<String,String> fPreviewPreferences;
|
||||
|
||||
/**
|
||||
* The key for the preview line width.
|
||||
|
@ -536,14 +539,14 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
* @param modifyDialog
|
||||
* @param workingValues
|
||||
*/
|
||||
public LineWrappingTabPage(ModifyDialog modifyDialog, Map workingValues) {
|
||||
public LineWrappingTabPage(ModifyDialog modifyDialog, Map<String,String> workingValues) {
|
||||
super(modifyDialog, workingValues);
|
||||
|
||||
fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
|
||||
|
||||
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));
|
||||
|
||||
fCategories= createCategories();
|
||||
|
@ -553,7 +556,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
/**
|
||||
* @return Create the categories tree.
|
||||
*/
|
||||
protected List createCategories() {
|
||||
protected List<Category> createCategories() {
|
||||
|
||||
final Category classDeclarations= new Category(FormatterMessages.LineWrappingTabPage_class_decls);
|
||||
classDeclarations.children.add(fTypeDeclarationBaseClauseCategory);
|
||||
|
@ -587,7 +590,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
// final Category statements= new Category(FormatterMessages.LineWrappingTabPage_statements);
|
||||
// statements.children.add(fCompactIfCategory);
|
||||
|
||||
final List root= new ArrayList();
|
||||
final List<Category> root= new ArrayList<Category>();
|
||||
root.add(classDeclarations);
|
||||
// root.add(constructorDeclarations);
|
||||
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.setContentProvider(new ITreeContentProvider() {
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return ((Collection)inputElement).toArray();
|
||||
return ((Collection<?>)inputElement).toArray();
|
||||
}
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
return ((Category)parentElement).children.toArray();
|
||||
|
@ -676,7 +679,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
previewLineWidth.addObserver(fUpdater);
|
||||
previewLineWidth.addObserver(new Observer() {
|
||||
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
|
||||
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));
|
||||
fPreview.update();
|
||||
fWorkingValues.put(LINE_SPLIT, normalSetting);
|
||||
}
|
||||
|
||||
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));
|
||||
fPreview.setPreviewText(text);
|
||||
fWorkingValues.put(LINE_SPLIT, normalSetting);
|
||||
}
|
||||
|
||||
protected void forceSplitChanged(boolean forceSplit) {
|
||||
Iterator iterator= fSelectionState.fElements.iterator();
|
||||
Iterator<Category> iterator= fSelectionState.fElements.iterator();
|
||||
String currentKey;
|
||||
while (iterator.hasNext()) {
|
||||
currentKey= ((Category)iterator.next()).key;
|
||||
currentKey= (iterator.next()).key;
|
||||
try {
|
||||
changeForceSplit(currentKey, forceSplit);
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -764,7 +767,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
}
|
||||
|
||||
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);
|
||||
if (value == null)
|
||||
throw new IllegalArgumentException();
|
||||
|
@ -772,10 +775,10 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
}
|
||||
|
||||
protected void wrappingStyleChanged(int wrappingStyle) {
|
||||
Iterator iterator= fSelectionState.fElements.iterator();
|
||||
Iterator<Category> iterator= fSelectionState.fElements.iterator();
|
||||
String currentKey;
|
||||
while (iterator.hasNext()) {
|
||||
currentKey= ((Category)iterator.next()).key;
|
||||
currentKey= (iterator.next()).key;
|
||||
try {
|
||||
changeWrappingStyle(currentKey, wrappingStyle);
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -788,7 +791,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
}
|
||||
|
||||
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);
|
||||
if (value == null)
|
||||
throw new IllegalArgumentException();
|
||||
|
@ -796,10 +799,10 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
}
|
||||
|
||||
protected void indentStyleChanged(int indentStyle) {
|
||||
Iterator iterator= fSelectionState.fElements.iterator();
|
||||
Iterator<Category> iterator= fSelectionState.fElements.iterator();
|
||||
String currentKey;
|
||||
while (iterator.hasNext()) {
|
||||
currentKey= ((Category)iterator.next()).key;
|
||||
currentKey= iterator.next().key;
|
||||
try {
|
||||
changeIndentStyle(currentKey, indentStyle);
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
@ -812,7 +815,7 @@ public class LineWrappingTabPage extends FormatterTabPage {
|
|||
}
|
||||
|
||||
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);
|
||||
if (value == null)
|
||||
throw new IllegalArgumentException();
|
||||
|
|
|
@ -85,8 +85,8 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
|
|||
private final ProfileStore fProfileStore;
|
||||
private final boolean fNewProfile;
|
||||
private Profile fProfile;
|
||||
private final Map fWorkingValues;
|
||||
private final List fTabPages;
|
||||
private final Map<String, String> fWorkingValues;
|
||||
private final List<IModifyDialogTabPage> fTabPages;
|
||||
private final IDialogSettings fDialogSettings;
|
||||
private TabFolder fTabFolder;
|
||||
private final ProfileManager fProfileManager;
|
||||
|
@ -112,13 +112,13 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
|
|||
|
||||
fProfile= profile;
|
||||
setTitle(Messages.format(FormatterMessages.ModifyDialog_dialog_title, profile.getName()));
|
||||
fWorkingValues= new HashMap(fProfile.getSettings());
|
||||
fWorkingValues= new HashMap<String, String>(fProfile.getSettings());
|
||||
setStatusLineAboveButtons(false);
|
||||
fTabPages= new ArrayList();
|
||||
fTabPages= new ArrayList<IModifyDialogTabPage>();
|
||||
fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
|
||||
}
|
||||
|
||||
protected abstract void addPages(Map values);
|
||||
protected abstract void addPages(Map<String, String> values);
|
||||
|
||||
@Override
|
||||
public void create() {
|
||||
|
@ -261,13 +261,13 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
|
|||
if (!fProfile.getName().equals(fProfileNameField.getText())) {
|
||||
fProfile= fProfile.rename(fProfileNameField.getText(), fProfileManager);
|
||||
}
|
||||
fProfile.setSettings(new HashMap(fWorkingValues));
|
||||
fProfile.setSettings(new HashMap<String, String>(fWorkingValues));
|
||||
fProfileManager.setSelected(fProfile);
|
||||
doValidate();
|
||||
}
|
||||
|
||||
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);
|
||||
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$
|
||||
if (type != null)
|
||||
encoding= type.getDefaultCharset();
|
||||
final Collection profiles= new ArrayList();
|
||||
final Collection<Profile> profiles= new ArrayList<Profile>();
|
||||
profiles.add(selected);
|
||||
try {
|
||||
fProfileStore.writeProfilesToFile(profiles, file, encoding);
|
||||
|
@ -393,9 +393,9 @@ public abstract class ModifyDialog extends StatusDialog implements IModifyDialog
|
|||
if (!fProfileNameField.getText().trim().equals(fProfile.getName()))
|
||||
return true;
|
||||
|
||||
Iterator iter= fProfile.getSettings().entrySet().iterator();
|
||||
Iterator<Map.Entry<String, String>> iter= fProfile.getSettings().entrySet().iterator();
|
||||
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())) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
*/
|
||||
protected abstract class Preference extends Observable {
|
||||
private final Map fPreferences;
|
||||
private final Map<String, String> fPreferences;
|
||||
private boolean fEnabled;
|
||||
private String fKey;
|
||||
|
||||
|
@ -82,7 +82,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
|
|||
* @param preferences The map where the value is written.
|
||||
* @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;
|
||||
fEnabled= true;
|
||||
fKey= key;
|
||||
|
@ -90,7 +90,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
|
|||
/**
|
||||
* @return Gets the map of this Preference.
|
||||
*/
|
||||
protected final Map getPreferences() {
|
||||
protected final Map<String, String> getPreferences() {
|
||||
return fPreferences;
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
|
|||
* @param style SWT style flag for the button
|
||||
*/
|
||||
public ButtonPreference(Composite composite, int numColumns,
|
||||
Map preferences, String key,
|
||||
Map<String, String> preferences, String key,
|
||||
String [] values, String text, int style) {
|
||||
super(preferences, key);
|
||||
if (values == null || text == null)
|
||||
|
@ -216,13 +216,13 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
|
|||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
*/
|
||||
public ComboPreference(Composite composite, int numColumns,
|
||||
Map preferences, String key,
|
||||
Map<String, String> preferences, String key,
|
||||
String [] values, String text, String [] items) {
|
||||
super(preferences, key);
|
||||
if (values == null || items == null || text == null)
|
||||
|
@ -259,8 +259,8 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
|
|||
fCombo.setItems(items);
|
||||
|
||||
int max= 0;
|
||||
for (int i= 0; i < items.length; i++)
|
||||
if (items[i].length() > max) max= items[i].length();
|
||||
for (String item : items)
|
||||
if (item.length() > max) max= item.length();
|
||||
|
||||
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() {
|
||||
final String selected= (String)getPreferences().get(getKey());
|
||||
final String selected= getPreferences().get(getKey());
|
||||
for (int i= 0; i < fValues.length; i++) {
|
||||
if (fValues[i].equals(selected)) {
|
||||
return fItems[i];
|
||||
|
@ -335,7 +335,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
|
|||
* @param text The label text for this Preference.
|
||||
*/
|
||||
public NumberPreference(Composite composite, int numColumns,
|
||||
Map preferences, String key,
|
||||
Map<String, String> preferences, String key,
|
||||
int minValue, int maxValue, String text) {
|
||||
super(preferences, key);
|
||||
|
||||
|
@ -433,7 +433,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
|
|||
fNumberText.setEnabled(hasKey && getEnabled());
|
||||
|
||||
if (hasKey) {
|
||||
String s= (String)getPreferences().get(getKey());
|
||||
String s= getPreferences().get(getKey());
|
||||
try {
|
||||
fSelected= Integer.parseInt(s);
|
||||
} catch (NumberFormatException e) {
|
||||
|
@ -470,21 +470,21 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
|
|||
|
||||
private final IDialogSettings fDialogSettings;
|
||||
|
||||
private final Map fItemMap;
|
||||
private final List fItemList;
|
||||
private final Map<Control, Integer> fItemMap;
|
||||
private final List<Control> fItemList;
|
||||
|
||||
private int fIndex;
|
||||
|
||||
public DefaultFocusManager() {
|
||||
fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
|
||||
fItemMap= new HashMap();
|
||||
fItemList= new ArrayList();
|
||||
fItemMap= new HashMap<Control, Integer>();
|
||||
fItemList= new ArrayList<Control>();
|
||||
fIndex= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
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) {
|
||||
|
@ -509,7 +509,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
|
|||
index= fDialogSettings.getInt(PREF_LAST_FOCUS_INDEX);
|
||||
// make sure the value is within the range
|
||||
if ((index >= 0) && (index <= fItemList.size() - 1)) {
|
||||
((Control)fItemList.get(index)).setFocus();
|
||||
fItemList.get(index).setFocus();
|
||||
}
|
||||
} catch (NumberFormatException ex) {
|
||||
// this is the first time
|
||||
|
@ -546,8 +546,8 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
|
|||
int x = fMinimalWidth;
|
||||
int y = fMinimalHight;
|
||||
Control[] children = composite.getChildren();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
Point size = children[i].computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
|
||||
for (Control element : children) {
|
||||
Point size = element.computeSize(SWT.DEFAULT, SWT.DEFAULT, force);
|
||||
x = Math.max(x, size.x);
|
||||
y = Math.max(y, size.y);
|
||||
}
|
||||
|
@ -579,8 +579,8 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
|
|||
public void layout(Composite composite, boolean force) {
|
||||
Rectangle rect = composite.getClientArea();
|
||||
Control[] children = composite.getChildren();
|
||||
for (int i = 0; i < children.length; i++) {
|
||||
children[i].setSize(rect.width, rect.height);
|
||||
for (Control element : children) {
|
||||
element.setSize(rect.width, rect.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -606,7 +606,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
|
|||
/**
|
||||
* 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.
|
||||
|
@ -617,7 +617,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
|
|||
/*
|
||||
* Create a new <code>ModifyDialogTabPage</code>
|
||||
*/
|
||||
public ModifyDialogTabPage(IModifyDialogTabPage.IModificationListener modifyListener, Map workingValues) {
|
||||
public ModifyDialogTabPage(IModifyDialogTabPage.IModificationListener modifyListener, Map<String,String> workingValues) {
|
||||
fWorkingValues= workingValues;
|
||||
fModifyListener= modifyListener;
|
||||
fDefaultFocusManager= new DefaultFocusManager();
|
||||
|
@ -630,7 +630,7 @@ public abstract class ModifyDialogTabPage implements IModifyDialogTabPage {
|
|||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void setWorkingValues(Map workingValues) {
|
||||
public void setWorkingValues(Map<String,String> workingValues) {
|
||||
fWorkingValues= workingValues;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ public abstract class ProfileConfigurationBlock {
|
|||
|
||||
class ProfileComboController implements Observer, SelectionListener {
|
||||
|
||||
private final List fSortedProfiles;
|
||||
private final List<Profile> fSortedProfiles;
|
||||
|
||||
public ProfileComboController() {
|
||||
fSortedProfiles= fProfileManager.getSortedProfiles();
|
||||
|
@ -101,7 +101,7 @@ public abstract class ProfileConfigurationBlock {
|
|||
|
||||
public void widgetSelected(SelectionEvent e) {
|
||||
final int index= fProfileCombo.getSelectionIndex();
|
||||
fProfileManager.setSelected((Profile)fSortedProfiles.get(index));
|
||||
fProfileManager.setSelected(fSortedProfiles.get(index));
|
||||
}
|
||||
|
||||
public void widgetDefaultSelected(SelectionEvent e) {}
|
||||
|
@ -201,7 +201,7 @@ public abstract class ProfileConfigurationBlock {
|
|||
CUIPlugin.getDefault().getDialogSettings().put(fLastSaveLoadPathKey + ".loadpath", dialog.getFilterPath()); //$NON-NLS-1$
|
||||
|
||||
final File file= new File(path);
|
||||
Collection profiles= null;
|
||||
Collection<Profile> profiles= null;
|
||||
try {
|
||||
profiles= fProfileStore.readProfilesFromFile(file);
|
||||
} catch (CoreException e) {
|
||||
|
@ -275,7 +275,7 @@ public abstract class ProfileConfigurationBlock {
|
|||
fCurrContext= fInstanceScope;
|
||||
}
|
||||
|
||||
List profiles= null;
|
||||
List<Profile> profiles= null;
|
||||
try {
|
||||
profiles= fProfileStore.readProfiles(fInstanceScope);
|
||||
} catch (CoreException e) {
|
||||
|
@ -291,7 +291,7 @@ public abstract class ProfileConfigurationBlock {
|
|||
}
|
||||
|
||||
if (profiles == null)
|
||||
profiles= new ArrayList();
|
||||
profiles= new ArrayList<Profile>();
|
||||
|
||||
fProfileManager= createProfileManager(profiles, fCurrContext, access, fProfileVersioner);
|
||||
|
||||
|
@ -317,7 +317,7 @@ public abstract class ProfileConfigurationBlock {
|
|||
|
||||
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);
|
||||
|
||||
|
|
|
@ -16,7 +16,6 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
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.InstanceScope;
|
||||
import org.eclipse.osgi.util.TextProcessor;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.preferences.formatter.IProfileVersioner;
|
||||
import org.osgi.service.prefs.BackingStoreException;
|
||||
|
||||
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.
|
||||
*/
|
||||
public abstract class ProfileManager extends Observable {
|
||||
private static final Map<String, String> EMPTY_MAP = Collections.emptyMap();
|
||||
|
||||
public static final class KeySet {
|
||||
|
||||
private final List fKeys;
|
||||
private final List<String> fKeys;
|
||||
private final String fNodeName;
|
||||
|
||||
public KeySet(String nodeName, List keys) {
|
||||
public KeySet(String nodeName, List<String> keys) {
|
||||
fNodeName= nodeName;
|
||||
fKeys= keys;
|
||||
}
|
||||
|
@ -58,7 +56,7 @@ public abstract class ProfileManager extends Observable {
|
|||
return fNodeName;
|
||||
}
|
||||
|
||||
public List getKeys() {
|
||||
public List<String> getKeys() {
|
||||
return fKeys;
|
||||
}
|
||||
}
|
||||
|
@ -73,20 +71,20 @@ public abstract class ProfileManager extends Observable {
|
|||
* Represents a profile with a unique ID, a name and a map
|
||||
* 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 Profile rename(String name, ProfileManager manager);
|
||||
|
||||
public abstract Map getSettings();
|
||||
public abstract void setSettings(Map settings);
|
||||
public abstract Map<String,String> getSettings();
|
||||
public abstract void setSettings(Map<String,String> settings);
|
||||
|
||||
public abstract int getVersion();
|
||||
|
||||
public boolean hasEqualSettings(Map otherMap, Collection allKeys) {
|
||||
Map settings= getSettings();
|
||||
for (Iterator iter= allKeys.iterator(); iter.hasNext(); ){
|
||||
String key= (String) iter.next();
|
||||
public boolean hasEqualSettings(Map<String,String> otherMap, Collection<String> allKeys) {
|
||||
Map<String,String> settings= getSettings();
|
||||
for (Object element : allKeys) {
|
||||
String key= (String) element;
|
||||
Object other= otherMap.get(key);
|
||||
Object curr= settings.get(key);
|
||||
if (other == null) {
|
||||
|
@ -120,12 +118,12 @@ public abstract class ProfileManager extends Observable {
|
|||
public final static class BuiltInProfile extends Profile {
|
||||
private final String fName;
|
||||
private final String fID;
|
||||
private final Map fSettings;
|
||||
private final Map<String,String> fSettings;
|
||||
private final int fOrder;
|
||||
private final int fCurrentVersion;
|
||||
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);
|
||||
fID= ID;
|
||||
fSettings= settings;
|
||||
|
@ -148,12 +146,12 @@ public abstract class ProfileManager extends Observable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map getSettings() {
|
||||
public Map<String,String> getSettings() {
|
||||
return fSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSettings(Map settings) {
|
||||
public void setSettings(Map<String,String> settings) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -161,7 +159,7 @@ public abstract class ProfileManager extends Observable {
|
|||
return fID;
|
||||
}
|
||||
|
||||
public final int compareTo(Object o) {
|
||||
public final int compareTo(Profile o) {
|
||||
if (o instanceof BuiltInProfile) {
|
||||
return fOrder - ((BuiltInProfile)o).fOrder;
|
||||
}
|
||||
|
@ -190,12 +188,12 @@ public abstract class ProfileManager extends Observable {
|
|||
*/
|
||||
public static class CustomProfile extends Profile {
|
||||
private String fName;
|
||||
private Map fSettings;
|
||||
private Map<String,String> fSettings;
|
||||
protected ProfileManager fManager;
|
||||
private int fVersion;
|
||||
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;
|
||||
fSettings= settings;
|
||||
fVersion= version;
|
||||
|
@ -221,12 +219,12 @@ public abstract class ProfileManager extends Observable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map getSettings() {
|
||||
public Map<String,String> getSettings() {
|
||||
return fSettings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSettings(Map settings) {
|
||||
public void setSettings(Map<String,String> settings) {
|
||||
if (settings == null)
|
||||
throw new IllegalArgumentException();
|
||||
fSettings= settings;
|
||||
|
@ -257,12 +255,12 @@ public abstract class ProfileManager extends Observable {
|
|||
fVersion= version;
|
||||
}
|
||||
|
||||
public int compareTo(Object o) {
|
||||
public int compareTo(Profile o) {
|
||||
if (o instanceof SharedProfile) {
|
||||
return -1;
|
||||
}
|
||||
if (o instanceof CustomProfile) {
|
||||
return getName().compareToIgnoreCase(((Profile)o).getName());
|
||||
return getName().compareToIgnoreCase((o).getName());
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -280,7 +278,7 @@ public abstract class ProfileManager extends Observable {
|
|||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -298,7 +296,7 @@ public abstract class ProfileManager extends Observable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public final int compareTo(Object o) {
|
||||
public final int compareTo(Profile o) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -339,12 +337,12 @@ public abstract class ProfileManager extends Observable {
|
|||
/**
|
||||
* 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.
|
||||
*/
|
||||
private final List fProfilesByName;
|
||||
private final List<Profile> fProfilesByName;
|
||||
|
||||
/**
|
||||
* The currently selected profile.
|
||||
|
@ -365,7 +363,7 @@ public abstract class ProfileManager extends Observable {
|
|||
* @param profileVersioner
|
||||
*/
|
||||
public ProfileManager(
|
||||
List profiles,
|
||||
List<Profile> profiles,
|
||||
IScopeContext context,
|
||||
PreferencesAccess preferencesAccess,
|
||||
IProfileVersioner profileVersioner,
|
||||
|
@ -379,11 +377,11 @@ public abstract class ProfileManager extends Observable {
|
|||
fProfileKey= profileKey;
|
||||
fProfileVersionKey= profileVersionKey;
|
||||
|
||||
fProfiles= new HashMap();
|
||||
fProfilesByName= new ArrayList();
|
||||
fProfiles= new HashMap<String, Profile>();
|
||||
fProfilesByName= new ArrayList<Profile>();
|
||||
|
||||
for (final Iterator iter = profiles.iterator(); iter.hasNext();) {
|
||||
final Profile profile= (Profile) iter.next();
|
||||
for (Object element : profiles) {
|
||||
final Profile profile= (Profile) element;
|
||||
if (profile instanceof CustomProfile) {
|
||||
((CustomProfile)profile).setManager(this);
|
||||
}
|
||||
|
@ -395,19 +393,19 @@ public abstract class ProfileManager extends Observable {
|
|||
|
||||
String profileId= getSelectedProfileId(fPreferencesAccess.getInstanceScope());
|
||||
|
||||
Profile profile= (Profile) fProfiles.get(profileId);
|
||||
Profile profile= fProfiles.get(profileId);
|
||||
if (profile == null) {
|
||||
profile= getDefaultProfile();
|
||||
}
|
||||
fSelected= profile;
|
||||
|
||||
if (context.getName() == ProjectScope.SCOPE && hasProjectSpecificSettings(context)) {
|
||||
Map map= readFromPreferenceStore(context, profile);
|
||||
Map<String, String> map= readFromPreferenceStore(context, profile);
|
||||
if (map != null) {
|
||||
|
||||
List allKeys= new ArrayList();
|
||||
for (int i= 0; i < fKeySets.length; i++) {
|
||||
allKeys.addAll(fKeySets[i].getKeys());
|
||||
List<String> allKeys= new ArrayList<String>();
|
||||
for (KeySet keySet : fKeySets) {
|
||||
allKeys.addAll(keySet.getKeys());
|
||||
}
|
||||
Collections.sort(allKeys);
|
||||
|
||||
|
@ -415,14 +413,14 @@ public abstract class ProfileManager extends Observable {
|
|||
|
||||
String projProfileId= context.getNode(CUIPlugin.PLUGIN_ID).get(fProfileKey, null);
|
||||
if (projProfileId != null) {
|
||||
Profile curr= (Profile) fProfiles.get(projProfileId);
|
||||
Profile curr= fProfiles.get(projProfileId);
|
||||
if (curr != null && (curr.isBuiltInProfile() || curr.hasEqualSettings(map, allKeys))) {
|
||||
matching= curr;
|
||||
}
|
||||
} else {
|
||||
// old version: look for similar
|
||||
for (final Iterator iter = fProfilesByName.iterator(); iter.hasNext();) {
|
||||
Profile curr= (Profile) iter.next();
|
||||
for (Object element : fProfilesByName) {
|
||||
Profile curr= (Profile) element;
|
||||
if (curr.hasEqualSettings(map, allKeys)) {
|
||||
matching= curr;
|
||||
break;
|
||||
|
@ -473,11 +471,10 @@ public abstract class ProfileManager extends Observable {
|
|||
}
|
||||
|
||||
public static boolean hasProjectSpecificSettings(IScopeContext context, KeySet[] keySets) {
|
||||
for (int i= 0; i < keySets.length; i++) {
|
||||
KeySet keySet= keySets[i];
|
||||
for (KeySet keySet : keySets) {
|
||||
IEclipsePreferences preferences= context.getNode(keySet.getNodeName());
|
||||
for (final Iterator keyIter= keySet.getKeys().iterator(); keyIter.hasNext();) {
|
||||
final String key= (String)keyIter.next();
|
||||
for (Object element : keySet.getKeys()) {
|
||||
final String key= (String)element;
|
||||
Object val= preferences.get(key, null);
|
||||
if (val != null) {
|
||||
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.
|
||||
* @param context The project context
|
||||
*/
|
||||
public Map readFromPreferenceStore(IScopeContext context, Profile workspaceProfile) {
|
||||
final Map profileOptions= new HashMap();
|
||||
public Map<String, String> readFromPreferenceStore(IScopeContext context, Profile workspaceProfile) {
|
||||
final Map<String, String> profileOptions= new HashMap<String, String>();
|
||||
IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
|
||||
|
||||
int version= uiPrefs.getInt(fProfileVersionKey, fProfileVersioner.getFirstVersion());
|
||||
if (version != fProfileVersioner.getCurrentVersion()) {
|
||||
Map allOptions= new HashMap();
|
||||
for (int i= 0; i < fKeySets.length; i++) {
|
||||
addAll(context.getNode(fKeySets[i].getNodeName()), allOptions);
|
||||
Map<String, String> allOptions= new HashMap<String, String>();
|
||||
for (KeySet keySet : fKeySets) {
|
||||
addAll(context.getNode(keySet.getNodeName()), allOptions);
|
||||
}
|
||||
CustomProfile profile= new CustomProfile("tmp", allOptions, version, fProfileVersioner.getProfileKind()); //$NON-NLS-1$
|
||||
fProfileVersioner.update(profile);
|
||||
|
@ -511,12 +508,11 @@ public abstract class ProfileManager extends Observable {
|
|||
}
|
||||
|
||||
boolean hasValues= false;
|
||||
for (int i= 0; i < fKeySets.length; i++) {
|
||||
KeySet keySet= fKeySets[i];
|
||||
for (KeySet keySet : fKeySets) {
|
||||
IEclipsePreferences preferences= context.getNode(keySet.getNodeName());
|
||||
for (final Iterator keyIter = keySet.getKeys().iterator(); keyIter.hasNext(); ) {
|
||||
final String key= (String) keyIter.next();
|
||||
Object val= preferences.get(key, null);
|
||||
for (Object element : keySet.getKeys()) {
|
||||
final String key= (String) element;
|
||||
String val= preferences.get(key, null);
|
||||
if (val != null) {
|
||||
hasValues= true;
|
||||
} else {
|
||||
|
@ -537,11 +533,10 @@ public abstract class ProfileManager extends Observable {
|
|||
* @param uiPrefs
|
||||
* @param allOptions
|
||||
*/
|
||||
private void addAll(IEclipsePreferences uiPrefs, Map allOptions) {
|
||||
private void addAll(IEclipsePreferences uiPrefs, Map<String,String> allOptions) {
|
||||
try {
|
||||
String[] keys= uiPrefs.keys();
|
||||
for (int i= 0; i < keys.length; i++) {
|
||||
String key= keys[i];
|
||||
for (String key : keys) {
|
||||
String val= uiPrefs.get(key, null);
|
||||
if (val != null) {
|
||||
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;
|
||||
for (final Iterator keyIter = keys.iterator(); keyIter.hasNext(); ) {
|
||||
final String key= (String) keyIter.next();
|
||||
for (Object element : keys) {
|
||||
final String key= (String) element;
|
||||
final String oldVal= prefs.get(key, null);
|
||||
final String val= (String) profileOptions.get(key);
|
||||
final String val= profileOptions.get(key);
|
||||
if (val == null) {
|
||||
if (oldVal != null) {
|
||||
prefs.remove(key);
|
||||
|
@ -578,10 +573,10 @@ public abstract class ProfileManager extends Observable {
|
|||
* @param profile The profile to write to the preference store
|
||||
*/
|
||||
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++) {
|
||||
updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), profileOptions);
|
||||
for (KeySet keySet : fKeySets) {
|
||||
updatePreferences(context.getNode(keySet.getNodeName()), keySet.getKeys(), profileOptions);
|
||||
}
|
||||
|
||||
final IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
|
||||
|
@ -604,7 +599,7 @@ public abstract class ProfileManager extends Observable {
|
|||
*
|
||||
* @see #getSortedDisplayNames()
|
||||
*/
|
||||
public List getSortedProfiles() {
|
||||
public List<Profile> getSortedProfiles() {
|
||||
return Collections.unmodifiableList(fProfilesByName);
|
||||
}
|
||||
|
||||
|
@ -618,8 +613,8 @@ public abstract class ProfileManager extends Observable {
|
|||
public String[] getSortedDisplayNames() {
|
||||
final String[] sortedNames= new String[fProfilesByName.size()];
|
||||
int i= 0;
|
||||
for (final Iterator iter = fProfilesByName.iterator(); iter.hasNext();) {
|
||||
Profile curr= (Profile) iter.next();
|
||||
for (Object element : fProfilesByName) {
|
||||
Profile curr= (Profile) element;
|
||||
sortedNames[i++]= curr.getName();
|
||||
}
|
||||
return sortedNames;
|
||||
|
@ -631,7 +626,7 @@ public abstract class ProfileManager extends Observable {
|
|||
* @return The profile with the given ID or <code>null</code>
|
||||
*/
|
||||
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) {
|
||||
for (int i= 0; i < fKeySets.length; i++) {
|
||||
updatePreferences(context.getNode(fKeySets[i].getNodeName()), fKeySets[i].getKeys(), Collections.EMPTY_MAP);
|
||||
for (KeySet keySet : fKeySets) {
|
||||
updatePreferences(context.getNode(keySet.getNodeName()), keySet.getKeys(), EMPTY_MAP);
|
||||
}
|
||||
|
||||
final IEclipsePreferences uiPrefs= context.getNode(CUIPlugin.PLUGIN_ID);
|
||||
|
@ -666,7 +661,7 @@ public abstract class ProfileManager extends Observable {
|
|||
* @param profile The profile to select
|
||||
*/
|
||||
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)) {
|
||||
fSelected= newSelected;
|
||||
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
|
||||
*/
|
||||
public boolean containsName(String name) {
|
||||
for (final Iterator iter = fProfilesByName.iterator(); iter.hasNext();) {
|
||||
Profile curr= (Profile) iter.next();
|
||||
for (Object element : fProfilesByName) {
|
||||
Profile curr= (Profile) element;
|
||||
if (name.equals(curr.getName())) {
|
||||
return true;
|
||||
}
|
||||
|
@ -730,7 +725,7 @@ public abstract class ProfileManager extends Observable {
|
|||
|
||||
if (index >= fProfilesByName.size())
|
||||
index--;
|
||||
fSelected= (Profile) fProfilesByName.get(index);
|
||||
fSelected= fProfilesByName.get(index);
|
||||
|
||||
if (!profile.isSharedProfile()) {
|
||||
updateProfilesWithName(profile.getID(), null, false);
|
||||
|
@ -779,8 +774,8 @@ public abstract class ProfileManager extends Observable {
|
|||
|
||||
private void updateProfilesWithName(String oldName, Profile newProfile, boolean applySettings) {
|
||||
IProject[] projects= ResourcesPlugin.getWorkspace().getRoot().getProjects();
|
||||
for (int i= 0; i < projects.length; i++) {
|
||||
IScopeContext projectScope= fPreferencesAccess.getProjectScope(projects[i]);
|
||||
for (IProject project : projects) {
|
||||
IScopeContext projectScope= fPreferencesAccess.getProjectScope(project);
|
||||
IEclipsePreferences node= projectScope.getNode(CUIPlugin.PLUGIN_ID);
|
||||
String profileId= node.get(fProfileKey, null);
|
||||
if (oldName.equals(profileId)) {
|
||||
|
|
|
@ -44,7 +44,6 @@ import org.eclipse.core.runtime.CoreException;
|
|||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
|
||||
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.Element;
|
||||
import org.xml.sax.Attributes;
|
||||
|
@ -73,11 +72,11 @@ public class ProfileStore {
|
|||
*/
|
||||
private final static class ProfileDefaultHandler extends DefaultHandler {
|
||||
|
||||
private List fProfiles;
|
||||
private List<Profile> fProfiles;
|
||||
private int fVersion;
|
||||
|
||||
private String fName;
|
||||
private Map fSettings;
|
||||
private Map<String, String> fSettings;
|
||||
private String fKind;
|
||||
|
||||
@Override
|
||||
|
@ -96,12 +95,12 @@ public class ProfileStore {
|
|||
if (fKind == null) //Can only be an CodeFormatterProfile created pre 20061106
|
||||
fKind= ProfileVersioner.CODE_FORMATTER_PROFILE_KIND;
|
||||
|
||||
fSettings= new HashMap(200);
|
||||
fSettings= new HashMap<String, String>(200);
|
||||
|
||||
}
|
||||
else if (qName.equals(XML_NODE_ROOT)) {
|
||||
|
||||
fProfiles= new ArrayList();
|
||||
fProfiles= new ArrayList<Profile>();
|
||||
try {
|
||||
fVersion= Integer.parseInt(attributes.getValue(XML_ATTRIBUTE_VERSION));
|
||||
} catch (NumberFormatException ex) {
|
||||
|
@ -121,7 +120,7 @@ public class ProfileStore {
|
|||
}
|
||||
}
|
||||
|
||||
public List getProfiles() {
|
||||
public List<Profile> getProfiles() {
|
||||
return fProfiles;
|
||||
}
|
||||
|
||||
|
@ -157,11 +156,11 @@ public class ProfileStore {
|
|||
* and are all updated to the latest version.
|
||||
* @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));
|
||||
}
|
||||
|
||||
public void writeProfiles(Collection profiles, IScopeContext instanceScope) throws CoreException {
|
||||
public void writeProfiles(Collection<Profile> profiles, IScopeContext instanceScope) throws CoreException {
|
||||
ByteArrayOutputStream stream= new ByteArrayOutputStream(2000);
|
||||
try {
|
||||
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) {
|
||||
byte[] bytes;
|
||||
try {
|
||||
|
@ -189,7 +188,7 @@ public class ProfileStore {
|
|||
}
|
||||
InputStream is= new ByteArrayInputStream(bytes);
|
||||
try {
|
||||
List res= readProfilesFromStream(new InputSource(is));
|
||||
List<Profile> res= readProfilesFromStream(new InputSource(is));
|
||||
if (res != null) {
|
||||
for (int i= 0; i < res.size(); 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>
|
||||
* @throws CoreException
|
||||
*/
|
||||
public List readProfilesFromFile(File file) throws CoreException {
|
||||
public List<Profile> readProfilesFromFile(File file) throws CoreException {
|
||||
try {
|
||||
final FileInputStream reader= new FileInputStream(file);
|
||||
try {
|
||||
|
@ -229,7 +228,7 @@ public class ProfileStore {
|
|||
* @return returns a list of <code>CustomProfile</code> or <code>null</code>
|
||||
* @throws CoreException
|
||||
*/
|
||||
protected static List readProfilesFromStream(InputSource inputSource) throws CoreException {
|
||||
protected static List<Profile> readProfilesFromStream(InputSource inputSource) throws CoreException {
|
||||
|
||||
final ProfileDefaultHandler handler= new ProfileDefaultHandler();
|
||||
try {
|
||||
|
@ -253,7 +252,7 @@ public class ProfileStore {
|
|||
* @param encoding the encoding to use
|
||||
* @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;
|
||||
try {
|
||||
stream= new FileOutputStream(file);
|
||||
|
@ -274,7 +273,7 @@ public class ProfileStore {
|
|||
* @param encoding the encoding to use
|
||||
* @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 {
|
||||
|
@ -287,8 +286,8 @@ public class ProfileStore {
|
|||
|
||||
document.appendChild(rootElement);
|
||||
|
||||
for(final Iterator iter= profiles.iterator(); iter.hasNext();) {
|
||||
final Profile profile= (Profile)iter.next();
|
||||
for (Object element : profiles) {
|
||||
final Profile profile= (Profile)element;
|
||||
if (profile.isProfileToSave()) {
|
||||
final Element profileElement= createProfileElement(profile, document, profileVersioner);
|
||||
rootElement.appendChild(profileElement);
|
||||
|
@ -318,11 +317,11 @@ public class ProfileStore {
|
|||
element.setAttribute(XML_ATTRIBUTE_VERSION, Integer.toString(profile.getVersion()));
|
||||
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()) {
|
||||
final String key= (String)keyIter.next();
|
||||
final String value= (String)profile.getSettings().get(key);
|
||||
final String key= keyIter.next();
|
||||
final String value= profile.getSettings().get(key);
|
||||
if (value != null) {
|
||||
final Element setting= document.createElement(XML_NODE_SETTING);
|
||||
setting.setAttribute(XML_ATTRIBUTE_ID, key);
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
|
||||
package org.eclipse.cdt.internal.ui.preferences.formatter;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.preferences.formatter.ProfileManager.CustomProfile;
|
||||
|
@ -43,8 +42,8 @@ public class ProfileVersioner implements IProfileVersioner {
|
|||
}
|
||||
|
||||
public void update(CustomProfile profile) {
|
||||
final Map oldSettings= profile.getSettings();
|
||||
Map newSettings= updateAndComplete(oldSettings, profile.getVersion());
|
||||
final Map<String, String> oldSettings= profile.getSettings();
|
||||
Map<String, String> newSettings= updateAndComplete(oldSettings, profile.getVersion());
|
||||
profile.setVersion(CURRENT_VERSION);
|
||||
profile.setSettings(newSettings);
|
||||
}
|
||||
|
@ -60,28 +59,28 @@ public class ProfileVersioner implements IProfileVersioner {
|
|||
}
|
||||
|
||||
public static void updateAndComplete(CustomProfile profile) {
|
||||
final Map oldSettings= profile.getSettings();
|
||||
Map newSettings= updateAndComplete(oldSettings, profile.getVersion());
|
||||
final Map<String, String> oldSettings= profile.getSettings();
|
||||
Map<String, String> newSettings= updateAndComplete(oldSettings, profile.getVersion());
|
||||
profile.setVersion(CURRENT_VERSION);
|
||||
profile.setSettings(newSettings);
|
||||
}
|
||||
|
||||
public static Map updateAndComplete(Map oldSettings, int version) {
|
||||
final Map newSettings= FormatterProfileManager.getDefaultSettings();
|
||||
public static Map<String, String> updateAndComplete(Map<String, String> oldSettings, int version) {
|
||||
final Map<String, String> newSettings= FormatterProfileManager.getDefaultSettings();
|
||||
|
||||
switch (version) {
|
||||
|
||||
default:
|
||||
for (final Iterator iter= oldSettings.keySet().iterator(); iter.hasNext(); ) {
|
||||
final String key= (String)iter.next();
|
||||
if (!newSettings.containsKey(key))
|
||||
continue;
|
||||
|
||||
final String value= (String)oldSettings.get(key);
|
||||
if (value != null) {
|
||||
newSettings.put(key, value);
|
||||
}
|
||||
}
|
||||
for (Object element : oldSettings.keySet()) {
|
||||
final String key= (String)element;
|
||||
if (!newSettings.containsKey(key))
|
||||
continue;
|
||||
|
||||
final String value= oldSettings.get(key);
|
||||
if (value != null) {
|
||||
newSettings.put(key, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return newSettings;
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.preferences.formatter;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
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);
|
||||
fSnippets= new ArrayList();
|
||||
fSnippets= new ArrayList<PreviewSnippet>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -62,8 +61,7 @@ public class SnippetPreview extends CPreview {
|
|||
final String delimiter= "\n"; //$NON-NLS-1$
|
||||
|
||||
final StringBuffer buffer= new StringBuffer();
|
||||
for (final Iterator iter= fSnippets.iterator(); iter.hasNext();) {
|
||||
final PreviewSnippet snippet= (PreviewSnippet) iter.next();
|
||||
for (PreviewSnippet snippet: fSnippets) {
|
||||
String formattedSource;
|
||||
try {
|
||||
TextEdit edit= CodeFormatterUtil.format(snippet.kind, snippet.source, 0, delimiter, fWorkingValues);
|
||||
|
@ -98,7 +96,7 @@ public class SnippetPreview extends CPreview {
|
|||
fSnippets.remove(snippet);
|
||||
}
|
||||
|
||||
public void addAll(Collection snippets) {
|
||||
public void addAll(Collection<PreviewSnippet> snippets) {
|
||||
fSnippets.addAll(snippets);
|
||||
}
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ public class TranslationUnitPreview extends CPreview {
|
|||
* @param workingValues
|
||||
* @param parent
|
||||
*/
|
||||
public TranslationUnitPreview(Map workingValues, Composite parent) {
|
||||
public TranslationUnitPreview(Map<String, String> workingValues, Composite parent) {
|
||||
super(workingValues, parent);
|
||||
}
|
||||
|
||||
|
@ -59,9 +59,9 @@ public class TranslationUnitPreview extends CPreview {
|
|||
final IContentFormatter formatter = fViewerConfiguration.getContentFormatter(fSourceViewer);
|
||||
if (formatter instanceof IContentFormatterExtension) {
|
||||
final IContentFormatterExtension extension = (IContentFormatterExtension) formatter;
|
||||
Map prefs= fWorkingValues;
|
||||
Map<String, String> prefs= fWorkingValues;
|
||||
if (fFormatterId != null) {
|
||||
prefs= new HashMap(fWorkingValues);
|
||||
prefs= new HashMap<String, String>(fWorkingValues);
|
||||
prefs.put(CCorePreferenceConstants.CODE_FORMATTER, fFormatterId);
|
||||
}
|
||||
context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, prefs);
|
||||
|
|
|
@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.preferences.formatter;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -40,16 +39,16 @@ public final class WhiteSpaceOptions {
|
|||
|
||||
public int index;
|
||||
|
||||
protected final Map fWorkingValues;
|
||||
protected final ArrayList fChildren;
|
||||
protected final Map<String,String> fWorkingValues;
|
||||
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)
|
||||
throw new IllegalArgumentException();
|
||||
fParent= parent;
|
||||
fWorkingValues= workingValues;
|
||||
fName= message;
|
||||
fChildren= new ArrayList();
|
||||
fChildren= new ArrayList<Node>();
|
||||
if (fParent != null)
|
||||
fParent.add(this);
|
||||
}
|
||||
|
@ -60,7 +59,7 @@ public final class WhiteSpaceOptions {
|
|||
return !fChildren.isEmpty();
|
||||
}
|
||||
|
||||
public List getChildren() {
|
||||
public List<Node> getChildren() {
|
||||
return Collections.unmodifiableList(fChildren);
|
||||
}
|
||||
|
||||
|
@ -73,9 +72,9 @@ public final class WhiteSpaceOptions {
|
|||
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 InnerNode(InnerNode parent, Map workingValues, String messageKey) {
|
||||
public InnerNode(InnerNode parent, Map<String,String> workingValues, String messageKey) {
|
||||
super(parent, workingValues, messageKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChecked(boolean checked) {
|
||||
for (final Iterator iter = fChildren.iterator(); iter.hasNext();)
|
||||
((Node)iter.next()).setChecked(checked);
|
||||
for (Object element : fChildren)
|
||||
((Node)element).setChecked(checked);
|
||||
}
|
||||
|
||||
public void add(Node child) {
|
||||
|
@ -98,12 +97,11 @@ public final class WhiteSpaceOptions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List getSnippets() {
|
||||
final ArrayList snippets= new ArrayList(fChildren.size());
|
||||
for (Iterator iter= fChildren.iterator(); iter.hasNext();) {
|
||||
final List childSnippets= ((Node)iter.next()).getSnippets();
|
||||
for (final Iterator chIter= childSnippets.iterator(); chIter.hasNext(); ) {
|
||||
final Object snippet= chIter.next();
|
||||
public List<PreviewSnippet> getSnippets() {
|
||||
final ArrayList<PreviewSnippet> snippets= new ArrayList<PreviewSnippet>(fChildren.size());
|
||||
for (Object element : fChildren) {
|
||||
final List<PreviewSnippet> childSnippets= ((Node)element).getSnippets();
|
||||
for (PreviewSnippet snippet : childSnippets) {
|
||||
if (!snippets.contains(snippet))
|
||||
snippets.add(snippet);
|
||||
}
|
||||
|
@ -112,9 +110,9 @@ public final class WhiteSpaceOptions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void getCheckedLeafs(List list) {
|
||||
for (Iterator iter= fChildren.iterator(); iter.hasNext();) {
|
||||
((Node)iter.next()).getCheckedLeafs(list);
|
||||
public void getCheckedLeafs(List<OptionNode> list) {
|
||||
for (Node element : fChildren) {
|
||||
element.getCheckedLeafs(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -125,12 +123,12 @@ public final class WhiteSpaceOptions {
|
|||
*/
|
||||
public static class OptionNode extends Node {
|
||||
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);
|
||||
fKey= key;
|
||||
fSnippets= new ArrayList(1);
|
||||
fSnippets= new ArrayList<PreviewSnippet>(1);
|
||||
fSnippets.add(snippet);
|
||||
}
|
||||
|
||||
|
@ -144,12 +142,12 @@ public final class WhiteSpaceOptions {
|
|||
}
|
||||
|
||||
@Override
|
||||
public List getSnippets() {
|
||||
public List<PreviewSnippet> getSnippets() {
|
||||
return fSnippets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getCheckedLeafs(List list) {
|
||||
public void getCheckedLeafs(List<OptionNode> list) {
|
||||
if (getChecked())
|
||||
list.add(this);
|
||||
}
|
||||
|
@ -255,8 +253,8 @@ public final class WhiteSpaceOptions {
|
|||
* @param workingValues
|
||||
* @return returns roots (type <code>Node</code>)
|
||||
*/
|
||||
public List createTreeBySyntaxElem(Map workingValues) {
|
||||
final ArrayList roots= new ArrayList();
|
||||
public List<InnerNode> createTreeBySyntaxElem(Map<String, String> workingValues) {
|
||||
final ArrayList<InnerNode> roots= new ArrayList<InnerNode>();
|
||||
|
||||
InnerNode element;
|
||||
|
||||
|
@ -335,9 +333,9 @@ public final class WhiteSpaceOptions {
|
|||
* @param workingValues
|
||||
* @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;
|
||||
|
||||
|
@ -435,13 +433,13 @@ public final class WhiteSpaceOptions {
|
|||
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);
|
||||
roots.add(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);
|
||||
createClassTree(workingValues, declarations);
|
||||
|
@ -478,7 +476,7 @@ public final class WhiteSpaceOptions {
|
|||
createTemplateArgumentTree(workingValues, templates);
|
||||
createTemplateParameterTree(workingValues, templates);
|
||||
|
||||
final ArrayList roots= new ArrayList();
|
||||
final ArrayList<InnerNode> roots= new ArrayList<InnerNode>();
|
||||
roots.add(declarations);
|
||||
roots.add(statements);
|
||||
roots.add(expressions);
|
||||
|
@ -487,16 +485,16 @@ public final class WhiteSpaceOptions {
|
|||
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);
|
||||
}
|
||||
|
||||
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_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_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);
|
||||
|
@ -506,7 +504,7 @@ public final class WhiteSpaceOptions {
|
|||
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);
|
||||
// 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);
|
||||
}
|
||||
|
||||
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_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);
|
||||
|
@ -541,30 +539,30 @@ public final class WhiteSpaceOptions {
|
|||
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);
|
||||
}
|
||||
|
||||
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_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);
|
||||
}
|
||||
|
||||
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_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);
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
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_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);
|
||||
}
|
||||
|
||||
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_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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -626,17 +624,17 @@ public final class WhiteSpaceOptions {
|
|||
// 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);
|
||||
}
|
||||
|
||||
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_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);
|
||||
}
|
||||
|
||||
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); {
|
||||
// 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);
|
||||
}
|
||||
|
||||
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_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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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_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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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, "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);
|
||||
}
|
||||
|
||||
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_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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
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_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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
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);
|
||||
|
@ -747,14 +745,14 @@ public final class WhiteSpaceOptions {
|
|||
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);
|
||||
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);
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
// }
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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_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);
|
||||
|
@ -838,7 +836,7 @@ public final class WhiteSpaceOptions {
|
|||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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;
|
||||
// }
|
||||
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
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);
|
||||
|
@ -945,7 +943,7 @@ public final class WhiteSpaceOptions {
|
|||
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);
|
||||
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);
|
||||
|
@ -956,7 +954,7 @@ public final class WhiteSpaceOptions {
|
|||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static void makeIndexForNodes(List tree, List flatList) {
|
||||
for (final Iterator iter= tree.iterator(); iter.hasNext();) {
|
||||
final Node node= (Node) iter.next();
|
||||
public static void makeIndexForNodes(List<? extends Node> tree, List<Node> flatList) {
|
||||
for (Node node : tree) {
|
||||
node.index= flatList.size();
|
||||
flatList.add(node);
|
||||
makeIndexForNodes(node.getChildren(), flatList);
|
||||
|
|
|
@ -13,19 +13,9 @@ package org.eclipse.cdt.internal.ui.preferences.formatter;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
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.viewers.ArrayContentProvider;
|
||||
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.TreeViewer;
|
||||
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.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 List fIndexedNodeList;
|
||||
private final List fTree;
|
||||
private final List<Node> fIndexedNodeList;
|
||||
private final List<? extends Node> fTree;
|
||||
|
||||
private ContainerCheckedTreeViewer fTreeViewer;
|
||||
private Composite fComposite;
|
||||
|
@ -74,7 +71,7 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
|
|||
private Node fLastSelected= null;
|
||||
|
||||
public SyntaxComponent() {
|
||||
fIndexedNodeList= new ArrayList();
|
||||
fIndexedNodeList= new ArrayList<Node>();
|
||||
fTree= new WhiteSpaceOptions().createAltTree(fWorkingValues);
|
||||
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.setContentProvider(new ITreeContentProvider() {
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return ((Collection)inputElement).toArray();
|
||||
return ((Collection<?>)inputElement).toArray();
|
||||
}
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
return ((Node)parentElement).getChildren().toArray();
|
||||
|
@ -118,9 +115,9 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
|
|||
}
|
||||
|
||||
public void refreshState() {
|
||||
final ArrayList checked= new ArrayList(100);
|
||||
for (Iterator iter= fTree.iterator(); iter.hasNext();)
|
||||
((Node) iter.next()).getCheckedLeafs(checked);
|
||||
final ArrayList<OptionNode> checked= new ArrayList<OptionNode>(100);
|
||||
for (Node node : fTree)
|
||||
(node).getCheckedLeafs(checked);
|
||||
fTreeViewer.setGrayedElements(new Object[0]);
|
||||
fTreeViewer.setCheckedElements(checked.toArray());
|
||||
fPreview.clear();
|
||||
|
@ -161,7 +158,7 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
|
|||
if (index < 0 || index > fIndexedNodeList.size() - 1) {
|
||||
index= 0;
|
||||
}
|
||||
final Node node= (Node)fIndexedNodeList.get(index);
|
||||
final Node node= fIndexedNodeList.get(index);
|
||||
if (node != null) {
|
||||
fTreeViewer.expandToLevel(node, 0);
|
||||
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_OPTION_INDEX= CUIPlugin.PLUGIN_ID + "formatter_page.white_space.java_view.option"; //$NON-NLS-1$
|
||||
|
||||
private final ArrayList fIndexedNodeList;
|
||||
private final ArrayList fTree;
|
||||
private final ArrayList<Node> fIndexedNodeList;
|
||||
private final ArrayList<InnerNode> fTree;
|
||||
|
||||
private InnerNode fLastSelected;
|
||||
|
||||
|
@ -200,7 +197,7 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
|
|||
private Composite fComposite;
|
||||
|
||||
public JavaElementComponent() {
|
||||
fIndexedNodeList= new ArrayList();
|
||||
fIndexedNodeList= new ArrayList<Node>();
|
||||
fTree= new WhiteSpaceOptions().createTreeByJavaElement(fWorkingValues);
|
||||
WhiteSpaceOptions.makeIndexForNodes(fTree, fIndexedNodeList);
|
||||
}
|
||||
|
@ -220,13 +217,12 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
|
|||
|
||||
fInnerViewer.setContentProvider(new ITreeContentProvider() {
|
||||
public Object[] getElements(Object inputElement) {
|
||||
return ((Collection)inputElement).toArray();
|
||||
return ((Collection<?>)inputElement).toArray();
|
||||
}
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
final List children= ((Node)parentElement).getChildren();
|
||||
final ArrayList innerChildren= new ArrayList();
|
||||
for (final Iterator iter= children.iterator(); iter.hasNext();) {
|
||||
final Object o= iter.next();
|
||||
final List<Node> children= ((Node)parentElement).getChildren();
|
||||
final ArrayList<Object> innerChildren= new ArrayList<Object>();
|
||||
for (Object o : children) {
|
||||
if (o instanceof InnerNode) innerChildren.add(o);
|
||||
}
|
||||
return innerChildren.toArray();
|
||||
|
@ -237,9 +233,9 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
|
|||
return null;
|
||||
}
|
||||
public boolean hasChildren(Object element) {
|
||||
final List children= ((Node)element).getChildren();
|
||||
for (final Iterator iter= children.iterator(); iter.hasNext();)
|
||||
if (iter.next() instanceof InnerNode) return true;
|
||||
final List<?> children= ((Node)element).getChildren();
|
||||
for (Object child : children)
|
||||
if (child instanceof InnerNode) return true;
|
||||
return false;
|
||||
}
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {}
|
||||
|
@ -283,7 +279,7 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
|
|||
private void restoreSelections() {
|
||||
Node node;
|
||||
final int innerIndex= getValidatedIndex(PREF_INNER_INDEX);
|
||||
node= (Node)fIndexedNodeList.get(innerIndex);
|
||||
node= fIndexedNodeList.get(innerIndex);
|
||||
if (node instanceof InnerNode) {
|
||||
fInnerViewer.expandToLevel(node, 0);
|
||||
fInnerViewer.setSelection(new StructuredSelection(new Object[] {node}));
|
||||
|
@ -291,7 +287,7 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
|
|||
}
|
||||
|
||||
final int optionIndex= getValidatedIndex(PREF_OPTION_INDEX);
|
||||
node= (Node)fIndexedNodeList.get(optionIndex);
|
||||
node= fIndexedNodeList.get(optionIndex);
|
||||
if (node instanceof OptionNode) {
|
||||
fOptionsViewer.setSelection(new StructuredSelection(new Object[] {node}));
|
||||
}
|
||||
|
@ -338,19 +334,17 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
|
|||
|
||||
private void innerViewerChanged(InnerNode selectedNode) {
|
||||
|
||||
final List children= selectedNode.getChildren();
|
||||
final List<Node> children= selectedNode.getChildren();
|
||||
|
||||
final ArrayList optionsChildren= new ArrayList();
|
||||
for (final Iterator iter= children.iterator(); iter.hasNext();) {
|
||||
final Object o= iter.next();
|
||||
if (o instanceof OptionNode) optionsChildren.add(o);
|
||||
final ArrayList<OptionNode> optionsChildren= new ArrayList<OptionNode>();
|
||||
for (Object o : children) {
|
||||
if (o instanceof OptionNode) optionsChildren.add((OptionNode) o);
|
||||
}
|
||||
|
||||
fOptionsViewer.setInput(optionsChildren.toArray());
|
||||
|
||||
for (final Iterator iter= optionsChildren.iterator(); iter.hasNext();) {
|
||||
final OptionNode child= (OptionNode)iter.next();
|
||||
fOptionsViewer.setChecked(child, child.getChecked());
|
||||
for (OptionNode child : optionsChildren) {
|
||||
fOptionsViewer.setChecked(child, child.getChecked());
|
||||
}
|
||||
|
||||
fPreview.clear();
|
||||
|
@ -454,7 +448,7 @@ public class WhiteSpaceTabPage extends FormatterTabPage {
|
|||
* @param modifyDialog
|
||||
* @param workingValues
|
||||
*/
|
||||
public WhiteSpaceTabPage(ModifyDialog modifyDialog, Map workingValues) {
|
||||
public WhiteSpaceTabPage(ModifyDialog modifyDialog, Map<String,String> workingValues) {
|
||||
super(modifyDialog, workingValues);
|
||||
fDialogSettings= CUIPlugin.getDefault().getDialogSettings();
|
||||
fSwitchComponent= new SwitchComponent();
|
||||
|
|
|
@ -13,11 +13,12 @@
|
|||
*/
|
||||
package org.eclipse.cdt.internal.ui.search;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.core.resources.IMarker;
|
||||
import org.eclipse.swt.widgets.Shell;
|
||||
import org.eclipse.ui.IWorkingSet;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*
|
||||
|
@ -54,7 +55,7 @@ public class CSearchUtil {
|
|||
}
|
||||
|
||||
public static String toString(IWorkingSet[] workingSets) {
|
||||
if( workingSets != null & workingSets.length > 0 ){
|
||||
if( workingSets != null && workingSets.length > 0 ){
|
||||
String string = new String();
|
||||
for( int i = 0; i < workingSets.length; i++ ){
|
||||
if( i > 0 )
|
||||
|
|
|
@ -35,11 +35,11 @@ import org.eclipse.ui.PlatformUI;
|
|||
*/
|
||||
public class LRUWorkingSets {
|
||||
|
||||
ArrayList workingSetsCache = null;
|
||||
ArrayList<IWorkingSet[]> workingSetsCache = null;
|
||||
int size=0;
|
||||
|
||||
public LRUWorkingSets(int size){
|
||||
workingSetsCache = new ArrayList(size);
|
||||
workingSetsCache = new ArrayList<IWorkingSet[]>(size);
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
|
@ -54,12 +54,12 @@ public class LRUWorkingSets {
|
|||
workingSetsCache.add(0, workingSet);
|
||||
}
|
||||
|
||||
private IWorkingSet[] find(ArrayList list, IWorkingSet[] workingSet) {
|
||||
Set workingSetList= new HashSet(Arrays.asList(workingSet));
|
||||
Iterator iter= list.iterator();
|
||||
private IWorkingSet[] find(ArrayList<IWorkingSet[]> list, IWorkingSet[] workingSet) {
|
||||
Set<IWorkingSet> workingSetList= new HashSet<IWorkingSet>(Arrays.asList(workingSet));
|
||||
Iterator<IWorkingSet[]> iter= list.iterator();
|
||||
while (iter.hasNext()) {
|
||||
IWorkingSet[] lruWorkingSets= (IWorkingSet[])iter.next();
|
||||
Set lruWorkingSetList= new HashSet(Arrays.asList(lruWorkingSets));
|
||||
IWorkingSet[] lruWorkingSets= iter.next();
|
||||
Set<IWorkingSet> lruWorkingSetList= new HashSet<IWorkingSet>(Arrays.asList(lruWorkingSets));
|
||||
if (lruWorkingSetList.equals(workingSetList))
|
||||
return lruWorkingSets;
|
||||
}
|
||||
|
@ -68,9 +68,9 @@ public class LRUWorkingSets {
|
|||
|
||||
private void cleanUpCache(){
|
||||
//Remove any previously deleted entries
|
||||
Iterator iter = workingSetsCache.iterator();
|
||||
Iterator<IWorkingSet[]> iter = workingSetsCache.iterator();
|
||||
while (iter.hasNext()){
|
||||
IWorkingSet[] workingSet = (IWorkingSet []) iter.next();
|
||||
IWorkingSet[] workingSet = iter.next();
|
||||
for (int i= 0; i < workingSet.length; i++) {
|
||||
if (PlatformUI.getWorkbench().getWorkingSetManager().getWorkingSet(workingSet[i].getName()) == null) {
|
||||
workingSetsCache.remove(workingSet);
|
||||
|
@ -80,7 +80,7 @@ public class LRUWorkingSets {
|
|||
}
|
||||
}
|
||||
|
||||
public Iterator iterator() {
|
||||
public Iterator<IWorkingSet[]> iterator() {
|
||||
return workingSetsCache.iterator();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ public class PDOMSearchElementQuery extends PDOMSearchQuery {
|
|||
public String getLabel() {
|
||||
if (element instanceof ICElement)
|
||||
return super.getLabel() + " " + ((ICElement)element).getElementName(); //$NON-NLS-1$
|
||||
else
|
||||
return super.getLabel() + " something."; //$NON-NLS-1$
|
||||
return super.getLabel() + " something."; //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,12 +42,12 @@ public class PDOMSearchListContentProvider implements
|
|||
private PDOMSearchResult result;
|
||||
|
||||
public Object[] getElements(Object inputElement) {
|
||||
Set uncoveredProjects = new HashSet();
|
||||
Set<String> uncoveredProjects = new HashSet<String>();
|
||||
|
||||
PDOMSearchResult result = (PDOMSearchResult) inputElement;
|
||||
|
||||
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
|
||||
if (result.wasIndexerBusy()) {
|
||||
|
|
|
@ -178,13 +178,13 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
|
|||
}
|
||||
|
||||
// get the list of elements for the scope
|
||||
List elements = new ArrayList();
|
||||
List<Object> elements = new ArrayList<Object>();
|
||||
String scopeDescription = ""; //$NON-NLS-1$
|
||||
switch (getContainer().getSelectedScope()) {
|
||||
case ISearchPageContainer.SELECTED_PROJECTS_SCOPE:
|
||||
if (structuredSelection != null) {
|
||||
scopeDescription = CSearchMessages.ProjectScope;
|
||||
for (Iterator i = structuredSelection.iterator(); i.hasNext();) {
|
||||
for (Iterator<?> i = structuredSelection.iterator(); i.hasNext();) {
|
||||
ICProject project = getProject(i.next());
|
||||
if (project != null)
|
||||
elements.add(project);
|
||||
|
@ -194,7 +194,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
|
|||
case ISearchPageContainer.SELECTION_SCOPE:
|
||||
if( structuredSelection != null) {
|
||||
scopeDescription = CSearchMessages.SelectionScope;
|
||||
for (Iterator i = structuredSelection.iterator(); i.hasNext();) {
|
||||
for (Iterator<?> i = structuredSelection.iterator(); i.hasNext();) {
|
||||
Object obj = i.next();
|
||||
if (obj instanceof IResource)
|
||||
elements.add(CoreModel.getDefault().create((IResource)obj));
|
||||
|
@ -225,7 +225,7 @@ public class PDOMSearchPage extends DialogPage implements ISearchPage {
|
|||
ICElement[] scope
|
||||
= elements.isEmpty()
|
||||
? null
|
||||
: (ICElement[])elements.toArray(new ICElement[elements.size()]);
|
||||
: elements.toArray(new ICElement[elements.size()]);
|
||||
|
||||
try {
|
||||
PDOMSearchPatternQuery job = new PDOMSearchPatternQuery(scope, scopeDescription, patternStr,
|
||||
|
|
|
@ -49,17 +49,17 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
|||
private Map<Object, Set<Object>> tree = new HashMap<Object, Set<Object>>();
|
||||
|
||||
public Object[] getChildren(Object parentElement) {
|
||||
Set children = tree.get(parentElement);
|
||||
Set<Object> children = tree.get(parentElement);
|
||||
if (children == null)
|
||||
return new Object[0];
|
||||
return children.toArray();
|
||||
}
|
||||
|
||||
public Object getParent(Object element) {
|
||||
Iterator p = tree.keySet().iterator();
|
||||
Iterator<Object> p = tree.keySet().iterator();
|
||||
while (p.hasNext()) {
|
||||
Object parent = p.next();
|
||||
Set children = tree.get(parent);
|
||||
Set<Object> children = tree.get(parent);
|
||||
if (children.contains(element))
|
||||
return parent;
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ public class PDOMSearchTreeContentProvider implements ITreeContentProvider, IPDO
|
|||
// reached the search result
|
||||
return;
|
||||
|
||||
Set siblings = tree.get(parent);
|
||||
Set<Object> siblings = tree.get(parent);
|
||||
siblings.remove(element);
|
||||
|
||||
if (siblings.isEmpty()) {
|
||||
|
|
|
@ -88,17 +88,17 @@ public class DeclarationsSearchGroup extends ActionGroup {
|
|||
incomingMenu.add(fFindDeclarationsProjectAction);
|
||||
incomingMenu.add(fFindDeclarationsInWorkingSetAction);
|
||||
|
||||
for (int i=0; i<actions.length; i++){
|
||||
incomingMenu.add(actions[i]);
|
||||
for (FindAction action : actions) {
|
||||
incomingMenu.add(action);
|
||||
}
|
||||
}
|
||||
|
||||
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()) {
|
||||
IWorkingSet[] workingSets= (IWorkingSet[])iter.next();
|
||||
IWorkingSet[] workingSets= iter.next();
|
||||
FindAction action;
|
||||
if (fEditor != null)
|
||||
action= new WorkingSetFindAction(fEditor, new FindDeclarationsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
|
||||
|
@ -108,19 +108,18 @@ public class DeclarationsSearchGroup extends ActionGroup {
|
|||
actions.add(action);
|
||||
}
|
||||
|
||||
return (FindAction[])actions.toArray(new FindAction[actions.size()]);
|
||||
return actions.toArray(new FindAction[actions.size()]);
|
||||
}
|
||||
public static boolean canActionBeAdded(ISelection selection) {
|
||||
if(selection instanceof ITextSelection) {
|
||||
return (((ITextSelection)selection).getLength() > 0);
|
||||
} else {
|
||||
return getElement(selection) != null;
|
||||
}
|
||||
return getElement(selection) != null;
|
||||
}
|
||||
|
||||
private static ICElement getElement(ISelection sel) {
|
||||
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||
List list= ((IStructuredSelection)sel).toList();
|
||||
List<?> list= ((IStructuredSelection)sel).toList();
|
||||
if (list.size() == 1) {
|
||||
Object element= list.get(0);
|
||||
if (element instanceof ICElement) {
|
||||
|
|
|
@ -70,7 +70,7 @@ public abstract class FindInWorkingSetAction extends FindAction {
|
|||
if (fWorkingSets == null) {
|
||||
return new ICElement[0];
|
||||
}
|
||||
List scope = new ArrayList();
|
||||
List<ICElement> scope = new ArrayList<ICElement>();
|
||||
for (int i = 0; i < fWorkingSets.length; ++i) {
|
||||
IAdaptable[] elements = fWorkingSets[i].getElements();
|
||||
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() {
|
||||
|
|
|
@ -45,7 +45,7 @@ public class FindUnresolvedIncludesProjectAction implements IObjectActionDelegat
|
|||
public void run(IAction action) {
|
||||
List<ICProject> projects= new ArrayList<ICProject>();
|
||||
IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection);
|
||||
for (Iterator i = cElements.iterator(); i.hasNext();) {
|
||||
for (Iterator<?> i = cElements.iterator(); i.hasNext();) {
|
||||
Object elem = i.next();
|
||||
if (elem instanceof ICProject) {
|
||||
projects.add((ICProject) elem);
|
||||
|
|
|
@ -203,13 +203,11 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
|
|||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
// Check if we're in an include statement
|
||||
if (searchName == null) {
|
||||
IASTNode node= nodeSelector.findEnclosingNode(selectionStart, selectionLength);
|
||||
if (node instanceof IASTPreprocessorIncludeStatement) {
|
||||
openInclude(((IASTPreprocessorIncludeStatement) node));
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
// no enclosing name, check if we're in an include statement
|
||||
IASTNode node= nodeSelector.findEnclosingNode(selectionStart, selectionLength);
|
||||
if (node instanceof IASTPreprocessorIncludeStatement) {
|
||||
openInclude(((IASTPreprocessorIncludeStatement) node));
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
if (!navigationFallBack(ast)) {
|
||||
reportSelectionMatchFailure();
|
||||
|
@ -267,8 +265,8 @@ public class OpenDeclarationsAction extends SelectionParseAction implements ASTR
|
|||
}
|
||||
|
||||
private boolean navigateOneLocation(IName[] declNames) {
|
||||
for (int i = 0; i < declNames.length; i++) {
|
||||
IASTFileLocation fileloc = declNames[i].getFileLocation();
|
||||
for (IName declName : declNames) {
|
||||
IASTFileLocation fileloc = declName.getFileLocation();
|
||||
if (fileloc != null) {
|
||||
|
||||
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) {
|
||||
for (int i = 0; i < declNames.length; i++) {
|
||||
for (IName declName : declNames) {
|
||||
try {
|
||||
ICElement elem = getCElementForName(project, index, declNames[i]);
|
||||
ICElement elem = getCElementForName(project, index, declName);
|
||||
if (elem instanceof ISourceReference) {
|
||||
elements.add(elem);
|
||||
}
|
||||
|
|
|
@ -82,18 +82,18 @@ public class ReferencesSearchGroup extends ActionGroup {
|
|||
incomingMenu.add(fFindRefsProjectAction);
|
||||
incomingMenu.add(fFindRefsInWorkingSetAction);
|
||||
|
||||
for (int i=0; i<actions.length; i++){
|
||||
incomingMenu.add(actions[i]);
|
||||
for (FindAction action : actions) {
|
||||
incomingMenu.add(action);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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()) {
|
||||
IWorkingSet[] workingSets= (IWorkingSet[])iter.next();
|
||||
IWorkingSet[] workingSets= iter.next();
|
||||
FindAction action;
|
||||
if (fEditor != null)
|
||||
action= new WorkingSetFindAction(fEditor, new FindRefsInWorkingSetAction(fEditor, workingSets), CSearchUtil.toString(workingSets));
|
||||
|
@ -103,7 +103,7 @@ public class ReferencesSearchGroup extends ActionGroup {
|
|||
actions.add(action);
|
||||
}
|
||||
|
||||
return (FindAction[])actions.toArray(new FindAction[actions.size()]);
|
||||
return actions.toArray(new FindAction[actions.size()]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -12,8 +12,6 @@ package org.eclipse.cdt.internal.ui.search.actions;
|
|||
|
||||
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.text.ITextSelection;
|
||||
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.part.Page;
|
||||
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
|
||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||
|
||||
public class SelectionSearchGroup extends ActionGroup {
|
||||
|
||||
private CEditor fEditor;
|
||||
|
@ -63,14 +65,13 @@ public class SelectionSearchGroup extends ActionGroup {
|
|||
public static boolean canActionBeAdded(ISelection selection) {
|
||||
if(selection instanceof ITextSelection) {
|
||||
return (((ITextSelection)selection).getLength() > 0);
|
||||
} else {
|
||||
return getElement(selection) != null;
|
||||
}
|
||||
return getElement(selection) != null;
|
||||
}
|
||||
|
||||
private static ICElement getElement(ISelection sel) {
|
||||
if (!sel.isEmpty() && sel instanceof IStructuredSelection) {
|
||||
List list= ((IStructuredSelection)sel).toList();
|
||||
List<?> list= ((IStructuredSelection)sel).toList();
|
||||
if (list.size() == 1) {
|
||||
Object element= list.get(0);
|
||||
if (element instanceof ICElement) {
|
||||
|
|
Loading…
Add table
Reference in a new issue