Skip to main content
aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarkus Schorn2008-04-14 10:08:14 -0400
committerMarkus Schorn2008-04-14 10:08:14 -0400
commit29abe81d9e741de721c56d097820082d8e97ec21 (patch)
treef4f1513c24e16fbd12e06e0ca8e2918f7a87bd56 /core
parentd29b51bbd45c84fe0aa26f423c5025f18df0fab6 (diff)
downloadorg.eclipse.cdt-29abe81d9e741de721c56d097820082d8e97ec21.tar.gz
org.eclipse.cdt-29abe81d9e741de721c56d097820082d8e97ec21.tar.xz
org.eclipse.cdt-29abe81d9e741de721c56d097820082d8e97ec21.zip
Fix warnings.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractInformationControl.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java3
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java18
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTML2TextReader.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLAnnotationHover.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLTextPresenter.java13
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SequenceCharacterIterator.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverDescriptor.java33
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java15
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistComputerParameter.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java93
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java53
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HippieProposalComputer.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposalComputer.java31
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java33
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java26
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java43
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor.java36
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java29
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ContributedProcessorDescriptor.java21
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandInstaller.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/AbstractDocCommentProposalComputer.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwnerManager.java24
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderRegistry.java8
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java51
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingProblem.java11
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckIterator.java14
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngineDispatcher.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposalComputer.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordQuickFixProcessor.java6
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java57
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java30
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java59
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellChecker.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellDictionary.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellEvent.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java9
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordProposal.java5
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/SpellEvent.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java16
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java19
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java23
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java12
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java26
68 files changed, 581 insertions, 601 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java
index 212baa9d44b..81d8f41657b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCScanner.java
@@ -86,8 +86,8 @@ public abstract class AbstractCScanner extends BufferedRuleBasedScanner implemen
if(fTokenStore.affectsBehavior(event)) {
fTokenStore.adaptToPreferenceChange(event);
}
- for(Iterator i= pcps.iterator(); i.hasNext(); ) {
- ((IPropertyChangeParticipant)i.next()).adaptToPreferenceChange(event);
+ for (IPropertyChangeParticipant propertyChangeParticipant : pcps) {
+ propertyChangeParticipant.adaptToPreferenceChange(event);
}
}
@@ -96,8 +96,8 @@ public abstract class AbstractCScanner extends BufferedRuleBasedScanner implemen
*/
public boolean affectsBehavior(PropertyChangeEvent event) {
boolean result= fTokenStore.affectsBehavior(event);
- for(Iterator i= pcps.iterator(); !result && i.hasNext(); ) {
- result |= ((IPropertyChangeParticipant)i.next()).affectsBehavior(event);
+ for(Iterator<IPropertyChangeParticipant> i= pcps.iterator(); !result && i.hasNext(); ) {
+ result |= (i.next()).affectsBehavior(event);
}
return result;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractInformationControl.java
index eefb7925f51..b7678b67f69 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractInformationControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractInformationControl.java
@@ -96,8 +96,8 @@ public abstract class AbstractInformationControl extends PopupDialog implements
private boolean hasUnfilteredChild(TreeViewer viewer, Object element) {
if (element instanceof IParent) {
Object[] children= ((ITreeContentProvider) viewer.getContentProvider()).getChildren(element);
- for (int i= 0; i < children.length; i++)
- if (select(viewer, element, children[i]))
+ for (Object element2 : children)
+ if (select(viewer, element, element2))
return true;
}
return false;
@@ -413,21 +413,19 @@ public abstract class AbstractInformationControl extends PopupDialog implements
private ICElement findElement(TreeItem[] items) {
ILabelProvider labelProvider= (ILabelProvider)fTreeViewer.getLabelProvider();
- for (int i= 0; i < items.length; i++) {
- Object item= items[i].getData();
+ for (TreeItem item2 : items) {
+ Object item= item2.getData();
ICElement element= null;
if (item instanceof ICElement) {
element= (ICElement)item;
if (fStringMatcher == null)
return element;
- if (element != null) {
- String label= labelProvider.getText(element);
- if (fStringMatcher.match(label))
- return element;
- }
+ String label= labelProvider.getText(element);
+ if (fStringMatcher.match(label))
+ return element;
}
- element= findElement(items[i].getItems());
+ element= findElement(item2.getItems());
if (element != null)
return element;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java
index 9b65f64309c..3303dc347a4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java
@@ -11,7 +11,6 @@
package org.eclipse.cdt.internal.ui.text;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.jface.action.IMenuManager;
@@ -128,8 +127,7 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
@Override
protected Control createContents(Composite parent) {
Control contents= super.createContents(parent);
- for (Iterator<Control> it= fColorExclusionControls.iterator(); it.hasNext(); ) {
- Control ctrl = it.next();
+ for (Control ctrl : fColorExclusionControls) {
ctrl.setBackground(fBackgroundColor);
}
return contents;
@@ -207,6 +205,7 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
*/
@Override
protected List<Control> getBackgroundColorExclusions() {
+ @SuppressWarnings("unchecked")
List<Control> exclusions= super.getBackgroundColorExclusions();
exclusions.addAll(fColorExclusionControls);
return exclusions;
@@ -217,6 +216,7 @@ public abstract class AbstractSourceViewerInformationControl extends PopupDialog
*/
@Override
protected List<Control> getForegroundColorExclusions() {
+ @SuppressWarnings("unchecked")
List<Control> exclusions= super.getForegroundColorExclusions();
exclusions.addAll(fColorExclusionControls);
return exclusions;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java
index 4c5c7f27bf0..ec6fe666f22 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CAutoIndentStrategy.java
@@ -765,8 +765,7 @@ public class CAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy {
private int computeVisualLength(char ch) {
if (ch == '\t')
return getVisualTabLengthPreference();
- else
- return 1;
+ return 1;
}
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java
index 7e6831410e0..7b95949ddec 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CBreakIterator.java
@@ -11,11 +11,12 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.text;
-import com.ibm.icu.text.BreakIterator;
import java.text.CharacterIterator;
import org.eclipse.core.runtime.Assert;
+import com.ibm.icu.text.BreakIterator;
+
/**
* A C break iterator. It returns all breaks, including before and after
@@ -355,8 +356,7 @@ public class CBreakIterator extends BreakIterator {
public boolean isBoundary(int offset) {
if (offset == getText().getBeginIndex())
return true;
- else
- return following(offset - 1) == offset;
+ return following(offset - 1) == offset;
}
/*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java
index 8ecb186fca6..d5c7a6ab2d8 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CFormattingStrategy.java
@@ -12,6 +12,7 @@
package org.eclipse.cdt.internal.ui.text;
import java.util.LinkedList;
+import java.util.Map;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
@@ -35,9 +36,9 @@ public class CFormattingStrategy extends ContextBasedFormattingStrategy {
/** Documents to be formatted by this strategy */
- private final LinkedList fDocuments= new LinkedList();
+ private final LinkedList<IDocument> fDocuments= new LinkedList<IDocument>();
/** Partitions to be formatted by this strategy */
- private final LinkedList fPartitions= new LinkedList();
+ private final LinkedList<TypedPosition> fPartitions= new LinkedList<TypedPosition>();
/**
* Creates a new java formatting strategy.
@@ -53,17 +54,18 @@ public class CFormattingStrategy extends ContextBasedFormattingStrategy {
public void format() {
super.format();
- final IDocument document= (IDocument)fDocuments.removeFirst();
- final TypedPosition partition= (TypedPosition)fPartitions.removeFirst();
+ final IDocument document= fDocuments.removeFirst();
+ final TypedPosition partition= fPartitions.removeFirst();
if (document != null && partition != null) {
try {
-
+ @SuppressWarnings("unchecked")
+ final Map<String,String> preferences = getPreferences();
final TextEdit edit = CodeFormatterUtil.format(
CodeFormatter.K_TRANSLATION_UNIT, document.get(),
partition.getOffset(), partition.getLength(), 0,
TextUtilities.getDefaultLineDelimiter(document),
- getPreferences());
+ preferences);
if (edit != null)
edit.apply(document);
@@ -85,8 +87,14 @@ public class CFormattingStrategy extends ContextBasedFormattingStrategy {
public void formatterStarts(final IFormattingContext context) {
super.formatterStarts(context);
- fPartitions.addLast(context.getProperty(FormattingContextProperties.CONTEXT_PARTITION));
- fDocuments.addLast(context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM));
+ Object property = context.getProperty(FormattingContextProperties.CONTEXT_PARTITION);
+ if (property instanceof TypedPosition) {
+ fPartitions.addLast((TypedPosition) property);
+ }
+ property= context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM);
+ if (property instanceof IDocument) {
+ fDocuments.addLast((IDocument) property);
+ }
}
/*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java
index 3309bc2c0ef..c10b9f7676c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpProviderDescriptor.java
@@ -38,7 +38,7 @@ public class CHelpProviderDescriptor {
final private static String ELEMENT_PROVIDER = "provider"; //$NON-NLS-1$
final private static String ATTRIBUTE_ID = "id"; //$NON-NLS-1$
- private static Map fProvidersMap = null;
+ private static Map<String, ICHelpProvider> fProvidersMap = null;
private ICHelpProvider fHelpProvider = null;
private IConfigurationElement fConfigElement;
@@ -79,9 +79,9 @@ public class CHelpProviderDescriptor {
return null;
}
- private static Map getProvidersMap(){
+ private static Map<String, ICHelpProvider> getProvidersMap(){
if(fProvidersMap == null){
- fProvidersMap = new HashMap();
+ fProvidersMap = new HashMap<String, ICHelpProvider>();
}
return fProvidersMap;
}
@@ -91,9 +91,9 @@ public class CHelpProviderDescriptor {
if(id == null || "".equals(id)) //$NON-NLS-1$
return null;
- Map providersMap = getProvidersMap();
+ Map<String, ICHelpProvider> providersMap = getProvidersMap();
try{
- ICHelpProvider provider = (ICHelpProvider)providersMap.get(id);
+ ICHelpProvider provider = providersMap.get(id);
if(provider == null){
provider = (ICHelpProvider)element.createExecutableExtension(CLASS);
providersMap.put(id,provider);
@@ -133,13 +133,13 @@ public class CHelpProviderDescriptor {
if (provider != null && fProject != null) {
ICHelpBook books[] = provider.getCHelpBooks();
if(books != null){
- List descriptorList = new ArrayList();
+ List<CHelpBookDescriptor> descriptorList = new ArrayList<CHelpBookDescriptor>();
for(int i = 0; i < books.length; i++){
CHelpBookDescriptor des = new CHelpBookDescriptor(books[i],projectElement);
if(des.matches(fProject))
descriptorList.add(des);
}
- fHelpBookDescriptors = (CHelpBookDescriptor[])descriptorList.toArray(new CHelpBookDescriptor[descriptorList.size()]);
+ fHelpBookDescriptors = descriptorList.toArray(new CHelpBookDescriptor[descriptorList.size()]);
}
}
if(fHelpBookDescriptors == null)
@@ -156,12 +156,12 @@ public class CHelpProviderDescriptor {
CHelpBookDescriptor bookDescriptors[] = getCHelpBookDescriptors();
if(bookDescriptors.length == 0)
return null;
- List bookList = new ArrayList();
+ List<ICHelpBook> bookList = new ArrayList<ICHelpBook>();
for(int i = 0; i < bookDescriptors.length; i++){
if(bookDescriptors[i].isEnabled() && bookDescriptors[i].matches(context))
bookList.add(bookDescriptors[i].getCHelpBook());
}
- return (ICHelpBook[])bookList.toArray(new ICHelpBook[bookList.size()]);
+ return bookList.toArray(new ICHelpBook[bookList.size()]);
}
public void serialize(Document doc, Element parentElement){
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java
index b109d885de4..cd76d5e341b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHelpSettings.java
@@ -93,13 +93,13 @@ public class CHelpSettings {
if(providerDescriptors.length == 0)
return new CHelpBookDescriptor[0];
- List bookList = new ArrayList();
+ List<CHelpBookDescriptor> bookList = new ArrayList<CHelpBookDescriptor>();
for(int i = 0; i < providerDescriptors.length; i++){
CHelpBookDescriptor bookDescriptors[] = providerDescriptors[i].getCHelpBookDescriptors();
if(bookDescriptors.length != 0)
bookList.addAll(Arrays.asList(bookDescriptors));
}
- return (CHelpBookDescriptor[])bookList.toArray(new CHelpBookDescriptor[bookList.size()]);
+ return bookList.toArray(new CHelpBookDescriptor[bookList.size()]);
}
private static IConfigurationElement[] getConfigElements(){
@@ -129,7 +129,7 @@ public class CHelpSettings {
public IFunctionSummary[] getMatchingFunctions(ICHelpInvocationContext context, String frag){
CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
- List sumaryList = new ArrayList();
+ List<IFunctionSummary> sumaryList = new ArrayList<IFunctionSummary>();
for(int i = 0; i < providerDescriptors.length; i++){
ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
if(books != null && books.length != 0){
@@ -144,12 +144,12 @@ public class CHelpSettings {
if(sumaryList.size() == 0)
return null;
- return (IFunctionSummary[])sumaryList.toArray(new IFunctionSummary[sumaryList.size()]);
+ return sumaryList.toArray(new IFunctionSummary[sumaryList.size()]);
}
public ICHelpResourceDescriptor[] getHelpResources(ICHelpInvocationContext context, String name){
CHelpProviderDescriptor providerDescriptors[] = getCHelpProviderDescriptors();
- List resourcesList = new ArrayList();
+ List<ICHelpResourceDescriptor> resourcesList = new ArrayList<ICHelpResourceDescriptor>();
for(int i = 0; i < providerDescriptors.length; i++){
ICHelpBook books[] = providerDescriptors[i].getEnabledMatchedCHelpBooks(context);
if(books != null && books.length != 0){
@@ -164,7 +164,7 @@ public class CHelpSettings {
if(resourcesList.size() == 0)
return null;
- return (ICHelpResourceDescriptor[])resourcesList.toArray(new ICHelpResourceDescriptor[resourcesList.size()]);
+ return resourcesList.toArray(new ICHelpResourceDescriptor[resourcesList.size()]);
}
public void serialize(Document doc, Element parentElement){
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java
index a9f5fdd3d18..2d632d723ea 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CHeuristicScanner.java
@@ -409,10 +409,9 @@ public final class CHeuristicScanner implements Symbols {
return getToken(identOrKeyword);
- } else {
- // operators, number literals etc
- return TokenOTHER;
}
+ // operators, number literals etc
+ return TokenOTHER;
}
/**
@@ -511,10 +510,9 @@ public final class CHeuristicScanner implements Symbols {
return getToken(identOrKeyword);
- } else {
- // operators, number literals etc
- return TokenOTHER;
}
+ // operators, number literals etc
+ return TokenOTHER;
}
@@ -1084,6 +1082,7 @@ public final class CHeuristicScanner implements Symbols {
* <code>bound</code> &lt; <code>start</code>, or <code>UNBOUND</code>
* @return <code>true</code> if the current position looks like a composite type definition
*/
+ @SuppressWarnings("fallthrough")
public boolean looksLikeCompositeTypeDefinitionBackward(int start, int bound) {
int token= previousToken(start - 1, bound);
switch (token) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java
index 283f59896c6..1125c11b783 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CParameterListValidator.java
@@ -217,7 +217,7 @@ public class CParameterListValidator implements IContextInformationValidator, IC
private int[] computeCommaPositions(String code) {
final int length= code.length();
int pos= 0;
- List positions= new ArrayList();
+ List<Integer> positions= new ArrayList<Integer>();
positions.add(new Integer(-1));
while (pos < length && pos != -1) {
char ch= code.charAt(pos);
@@ -244,7 +244,7 @@ public class CParameterListValidator implements IContextInformationValidator, IC
int[] fields= new int[positions.size()];
for (int i= 0; i < fields.length; i++)
- fields[i]= ((Integer) positions.get(i)).intValue();
+ fields[i]= positions.get(i).intValue();
return fields;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
index 5a019090b86..ea2ac434ef7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CSourceViewerConfiguration.java
@@ -21,6 +21,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.content.IContentType;
@@ -642,10 +643,10 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
int stateMasks[]= new int[hoverDescs.length];
int stateMasksLength= 0;
- for (int i= 0; i < hoverDescs.length; i++) {
- if (hoverDescs[i].isEnabled()) {
+ for (CEditorTextHoverDescriptor hoverDesc : hoverDescs) {
+ if (hoverDesc.isEnabled()) {
int j= 0;
- int stateMask= hoverDescs[i].getStateMask();
+ int stateMask= hoverDesc.getStateMask();
while (j < stateMasksLength) {
if (stateMasks[j] == stateMask)
break;
@@ -784,8 +785,8 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
// Register information provider
IInformationProvider provider= new CInformationProvider(getEditor());
String[] contentTypes= getConfiguredContentTypes(sourceViewer);
- for (int i= 0; i < contentTypes.length; i++)
- presenter.setInformationProvider(provider, contentTypes[i]);
+ for (String contentType : contentTypes)
+ presenter.setInformationProvider(provider, contentType);
presenter.setSizeConstraints(60, 10, true, true);
return presenter;
@@ -975,8 +976,9 @@ public class CSourceViewerConfiguration extends TextSourceViewerConfiguration {
* @see org.eclipse.jface.text.source.SourceViewerConfiguration#getHyperlinkDetectorTargets(org.eclipse.jface.text.source.ISourceViewer)
*/
@Override
- protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
- Map targets= super.getHyperlinkDetectorTargets(sourceViewer);
+ protected Map<String, IAdaptable> getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
+ @SuppressWarnings("unchecked")
+ Map<String, IAdaptable> targets= super.getHyperlinkDetectorTargets(sourceViewer);
targets.put("org.eclipse.cdt.ui.cCode", fTextEditor); //$NON-NLS-1$
return targets;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.java
index aeb50bf5c1d..c0fa0532ea3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CStringAutoIndentStrategy.java
@@ -13,14 +13,12 @@
package org.eclipse.cdt.internal.ui.text;
import org.eclipse.jface.preference.IPreferenceStore;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
import org.eclipse.jface.text.DocumentCommand;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.TextUtilities;
-
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.part.MultiPageEditorPart;
@@ -60,11 +58,10 @@ public class CStringAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy
buffer.append(indentation);
buffer.append("\""); //$NON-NLS-1$
continue;
- } else {
- buffer.append("\"" + delimiter); //$NON-NLS-1$
- buffer.append(indentation);
- buffer.append("\""); //$NON-NLS-1$
}
+ buffer.append("\"" + delimiter); //$NON-NLS-1$
+ buffer.append(indentation);
+ buffer.append("\""); //$NON-NLS-1$
} else {
continue;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java
index a0dace624e2..8f4033d0bdd 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/CWordFinder.java
@@ -278,8 +278,9 @@ public class CWordFinder {
* @return true if curled brace found.
*/
public static boolean hasCBraces (String s) {
- if (s.indexOf(CBRACE_L) > -1 || s.indexOf(CBRACE_R) > -1) return true;
- else return false;
+ if (s.indexOf(CBRACE_L) > -1 || s.indexOf(CBRACE_R) > -1)
+ return true;
+ return false;
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java
index 1208eaf5763..395dd6fe9b0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/DocumentCharacterIterator.java
@@ -97,8 +97,7 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
public char last() {
if (fFirst == fLast)
return setIndex(getEndIndex());
- else
- return setIndex(getEndIndex() - 1);
+ return setIndex(getEndIndex() - 1);
}
/*
@@ -127,9 +126,8 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
public char previous() {
if (fIndex > getBeginIndex()) {
return setIndex(fIndex - 1);
- } else {
- return DONE;
}
+ return DONE;
}
/*
@@ -204,8 +202,7 @@ public class DocumentCharacterIterator implements CharacterIterator, CharSequenc
// ignore and return DONE
return DONE;
}
- else
- throw new IndexOutOfBoundsException();
+ throw new IndexOutOfBoundsException();
}
/*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTML2TextReader.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTML2TextReader.java
index 644df51c336..0f918c98d6c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTML2TextReader.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTML2TextReader.java
@@ -31,12 +31,12 @@ import org.eclipse.swt.custom.StyleRange;
* the tags or cut them out.
*/
public class HTML2TextReader extends SubstitutionTextReader {
- private static final Map fgEntityLookup;
- private static final Set fgTags;
+ private static final Map<String, String> fgEntityLookup;
+ private static final Set<String> fgTags;
static {
- fgTags= new HashSet();
+ fgTags= new HashSet<String>();
fgTags.add("b"); //$NON-NLS-1$
fgTags.add("br"); //$NON-NLS-1$
fgTags.add("h5"); //$NON-NLS-1$
@@ -47,7 +47,7 @@ public class HTML2TextReader extends SubstitutionTextReader {
fgTags.add("li"); //$NON-NLS-1$
fgTags.add("ul"); //$NON-NLS-1$
- fgEntityLookup= new HashMap(7);
+ fgEntityLookup= new HashMap<String, String>(7);
fgEntityLookup.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$
fgEntityLookup.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$
fgEntityLookup.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$
@@ -230,7 +230,7 @@ public class HTML2TextReader extends SubstitutionTextReader {
} catch (NumberFormatException e) {
}
} else {
- String str= (String) fgEntityLookup.get(symbol);
+ String str= fgEntityLookup.get(symbol);
if (str != null) {
return str;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLAnnotationHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLAnnotationHover.java
index b3d30e7e888..59521dd800b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLAnnotationHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLAnnotationHover.java
@@ -40,6 +40,7 @@ public class HTMLAnnotationHover extends DefaultAnnotationHover {
/*
* Formats several message as HTML text.
*/
+ @SuppressWarnings("unchecked")
@Override
protected String formatMultipleMessages(List messages) {
StringBuffer buffer= new StringBuffer();
@@ -47,9 +48,9 @@ public class HTMLAnnotationHover extends DefaultAnnotationHover {
HTMLPrinter.addParagraph(buffer, HTMLPrinter.convertToHTMLContent(CUIMessages.getString("CAnnotationHover.multipleMarkers"))); //$NON-NLS-1$
HTMLPrinter.startBulletList(buffer);
- Iterator e= messages.iterator();
+ Iterator<String> e= messages.iterator();
while (e.hasNext())
- HTMLPrinter.addBullet(buffer, HTMLPrinter.convertToHTMLContent((String) e.next()));
+ HTMLPrinter.addBullet(buffer, HTMLPrinter.convertToHTMLContent(e.next()));
HTMLPrinter.endBulletList(buffer);
HTMLPrinter.addPageEpilog(buffer);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLTextPresenter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLTextPresenter.java
index be0164c4af5..7f1e33b7752 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLTextPresenter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/HTMLTextPresenter.java
@@ -14,16 +14,16 @@ package org.eclipse.cdt.internal.ui.text;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
-
import java.util.Iterator;
+
+import org.eclipse.jface.text.DefaultInformationControl;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.TextPresentation;
import org.eclipse.swt.custom.StyleRange;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Display;
import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextPresentation;
public class HTMLTextPresenter implements DefaultInformationControl.IInformationPresenter {
@@ -52,10 +52,11 @@ public class HTMLTextPresenter implements DefaultInformationControl.IInformation
int yoursEnd= offset + insertLength -1;
yoursEnd= Math.max(yoursStart, yoursEnd);
- Iterator e= presentation.getAllStyleRangeIterator();
+ @SuppressWarnings("unchecked")
+ Iterator<StyleRange> e= presentation.getAllStyleRangeIterator();
while (e.hasNext()) {
- StyleRange range= (StyleRange) e.next();
+ StyleRange range= e.next();
int myStart= range.start;
int myEnd= range.start + range.length -1;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SequenceCharacterIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SequenceCharacterIterator.java
index f395e8a16b1..204abbcf416 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SequenceCharacterIterator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SequenceCharacterIterator.java
@@ -87,8 +87,7 @@ public class SequenceCharacterIterator implements CharacterIterator {
public char last() {
if (fFirst == fLast)
return setIndex(getEndIndex());
- else
- return setIndex(getEndIndex() - 1);
+ return setIndex(getEndIndex() - 1);
}
/*
@@ -97,8 +96,7 @@ public class SequenceCharacterIterator implements CharacterIterator {
public char current() {
if (fIndex >= fFirst && fIndex < fLast)
return fSequence.charAt(fIndex);
- else
- return DONE;
+ return DONE;
}
/*
@@ -114,9 +112,8 @@ public class SequenceCharacterIterator implements CharacterIterator {
public char previous() {
if (fIndex > getBeginIndex()) {
return setIndex(fIndex - 1);
- } else {
- return DONE;
}
+ return DONE;
}
/*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java
index 4a9e78214f2..7cd309d0568 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/SimpleCSourceViewerConfiguration.java
@@ -13,7 +13,6 @@
package org.eclipse.cdt.internal.ui.text;
import org.eclipse.jface.preference.IPreferenceStore;
-
import org.eclipse.jface.text.IAutoEditStrategy;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.ITextHover;
@@ -22,7 +21,6 @@ import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.text.information.IInformationPresenter;
import org.eclipse.jface.text.source.IAnnotationHover;
import org.eclipse.jface.text.source.ISourceViewer;
-
import org.eclipse.ui.texteditor.ITextEditor;
@@ -108,8 +106,7 @@ public class SimpleCSourceViewerConfiguration extends CSourceViewerConfiguration
public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
if (fConfigureFormatter)
return super.getContentFormatter(sourceViewer);
- else
- return null;
+ return null;
}
/*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover.java
index 7ac5daf6cc2..5e0aec27ebb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/AbstractAnnotationHover.java
@@ -13,10 +13,6 @@ package org.eclipse.cdt.internal.ui.text.c.hover;
import java.util.Iterator;
-import org.eclipse.cdt.internal.ui.editor.CAnnotationIterator;
-import org.eclipse.cdt.internal.ui.editor.CEditor;
-import org.eclipse.cdt.internal.ui.text.HTMLPrinter;
-import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
@@ -29,6 +25,12 @@ import org.eclipse.ui.texteditor.AnnotationPreference;
import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.cdt.ui.CUIPlugin;
+
+import org.eclipse.cdt.internal.ui.editor.CAnnotationIterator;
+import org.eclipse.cdt.internal.ui.editor.CEditor;
+import org.eclipse.cdt.internal.ui.text.HTMLPrinter;
+
/**
* AbstractAnnotationHover
* Abstract super class for annotation hovers.
@@ -68,11 +70,11 @@ public class AbstractAnnotationHover extends AbstractCEditorTextHover {
IAnnotationModel model= provider.getAnnotationModel(getEditor().getEditorInput());
if (model != null) {
- Iterator e= new CAnnotationIterator(model, true, fAllAnnotations);
+ Iterator<Annotation> e= new CAnnotationIterator(model, true, fAllAnnotations);
int layer= -1;
String message= null;
while (e.hasNext()) {
- Annotation a= (Annotation) e.next();
+ Annotation a= e.next();
AnnotationPreference preference= getAnnotationPreference(a);
if (preference == null || !(preference.getTextPreferenceKey() != null && fStore.getBoolean(preference.getTextPreferenceKey()) || (preference.getHighlightPreferenceKey() != null && fStore.getBoolean(preference.getHighlightPreferenceKey()))))
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java
index f713d927440..f6e7e88bfda 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/BestMatchHover.java
@@ -33,8 +33,8 @@ import org.eclipse.ui.IEditorPart;
*/
public class BestMatchHover extends AbstractCEditorTextHover {
- private List fTextHoverSpecifications;
- private List fInstantiatedTextHovers;
+ private List<CEditorTextHoverDescriptor> fTextHoverSpecifications;
+ private List<ITextHover> fInstantiatedTextHovers;
private ITextHover fBestHover;
public BestMatchHover() {
@@ -52,8 +52,8 @@ public class BestMatchHover extends AbstractCEditorTextHover {
private void installTextHovers() {
// initialize lists - indicates that the initialization happened
- fTextHoverSpecifications= new ArrayList(2);
- fInstantiatedTextHovers= new ArrayList(2);
+ fTextHoverSpecifications= new ArrayList<CEditorTextHoverDescriptor>(2);
+ fInstantiatedTextHovers= new ArrayList<ITextHover>(2);
// populate list
CEditorTextHoverDescriptor[] hoverDescs= CUIPlugin.getDefault().getCEditorTextHoverDescriptors();
@@ -68,8 +68,8 @@ public class BestMatchHover extends AbstractCEditorTextHover {
if (fTextHoverSpecifications.size() == 0)
return;
- for (Iterator iterator= new ArrayList(fTextHoverSpecifications).iterator(); iterator.hasNext(); ) {
- CEditorTextHoverDescriptor spec= (CEditorTextHoverDescriptor) iterator.next();
+ for (Iterator<CEditorTextHoverDescriptor> iterator= new ArrayList<CEditorTextHoverDescriptor>(fTextHoverSpecifications).iterator(); iterator.hasNext(); ) {
+ CEditorTextHoverDescriptor spec= iterator.next();
ICEditorTextHover hover= spec.createTextHover();
if (hover != null) {
@@ -97,8 +97,8 @@ public class BestMatchHover extends AbstractCEditorTextHover {
if (fInstantiatedTextHovers == null)
return null;
- for (Iterator iterator= fInstantiatedTextHovers.iterator(); iterator.hasNext(); ) {
- ITextHover hover= (ITextHover)iterator.next();
+ for (Iterator<ITextHover> iterator= fInstantiatedTextHovers.iterator(); iterator.hasNext(); ) {
+ ITextHover hover= iterator.next();
String s= hover.getHoverInfo(textViewer, hoverRegion);
if (s != null && s.trim().length() > 0) {
@@ -122,8 +122,8 @@ public class BestMatchHover extends AbstractCEditorTextHover {
if (fInstantiatedTextHovers == null)
return null;
- for (Iterator iterator= fInstantiatedTextHovers.iterator(); iterator.hasNext(); ) {
- ITextHover hover= (ITextHover)iterator.next();
+ for (Iterator<ITextHover> iterator= fInstantiatedTextHovers.iterator(); iterator.hasNext(); ) {
+ ITextHover hover= iterator.next();
if (hover instanceof ITextHoverExtension2) {
Object info= ((ITextHoverExtension2) hover).getHoverInfo2(textViewer, hoverRegion);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java
index c95d3a49b88..8293978eb00 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CDocHover.java
@@ -119,14 +119,16 @@ public class CDocHover extends AbstractCEditorTextHover {
*/
@Override
public IRegion getHoverRegion(ITextViewer viewer, int offset) {
- Point selectedRange = viewer.getSelectedRange();
- if (selectedRange.x >= 0 &&
- selectedRange.y > 0 &&
- offset >= selectedRange.x &&
- offset <= selectedRange.x + selectedRange.y)
- return new Region( selectedRange.x, selectedRange.y );
- if (viewer != null)
+ if (viewer != null) {
+ Point selectedRange = viewer.getSelectedRange();
+ if (selectedRange.x >= 0 &&
+ selectedRange.y > 0 &&
+ offset >= selectedRange.x &&
+ offset <= selectedRange.x + selectedRange.y)
+ return new Region( selectedRange.x, selectedRange.y );
+
return CWordFinder.findWord(viewer.getDocument(), offset);
+ }
return null;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverDescriptor.java
index 0dae58e800e..66725ca8ad2 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CEditorTextHoverDescriptor.java
@@ -18,24 +18,26 @@ import java.util.HashMap;
import java.util.List;
import java.util.StringTokenizer;
-import org.eclipse.cdt.internal.ui.util.EditorUtility;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.PreferenceConstants;
-import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.SWT;
import org.osgi.framework.Bundle;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.PreferenceConstants;
+import org.eclipse.cdt.ui.text.c.hover.ICEditorTextHover;
+
+import org.eclipse.cdt.internal.ui.util.EditorUtility;
+
/**
* CEditorTexHoverDescriptor
*/
-public class CEditorTextHoverDescriptor implements Comparable {
+public class CEditorTextHoverDescriptor implements Comparable<CEditorTextHoverDescriptor> {
private static final String C_EDITOR_TEXT_HOVER_EXTENSION_POINT= "org.eclipse.cdt.ui.textHovers"; //$NON-NLS-1$
private static final String HOVER_TAG= "hover"; //$NON-NLS-1$
@@ -182,28 +184,27 @@ public class CEditorTextHoverDescriptor implements Comparable {
/**
* {@inheritDoc}
*/
- public int compareTo(Object o) {
- return Collator.getInstance().compare(getLabel(), ((CEditorTextHoverDescriptor)o).getLabel());
+ public int compareTo(CEditorTextHoverDescriptor o) {
+ return Collator.getInstance().compare(getLabel(), o.getLabel());
}
private static CEditorTextHoverDescriptor[] createDescriptors(IConfigurationElement[] elements) {
- List result= new ArrayList(elements.length);
- for (int i= 0; i < elements.length; i++) {
- IConfigurationElement element= elements[i];
+ List<CEditorTextHoverDescriptor> result= new ArrayList<CEditorTextHoverDescriptor>(elements.length);
+ for (IConfigurationElement element : elements) {
if (HOVER_TAG.equals(element.getName())) {
CEditorTextHoverDescriptor desc= new CEditorTextHoverDescriptor(element);
result.add(desc);
}
}
Collections.sort(result);
- return (CEditorTextHoverDescriptor[])result.toArray(new CEditorTextHoverDescriptor[result.size()]);
+ return result.toArray(new CEditorTextHoverDescriptor[result.size()]);
}
private static void initializeFromPreferences(CEditorTextHoverDescriptor[] hovers) {
String compiledTextHoverModifiers= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);
StringTokenizer tokenizer= new StringTokenizer(compiledTextHoverModifiers, VALUE_SEPARATOR);
- HashMap idToModifier= new HashMap(tokenizer.countTokens() / 2);
+ HashMap<String, String> idToModifier= new HashMap<String, String>(tokenizer.countTokens() / 2);
while (tokenizer.hasMoreTokens()) {
String id= tokenizer.nextToken();
@@ -214,7 +215,7 @@ public class CEditorTextHoverDescriptor implements Comparable {
String compiledTextHoverModifierMasks= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);
tokenizer= new StringTokenizer(compiledTextHoverModifierMasks, VALUE_SEPARATOR);
- HashMap idToModifierMask= new HashMap(tokenizer.countTokens() / 2);
+ HashMap<String, String> idToModifierMask= new HashMap<String, String>(tokenizer.countTokens() / 2);
while (tokenizer.hasMoreTokens()) {
String id= tokenizer.nextToken();
@@ -223,7 +224,7 @@ public class CEditorTextHoverDescriptor implements Comparable {
}
for (int i= 0; i < hovers.length; i++) {
- String modifierString= (String)idToModifier.get(hovers[i].getId());
+ String modifierString= idToModifier.get(hovers[i].getId());
boolean enabled= true;
if (modifierString == null)
modifierString= DISABLED_TAG;
@@ -242,7 +243,7 @@ public class CEditorTextHoverDescriptor implements Comparable {
if (hovers[i].fStateMask == -1) {
// Fallback: use stored modifier masks
try {
- hovers[i].fStateMask= Integer.parseInt((String)idToModifierMask.get(hovers[i].getId()));
+ hovers[i].fStateMask= Integer.parseInt(idToModifierMask.get(hovers[i].getId()));
} catch (NumberFormatException ex) {
hovers[i].fStateMask= -1;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java
index 3126f445618..cc8e31cfbc3 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CSourceHover.java
@@ -188,9 +188,9 @@ public class CSourceHover extends AbstractCEditorTextHover {
IASTPreprocessorMacroDefinition[] macroDefs;
final IASTPreprocessorMacroDefinition[] localMacroDefs= ast.getMacroDefinitions();
for (macroDefs= localMacroDefs; macroDefs != null; macroDefs= (macroDefs == localMacroDefs) ? ast.getBuiltinMacroDefinitions() : null) {
- for (int i = 0; i < macroDefs.length; i++) {
- if (Arrays.equals(macroDefs[i].getName().toCharArray(), macroName)) {
- macroDef= macroDefs[i];
+ for (IASTPreprocessorMacroDefinition macroDef2 : macroDefs) {
+ if (Arrays.equals(macroDef2.getName().toCharArray(), macroName)) {
+ macroDef= macroDef2;
break;
}
}
@@ -244,8 +244,8 @@ public class CSourceHover extends AbstractCEditorTextHover {
names= findDeclarations(ast, binding);
}
if (names.length > 0) {
- for (int i = 0; i < names.length; i++) {
- String source= computeSourceForName(names[0], binding);
+ for (IName name : names) {
+ String source= computeSourceForName(name, binding);
if (source != null) {
return source;
}
@@ -417,9 +417,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
type= ((ITypedef)binding).getType();
} else if (binding instanceof IVariable) {
type= ((IVariable)binding).getType();
- } else {
- type= null;
- }
+ }
} catch (DOMException exc) {
}
expectClosingBrace= type instanceof ICompositeType || type instanceof IEnumeration;
@@ -786,8 +784,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
i= 0;
} finally {
try {
- if (reader != null)
- reader.close();
+ reader.close();
} catch (IOException ex) {
CUIPlugin.log(ex);
}
@@ -831,7 +828,7 @@ public class CSourceHover extends AbstractCEditorTextHover {
* name is not considered a keyword
*/
private boolean selectionIsKeyword(String name) {
- Set keywords= ParserFactory.getKeywordSet(KeywordSetKey.KEYWORDS, ParserLanguage.CPP);
+ Set<String> keywords= ParserFactory.getKeywordSet(KeywordSetKey.KEYWORDS, ParserLanguage.CPP);
return keywords.contains(name);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java
index 7dc16f6c915..d32de99487e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CCompletionProposal.java
@@ -12,12 +12,9 @@
package org.eclipse.cdt.internal.ui.text.contentassist;
-import org.eclipse.cdt.internal.ui.text.CTextTools;
-import org.eclipse.cdt.ui.CUIPlugin;
-import org.eclipse.cdt.ui.text.ICCompletionProposal;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.BadPositionCategoryException;
import org.eclipse.jface.text.DefaultPositionUpdater;
@@ -52,6 +49,11 @@ import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
+import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
+
+import org.eclipse.cdt.internal.ui.text.CTextTools;
+
public class CCompletionProposal implements ICCompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2, ICompletionProposalExtension3 {
private String fDisplayString;
@@ -510,7 +512,10 @@ public class CCompletionProposal implements ICCompletionProposal, ICompletionPro
* <code>false</code> otherwise.
*/
protected boolean startsWith(IDocument document, int offset, String word) {
- int wordLength= word == null ? 0 : word.length();
+ if (word == null)
+ return false;
+
+ final int wordLength= word.length();
if (offset >= fReplacementOffset + wordLength)
return false;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java
index e346031556e..1cc1f0a3c11 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/CContentAssistProcessor.java
@@ -15,7 +15,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.CoreException;
@@ -148,14 +147,14 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
* @see org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistProcessor#filterAndSort(java.util.List, org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
- protected List filterAndSortProposals(List proposals, IProgressMonitor monitor, ContentAssistInvocationContext context) {
+ protected List<ICompletionProposal> filterAndSortProposals(List<ICompletionProposal> proposals, IProgressMonitor monitor, ContentAssistInvocationContext context) {
IProposalFilter filter = getCompletionFilter();
ICCompletionProposal[] proposalsInput= new ICCompletionProposal[proposals.size()];
// wrap proposals which are no ICCompletionProposals
boolean wrapped= false;
int i=0;
- for (Iterator iterator = proposals.iterator(); iterator.hasNext(); ) {
- ICompletionProposal proposal= (ICompletionProposal) iterator.next();
+ for (Object element : proposals) {
+ ICompletionProposal proposal= (ICompletionProposal) element;
if (proposal instanceof ICCompletionProposal) {
proposalsInput[i++]= (ICCompletionProposal)proposal;
} else {
@@ -177,12 +176,11 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
propsComp.setOrderAlphabetically(sortByAlphabet);
Arrays.sort(proposalsFiltered, propsComp);
}
- List filteredList;
+ List<ICompletionProposal> filteredList;
if (wrapped) {
// unwrap again
- filteredList= new ArrayList(proposalsFiltered.length);
- for (int j= 0; j < proposalsFiltered.length; j++) {
- ICCompletionProposal proposal= proposalsFiltered[j];
+ filteredList= new ArrayList<ICompletionProposal>(proposalsFiltered.length);
+ for (ICCompletionProposal proposal : proposalsFiltered) {
if (proposal instanceof CCompletionProposalWrapper) {
filteredList.add(((CCompletionProposalWrapper)proposal).unwrap());
} else {
@@ -190,7 +188,8 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
}
}
} else {
- filteredList= Arrays.asList(proposalsFiltered);
+ final ICompletionProposal[] tmp= proposalsFiltered;
+ filteredList= Arrays.asList(tmp);
}
return filteredList;
}
@@ -222,7 +221,7 @@ public class CContentAssistProcessor extends ContentAssistProcessor {
}
@Override
- protected List filterAndSortContextInformation(List contexts,
+ protected List<IContextInformation> filterAndSortContextInformation(List<IContextInformation> contexts,
IProgressMonitor monitor) {
return contexts;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistComputerParameter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistComputerParameter.java
index 5a016ab9c22..4df267c1f0a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistComputerParameter.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistComputerParameter.java
@@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
import java.util.Collection;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
import org.eclipse.core.commands.IParameterValues;
@@ -27,11 +26,10 @@ public final class ContentAssistComputerParameter implements IParameterValues {
/*
* @see org.eclipse.core.commands.IParameterValues#getParameterValues()
*/
- public Map getParameterValues() {
- Collection descriptors= CompletionProposalComputerRegistry.getDefault().getProposalCategories();
- Map map= new HashMap(descriptors.size());
- for (Iterator it= descriptors.iterator(); it.hasNext();) {
- CompletionProposalCategory category= (CompletionProposalCategory) it.next();
+ public Map<String,String> getParameterValues() {
+ Collection<CompletionProposalCategory> descriptors= CompletionProposalComputerRegistry.getDefault().getProposalCategories();
+ Map<String, String> map= new HashMap<String, String>(descriptors.size());
+ for (CompletionProposalCategory category : descriptors) {
map.put(category.getDisplayName(), category.getId());
}
return map;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java
index 409bbb4df7d..1f497309c34 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ContentAssistProcessor.java
@@ -16,7 +16,6 @@ package org.eclipse.cdt.internal.ui.text.contentassist;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.Assert;
@@ -91,12 +90,9 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
*/
private static final String PREF_WARN_ABOUT_EMPTY_ASSIST_CATEGORY= "EmptyDefaultAssistCategory"; //$NON-NLS-1$
- private static final Comparator ORDER_COMPARATOR= new Comparator() {
+ private static final Comparator<CompletionProposalCategory> ORDER_COMPARATOR= new Comparator<CompletionProposalCategory>() {
- public int compare(Object o1, Object o2) {
- CompletionProposalCategory d1= (CompletionProposalCategory) o1;
- CompletionProposalCategory d2= (CompletionProposalCategory) o2;
-
+ public int compare(CompletionProposalCategory d1, CompletionProposalCategory d2) {
return d1.getSortOrder() - d2.getSortOrder();
}
@@ -104,7 +100,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
private static final ICompletionProposal[] NO_PROPOSALS= {};
- private final List fCategories;
+ private final List<CompletionProposalCategory> fCategories;
private final String fPartition;
private final ContentAssistant fAssistant;
@@ -112,7 +108,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
/* cycling stuff */
private int fRepetition= -1;
- private List/*<List<CompletionProposalCategory>>*/ fCategoryIteration= null;
+ private List<List<CompletionProposalCategory>> fCategoryIteration= null;
private String fIterationGesture= null;
private int fNumberOfComputedResults= 0;
private String fErrorMessage;
@@ -139,8 +135,8 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
// this may show the warning dialog if all categories are disabled
fCategoryIteration= getCategoryIteration();
- for (Iterator it= fCategories.iterator(); it.hasNext();) {
- CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
+ for (Object element : fCategories) {
+ CompletionProposalCategory cat= (CompletionProposalCategory) element;
cat.sessionStarted();
}
@@ -172,8 +168,8 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
if (event.processor != ContentAssistProcessor.this)
return;
- for (Iterator it= fCategories.iterator(); it.hasNext();) {
- CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
+ for (Object element : fCategories) {
+ CompletionProposalCategory cat= (CompletionProposalCategory) element;
cat.sessionEnded();
}
@@ -221,15 +217,15 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
long setup= DEBUG ? System.currentTimeMillis() : 0;
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_collecting_proposals);
- List proposals= collectProposals(viewer, offset, monitor, context);
+ List<ICompletionProposal> proposals= collectProposals(viewer, offset, monitor, context);
long collect= DEBUG ? System.currentTimeMillis() : 0;
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_sorting_proposals);
- List filtered= filterAndSortProposals(proposals, monitor, context);
+ List<ICompletionProposal> filtered= filterAndSortProposals(proposals, monitor, context);
fNumberOfComputedResults= filtered.size();
long filter= DEBUG ? System.currentTimeMillis() : 0;
- ICompletionProposal[] result= (ICompletionProposal[]) filtered.toArray(new ICompletionProposal[filtered.size()]);
+ ICompletionProposal[] result= filtered.toArray(new ICompletionProposal[filtered.size()]);
monitor.done();
if (DEBUG) {
@@ -264,12 +260,11 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
fNumberOfComputedResults= 0;
}
- private List collectProposals(ITextViewer viewer, int offset, IProgressMonitor monitor, ContentAssistInvocationContext context) {
- List proposals= new ArrayList();
- List providers= getCategories();
- for (Iterator it= providers.iterator(); it.hasNext();) {
- CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
- List computed= cat.computeCompletionProposals(context, fPartition, new SubProgressMonitor(monitor, 1));
+ private List<ICompletionProposal> collectProposals(ITextViewer viewer, int offset, IProgressMonitor monitor, ContentAssistInvocationContext context) {
+ List<ICompletionProposal> proposals= new ArrayList<ICompletionProposal>();
+ List<CompletionProposalCategory> providers= getCategories();
+ for (CompletionProposalCategory cat : providers) {
+ List<ICompletionProposal> computed= cat.computeCompletionProposals(context, fPartition, new SubProgressMonitor(monitor, 1));
proposals.addAll(computed);
if (fErrorMessage == null)
fErrorMessage= cat.getErrorMessage();
@@ -289,7 +284,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
* @return the list of filtered and sorted proposals, ready for
* display (element type: {@link ICompletionProposal})
*/
- protected List filterAndSortProposals(List proposals, IProgressMonitor monitor, ContentAssistInvocationContext context) {
+ protected List<ICompletionProposal> filterAndSortProposals(List<ICompletionProposal> proposals, IProgressMonitor monitor, ContentAssistInvocationContext context) {
return proposals;
}
@@ -303,26 +298,25 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
monitor.beginTask(ContentAssistMessages.ContentAssistProcessor_computing_contexts, fCategories.size() + 1);
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_collecting_contexts);
- List proposals= collectContextInformation(viewer, offset, monitor);
-
+ List<IContextInformation> proposals= collectContextInformation(viewer, offset, monitor);
+
monitor.subTask(ContentAssistMessages.ContentAssistProcessor_sorting_contexts);
- List filtered= filterAndSortContextInformation(proposals, monitor);
+ List<IContextInformation> filtered= filterAndSortContextInformation(proposals, monitor);
fNumberOfComputedResults= filtered.size();
- IContextInformation[] result= (IContextInformation[]) filtered.toArray(new IContextInformation[filtered.size()]);
+ IContextInformation[] result= filtered.toArray(new IContextInformation[filtered.size()]);
monitor.done();
return result;
}
- private List collectContextInformation(ITextViewer viewer, int offset, IProgressMonitor monitor) {
- List proposals= new ArrayList();
+ private List<IContextInformation> collectContextInformation(ITextViewer viewer, int offset, IProgressMonitor monitor) {
+ List<IContextInformation> proposals= new ArrayList<IContextInformation>();
ContentAssistInvocationContext context= createContext(viewer, offset, false);
try {
- List providers= getCategories();
- for (Iterator it= providers.iterator(); it.hasNext();) {
- CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
- List computed= cat.computeContextInformation(context, fPartition, new SubProgressMonitor(monitor, 1));
+ List<CompletionProposalCategory> providers= getCategories();
+ for (CompletionProposalCategory cat : providers) {
+ List<IContextInformation> computed= cat.computeContextInformation(context, fPartition, new SubProgressMonitor(monitor, 1));
proposals.addAll(computed);
if (fErrorMessage == null)
fErrorMessage= cat.getErrorMessage();
@@ -345,7 +339,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
* @return the list of filtered and sorted proposals, ready for
* display (element type: {@link IContextInformation})
*/
- protected List filterAndSortContextInformation(List contexts, IProgressMonitor monitor) {
+ protected List<IContextInformation> filterAndSortContextInformation(List<IContextInformation> contexts, IProgressMonitor monitor) {
return contexts;
}
@@ -426,7 +420,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
return fIsAutoActivated;
}
- private List getCategories() {
+ private List<CompletionProposalCategory> getCategories() {
if (fCategoryIteration == null)
return fCategories;
@@ -437,22 +431,21 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
// fAssistant.setShowMessage(fRepetition % 2 != 0);
//
- return (List) fCategoryIteration.get(iteration);
+ return fCategoryIteration.get(iteration);
}
- private List getCategoryIteration() {
- List sequence= new ArrayList();
+ private List<List<CompletionProposalCategory>> getCategoryIteration() {
+ List<List<CompletionProposalCategory>> sequence= new ArrayList<List<CompletionProposalCategory>>();
sequence.add(getDefaultCategories());
- for (Iterator it= getSeparateCategories().iterator(); it.hasNext();) {
- CompletionProposalCategory cat= (CompletionProposalCategory) it.next();
+ for (CompletionProposalCategory cat : getSeparateCategories()) {
sequence.add(Collections.singletonList(cat));
}
return sequence;
}
- private List getDefaultCategories() {
+ private List<CompletionProposalCategory> getDefaultCategories() {
// default mix - enable all included computers
- List included= getDefaultCategoriesUnchecked();
+ List<CompletionProposalCategory> included= getDefaultCategoriesUnchecked();
if (IDocument.DEFAULT_CONTENT_TYPE.equals(fPartition) && included.isEmpty() && !fCategories.isEmpty())
if (informUserAboutEmptyDefaultCategory())
@@ -462,10 +455,10 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
return included;
}
- private List getDefaultCategoriesUnchecked() {
- List included= new ArrayList();
- for (Iterator it= fCategories.iterator(); it.hasNext();) {
- CompletionProposalCategory category= (CompletionProposalCategory) it.next();
+ private List<CompletionProposalCategory> getDefaultCategoriesUnchecked() {
+ List<CompletionProposalCategory> included= new ArrayList<CompletionProposalCategory>();
+ for (Object element : fCategories) {
+ CompletionProposalCategory category= (CompletionProposalCategory) element;
if (category.isIncluded() && category.hasComputers(fPartition))
included.add(category);
}
@@ -554,10 +547,10 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
return false;
}
- private List getSeparateCategories() {
- ArrayList sorted= new ArrayList();
- for (Iterator it= fCategories.iterator(); it.hasNext();) {
- CompletionProposalCategory category= (CompletionProposalCategory) it.next();
+ private List<CompletionProposalCategory> getSeparateCategories() {
+ ArrayList<CompletionProposalCategory> sorted= new ArrayList<CompletionProposalCategory>();
+ for (Object element : fCategories) {
+ CompletionProposalCategory category= (CompletionProposalCategory) element;
if (category.isSeparateCommand() && category.hasComputers(fPartition))
sorted.add(category);
}
@@ -577,7 +570,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor {
int iteration= repetition % fCategoryIteration.size();
if (iteration == 0)
return ContentAssistMessages.ContentAssistProcessor_defaultProposalCategory;
- return toString((CompletionProposalCategory) ((List) fCategoryIteration.get(iteration)).get(0));
+ return toString(fCategoryIteration.get(iteration).get(0));
}
private String toString(CompletionProposalCategory category) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java
index aded064fce6..b46dc3d156d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionProposalComputer.java
@@ -20,6 +20,7 @@ import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.swt.graphics.Image;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
@@ -86,11 +87,11 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
}
@Override
- protected List<CCompletionProposal> computeCompletionProposals(
+ protected List<ICompletionProposal> computeCompletionProposals(
CContentAssistInvocationContext context,
IASTCompletionNode completionNode, String prefix) {
- List<CCompletionProposal> proposals = new ArrayList<CCompletionProposal>();
+ List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
if(inPreprocessorDirective(context)) {
if (!inPreprocessorKeyword(context)) {
@@ -183,7 +184,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
return false;
}
- private void addMacroProposals(CContentAssistInvocationContext context, String prefix, List<CCompletionProposal> proposals) {
+ private void addMacroProposals(CContentAssistInvocationContext context, String prefix, List<ICompletionProposal> proposals) {
char[] prefixChars= prefix.toCharArray();
final boolean matchPrefix= !context.isContextInformationStyle();
IASTCompletionNode completionNode = context.getCompletionNode();
@@ -203,7 +204,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
}
}
- private void handleMacro(IASTPreprocessorMacroDefinition macro, CContentAssistInvocationContext context, String prefix, List<CCompletionProposal> proposals) {
+ private void handleMacro(IASTPreprocessorMacroDefinition macro, CContentAssistInvocationContext context, String prefix, List<ICompletionProposal> proposals) {
final String macroName = macro.getName().toString();
final int baseRelevance= computeBaseRelevance(prefix, macroName);
@@ -255,7 +256,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
CContentAssistInvocationContext cContext,
String prefix,
IASTCompletionContext astContext,
- List<CCompletionProposal> proposals) {
+ List<ICompletionProposal> proposals) {
if ((binding instanceof CPPImplicitFunction
|| binding instanceof CPPImplicitFunctionTemplate || binding instanceof CPPImplicitTypedef)
@@ -293,12 +294,12 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
return name.length == 0 || name[0] == '{';
}
- private void handleClass(ICPPClassType classType, IASTCompletionContext astContext, CContentAssistInvocationContext context, int baseRelevance, List<CCompletionProposal> proposals) {
+ private void handleClass(ICPPClassType classType, IASTCompletionContext astContext, CContentAssistInvocationContext context, int baseRelevance, List<ICompletionProposal> proposals) {
if (context.isContextInformationStyle()) {
try {
ICPPConstructor[] constructors = classType.getConstructors();
- for (int i = 0; i < constructors.length; i++) {
- handleFunction(constructors[i], context, baseRelevance, proposals);
+ for (ICPPConstructor constructor : constructors) {
+ handleFunction(constructor, context, baseRelevance, proposals);
}
} catch (DOMException e) {
}
@@ -309,10 +310,10 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
case ICPPClassType.k_class:
relevance= RelevanceConstants.CLASS_TYPE_RELEVANCE;
break;
- case ICPPClassType.k_struct:
+ case ICompositeType.k_struct:
relevance= RelevanceConstants.STRUCT_TYPE_RELEVANCE;
break;
- case ICPPClassType.k_union:
+ case ICompositeType.k_union:
relevance= RelevanceConstants.UNION_TYPE_RELEVANCE;
break;
}
@@ -328,7 +329,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
}
}
- private void handleFunction(IFunction function, CContentAssistInvocationContext context, int baseRelevance, List<CCompletionProposal> proposals) {
+ private void handleFunction(IFunction function, CContentAssistInvocationContext context, int baseRelevance, List<ICompletionProposal> proposals) {
Image image = getImage(function);
StringBuilder repStringBuff = new StringBuilder();
@@ -340,7 +341,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
String returnTypeStr = null;
try {
IParameter[] params = function.getParameters();
- if (params != null)
+ if (params != null) {
for (int i = 0; i < params.length; ++i) {
IType paramType = params[i].getType();
if (i > 0) {
@@ -357,18 +358,18 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
}
}
- if (function.takesVarArgs()) {
- if (params.length > 0) {
- dispargs.append(',');
- idargs.append(',');
- }
- dispargs.append("..."); //$NON-NLS-1$
- idargs.append("..."); //$NON-NLS-1$
- } else if (params.length == 0) { // force the void in
- dispargs.append("void"); //$NON-NLS-1$
- idargs.append("void"); //$NON-NLS-1$
- }
-
+ if (function.takesVarArgs()) {
+ if (params.length > 0) {
+ dispargs.append(',');
+ idargs.append(',');
+ }
+ dispargs.append("..."); //$NON-NLS-1$
+ idargs.append("..."); //$NON-NLS-1$
+ } else if (params.length == 0) { // force the void in
+ dispargs.append("void"); //$NON-NLS-1$
+ idargs.append("void"); //$NON-NLS-1$
+ }
+ }
IFunctionType functionType = function.getType();
if (functionType != null) {
IType returnType = functionType.getReturnType();
@@ -413,7 +414,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
proposals.add(proposal);
}
- private void handleVariable(IVariable variable, CContentAssistInvocationContext context, int baseRelevance, List<CCompletionProposal> proposals) {
+ private void handleVariable(IVariable variable, CContentAssistInvocationContext context, int baseRelevance, List<ICompletionProposal> proposals) {
StringBuilder repStringBuff = new StringBuilder();
repStringBuff.append(variable.getName());
@@ -479,7 +480,7 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
IASTCompletionContext astContext,
CContentAssistInvocationContext cContext,
int baseRelevance,
- List<CCompletionProposal> proposals) {
+ List<ICompletionProposal> proposals) {
if (astContext instanceof ICPPASTQualifiedName) {
IASTCompletionContext parent = ((ICPPASTQualifiedName) astContext)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java
index dc9f8d0e1f3..d31d4f61cfe 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HelpCompletionProposalComputer.java
@@ -17,6 +17,7 @@ import java.util.List;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.swt.graphics.Image;
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
@@ -33,7 +34,7 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer {
@Override
- protected List computeCompletionProposals(
+ protected List<ICompletionProposal> computeCompletionProposals(
CContentAssistInvocationContext cContext,
IASTCompletionNode completionNode, String prefix)
throws CoreException {
@@ -58,7 +59,7 @@ public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer
}
if (!handleHelp) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
final ITranslationUnit tu = cContext.getTranslationUnit();
@@ -77,17 +78,16 @@ public class HelpCompletionProposalComputer extends ParsingBasedProposalComputer
IFunctionSummary[] summaries = CHelpProviderManager.getDefault()
.getMatchingFunctions(helpContext, prefix);
if (summaries == null)
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
int repOffset = cContext.getInvocationOffset() - prefix.length();
int repLength = prefix.length();
Image image = CUIPlugin.getImageDescriptorRegistry().get(
CElementImageProvider.getFunctionImageDescriptor());
- List proposals = new ArrayList();
+ List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
- for (int j = 0; j < summaries.length; j++) {
- IFunctionSummary summary = summaries[j];
+ for (IFunctionSummary summary : summaries) {
String fname = summary.getName() + "()"; //$NON-NLS-1$
String fdesc = summary.getDescription();
IFunctionSummary.IFunctionPrototypeSummary fproto = summary
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HippieProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HippieProposalComputer.java
index 1144b0c7b4e..6c2aa73385e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HippieProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/HippieProposalComputer.java
@@ -15,6 +15,8 @@ import java.util.Arrays;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.ui.texteditor.HippieProposalProcessor;
import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
@@ -39,14 +41,14 @@ public final class HippieProposalComputer implements ICompletionProposalComputer
/*
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
*/
- public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
return Arrays.asList(fProcessor.computeCompletionProposals(context.getViewer(), context.getInvocationOffset()));
}
/*
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
*/
- public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
return Arrays.asList(fProcessor.computeContextInformation(context.getViewer(), context.getInvocationOffset()));
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposalComputer.java
index 5f6f597839e..db1ec7b27da 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/InclusionProposalComputer.java
@@ -31,6 +31,8 @@ import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.swt.graphics.Image;
import org.eclipse.cdt.core.model.CoreModel;
@@ -54,15 +56,15 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
private String fErrorMessage;
- public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
- List<CCompletionProposal> proposals= Collections.emptyList();
+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ List<ICompletionProposal> proposals= Collections.emptyList();
fErrorMessage= null;
if (context instanceof CContentAssistInvocationContext) {
CContentAssistInvocationContext cContext= (CContentAssistInvocationContext) context;
if (inIncludeDirective(cContext)) {
// add include file proposals
- proposals= new ArrayList<CCompletionProposal>();
+ proposals= new ArrayList<ICompletionProposal>();
try {
addInclusionProposals(cContext, proposals);
} catch (Exception exc) {
@@ -74,7 +76,7 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
return proposals;
}
- public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
return null;
}
@@ -113,7 +115,7 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
return false;
}
- private void addInclusionProposals(CContentAssistInvocationContext context, List<CCompletionProposal> proposals) throws Exception {
+ private void addInclusionProposals(CContentAssistInvocationContext context, List<ICompletionProposal> proposals) throws Exception {
if (context.isContextInformationStyle()) {
return;
}
@@ -130,13 +132,11 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
if (potentialIncludes.length > 0) {
IInclude[] includes= context.getTranslationUnit().getIncludes();
Set<String> alreadyIncluded= new HashSet<String>();
- for (int i = 0; i < includes.length; i++) {
- IInclude includeDirective= includes[i];
+ for (IInclude includeDirective : includes) {
alreadyIncluded.add(includeDirective.getElementName());
}
Image image = getImage(CElementImageProvider.getIncludeImageDescriptor());
- for (int i = 0; i < potentialIncludes.length; i++) {
- String include= potentialIncludes[i];
+ for (String include : potentialIncludes) {
if (alreadyIncluded.add(include)) {
final char openingBracket= angleBrackets ? '<' : '"';
final char closingBracket= angleBrackets ? '>' : '"';
@@ -205,16 +205,16 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
String[] quoteIncludes= extendedInfo.getLocalIncludePath();
if (quoteIncludes != null) {
- for (int i = 0; i < quoteIncludes.length; i++) {
- IPath includeDir= new Path(quoteIncludes[i]);
+ for (String quoteInclude : quoteIncludes) {
+ IPath includeDir= new Path(quoteInclude);
collectIncludeFilesFromDirectory(tu, includeDir, prefixPath, includeFiles);
}
}
}
String[] allIncludes= info.getIncludePaths();
- for (int i = 0; i < allIncludes.length; i++) {
- IPath includeDir= new Path(allIncludes[i]);
+ for (String allInclude : allIncludes) {
+ IPath includeDir= new Path(allInclude);
collectIncludeFilesFromDirectory(tu, includeDir, prefixPath, includeFiles);
}
}
@@ -228,7 +228,6 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
* @param includeFiles the result list
*/
private void collectIncludeFilesFromDirectory(ITranslationUnit tu, IPath directory, IPath prefixPath, List<String> includeFiles) {
- final boolean isCpp= tu.isCXXLanguage();
final String namePrefix;
if (prefixPath.segmentCount() == 0) {
namePrefix= ""; //$NON-NLS-1$
@@ -250,8 +249,7 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
final int prefixLength = namePrefix.length();
final IProject project= tu.getCProject().getProject();
File[] files= fileDir.listFiles();
- for (int i = 0; i < files.length; i++) {
- File file = files[i];
+ for (File file : files) {
final String name= file.getName();
if (name.length() >= prefixLength && namePrefix.equalsIgnoreCase(name.substring(0, prefixLength))) {
if (file.isFile()) {
@@ -275,7 +273,6 @@ public class InclusionProposalComputer implements ICompletionProposalComputer {
* @throws CoreException
*/
private void collectIncludeFilesFromContainer(final ITranslationUnit tu, IContainer parent, IPath prefixPath, final List<String> includeFiles) throws CoreException {
- final boolean isCpp= tu.isCXXLanguage();
final String namePrefix;
if (prefixPath.segmentCount() == 0) {
namePrefix= ""; //$NON-NLS-1$
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java
index 3ca36f22593..b4beb87b895 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/KeywordCompletionProposalComputer.java
@@ -21,6 +21,7 @@ import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.swt.graphics.Image;
import org.eclipse.cdt.core.dom.ast.IASTCompletionNode;
@@ -31,14 +32,13 @@ import org.eclipse.cdt.core.parser.Directives;
import org.eclipse.cdt.core.parser.Keywords;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.ICPartitions;
-import org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer;
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
-public class KeywordCompletionProposalComputer extends ParsingBasedProposalComputer implements ICompletionProposalComputer {
+public class KeywordCompletionProposalComputer extends ParsingBasedProposalComputer {
@Override
- protected List<CCompletionProposal> computeCompletionProposals(
+ protected List<ICompletionProposal> computeCompletionProposals(
CContentAssistInvocationContext context,
IASTCompletionNode completionNode, String prefix)
throws CoreException {
@@ -58,7 +58,7 @@ public class KeywordCompletionProposalComputer extends ParsingBasedProposalCompu
// keywords are matched case-sensitive
final int relevance = RelevanceConstants.CASE_MATCH_RELEVANCE + RelevanceConstants.KEYWORD_TYPE_RELEVANCE;
- List<CCompletionProposal> proposals = new ArrayList<CCompletionProposal>();
+ List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();
if (inPreprocessorDirective(context)) {
// TODO split this into a separate proposal computer?
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java
index f5c0c912e1e..0ecae2ab3db 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/ParsingBasedProposalComputer.java
@@ -13,8 +13,8 @@
package org.eclipse.cdt.internal.ui.text.contentassist;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.List;
@@ -38,14 +38,15 @@ public abstract class ParsingBasedProposalComputer implements ICompletionProposa
private String fErrorMessage = null;
- public List computeCompletionProposals(
+ public List<ICompletionProposal> computeCompletionProposals(
ContentAssistInvocationContext context, IProgressMonitor monitor) {
try {
if (context instanceof CContentAssistInvocationContext) {
CContentAssistInvocationContext cContext = (CContentAssistInvocationContext) context;
IASTCompletionNode completionNode = cContext.getCompletionNode();
- if (completionNode == null) return Collections.EMPTY_LIST;
+ if (completionNode == null)
+ return Collections.emptyList();
String prefix = completionNode.getPrefix();
if (prefix == null) {
prefix = cContext.computeIdentifierPrefix().toString();
@@ -58,23 +59,22 @@ public abstract class ParsingBasedProposalComputer implements ICompletionProposa
CUIPlugin.log(e);
}
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
- protected abstract List computeCompletionProposals(
+ protected abstract List<ICompletionProposal> computeCompletionProposals(
CContentAssistInvocationContext context,
IASTCompletionNode completionNode,
String prefix) throws CoreException;
- public List computeContextInformation(
+ public List<IContextInformation> computeContextInformation(
ContentAssistInvocationContext context, IProgressMonitor monitor) {
- List proposals= computeCompletionProposals(context, monitor);
+ Collection<ICompletionProposal> proposals= computeCompletionProposals(context, monitor);
// remove duplicates
- proposals= new ArrayList(new LinkedHashSet(proposals));
- List result= new ArrayList();
-
- for (Iterator it= proposals.iterator(); it.hasNext();) {
- ICompletionProposal proposal= (ICompletionProposal) it.next();
+
+ proposals= (new LinkedHashSet<ICompletionProposal>(proposals));
+ List<IContextInformation> result= new ArrayList<IContextInformation>();
+ for (ICompletionProposal proposal : proposals) {
IContextInformation contextInformation= proposal.getContextInformation();
if (contextInformation != null) {
result.add(contextInformation);
@@ -106,11 +106,10 @@ public abstract class ParsingBasedProposalComputer implements ICompletionProposa
boolean caseMatch= prefix.length() > 0 && match.startsWith(prefix);
if (caseMatch) {
return RelevanceConstants.CASE_MATCH_RELEVANCE;
- } else {
- boolean exactNameMatch= match.equalsIgnoreCase(prefix);
- if (exactNameMatch) {
- return RelevanceConstants.EXACT_NAME_MATCH_RELEVANCE;
- }
+ }
+ boolean exactNameMatch= match.equalsIgnoreCase(prefix);
+ if (exactNameMatch) {
+ return RelevanceConstants.EXACT_NAME_MATCH_RELEVANCE;
}
return 0;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java
index 37fa52978d0..8ee2f02c4c1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/TemplateCompletionProposalComputer.java
@@ -18,6 +18,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.templates.TemplateContextType;
import org.eclipse.cdt.core.model.ITranslationUnit;
@@ -51,25 +53,19 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo
contextType= new CContextType();
CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
}
- if (contextType != null)
- fCTemplateEngine= new TemplateEngine(contextType);
- else
- fCTemplateEngine= null;
+ fCTemplateEngine= new TemplateEngine(contextType);
contextType= CUIPlugin.getDefault().getTemplateContextRegistry().getContextType(CommentContextType.ID);
if (contextType == null) {
contextType= new CommentContextType();
CUIPlugin.getDefault().getTemplateContextRegistry().addContextType(contextType);
}
- if (contextType != null)
- fCommentTemplateEngine= new TemplateEngine(contextType);
- else
- fCommentTemplateEngine= null;
+ fCommentTemplateEngine= new TemplateEngine(contextType);
}
/*
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
*/
- public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
ITextViewer viewer= context.getViewer();
int offset= context.getInvocationOffset();
TemplateEngine engine= null;
@@ -83,23 +79,23 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo
}
}
} catch (BadLocationException x) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
if (engine != null && context instanceof CContentAssistInvocationContext) {
CContentAssistInvocationContext cContext= (CContentAssistInvocationContext)context;
ITranslationUnit tUnit = cContext.getTranslationUnit();
if (tUnit == null) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
engine.reset();
engine.complete(viewer, offset, tUnit);
- List result= engine.getResults();
+ List<ICompletionProposal> result= engine.getResults();
return result;
}
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
/**
@@ -117,8 +113,8 @@ public class TemplateCompletionProposalComputer implements ICompletionProposalCo
/*
* @see org.eclipse.cdt.ui.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
*/
- public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
- return Collections.EMPTY_LIST;
+ public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ return Collections.emptyList();
}
/*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java
index d870f58527d..b5259bd5687 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionAssistant.java
@@ -18,15 +18,8 @@ import java.util.Iterator;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Shell;
-
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
-
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.IDocument;
@@ -40,7 +33,10 @@ import org.eclipse.jface.text.quickassist.QuickAssistAssistant;
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.ISourceViewer;
-
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
@@ -156,7 +152,7 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
return super.showPossibleQuickAssists();
- ArrayList resultingAnnotations= new ArrayList(20);
+ ArrayList<Annotation> resultingAnnotations= new ArrayList<Annotation>(20);
try {
Point selectedRange= fViewer.getSelectedRange();
int currOffset= selectedRange.x;
@@ -172,7 +168,7 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
} catch (BadLocationException e) {
CUIPlugin.log(e);
}
- fCurrentAnnotations= (Annotation[]) resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
+ fCurrentAnnotations= resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
return super.showPossibleQuickAssists();
}
@@ -190,7 +186,7 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
return document.getLineInformationOfOffset(invocationLocation);
}
- public static int collectQuickFixableAnnotations(ITextEditor editor, int invocationLocation, boolean goToClosest, ArrayList resultingAnnotations) throws BadLocationException {
+ public static int collectQuickFixableAnnotations(ITextEditor editor, int invocationLocation, boolean goToClosest, ArrayList<Annotation> resultingAnnotations) throws BadLocationException {
IAnnotationModel model= CUIPlugin.getDefault().getDocumentProvider().getAnnotationModel(editor.getEditorInput());
if (model == null) {
return invocationLocation;
@@ -198,7 +194,7 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
ensureUpdatedAnnotations(editor);
- Iterator iter= model.getAnnotationIterator();
+ Iterator<?> iter= model.getAnnotationIterator();
if (goToClosest) {
IRegion lineInfo= getRegionOfInterest(editor, invocationLocation);
if (lineInfo == null) {
@@ -207,8 +203,8 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
int rangeStart= lineInfo.getOffset();
int rangeEnd= rangeStart + lineInfo.getLength();
- ArrayList allAnnotations= new ArrayList();
- ArrayList allPositions= new ArrayList();
+ ArrayList<Annotation> allAnnotations= new ArrayList<Annotation>();
+ ArrayList<Position> allPositions= new ArrayList<Position>();
int bestOffset= Integer.MAX_VALUE;
while (iter.hasNext()) {
Annotation annot= (Annotation) iter.next();
@@ -225,24 +221,23 @@ public class CCorrectionAssistant extends QuickAssistAssistant {
return invocationLocation;
}
for (int i= 0; i < allPositions.size(); i++) {
- Position pos= (Position) allPositions.get(i);
+ Position pos= allPositions.get(i);
if (isInside(bestOffset, pos.offset, pos.offset + pos.length)) {
resultingAnnotations.add(allAnnotations.get(i));
}
}
return bestOffset;
- } else {
- while (iter.hasNext()) {
- Annotation annot= (Annotation) iter.next();
- if (CCorrectionProcessor.isQuickFixableType(annot)) {
- Position pos= model.getPosition(annot);
- if (pos != null && isInside(invocationLocation, pos.offset, pos.offset + pos.length)) {
- resultingAnnotations.add(annot);
- }
+ }
+ while (iter.hasNext()) {
+ Annotation annot= (Annotation) iter.next();
+ if (CCorrectionProcessor.isQuickFixableType(annot)) {
+ Position pos= model.getPosition(annot);
+ if (pos != null && isInside(invocationLocation, pos.offset, pos.offset + pos.length)) {
+ resultingAnnotations.add(annot);
}
}
- return invocationLocation;
}
+ return invocationLocation;
}
private static void ensureUpdatedAnnotations(ITextEditor editor) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor.java
index f0860ac63f7..fca6d4cbaeb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CCorrectionProcessor.java
@@ -59,7 +59,7 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
private static ContributedProcessorDescriptor[] getProcessorDescriptors(String contributionId, boolean testMarkerTypes) {
IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(CUIPlugin.PLUGIN_ID, contributionId);
- ArrayList res= new ArrayList(elements.length);
+ ArrayList<ContributedProcessorDescriptor> res= new ArrayList<ContributedProcessorDescriptor>(elements.length);
for (int i= 0; i < elements.length; i++) {
ContributedProcessorDescriptor desc= new ContributedProcessorDescriptor(elements[i], testMarkerTypes);
@@ -70,7 +70,7 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
CUIPlugin.log(status);
}
}
- return (ContributedProcessorDescriptor[]) res.toArray(new ContributedProcessorDescriptor[res.size()]);
+ return res.toArray(new ContributedProcessorDescriptor[res.size()]);
}
private static ContributedProcessorDescriptor[] getCorrectionProcessors() {
@@ -198,9 +198,9 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
ICCompletionProposal[] res= null;
if (model != null && annotations != null) {
- ArrayList proposals= new ArrayList(10);
+ ArrayList<ICCompletionProposal> proposals= new ArrayList<ICCompletionProposal>(10);
IStatus status= collectProposals(context, model, annotations, true, !fAssistant.isUpdatedOffset(), proposals);
- res= (ICCompletionProposal[]) proposals.toArray(new ICCompletionProposal[proposals.size()]);
+ res= proposals.toArray(new ICCompletionProposal[proposals.size()]);
if (!status.isOK()) {
fErrorMessage= status.getMessage();
CUIPlugin.log(status);
@@ -217,8 +217,8 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
return res;
}
- public static IStatus collectProposals(CorrectionContext context, IAnnotationModel model, Annotation[] annotations, boolean addQuickFixes, boolean addQuickAssists, Collection proposals) {
- ArrayList problems= new ArrayList();
+ public static IStatus collectProposals(CorrectionContext context, IAnnotationModel model, Annotation[] annotations, boolean addQuickFixes, boolean addQuickAssists, Collection<ICCompletionProposal> proposals) {
+ ArrayList<ProblemLocation> problems= new ArrayList<ProblemLocation>();
// collect problem locations and corrections from marker annotations
for (int i= 0; i < annotations.length; i++) {
@@ -235,7 +235,7 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
}
MultiStatus resStatus= null;
- IProblemLocation[] problemLocations= (IProblemLocation[]) problems.toArray(new IProblemLocation[problems.size()]);
+ IProblemLocation[] problemLocations= problems.toArray(new IProblemLocation[problems.size()]);
if (addQuickFixes) {
IStatus status= collectCorrections(context, problemLocations, proposals);
if (!status.isOK()) {
@@ -269,7 +269,7 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
return null;
}
- private static void collectMarkerProposals(SimpleMarkerAnnotation annotation, Collection proposals) {
+ private static void collectMarkerProposals(SimpleMarkerAnnotation annotation, Collection<ICCompletionProposal> proposals) {
IMarker marker= annotation.getMarker();
IMarkerResolution[] res= IDE.getMarkerHelpRegistry().getResolutions(marker);
if (res.length > 0) {
@@ -318,10 +318,10 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
private static class SafeCorrectionCollector extends SafeCorrectionProcessorAccess {
private final CorrectionContext fContext;
- private final Collection fProposals;
+ private final Collection<ICCompletionProposal> fProposals;
private IProblemLocation[] fLocations;
- public SafeCorrectionCollector(CorrectionContext context, Collection proposals) {
+ public SafeCorrectionCollector(CorrectionContext context, Collection<ICCompletionProposal> proposals) {
fContext= context;
fProposals= proposals;
}
@@ -347,9 +347,9 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
private static class SafeAssistCollector extends SafeCorrectionProcessorAccess {
private final CorrectionContext fContext;
private final IProblemLocation[] fLocations;
- private final Collection fProposals;
+ private final Collection<ICCompletionProposal> fProposals;
- public SafeAssistCollector(CorrectionContext context, IProblemLocation[] locations, Collection proposals) {
+ public SafeAssistCollector(CorrectionContext context, IProblemLocation[] locations, Collection<ICCompletionProposal> proposals) {
fContext= context;
fLocations= locations;
fProposals= proposals;
@@ -415,7 +415,7 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
}
}
- public static IStatus collectCorrections(CorrectionContext context, IProblemLocation[] locations, Collection proposals) {
+ public static IStatus collectCorrections(CorrectionContext context, IProblemLocation[] locations, Collection<ICCompletionProposal> proposals) {
ContributedProcessorDescriptor[] processors= getCorrectionProcessors();
SafeCorrectionCollector collector= new SafeCorrectionCollector(context, proposals);
for (int i= 0; i < processors.length; i++) {
@@ -432,19 +432,19 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
private static IProblemLocation[] getHandledProblems(IProblemLocation[] locations, ContributedProcessorDescriptor processor) {
// implementation tries to avoid creating a new array
boolean allHandled= true;
- ArrayList res= null;
+ ArrayList<IProblemLocation> res= null;
for (int i= 0; i < locations.length; i++) {
IProblemLocation curr= locations[i];
if (processor.canHandleMarkerType(curr.getMarkerType())) {
if (!allHandled) { // first handled problem
if (res == null) {
- res= new ArrayList(locations.length - i);
+ res= new ArrayList<IProblemLocation>(locations.length - i);
}
res.add(curr);
}
} else if (allHandled) {
if (i > 0) { // first non handled problem
- res= new ArrayList(locations.length - i);
+ res= new ArrayList<IProblemLocation>(locations.length - i);
for (int k= 0; k < i; k++) {
res.add(locations[k]);
}
@@ -458,10 +458,10 @@ public class CCorrectionProcessor implements IQuickAssistProcessor {
if (res == null) {
return null;
}
- return (IProblemLocation[]) res.toArray(new IProblemLocation[res.size()]);
+ return res.toArray(new IProblemLocation[res.size()]);
}
- public static IStatus collectAssists(CorrectionContext context, IProblemLocation[] locations, Collection proposals) {
+ public static IStatus collectAssists(CorrectionContext context, IProblemLocation[] locations, Collection<ICCompletionProposal> proposals) {
ContributedProcessorDescriptor[] processors= getAssistProcessors();
SafeAssistCollector collector= new SafeAssistCollector(context, locations, proposals);
collector.process(processors);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java
index 5065bda4df1..1ed6619eb3b 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CSelectAnnotationRulerAction.java
@@ -111,7 +111,7 @@ public class CSelectAnnotationRulerAction extends SelectMarkerRulerAction {
if (model == null)
return ;
- Iterator iter= model.getAnnotationIterator();
+ Iterator<?> iter= model.getAnnotationIterator();
int layer= Integer.MIN_VALUE;
while (iter.hasNext()) {
@@ -138,21 +138,20 @@ public class CSelectAnnotationRulerAction extends SelectMarkerRulerAction {
fHasCorrection= true;
layer= annotationLayer;
continue;
- } else {
- AnnotationPreference preference= fAnnotationPreferenceLookup.getAnnotationPreference(annotation);
- if (preference == null)
- continue;
-
- String key= preference.getVerticalRulerPreferenceKey();
- if (key == null)
- continue;
-
- if (fStore.getBoolean(key)) {
- fPosition= position;
- fHasCorrection= false;
- layer= annotationLayer;
- }
}
+ AnnotationPreference preference= fAnnotationPreferenceLookup.getAnnotationPreference(annotation);
+ if (preference == null)
+ continue;
+
+ String key= preference.getVerticalRulerPreferenceKey();
+ if (key == null)
+ continue;
+
+ if (fStore.getBoolean(key)) {
+ fPosition= position;
+ fHasCorrection= false;
+ layer= annotationLayer;
+ }
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ContributedProcessorDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ContributedProcessorDescriptor.java
index 22dce4e7c0d..c21975f4d1e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ContributedProcessorDescriptor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/ContributedProcessorDescriptor.java
@@ -15,15 +15,14 @@ import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IStatus;
-
import org.eclipse.core.expressions.EvaluationContext;
import org.eclipse.core.expressions.EvaluationResult;
import org.eclipse.core.expressions.Expression;
import org.eclipse.core.expressions.ExpressionConverter;
import org.eclipse.core.expressions.ExpressionTagNames;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.cdt.core.model.ICModelMarker;
import org.eclipse.cdt.core.model.ICProject;
@@ -37,7 +36,7 @@ public final class ContributedProcessorDescriptor {
private Object fProcessorInstance;
private Boolean fStatus;
private boolean fLastResult;
- private final Set fHandledMarkerTypes;
+ private final Set<String> fHandledMarkerTypes;
private static final String ID= "id"; //$NON-NLS-1$
private static final String CLASS= "class"; //$NON-NLS-1$
@@ -55,13 +54,13 @@ public final class ContributedProcessorDescriptor {
fHandledMarkerTypes= testMarkerTypes ? getHandledMarkerTypes(element) : null;
}
- private Set getHandledMarkerTypes(IConfigurationElement element) {
- HashSet map= new HashSet(7);
+ private Set<String> getHandledMarkerTypes(IConfigurationElement element) {
+ HashSet<String> map= new HashSet<String>(7);
IConfigurationElement[] children= element.getChildren(HANDLED_MARKER_TYPES);
- for (int i= 0; i < children.length; i++) {
- IConfigurationElement[] types= children[i].getChildren(MARKER_TYPE);
- for (int k= 0; k < types.length; k++) {
- String attribute= types[k].getAttribute(ID);
+ for (IConfigurationElement element2 : children) {
+ IConfigurationElement[] types= element2.getChildren(MARKER_TYPE);
+ for (IConfigurationElement type : types) {
+ String attribute= type.getAttribute(ID);
if (attribute != null) {
map.add(attribute);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java
index 07972889f3e..d506f7e0b48 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandHandler.java
@@ -38,6 +38,7 @@ import org.eclipse.ui.keys.IBindingService;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.ui.text.ICCompletionProposal;
import org.eclipse.cdt.internal.ui.editor.CEditor;
@@ -74,7 +75,7 @@ public class CorrectionCommandHandler extends AbstractHandler {
private ICompletionProposal findCorrection(String id, boolean isAssist, ITextSelection selection, ITranslationUnit cu, IAnnotationModel model) {
CorrectionContext context= new CorrectionContext(cu, selection.getOffset(), selection.getLength());
- Collection proposals= new ArrayList(10);
+ Collection<ICCompletionProposal> proposals= new ArrayList<ICCompletionProposal>(10);
if (isAssist) {
CCorrectionProcessor.collectAssists(context, new ProblemLocation[0], proposals);
} else {
@@ -86,7 +87,7 @@ public class CorrectionCommandHandler extends AbstractHandler {
return null;
}
}
- for (Iterator iter= proposals.iterator(); iter.hasNext();) {
+ for (Iterator<ICCompletionProposal> iter= proposals.iterator(); iter.hasNext();) {
Object curr= iter.next();
if (curr instanceof ICommandAccess) {
if (id.equals(((ICommandAccess) curr).getCommandId())) {
@@ -98,9 +99,9 @@ public class CorrectionCommandHandler extends AbstractHandler {
}
private Annotation[] getAnnotations(int offset, boolean goToClosest) throws BadLocationException {
- ArrayList resultingAnnotations= new ArrayList();
+ ArrayList<Annotation> resultingAnnotations= new ArrayList<Annotation>();
CCorrectionAssistant.collectQuickFixableAnnotations(fEditor, offset, goToClosest, resultingAnnotations);
- return (Annotation[]) resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
+ return resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
}
private IDocument getDocument() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandInstaller.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandInstaller.java
index 436458bc783..eb3d3d1c10a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandInstaller.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/CorrectionCommandInstaller.java
@@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.text.correction;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.ui.IWorkbench;
@@ -39,7 +38,7 @@ public class CorrectionCommandInstaller {
*/
public static final String ASSIST_SUFFIX= ".assist"; //$NON-NLS-1$
- private List fCorrectionHandlerActivations;
+ private List<IHandlerActivation> fCorrectionHandlerActivations;
public CorrectionCommandInstaller() {
fCorrectionHandlerActivations= null;
@@ -56,11 +55,12 @@ public class CorrectionCommandInstaller {
if (fCorrectionHandlerActivations != null) {
CUIPlugin.getDefault().logErrorMessage("correction handler activations not released"); //$NON-NLS-1$
}
- fCorrectionHandlerActivations= new ArrayList();
+ fCorrectionHandlerActivations= new ArrayList<IHandlerActivation>();
- Collection definedCommandIds= commandService.getDefinedCommandIds();
- for (Iterator iter= definedCommandIds.iterator(); iter.hasNext();) {
- String id= (String) iter.next();
+ @SuppressWarnings("unchecked")
+ Collection<String> definedCommandIds= commandService.getDefinedCommandIds();
+ for (Object element : definedCommandIds) {
+ String id= (String) element;
if (id.startsWith(COMMAND_PREFIX)) {
boolean isAssist= id.endsWith(ASSIST_SUFFIX);
CorrectionCommandHandler handler= new CorrectionCommandHandler(editor, id, isAssist);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java
index 1fd9ed6d67a..defccd65b7e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/correction/QuickAssistLightBulbUpdater.java
@@ -260,7 +260,7 @@ public class QuickAssistLightBulbUpdater {
int currLine= document.getLineOfOffset(offset);
// this iterator is not protected, it may throw ConcurrentModificationExceptions
- Iterator iter= model.getAnnotationIterator();
+ Iterator<?> iter= model.getAnnotationIterator();
while (iter.hasNext()) {
Annotation annot= (Annotation) iter.next();
if (CCorrectionProcessor.isQuickFixableType(annot)) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/AbstractDocCommentProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/AbstractDocCommentProposalComputer.java
index 60fe0c0cc90..04af9f98e7a 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/AbstractDocCommentProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/AbstractDocCommentProposalComputer.java
@@ -14,6 +14,8 @@ import java.util.List;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
@@ -38,11 +40,11 @@ abstract class AbstractDocCommentProposalComputer implements ICompletionProposal
return getConfiguration(owner);
}
- public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
return getConfiguration().createProposalComputer().computeCompletionProposals(context, monitor);
}
- public List computeContextInformation(
+ public List<IContextInformation> computeContextInformation(
ContentAssistInvocationContext context, IProgressMonitor monitor) {
return getConfiguration().createProposalComputer().computeContextInformation(context, monitor);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwnerManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwnerManager.java
index 73d1fc198e1..a7877b5812e 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwnerManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/DocCommentOwnerManager.java
@@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.ui.text.doctools;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -225,16 +224,15 @@ public class DocCommentOwnerManager {
IExtensionRegistry registry = Platform.getExtensionRegistry();
IExtensionPoint indexProviders = registry.getExtensionPoint(CUIPlugin.ID_COMMENT_OWNER);
IExtension[] extensions = indexProviders.getExtensions();
- for(int i=0; i<extensions.length; i++) {
- IExtension extension = extensions[i];
+ for (IExtension extension : extensions) {
try {
IConfigurationElement[] ce = extension.getConfigurationElements();
- for(int j=0; j<ce.length; j++) {
- if(ce[j].getName().equals(ELEMENT_OWNER)) {
- IDocCommentViewerConfiguration multi = (IDocCommentViewerConfiguration) ce[j].createExecutableExtension(ATTRKEY_OWNER_MULTILINE);
- IDocCommentViewerConfiguration single = (IDocCommentViewerConfiguration) ce[j].createExecutableExtension(ATTRKEY_OWNER_SINGLELINE);
- String id= ce[j].getAttribute(ATTRKEY_OWNER_ID);
- String name= ce[j].getAttribute(ATTRKEY_OWNER_NAME);
+ for (IConfigurationElement element : ce) {
+ if(element.getName().equals(ELEMENT_OWNER)) {
+ IDocCommentViewerConfiguration multi = (IDocCommentViewerConfiguration) element.createExecutableExtension(ATTRKEY_OWNER_MULTILINE);
+ IDocCommentViewerConfiguration single = (IDocCommentViewerConfiguration) element.createExecutableExtension(ATTRKEY_OWNER_SINGLELINE);
+ String id= element.getAttribute(ATTRKEY_OWNER_ID);
+ String name= element.getAttribute(ATTRKEY_OWNER_NAME);
if(result.put(id, new DocCommentOwner(id, name, multi, single))!=null) {
String msg= MessageFormat.format(Messages.DocCommentOwnerManager_DuplicateMapping0, id);
CCorePlugin.log(new Status(IStatus.WARNING, CUIPlugin.PLUGIN_ID, msg));
@@ -250,14 +248,14 @@ public class DocCommentOwnerManager {
}
private void fireOwnershipChanged(IResource resource, boolean submappingsRemoved, IDocCommentOwner oldOwner, IDocCommentOwner newOwner) {
- for(Iterator i= fListeners.iterator(); i.hasNext();) {
- ((IDocCommentOwnershipListener)i.next()).ownershipChanged(resource, submappingsRemoved, oldOwner, newOwner);
+ for (IDocCommentOwnershipListener docCommentOwnershipListener : fListeners) {
+ docCommentOwnershipListener.ownershipChanged(resource, submappingsRemoved, oldOwner, newOwner);
}
}
private void fireWorkspaceOwnershipChanged(IDocCommentOwner oldOwner, IDocCommentOwner newOwner) {
- for(Iterator i= fListeners.iterator(); i.hasNext();) {
- ((IDocCommentOwnershipListener)i.next()).workspaceOwnershipChanged(oldOwner, newOwner);
+ for (IDocCommentOwnershipListener element : fListeners) {
+ element.workspaceOwnershipChanged(oldOwner, newOwner);
}
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java
index 8042b044c2e..6ae40f47ba0 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/doctools/ProjectMap.java
@@ -158,12 +158,12 @@ class ProjectMap {
}
// invert and persist associations
- for(Iterator i= fMap.values().iterator(); i.hasNext();) {
- String cid= (String) i.next();
+ for(Iterator<String> i= fMap.values().iterator(); i.hasNext();) {
+ String cid= i.next();
Element commentNode= data.getOwnerDocument().createElement(ELEMENT_DOC_COMMENT_OWNER);
commentNode.setAttribute(ATTRKEY_DCO_ID, cid);
- for(Iterator j= fMap.keySet().iterator(); j.hasNext(); ) {
- IPath path= (IPath) j.next();
+ for(Iterator<IPath> j= fMap.keySet().iterator(); j.hasNext(); ) {
+ IPath path= j.next();
String ccid= fMap.get(path);
if(cid.equals(ccid)) {
Element pathNode= data.getOwnerDocument().createElement(ELEMENT_PATH);
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderRegistry.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderRegistry.java
index 0676dbb77ee..b7b280b6416 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderRegistry.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/CFoldingStructureProviderRegistry.java
@@ -28,7 +28,7 @@ public class CFoldingStructureProviderRegistry {
private static final String EXTENSION_POINT= "foldingStructureProviders"; //$NON-NLS-1$
/** The map of descriptors, indexed by their identifiers. */
- private Map fDescriptors;
+ private Map<String, CFoldingStructureProviderDescriptor> fDescriptors;
/**
* Creates a new instance.
@@ -46,7 +46,7 @@ public class CFoldingStructureProviderRegistry {
public CFoldingStructureProviderDescriptor[] getFoldingProviderDescriptors() {
synchronized (this) {
ensureRegistered();
- return (CFoldingStructureProviderDescriptor[]) fDescriptors.values().toArray(new CFoldingStructureProviderDescriptor[fDescriptors.size()]);
+ return fDescriptors.values().toArray(new CFoldingStructureProviderDescriptor[fDescriptors.size()]);
}
}
@@ -61,7 +61,7 @@ public class CFoldingStructureProviderRegistry {
public CFoldingStructureProviderDescriptor getFoldingProviderDescriptor(String id) {
synchronized (this) {
ensureRegistered();
- return (CFoldingStructureProviderDescriptor) fDescriptors.get(id);
+ return fDescriptors.get(id);
}
}
@@ -102,7 +102,7 @@ public class CFoldingStructureProviderRegistry {
*/
public void reloadExtensions() {
IExtensionRegistry registry= Platform.getExtensionRegistry();
- Map map= new HashMap();
+ Map<String, CFoldingStructureProviderDescriptor> map= new HashMap<String, CFoldingStructureProviderDescriptor>();
IConfigurationElement[] elements= registry.getConfigurationElementsFor(CUIPlugin.getPluginId(), EXTENSION_POINT);
for (int i= 0; i < elements.length; i++) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java
index 4e16bd8f5d7..68162b95730 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingPreferenceBlock.java
@@ -43,14 +43,14 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
private IPreferenceStore fStore;
protected OverlayPreferenceStore fOverlayStore;
private OverlayKey[] fKeys;
- protected Map fCheckBoxes= new HashMap();
+ protected Map<Button, String> fCheckBoxes= new HashMap<Button, String>();
private SelectionListener fCheckBoxListener= new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
Button button= (Button) e.widget;
- String key= (String) fCheckBoxes.get(button);
+ String key= fCheckBoxes.get(button);
fOverlayStore.setValue(key, button.getSelection());
updateEnablement(key);
}
@@ -65,7 +65,7 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
}
private OverlayKey[] createKeys() {
- ArrayList overlayKeys= new ArrayList();
+ ArrayList<OverlayKey> overlayKeys= new ArrayList<OverlayKey>();
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_MACROS));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_FUNCTIONS));
@@ -77,7 +77,7 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_PREPROCESSOR_BRANCHES_ENABLED));
overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_STATEMENTS));
- return (OverlayKey[]) overlayKeys.toArray(new OverlayKey[overlayKeys.size()]);
+ return overlayKeys.toArray(new OverlayKey[overlayKeys.size()]);
}
/*
@@ -127,10 +127,10 @@ public class DefaultCFoldingPreferenceBlock implements ICFoldingPreferenceBlock
}
private void initializeFields() {
- Iterator it= fCheckBoxes.keySet().iterator();
+ Iterator<Button> it= fCheckBoxes.keySet().iterator();
while (it.hasNext()) {
- Button b= (Button) it.next();
- String key= (String) fCheckBoxes.get(b);
+ Button b= it.next();
+ String key= fCheckBoxes.get(b);
b.setSelection(fOverlayStore.getBoolean(key));
updateEnablement(key);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java
index 1e9d0922db3..bb5f18d1fe5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/folding/DefaultCFoldingStructureProvider.java
@@ -84,6 +84,7 @@ import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.core.model.ISourceRange;
import org.eclipse.cdt.core.model.ISourceReference;
import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.core.parser.IProblem;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants;
import org.eclipse.cdt.ui.text.ICPartitions;
@@ -170,8 +171,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
if (switchstmt instanceof IASTCompoundStatement) {
IASTStatement[] stmts = ((IASTCompoundStatement)switchstmt).getStatements();
boolean pushedMR = false;
- for (int i = 0; i < stmts.length; i++) {
- IASTStatement tmpstmt = stmts[i];
+ for (IASTStatement tmpstmt : stmts) {
StatementRegion tmpmr;
if (!(tmpstmt instanceof IASTCaseStatement || tmpstmt instanceof IASTDefaultStatement)) {
if (!pushedMR) return PROCESS_SKIP;
@@ -315,16 +315,14 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
return false;
}
IASTProblem[] problems= ast.getPreprocessorProblems();
- for (int i = 0; i < problems.length; i++) {
- IASTProblem problem = problems[i];
- if ((problem.getID() & (IASTProblem.SYNTAX_ERROR | IASTProblem.SCANNER_RELATED)) != 0) {
+ for (IASTProblem problem : problems) {
+ if ((problem.getID() & (IProblem.SYNTAX_ERROR | IProblem.SCANNER_RELATED)) != 0) {
return true;
}
}
problems= CPPVisitor.getProblems(ast);
- for (int i = 0; i < problems.length; i++) {
- IASTProblem problem = problems[i];
- if ((problem.getID() & (IASTProblem.SYNTAX_ERROR | IASTProblem.SCANNER_RELATED)) != 0) {
+ for (IASTProblem problem : problems) {
+ if ((problem.getID() & (IProblem.SYNTAX_ERROR | IProblem.SCANNER_RELATED)) != 0) {
return true;
}
}
@@ -1024,23 +1022,23 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
Map<CProjectionAnnotation,Position> updated= ctx.fMap;
Map<Object, List<Tuple>> previous= computeCurrentStructure(ctx);
- Iterator e= updated.keySet().iterator();
+ Iterator<CProjectionAnnotation> e= updated.keySet().iterator();
while (e.hasNext()) {
- CProjectionAnnotation newAnnotation= (CProjectionAnnotation) e.next();
+ CProjectionAnnotation newAnnotation= e.next();
Object key= newAnnotation.getElement();
Position newPosition= updated.get(newAnnotation);
- List annotations= previous.get(key);
+ List<Tuple> annotations= previous.get(key);
if (annotations == null) {
if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() new annotation " + newAnnotation); //$NON-NLS-1$
additions.put(newAnnotation, newPosition);
} else {
- Iterator x= annotations.iterator();
+ Iterator<Tuple> x= annotations.iterator();
boolean matched= false;
while (x.hasNext()) {
- Tuple tuple= (Tuple) x.next();
+ Tuple tuple= x.next();
CProjectionAnnotation existingAnnotation= tuple.annotation;
Position existingPosition= tuple.position;
if (newAnnotation.getCategory() == existingAnnotation.getCategory()) {
@@ -1072,12 +1070,12 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
}
}
- e= previous.values().iterator();
- while (e.hasNext()) {
- List list= (List) e.next();
+ Iterator<List<Tuple>> e2= previous.values().iterator();
+ while (e2.hasNext()) {
+ List<Tuple> list= e2.next();
int size= list.size();
for (int i= 0; i < size; i++) {
- CProjectionAnnotation annotation= ((Tuple) list.get(i)).annotation;
+ CProjectionAnnotation annotation= list.get(i).annotation;
if (DEBUG) System.out.println("DefaultCFoldingStructureProvider.update() deleted annotation " + annotation); //$NON-NLS-1$
deletions.add(annotation);
}
@@ -1109,9 +1107,9 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
List<CProjectionAnnotation> newDeletions= new ArrayList<CProjectionAnnotation>();
List<CProjectionAnnotation> newChanges= new ArrayList<CProjectionAnnotation>();
- Iterator deletionIterator= deletions.iterator();
+ Iterator<CProjectionAnnotation> deletionIterator= deletions.iterator();
while (deletionIterator.hasNext()) {
- CProjectionAnnotation deleted= (CProjectionAnnotation) deletionIterator.next();
+ CProjectionAnnotation deleted= deletionIterator.next();
Position deletedPosition= ctx.getModel().getPosition(deleted);
if (deletedPosition == null || deletedPosition.length < 5)
continue;
@@ -1197,7 +1195,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
boolean includeCModel= ctx.fAST != null || !(fPreprocessorBranchFoldingEnabled || fStatementsFoldingEnabled);
Map<Object, List<Tuple>> map= new HashMap<Object, List<Tuple>>();
ProjectionAnnotationModel model= ctx.getModel();
- Iterator e= model.getAnnotationIterator();
+ Iterator<?> e= model.getAnnotationIterator();
while (e.hasNext()) {
Object annotation= e.next();
if (annotation instanceof CProjectionAnnotation) {
@@ -1366,8 +1364,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
IASTPreprocessorStatement[] preprocStmts = ast.getAllPreprocessorStatements();
- for (int i = 0; i < preprocStmts.length; i++) {
- IASTPreprocessorStatement statement = preprocStmts[i];
+ for (IASTPreprocessorStatement statement : preprocStmts) {
if (!statement.isPartOfTranslationUnitFile()) {
// preprocessor directive is from a different file
continue;
@@ -1418,8 +1415,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
}
Map<String, Counter> keys= new HashMap<String, Counter>(branches.size());
- for (Iterator<Branch> iter = branches.iterator(); iter.hasNext(); ) {
- Branch branch= iter.next();
+ for (Branch branch : branches) {
IRegion aligned = alignRegion(branch, ctx, branch.fInclusive);
if (aligned != null) {
Position alignedPos= new Position(aligned.getOffset(), aligned.getLength());
@@ -1468,8 +1464,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
int endLine = -1;
List<Tuple> comments= new ArrayList<Tuple>();
ModifiableRegion commentRange = new ModifiableRegion();
- for (int i = 0; i < partitions.length; i++) {
- ITypedRegion partition = partitions[i];
+ for (ITypedRegion partition : partitions) {
boolean singleLine= false;
if (ICPartitions.C_MULTI_LINE_COMMENT.equals(partition.getType())
|| ICPartitions.C_MULTI_LINE_DOC_COMMENT.equals(partition.getType())) {
@@ -1550,9 +1545,7 @@ public class DefaultCFoldingStructureProvider implements ICFoldingStructureProvi
}
private void computeFoldingStructure(ICElement[] elements, FoldingStructureComputationContext ctx) throws CModelException {
- for (int i= 0; i < elements.length; i++) {
- ICElement element= elements[i];
-
+ for (ICElement element : elements) {
computeFoldingStructure(element, ctx);
if (element instanceof IParent) {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingProblem.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingProblem.java
index 0d8cce3f001..f4432cd7772 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingProblem.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/CSpellingProblem.java
@@ -21,6 +21,7 @@ import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.ui.texteditor.spelling.SpellingProblem;
import org.eclipse.cdt.ui.text.ICCompletionProposal;
@@ -81,9 +82,9 @@ public class CSpellingProblem extends SpellingProblem {
@Override
public String getMessage() {
if (isSentenceStart() && isDictionaryMatch())
- return Messages.bind(Messages.Spelling_error_case_label, fSpellEvent.getWord());
+ return NLS.bind(Messages.Spelling_error_case_label, fSpellEvent.getWord());
- return Messages.bind(Messages.Spelling_error_label, fSpellEvent.getWord());
+ return NLS.bind(Messages.Spelling_error_label, fSpellEvent.getWord());
}
/*
@@ -97,7 +98,7 @@ public class CSpellingProblem extends SpellingProblem {
final int threshold= SpellingPreferences.spellingProposalThreshold();
int size= 0;
- List proposals= null;
+ List<RankedWordProposal> proposals= null;
RankedWordProposal proposal= null;
ICCompletionProposal[] result= null;
@@ -118,7 +119,7 @@ public class CSpellingProblem extends SpellingProblem {
arguments, getOffset(), getLength(), context,
engine.getLocale()) };
} else {
- proposals= new ArrayList(checker.getProposals(arguments[0],
+ proposals= new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0],
sentence));
size= proposals.size();
@@ -132,7 +133,7 @@ public class CSpellingProblem extends SpellingProblem {
result= new ICCompletionProposal[size + (extendable ? 3 : 2)];
for (index= 0; index < size; index++) {
- proposal= (RankedWordProposal) proposals.get(index);
+ proposal= proposals.get(index);
result[index]= new WordCorrectionProposal(proposal
.getText(), arguments, getOffset(), getLength(),
context, proposal.getRank());
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckIterator.java
index 5ec10a2fdd2..a363586ffb5 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckIterator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellCheckIterator.java
@@ -46,7 +46,7 @@ public class SpellCheckIterator implements ISpellCheckIterator {
protected int fPrevious= 0;
/** The sentence breaks */
- private final LinkedList fSentenceBreaks= new LinkedList();
+ private final LinkedList<Integer> fSentenceBreaks= new LinkedList<Integer>();
/** Does the current word start a sentence? */
private boolean fStartsSentence= false;
@@ -174,8 +174,8 @@ public class SpellCheckIterator implements ISpellCheckIterator {
*/
protected final boolean isToken(final String token, final String[] tags) {
if (token != null) {
- for (int index= 0; index < tags.length; index++) {
- if (token.equals(tags[index]))
+ for (String tag : tags) {
+ if (token.equals(tag))
return true;
}
}
@@ -211,8 +211,8 @@ public class SpellCheckIterator implements ISpellCheckIterator {
* <code>false</code> otherwise
*/
protected final boolean isUrlToken(final int begin) {
- for (int index= 0; index < DefaultSpellChecker.URL_PREFIXES.length; index++) {
- if (fContent.startsWith(DefaultSpellChecker.URL_PREFIXES[index], begin))
+ for (String element : DefaultSpellChecker.URL_PREFIXES) {
+ if (fContent.startsWith(element, begin))
return true;
}
return false;
@@ -237,7 +237,7 @@ public class SpellCheckIterator implements ISpellCheckIterator {
/*
* @see java.util.Iterator#next()
*/
- public Object next() {
+ public String next() {
String token= nextToken();
while (token == null && fSuccessor != BreakIterator.DONE)
token= nextToken();
@@ -261,7 +261,7 @@ public class SpellCheckIterator implements ISpellCheckIterator {
* @return the next sentence break
*/
protected final int nextSentence() {
- return ((Integer) fSentenceBreaks.getFirst()).intValue();
+ return fSentenceBreaks.getFirst().intValue();
}
/**
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngineDispatcher.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngineDispatcher.java
index aa45eb7c1b9..077471e2f11 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngineDispatcher.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/SpellingEngineDispatcher.java
@@ -46,7 +46,7 @@ public class SpellingEngineDispatcher implements ISpellingEngine {
private static final IContentType CXXSOURCE_CONTENT_TYPE= Platform.getContentTypeManager().getContentType(CCorePlugin.CONTENT_TYPE_CXXSOURCE);
/** Available spelling engines by content type */
- private Map fEngines= new HashMap();
+ private Map<IContentType, SpellingEngine> fEngines= new HashMap<IContentType, SpellingEngine>();
private ISpellingEngine defaultEngine;
/**
@@ -96,7 +96,7 @@ public class SpellingEngineDispatcher implements ISpellingEngine {
return null;
if (fEngines.containsKey(contentType))
- return (ISpellingEngine) fEngines.get(contentType);
+ return fEngines.get(contentType);
return getEngine(contentType.getBaseType());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposalComputer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposalComputer.java
index 6142366097a..b489a1327f7 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposalComputer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordCompletionProposalComputer.java
@@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.text.spelling;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -22,6 +21,8 @@ import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.text.contentassist.ContentAssistInvocationContext;
@@ -45,7 +46,7 @@ public final class WordCompletionProposalComputer implements ICompletionProposal
/*
* @see org.eclipse.jface.text.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.jface.text.contentassist.TextContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
*/
- public List computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context, IProgressMonitor monitor) {
if (contributes()) {
try {
IDocument document= context.getDocument();
@@ -66,11 +67,11 @@ public final class WordCompletionProposalComputer implements ICompletionProposal
final ISpellChecker checker= engine.getSpellChecker();
if (checker != null) {
- final List proposals= new ArrayList(checker.getProposals(candidate, Character.isUpperCase(candidate.charAt(0))));
- final List result= new ArrayList(proposals.size());
+ final List<RankedWordProposal> proposals= new ArrayList<RankedWordProposal>(checker.getProposals(candidate, Character.isUpperCase(candidate.charAt(0))));
+ final List<ICompletionProposal> result= new ArrayList<ICompletionProposal>(proposals.size());
- for (Iterator it= proposals.iterator(); it.hasNext();) {
- RankedWordProposal word= (RankedWordProposal) it.next();
+ for (Object element : proposals) {
+ RankedWordProposal word= (RankedWordProposal) element;
String text= word.getText();
if (text.startsWith(candidate))
word.setRank(word.getRank() + PREFIX_RANK_SHIFT);
@@ -95,7 +96,7 @@ public final class WordCompletionProposalComputer implements ICompletionProposal
CUIPlugin.log(exception);
}
}
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
private boolean contributes() {
@@ -105,8 +106,8 @@ public final class WordCompletionProposalComputer implements ICompletionProposal
/*
* @see org.eclipse.jface.text.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.jface.text.contentassist.TextContentAssistInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
*/
- public List computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
- return Collections.EMPTY_LIST;
+ public List<IContextInformation> computeContextInformation(ContentAssistInvocationContext context, IProgressMonitor monitor) {
+ return Collections.emptyList();
}
/*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordQuickFixProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordQuickFixProcessor.java
index e9cf76746f7..17da9b4bc2f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordQuickFixProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/WordQuickFixProcessor.java
@@ -46,7 +46,7 @@ public class WordQuickFixProcessor implements IQuickFixProcessor {
final int threshold= SpellingPreferences.spellingProposalThreshold();
int size= 0;
- List proposals= null;
+ List<RankedWordProposal> proposals= null;
String[] arguments= null;
IProblemLocation location= null;
@@ -73,7 +73,7 @@ public class WordQuickFixProcessor implements IQuickFixProcessor {
if ((sentence && match) && !fixed) {
result= new ICCompletionProposal[] { new ChangeCaseProposal(arguments, location.getOffset(), location.getLength(), context, engine.getLocale())};
} else {
- proposals= new ArrayList(checker.getProposals(arguments[0], sentence));
+ proposals= new ArrayList<RankedWordProposal>(checker.getProposals(arguments[0], sentence));
size= proposals.size();
if (threshold > 0 && size > threshold) {
@@ -86,7 +86,7 @@ public class WordQuickFixProcessor implements IQuickFixProcessor {
result= new ICCompletionProposal[size + (extendable ? 3 : 2)];
for (index= 0; index < size; index++) {
- proposal= (RankedWordProposal)proposals.get(index);
+ proposal= proposals.get(index);
result[index]= new WordCorrectionProposal(proposal.getText(), arguments, location.getOffset(), location.getLength(), context, proposal.getRank());
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java
index 2e17a745d49..c2ae51e8c78 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/AbstractSpellDictionary.java
@@ -17,6 +17,7 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.io.Serializable;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.Charset;
@@ -33,6 +34,7 @@ import java.util.Set;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.osgi.util.NLS;
import org.eclipse.cdt.ui.CUIPlugin;
@@ -59,7 +61,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
private IPhoneticDistanceAlgorithm fDistanceAlgorithm= new DefaultPhoneticDistanceAlgorithm();
/** The mapping from phonetic hashes to word lists */
- private final Map fHashBuckets= new HashMap(HASH_CAPACITY);
+ private final Map<String, Serializable> fHashBuckets= new HashMap<String, Serializable>(HASH_CAPACITY);
/** The phonetic hash provider */
private IPhoneticHashProvider fHashProvider= new DefaultPhoneticHashProvider();
@@ -100,17 +102,17 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
* Array of close hashes to find the matches
* @return Set of ranked words with bounded distance to the specified word
*/
- protected final Set getCandidates(final String word, final boolean sentence, final ArrayList hashs) {
+ protected final Set<RankedWordProposal> getCandidates(final String word, final boolean sentence, final ArrayList<String> hashs) {
int distance= 0;
String hash= null;
final StringBuffer buffer= new StringBuffer(BUFFER_CAPACITY);
- final HashSet result= new HashSet(BUCKET_CAPACITY * hashs.size());
+ final HashSet<RankedWordProposal> result= new HashSet<RankedWordProposal>(BUCKET_CAPACITY * hashs.size());
for (int index= 0; index < hashs.size(); index++) {
- hash= (String)hashs.get(index);
+ hash= hashs.get(index);
final Object candidates= getCandidates(hash);
if (candidates == null)
@@ -128,10 +130,11 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
continue;
}
- final ArrayList candidateList= (ArrayList)candidates;
+ @SuppressWarnings("unchecked")
+ final ArrayList<String> candidateList= (ArrayList<String>)candidates;
for (int offset= 0; offset < candidateList.size(); offset++) {
- String candidate= (String)candidateList.get(offset);
+ String candidate= candidateList.get(offset);
distance= fDistanceAlgorithm.getDistance(word, candidate);
if (distance < DISTANCE_THRESHOLD) {
@@ -162,7 +165,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
* Set of ranked words with smallest possible distance to the
* specified word
*/
- protected final void getCandidates(final String word, final boolean sentence, final Set result) {
+ protected final void getCandidates(final String word, final boolean sentence, final Set<RankedWordProposal> result) {
int distance= 0;
int minimum= Integer.MAX_VALUE;
@@ -182,11 +185,12 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
return;
}
- final ArrayList candidateList= (ArrayList)candidates;
- final ArrayList matches= new ArrayList(candidateList.size());
+ @SuppressWarnings("unchecked")
+ final ArrayList<String> candidateList= (ArrayList<String>)candidates;
+ final ArrayList<RankedWordProposal> matches= new ArrayList<RankedWordProposal>(candidateList.size());
for (int index= 0; index < candidateList.size(); index++) {
- String candidate= (String)candidateList.get(index);
+ String candidate= candidateList.get(index);
distance= fDistanceAlgorithm.getDistance(word, candidate);
if (distance <= minimum) {
@@ -238,7 +242,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
/*
* @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellDictionary#getProposals(java.lang.String,boolean)
*/
- public Set getProposals(final String word, final boolean sentence) {
+ public Set<RankedWordProposal> getProposals(final String word, final boolean sentence) {
try {
@@ -257,10 +261,10 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
final String hash= fHashProvider.getHash(word);
final char[] mutators= fHashProvider.getMutators();
- final ArrayList neighborhood= new ArrayList((word.length() + 1) * (mutators.length + 2));
+ final ArrayList<String> neighborhood= new ArrayList<String>((word.length() + 1) * (mutators.length + 2));
neighborhood.add(hash);
- final Set candidates= getCandidates(word, sentence, neighborhood);
+ final Set<RankedWordProposal> candidates= getCandidates(word, sentence, neighborhood);
neighborhood.clear();
char previous= 0;
@@ -288,9 +292,9 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
while (true) {
- for (int index= 0; index < mutators.length; index++) {
+ for (char mutator : mutators) {
- characters[offset]= mutators[index];
+ characters[offset]= mutator;
neighborhood.add(fHashProvider.getHash(new String(characters)));
}
@@ -307,9 +311,9 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
for (int index= 0; index < word.length(); index++) {
mutated= characters[index];
- for (int mutator= 0; mutator < mutators.length; mutator++) {
+ for (char mutator2 : mutators) {
- characters[index]= mutators[mutator];
+ characters[index]= mutator2;
neighborhood.add(fHashProvider.getHash(new String(characters)));
}
characters[index]= mutated;
@@ -338,7 +342,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
}
neighborhood.remove(hash);
- final Set matches= getCandidates(word, sentence, neighborhood);
+ final Set<RankedWordProposal> matches= getCandidates(word, sentence, neighborhood);
if (matches.size() == 0 && candidates.size() == 0)
getCandidates(word, sentence, candidates);
@@ -371,9 +375,11 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
if (bucket == null) {
fHashBuckets.put(hash, word);
} else if (bucket instanceof ArrayList) {
- ((ArrayList)bucket).add(word);
+ @SuppressWarnings("unchecked")
+ final ArrayList<Object> bucket2 = (ArrayList)bucket;
+ bucket2.add(word);
} else {
- ArrayList list= new ArrayList(BUCKET_CAPACITY);
+ ArrayList<Object> list= new ArrayList<Object>(BUCKET_CAPACITY);
list.add(bucket);
list.add(word);
fHashBuckets.put(hash, list);
@@ -408,7 +414,8 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
return true;
return false;
}
- final ArrayList candidateList= (ArrayList)candidates;
+ @SuppressWarnings("unchecked")
+ final ArrayList<String> candidateList= (ArrayList)candidates;
if (candidateList.contains(word) || candidateList.contains(word.toLowerCase()))
return true;
@@ -492,7 +499,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
word= reader.readLine();
decoder.onMalformedInput(CodingErrorAction.REPORT);
- String message= Messages.bind(Messages.AbstractSpellingDictionary_encodingError,
+ String message= NLS.bind(Messages.AbstractSpellingDictionary_encodingError,
new String[] { word, decoder.replacement(), url.toString() });
IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, message, ex);
CUIPlugin.log(status);
@@ -520,7 +527,7 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
}
} catch (IOException exception) {
if (line > 0) {
- String message= Messages.bind(Messages.AbstractSpellingDictionary_encodingError,
+ String message= NLS.bind(Messages.AbstractSpellingDictionary_encodingError,
String.valueOf(line), url.toString());
IStatus status= new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, IStatus.OK, message, exception);
CUIPlugin.log(status);
@@ -543,11 +550,11 @@ public abstract class AbstractSpellDictionary implements ISpellDictionary {
* Compacts the dictionary.
*/
private void compact() {
- Iterator iter= fHashBuckets.values().iterator();
+ Iterator<Serializable> iter= fHashBuckets.values().iterator();
while (iter.hasNext()) {
Object element= iter.next();
if (element instanceof ArrayList)
- ((ArrayList)element).trimToSize();
+ ((ArrayList<?>)element).trimToSize();
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java
index b51d3f3153d..33e926a5d5f 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultPhoneticHashProvider.java
@@ -142,9 +142,9 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
return false;
final String checkable= new String(token, offset, length);
- for (int index= 0; index < candidates.length; index++) {
+ for (String candidate : candidates) {
- if (candidates[index].equals(checkable))
+ if (candidate.equals(checkable))
return true;
}
return false;
@@ -162,9 +162,9 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
* candidates, <code>false</code> otherwise.
*/
protected static final boolean hasOneOf(final String[] candidates, final String token) {
- for (int index= 0; index < candidates.length; index++) {
+ for (String candidate : candidates) {
- if (token.indexOf(candidates[index]) >= 0)
+ if (token.indexOf(candidate) >= 0)
return true;
}
return false;
@@ -186,8 +186,8 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
protected static final boolean hasVowel(final char[] token, final int offset, final int length) {
if (offset >= 0 && offset < length) {
final char character= token[offset];
- for (int index= 0; index < VOWEL_CHARACTERS.length; index++) {
- if (VOWEL_CHARACTERS[index] == character)
+ for (char element : VOWEL_CHARACTERS) {
+ if (element == character)
return true;
}
}
@@ -291,12 +291,11 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
else
buffer.append('X');
offset += 3;
- break;
} else {
buffer.append('K');
offset += 2;
- break;
}
+ break;
}
if (hasOneOf(meta24, hashable, offset, 2)) {
buffer.append('K');
@@ -324,12 +323,11 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
if (hasOneOf(meta31, hashable, offset + 2, 1)) {
buffer.append('J');
offset += 3;
- break;
} else {
buffer.append("TK"); //$NON-NLS-1$
offset += 2;
- break;
}
+ break;
}
buffer.append('T');
if (hasOneOf(meta32, hashable, offset, 2)) {
@@ -364,7 +362,6 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
}
if ((offset > 1) && hasOneOf(meta33, hashable, offset - 2, 1) || ((offset > 2) && hasOneOf(meta34, hashable, offset - 3, 1)) || ((offset > 3) && hasOneOf(meta35, hashable, offset - 4, 1))) {
offset += 2;
- break;
} else {
if ((offset > 2) && (hashable[offset - 1] == 'U') && hasOneOf(meta36, hashable, offset - 3, 1)) {
buffer.append('F');
@@ -373,8 +370,8 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
buffer.append('K');
}
offset += 2;
- break;
}
+ break;
}
if (hashable[offset + 1] == 'N') {
if ((offset == 1) && hasVowel(hashable, 0, hashable.length) && !has95) {
@@ -553,7 +550,7 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
break;
}
if (hasOneOf(meta74, hashable, offset, 2)) {
- if (hashable[offset + 2] == 'H')
+ if (hashable[offset + 2] == 'H') {
if (hasOneOf(meta75, hashable, offset + 3, 2)) {
if (hasOneOf(meta76, hashable, offset + 3, 2)) {
buffer.append("X"); //$NON-NLS-1$
@@ -561,12 +558,12 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
buffer.append("SK"); //$NON-NLS-1$
}
offset += 3;
- break;
} else {
buffer.append('X');
offset += 3;
- break;
}
+ break;
+ }
if (hasOneOf(meta77, hashable, offset + 2, 1)) {
buffer.append('S');
offset += 3;
@@ -650,9 +647,8 @@ public final class DefaultPhoneticHashProvider implements IPhoneticHashProvider
buffer.append('J');
offset += 2;
break;
- } else {
- buffer.append('S');
}
+ buffer.append('S');
if (hashable[offset + 1] == 'Z')
offset += 2;
else
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java
index af279cd5805..009c104f0fb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/DefaultSpellChecker.java
@@ -101,8 +101,8 @@ public class DefaultSpellChecker implements ISpellChecker {
* otherwise
*/
protected static boolean isUrl(final String word) {
- for (int index= 0; index < URL_PREFIXES.length; index++) {
- if (word.startsWith(URL_PREFIXES[index]))
+ for (String element : URL_PREFIXES) {
+ if (word.startsWith(element))
return true;
}
return false;
@@ -112,18 +112,18 @@ public class DefaultSpellChecker implements ISpellChecker {
* The dictionaries to use for spell checking. Synchronized to avoid
* concurrent modifications.
*/
- private final Set fDictionaries= Collections.synchronizedSet(new HashSet());
+ private final Set<ISpellDictionary> fDictionaries= Collections.synchronizedSet(new HashSet<ISpellDictionary>());
/**
* The words to be ignored. Synchronized to avoid concurrent modifications.
*/
- private final Set fIgnored= Collections.synchronizedSet(new HashSet());
+ private final Set<String> fIgnored= Collections.synchronizedSet(new HashSet<String>());
/**
* The spell event listeners. Synchronized to avoid concurrent
* modifications.
*/
- private final Set fListeners= Collections.synchronizedSet(new HashSet());
+ private final Set<ISpellEventListener> fListeners= Collections.synchronizedSet(new HashSet<ISpellEventListener>());
/**
* The locale of this checker.
@@ -166,14 +166,14 @@ public class DefaultSpellChecker implements ISpellChecker {
// synchronizing might not be needed here since acceptWords is
// a read-only access and only called in the same thread as
// the modifying methods add/checkWord (?)
- Set copy;
+ Set<ISpellDictionary> copy;
synchronized (fDictionaries) {
- copy= new HashSet(fDictionaries);
+ copy= new HashSet<ISpellDictionary>(fDictionaries);
}
ISpellDictionary dictionary= null;
- for (final Iterator iterator= copy.iterator(); iterator.hasNext();) {
- dictionary= (ISpellDictionary) iterator.next();
+ for (final Iterator<ISpellDictionary> iterator= copy.iterator(); iterator.hasNext();) {
+ dictionary= iterator.next();
if (dictionary.acceptsWords())
return true;
}
@@ -185,14 +185,13 @@ public class DefaultSpellChecker implements ISpellChecker {
*/
public void addWord(final String word) {
// synchronizing is necessary as this is a write access
- Set copy;
+ Set<ISpellDictionary> copy;
synchronized (fDictionaries) {
- copy= new HashSet(fDictionaries);
+ copy= new HashSet<ISpellDictionary>(fDictionaries);
}
final String addable= word.toLowerCase();
- for (final Iterator iterator= copy.iterator(); iterator.hasNext();) {
- ISpellDictionary dictionary= (ISpellDictionary) iterator.next();
+ for (ISpellDictionary dictionary : copy) {
if (dictionary.acceptsWords())
dictionary.addWord(addable);
}
@@ -220,15 +219,15 @@ public class DefaultSpellChecker implements ISpellChecker {
iterator.setIgnoreSingleLetters(ignoreSingleLetters);
- Iterator iter= fDictionaries.iterator();
+ Iterator<ISpellDictionary> iter= fDictionaries.iterator();
while (iter.hasNext())
- ((ISpellDictionary) iter.next()).setStripNonLetters(ignoreNonLetters);
+ iter.next().setStripNonLetters(ignoreNonLetters);
String word= null;
boolean starts= false;
while (iterator.hasNext()) {
- word= (String) iterator.next();
+ word= iterator.next();
if (word != null) {
// synchronizing is necessary as this is called inside the reconciler
if (!fIgnored.contains(word)) {
@@ -258,32 +257,32 @@ public class DefaultSpellChecker implements ISpellChecker {
*/
protected final void fireEvent(final ISpellEvent event) {
// synchronizing is necessary as this is called from execute
- Set copy;
+ Set<ISpellEventListener> copy;
synchronized (fListeners) {
- copy= new HashSet(fListeners);
+ copy= new HashSet<ISpellEventListener>(fListeners);
}
- for (final Iterator iterator= copy.iterator(); iterator.hasNext();) {
- ((ISpellEventListener)iterator.next()).handle(event);
+ for (ISpellEventListener spellEventListener : copy) {
+ spellEventListener.handle(event);
}
}
/*
* @see org.eclipse.spelling.done.ISpellChecker#getProposals(java.lang.String,boolean)
*/
- public Set getProposals(final String word, final boolean sentence) {
+ public Set<RankedWordProposal> getProposals(final String word, final boolean sentence) {
// synchronizing might not be needed here since getProposals is
// a read-only access and only called in the same thread as
// the modifying methods add/removeDictionary (?)
- Set copy;
+ Set<ISpellDictionary> copy;
synchronized (fDictionaries) {
- copy= new HashSet(fDictionaries);
+ copy= new HashSet<ISpellDictionary>(fDictionaries);
}
ISpellDictionary dictionary= null;
- final HashSet proposals= new HashSet();
+ final HashSet<RankedWordProposal> proposals= new HashSet<RankedWordProposal>();
- for (final Iterator iterator= copy.iterator(); iterator.hasNext();) {
- dictionary= (ISpellDictionary)iterator.next();
+ for (final Iterator<ISpellDictionary> iterator= copy.iterator(); iterator.hasNext();) {
+ dictionary= iterator.next();
proposals.addAll(dictionary.getProposals(word, sentence));
}
return proposals;
@@ -302,17 +301,17 @@ public class DefaultSpellChecker implements ISpellChecker {
*/
public final boolean isCorrect(final String word) {
// synchronizing is necessary as this is called from execute
- Set copy;
+ Set<ISpellDictionary> copy;
synchronized (fDictionaries) {
- copy= new HashSet(fDictionaries);
+ copy= new HashSet<ISpellDictionary>(fDictionaries);
}
if (fIgnored.contains(word.toLowerCase()))
return true;
ISpellDictionary dictionary= null;
- for (final Iterator iterator= copy.iterator(); iterator.hasNext();) {
- dictionary= (ISpellDictionary) iterator.next();
+ for (final Iterator<ISpellDictionary> iterator= copy.iterator(); iterator.hasNext();) {
+ dictionary= iterator.next();
if (dictionary.isCorrect(word))
return true;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java
index 71e814eee85..d717d8db761 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellCheckIterator.java
@@ -17,7 +17,7 @@ import java.util.Iterator;
/**
* Interface for iterators used for spell checking.
*/
-public interface ISpellCheckIterator extends Iterator {
+public interface ISpellCheckIterator extends Iterator<String> {
/**
* Returns the begin index (inclusive) of the current word.
*
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellChecker.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellChecker.java
index 7e8134bbbb8..3782f9ff582 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellChecker.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellChecker.java
@@ -71,7 +71,7 @@ public interface ISpellChecker {
* sentence, <code>false</code> otherwise
* @return Set of ranked proposals for the word
*/
- Set getProposals(String word, boolean sentence);
+ Set<RankedWordProposal> getProposals(String word, boolean sentence);
/**
* Ignores the specified word until calling <code>checkWord(String)</code>.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellDictionary.java
index df4e4ebe076..4f9d23eccc1 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellDictionary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellDictionary.java
@@ -40,7 +40,7 @@ public interface ISpellDictionary {
* <code>false</code> otherwise
* @return Array of ranked word proposals
*/
- public Set getProposals(String word, boolean sentence);
+ public Set<RankedWordProposal> getProposals(String word, boolean sentence);
/**
* Is the specified word correctly spelled?
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellEvent.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellEvent.java
index e1703d9cc25..8616ac58f4c 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellEvent.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/ISpellEvent.java
@@ -38,7 +38,7 @@ public interface ISpellEvent {
*
* @return Array of proposals for the word
*/
- public Set getProposals();
+ public Set<RankedWordProposal> getProposals();
/**
* Returns the incorrectly spelled word.
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java
index 88c7f9e8634..e911704fc27 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/PersistentSpellDictionary.java
@@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.text.spelling.engine;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.io.OutputStreamWriter;
import java.net.URL;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
@@ -53,7 +52,7 @@ public class PersistentSpellDictionary extends AbstractSpellDictionary {
if (isCorrect(word))
return;
- OutputStreamWriter writer= null;
+ FileOutputStream fileStream= null;
try {
Charset charset= Charset.forName(getEncoding());
ByteBuffer byteBuffer= charset.encode(word + "\n"); //$NON-NLS-1$
@@ -66,7 +65,7 @@ public class PersistentSpellDictionary extends AbstractSpellDictionary {
byteBuffer.get(byteArray);
}
- FileOutputStream fileStream= new FileOutputStream(fLocation.getPath(), true);
+ fileStream= new FileOutputStream(fLocation.getPath(), true);
// Encoding UTF-16 charset writes a BOM. In which case we need to cut it away if the file isn't empty
int bomCutSize= 0;
@@ -79,8 +78,8 @@ public class PersistentSpellDictionary extends AbstractSpellDictionary {
return;
} finally {
try {
- if (writer != null)
- writer.close();
+ if (fileStream != null)
+ fileStream.close();
} catch (IOException e) {
}
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordProposal.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordProposal.java
index 480f3da11cf..1d931b32a9d 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordProposal.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/RankedWordProposal.java
@@ -15,7 +15,7 @@ package org.eclipse.cdt.internal.ui.text.spelling.engine;
/**
* Ranked word proposal for quick fix and content assist.
*/
-public class RankedWordProposal implements Comparable {
+public class RankedWordProposal implements Comparable<RankedWordProposal> {
/** The word rank */
private int fRank;
@@ -36,9 +36,8 @@ public class RankedWordProposal implements Comparable {
/*
* @see java.lang.Comparable#compareTo(java.lang.Object)
*/
- public final int compareTo(Object object) {
+ public final int compareTo(RankedWordProposal word) {
- final RankedWordProposal word= (RankedWordProposal)object;
final int rank= word.getRank();
if (fRank < rank)
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/SpellEvent.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/SpellEvent.java
index 08d55121b4b..d143dd29eb6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/SpellEvent.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/spelling/engine/SpellEvent.java
@@ -74,7 +74,7 @@ public class SpellEvent implements ISpellEvent {
/*
* @see org.eclipse.cdt.internal.ui.text.spelling.engine.ISpellEvent#getProposals()
*/
- public final Set getProposals() {
+ public final Set<RankedWordProposal> getProposals() {
return fChecker.getProposals(fWord, fSentence);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java
index 46f040cb31e..7db1cfcc144 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateEngine.java
@@ -14,7 +14,6 @@ package org.eclipse.cdt.internal.ui.text.template;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -28,6 +27,7 @@ import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Position;
import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.templates.GlobalTemplateVariables;
import org.eclipse.jface.text.templates.Template;
import org.eclipse.jface.text.templates.TemplateContext;
@@ -58,9 +58,9 @@ public class TemplateEngine {
/** The context type. */
private TemplateContextType fContextType;
/** The result proposals. */
- private ArrayList fProposals= new ArrayList();
+ private ArrayList<ICompletionProposal> fProposals= new ArrayList<ICompletionProposal>();
/** Positions created on the key documents to remove in reset. */
- private final Map fPositions= new HashMap();
+ private final Map<IDocument, Position> fPositions= new HashMap<IDocument, Position>();
public class CTemplateProposal extends TemplateProposal implements ICCompletionProposal {
@@ -116,10 +116,10 @@ public class TemplateEngine {
*/
public void reset() {
fProposals.clear();
- for (Iterator it= fPositions.entrySet().iterator(); it.hasNext();) {
- Entry entry= (Entry) it.next();
- IDocument doc= (IDocument) entry.getKey();
- Position position= (Position) entry.getValue();
+ for (Entry<IDocument, Position> entry2 : fPositions.entrySet()) {
+ Entry<IDocument, Position> entry= entry2;
+ IDocument doc= entry.getKey();
+ Position position= entry.getValue();
doc.removePosition(position);
}
fPositions.clear();
@@ -128,7 +128,7 @@ public class TemplateEngine {
/**
* Returns the array of matching templates.
*/
- public List getResults() {
+ public List<ICompletionProposal> getResults() {
//return (TemplateProposal[]) fProposals.toArray(new TemplateProposal[fProposals.size()]);
return fProposals;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java
index 0024adcce0f..55dabd095f6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/template/TemplateVariableProcessor.java
@@ -29,12 +29,9 @@ import org.eclipse.jface.text.templates.TemplateVariableResolver;
public class TemplateVariableProcessor implements IContentAssistProcessor {
- private static Comparator fgTemplateVariableProposalComparator= new Comparator() {
- public int compare(Object arg0, Object arg1) {
- TemplateVariableProposal proposal0= (TemplateVariableProposal) arg0;
- TemplateVariableProposal proposal1= (TemplateVariableProposal) arg1;
-
- return proposal0.getDisplayString().compareTo(proposal1.getDisplayString());
+ private static Comparator<TemplateVariableProposal> fgTemplateVariableProposalComparator= new Comparator<TemplateVariableProposal>() {
+ public int compare(TemplateVariableProposal arg0, TemplateVariableProposal arg1) {
+ return arg0.getDisplayString().compareTo(arg1.getDisplayString());
}
@Override
@@ -73,7 +70,7 @@ public class TemplateVariableProcessor implements IContentAssistProcessor {
if (fContextType == null)
return null;
- List proposals= new ArrayList();
+ List<TemplateVariableProposal> proposals= new ArrayList<TemplateVariableProposal>();
String text= viewer.getDocument().get();
int start= getStart(text, documentOffset);
@@ -101,15 +98,17 @@ public class TemplateVariableProcessor implements IContentAssistProcessor {
int length= end - offset;
- for (Iterator iterator= fContextType.resolvers(); iterator.hasNext(); ) {
- TemplateVariableResolver variable= (TemplateVariableResolver) iterator.next();
+ @SuppressWarnings("unchecked")
+ final Iterator<TemplateVariableResolver> resolvers = fContextType.resolvers();
+ while (resolvers.hasNext()) {
+ TemplateVariableResolver variable= resolvers.next();
if (variable.getType().startsWith(prefix))
proposals.add(new TemplateVariableProposal(variable, offset, length, viewer, includeBrace));
}
Collections.sort(proposals, fgTemplateVariableProposalComparator);
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
+ return proposals.toArray(new ICompletionProposal[proposals.size()]);
}
/* Guesses the start position of the completion */
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java
index 74ebdde95a8..1d91d3fd1ed 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/util/CColorManager.java
@@ -12,8 +12,6 @@
*******************************************************************************/
package org.eclipse.cdt.internal.ui.text.util;
-import org.eclipse.cdt.internal.ui.text.IColorManager;
-import org.eclipse.cdt.internal.ui.text.IColorManagerExtension;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -22,13 +20,16 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.cdt.internal.ui.text.IColorManager;
+import org.eclipse.cdt.internal.ui.text.IColorManagerExtension;
+
/**
* CDT color manager.
*/
public class CColorManager implements IColorManager, IColorManagerExtension {
- protected Map fKeyTable= new HashMap(10);
- protected Map fDisplayTable= new HashMap(2);
+ protected Map<String, RGB> fKeyTable= new HashMap<String, RGB>(10);
+ protected Map<Display, Map<RGB, Color>> fDisplayTable= new HashMap<Display, Map<RGB, Color>>(2);
/**
* Flag which tells if the colors are automatically disposed when
@@ -59,11 +60,11 @@ public class CColorManager implements IColorManager, IColorManagerExtension {
}
protected void dispose(Display display) {
- Map colorTable= (Map) fDisplayTable.get(display);
+ Map<RGB, Color> colorTable= fDisplayTable.get(display);
if (colorTable != null) {
- Iterator e= colorTable.values().iterator();
+ Iterator<Color> e= colorTable.values().iterator();
while (e.hasNext())
- ((Color) e.next()).dispose();
+ (e.next()).dispose();
}
}
@@ -76,9 +77,9 @@ public class CColorManager implements IColorManager, IColorManagerExtension {
return null;
final Display display= Display.getCurrent();
- Map colorTable= (Map) fDisplayTable.get(display);
+ Map<RGB, Color> colorTable= fDisplayTable.get(display);
if (colorTable == null) {
- colorTable= new HashMap(10);
+ colorTable= new HashMap<RGB, Color>(10);
fDisplayTable.put(display, colorTable);
if (fAutoDisposeOnDisplayDispose) {
display.disposeExec(new Runnable() {
@@ -89,7 +90,7 @@ public class CColorManager implements IColorManager, IColorManagerExtension {
}
}
- Color color= (Color) colorTable.get(rgb);
+ Color color= colorTable.get(rgb);
if (color == null) {
color= new Color(Display.getCurrent(), rgb);
colorTable.put(rgb, color);
@@ -114,7 +115,7 @@ public class CColorManager implements IColorManager, IColorManagerExtension {
if (key == null)
return null;
- RGB rgb= (RGB) fKeyTable.get(key);
+ RGB rgb= fKeyTable.get(key);
return getColor(rgb);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java
index 21732c05416..06896e4ed66 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/typehierarchy/THHistoryListAction.java
@@ -41,7 +41,7 @@ public class THHistoryListAction extends Action {
private class HistoryListDialog extends StatusDialog {
- private ListDialogField fHistoryList;
+ private ListDialogField<ICElement> fHistoryList;
private IStatus fHistoryStatus;
private ICElement fResult;
@@ -53,22 +53,22 @@ public class THHistoryListAction extends Action {
Messages.THHistoryListAction_Remove,
};
- IListAdapter adapter= new IListAdapter() {
- public void customButtonPressed(ListDialogField field, int index) {
+ IListAdapter<ICElement> adapter= new IListAdapter<ICElement>() {
+ public void customButtonPressed(ListDialogField<ICElement> field, int index) {
doCustomButtonPressed();
}
- public void selectionChanged(ListDialogField field) {
+ public void selectionChanged(ListDialogField<ICElement> field) {
doSelectionChanged();
}
- public void doubleClicked(ListDialogField field) {
+ public void doubleClicked(ListDialogField<ICElement> field) {
doDoubleClicked();
}
};
LabelProvider labelProvider= new CUILabelProvider(THHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS);
- fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider);
+ fHistoryList= new ListDialogField<ICElement>(adapter, buttonLabels, labelProvider);
fHistoryList.setLabelText(Messages.THHistoryListAction_HistoryList_label);
fHistoryList.setElements(Arrays.asList(historyEntries));
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java
index 56210f11473..b49caba30a6 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/wizards/dialogfields/CheckedListDialogField.java
@@ -31,16 +31,16 @@ import org.eclipse.swt.widgets.Table;
* List model is independend of widget creation.
* DialogFields controls are: Label, List and Composite containing buttons.
*/
-public class CheckedListDialogField extends ListDialogField {
+public class CheckedListDialogField<T> extends ListDialogField<T> {
private int fCheckAllButtonIndex;
private int fUncheckAllButtonIndex;
- private List fCheckElements;
+ private List<T> fCheckElements;
- public CheckedListDialogField(IListAdapter adapter, String[] customButtonLabels, IBaseLabelProvider lprovider) {
+ public CheckedListDialogField(IListAdapter<T> adapter, String[] customButtonLabels, IBaseLabelProvider lprovider) {
super(adapter, customButtonLabels, lprovider);
- fCheckElements= new ArrayList();
+ fCheckElements= new ArrayList<T>();
fCheckAllButtonIndex= -1;
fUncheckAllButtonIndex= -1;
@@ -117,8 +117,8 @@ public class CheckedListDialogField extends ListDialogField {
/**
* Gets the checked elements.
*/
- public List getCheckedElements() {
- return new ArrayList(fCheckElements);
+ public List<T> getCheckedElements() {
+ return new ArrayList<T>(fCheckElements);
}
/**
@@ -138,8 +138,8 @@ public class CheckedListDialogField extends ListDialogField {
/**
* Sets the checked elements.
*/
- public void setCheckedElements(Collection list) {
- fCheckElements= new ArrayList(list);
+ public void setCheckedElements(Collection<T> list) {
+ fCheckElements= new ArrayList<T>(list);
if (fTable != null) {
((CheckboxTableViewer)fTable).setCheckedElements(list.toArray());
}
@@ -149,7 +149,7 @@ public class CheckedListDialogField extends ListDialogField {
/**
* Sets the checked state of an element.
*/
- public void setChecked(Object object, boolean state) {
+ public void setChecked(T object, boolean state) {
setCheckedWithoutUpdate(object, state);
checkStateChanged();
}
@@ -157,7 +157,7 @@ public class CheckedListDialogField extends ListDialogField {
/**
* Sets the checked state of an element. No dialog changed listener is informed.
*/
- public void setCheckedWithoutUpdate(Object object, boolean state) {
+ public void setCheckedWithoutUpdate(T object, boolean state) {
if (state) {
if (!fCheckElements.contains(object)) {
fCheckElements.add(object);
@@ -188,7 +188,9 @@ public class CheckedListDialogField extends ListDialogField {
void doCheckStateChanged(CheckStateChangedEvent e) {
if (e.getChecked()) {
- fCheckElements.add(e.getElement());
+ @SuppressWarnings("unchecked")
+ T elem= (T) e.getElement();
+ fCheckElements.add(elem);
} else {
fCheckElements.remove(e.getElement());
}
@@ -199,7 +201,7 @@ public class CheckedListDialogField extends ListDialogField {
* @see org.eclipse.jdt.internal.ui.wizards.dialogfields.ListDialogField#replaceElement(java.lang.Object, java.lang.Object)
*/
@Override
- public void replaceElement(Object oldElement, Object newElement) throws IllegalArgumentException {
+ public void replaceElement(T oldElement, T newElement) throws IllegalArgumentException {
boolean wasChecked= isChecked(oldElement);
super.replaceElement(oldElement, newElement);
setChecked(newElement, wasChecked);

Back to the top