diff options
| author | Lars Vogel | 2013-04-25 09:27:26 +0000 |
|---|---|---|
| committer | Dani Megert | 2013-04-25 09:27:26 +0000 |
| commit | 2d5bd8929f145ed59de22ea994964a0089c817e3 (patch) | |
| tree | be72e501b8356a06ef1d6912d73c0c9e7600080e | |
| parent | 82e7a99c8429022aaab5edd6cdaa0b55d97f74df (diff) | |
| download | eclipse.jdt.ui-2d5bd8929f145ed59de22ea994964a0089c817e3.tar.gz eclipse.jdt.ui-2d5bd8929f145ed59de22ea994964a0089c817e3.tar.xz eclipse.jdt.ui-2d5bd8929f145ed59de22ea994964a0089c817e3.zip | |
Fixed bug 406478: [implementation][content assist] Use enhanced for loop for CompletionProposalCollector and CompletionProposalCategory
2 files changed, 19 insertions, 32 deletions
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalCategory.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalCategory.java index 80156dfa33..3772a87191 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalCategory.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/CompletionProposalCategory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. + * Copyright (c) 2005, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,12 +9,12 @@ * IBM Corporation - initial API and implementation * Paul Fullbright <paul.fullbright@oracle.com> - content assist category enablement - http://bugs.eclipse.org/345213 * Marcel Bruch <bruch@cs.tu-darmstadt.de> - [content assist] Allow to re-sort proposals - https://bugs.eclipse.org/bugs/show_bug.cgi?id=350991 + * Lars Vogel <lars.vogel@gmail.com> - convert to foreach loop - https://bugs.eclipse.org/bugs/show_bug.cgi?id=406478 *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.java; import java.net.URL; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.osgi.framework.Bundle; @@ -249,8 +249,7 @@ public final class CompletionProposalCategory { */ public boolean hasComputers() { List<CompletionProposalComputerDescriptor> descriptors= fRegistry.getProposalComputerDescriptors(); - for (Iterator<CompletionProposalComputerDescriptor> it= descriptors.iterator(); it.hasNext();) { - CompletionProposalComputerDescriptor desc= it.next(); + for (CompletionProposalComputerDescriptor desc : descriptors) { if (desc.getCategory() == this) return true; } @@ -267,8 +266,7 @@ public final class CompletionProposalCategory { */ public boolean hasComputers(String partition) { List<CompletionProposalComputerDescriptor> descriptors= fRegistry.getProposalComputerDescriptors(partition); - for (Iterator<CompletionProposalComputerDescriptor> it= descriptors.iterator(); it.hasNext();) { - CompletionProposalComputerDescriptor desc= it.next(); + for (CompletionProposalComputerDescriptor desc : descriptors) { if (desc.getCategory() == this) return true; } @@ -334,8 +332,7 @@ public final class CompletionProposalCategory { fLastError= null; List<ICompletionProposal> result= new ArrayList<ICompletionProposal>(); List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors(partition)); - for (Iterator<CompletionProposalComputerDescriptor> it= descriptors.iterator(); it.hasNext();) { - CompletionProposalComputerDescriptor desc= it.next(); + for (CompletionProposalComputerDescriptor desc : descriptors) { if (desc.getCategory() == this) result.addAll(desc.computeCompletionProposals(context, monitor)); if (fLastError == null && desc.getErrorMessage() != null) @@ -359,8 +356,7 @@ public final class CompletionProposalCategory { fLastError= null; List<IContextInformation> result= new ArrayList<IContextInformation>(); List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors(partition)); - for (Iterator<CompletionProposalComputerDescriptor> it= descriptors.iterator(); it.hasNext();) { - CompletionProposalComputerDescriptor desc= it.next(); + for (CompletionProposalComputerDescriptor desc : descriptors) { if (desc.getCategory() == this && (isIncluded() || isSeparateCommand())) result.addAll(desc.computeContextInformation(context, monitor)); if (fLastError == null) @@ -383,9 +379,8 @@ public final class CompletionProposalCategory { */ public void sessionStarted() { List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors()); - for (Iterator<CompletionProposalComputerDescriptor> it= descriptors.iterator(); it.hasNext();) { - CompletionProposalComputerDescriptor desc= it.next(); - if (desc.getCategory() == this){ + for (CompletionProposalComputerDescriptor desc : descriptors) { + if (desc.getCategory() == this) { desc.sessionStarted(); fNeedsSortingAfterFiltering= fNeedsSortingAfterFiltering || desc.isSortingAfterFilteringNeeded(); } @@ -400,8 +395,7 @@ public final class CompletionProposalCategory { public void sessionEnded() { fNeedsSortingAfterFiltering= false; List<CompletionProposalComputerDescriptor> descriptors= new ArrayList<CompletionProposalComputerDescriptor>(fRegistry.getProposalComputerDescriptors()); - for (Iterator<CompletionProposalComputerDescriptor> it= descriptors.iterator(); it.hasNext();) { - CompletionProposalComputerDescriptor desc= it.next(); + for (CompletionProposalComputerDescriptor desc : descriptors) { if (desc.getCategory() == this) desc.sessionEnded(); if (fLastError == null) diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java index ab46c95f51..d046d76401 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/ContentAssistProcessor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2012 IBM Corporation and others. + * Copyright (c) 2005, 2013 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -9,6 +9,7 @@ * IBM Corporation - initial API and implementation * Paul Fullbright <paul.fullbright@oracle.com> - content assist category enablement - http://bugs.eclipse.org/345213 * Marcel Bruch <bruch@cs.tu-darmstadt.de> - [content assist] Allow to re-sort proposals - https://bugs.eclipse.org/bugs/show_bug.cgi?id=350991 + * Lars Vogel <lars.vogel@gmail.com> - convert to foreach loop - https://bugs.eclipse.org/bugs/show_bug.cgi?id=406478 *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.java; @@ -114,8 +115,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor { // This may show the warning dialog if all categories are disabled setCategoryIteration(); - for (Iterator<CompletionProposalCategory> it= getCategoriesToNotify().iterator(); it.hasNext();) { - CompletionProposalCategory cat= it.next(); + for (CompletionProposalCategory cat : getCategoriesToNotify()) { cat.sessionStarted(); } @@ -157,8 +157,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor { } // Backwards compatibility: notify all categories which have no enablement expression - for (Iterator<CompletionProposalCategory> it= fCategories.iterator(); it.hasNext();) { - CompletionProposalCategory cat= it.next(); + for (CompletionProposalCategory cat : fCategories) { if (cat.getEnablementExpression() == null) currentCategories.add(cat); } @@ -173,8 +172,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor { if (event.processor != ContentAssistProcessor.this) return; - for (Iterator<CompletionProposalCategory> it= getCategoriesToNotify().iterator(); it.hasNext();) { - CompletionProposalCategory cat= it.next(); + for (CompletionProposalCategory cat : getCategoriesToNotify()) { cat.sessionEnded(); } @@ -323,8 +321,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor { boolean needsSortingAfterFiltering= false; List<ICompletionProposal> proposals= new ArrayList<ICompletionProposal>(); List<CompletionProposalCategory> providers= getCategories(); - for (Iterator<CompletionProposalCategory> it= providers.iterator(); it.hasNext();) { - CompletionProposalCategory cat= it.next(); + for (CompletionProposalCategory cat : providers) { List<ICompletionProposal> computed= cat.computeCompletionProposals(context, fPartition, new SubProgressMonitor(monitor, 1)); proposals.addAll(computed); needsSortingAfterFiltering= needsSortingAfterFiltering || (cat.isSortingAfterFilteringNeeded() && !computed.isEmpty()); @@ -378,8 +375,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor { ContentAssistInvocationContext context= createContext(viewer, offset); List<CompletionProposalCategory> providers= getCategories(); - for (Iterator<CompletionProposalCategory> it= providers.iterator(); it.hasNext();) { - CompletionProposalCategory cat= it.next(); + for (CompletionProposalCategory cat : providers) { List<IContextInformation> computed= cat.computeContextInformation(context, fPartition, new SubProgressMonitor(monitor, 1)); proposals.addAll(computed); if (fErrorMessage == null) @@ -494,8 +490,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor { private List<List<CompletionProposalCategory>> getCategoryIteration() { List<List<CompletionProposalCategory>> sequence= new ArrayList<List<CompletionProposalCategory>>(); sequence.add(getDefaultCategories()); - for (Iterator<CompletionProposalCategory> it= getSeparateCategories().iterator(); it.hasNext();) { - CompletionProposalCategory cat= it.next(); + for (CompletionProposalCategory cat : getSeparateCategories()) { sequence.add(Collections.singletonList(cat)); } return sequence; @@ -517,8 +512,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor { private List<CompletionProposalCategory> getDefaultCategoriesUnchecked() { List<CompletionProposalCategory> included= new ArrayList<CompletionProposalCategory>(); - for (Iterator<CompletionProposalCategory> it= fCategories.iterator(); it.hasNext();) { - CompletionProposalCategory category= it.next(); + for (CompletionProposalCategory category : fCategories) { if (checkDefaultEnablement(category)) included.add(category); } @@ -623,8 +617,7 @@ public class ContentAssistProcessor implements IContentAssistProcessor { private List<CompletionProposalCategory> getSeparateCategories() { ArrayList<CompletionProposalCategory> sorted= new ArrayList<CompletionProposalCategory>(); - for (Iterator<CompletionProposalCategory> it= fCategories.iterator(); it.hasNext();) { - CompletionProposalCategory category= it.next(); + for (CompletionProposalCategory category : fCategories) { if (checkSeparateEnablement(category)) sorted.add(category); } |
