diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java index 88147b3f600..2c3dfde4de2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchQuery.java @@ -112,8 +112,8 @@ public abstract class CSearchQuery implements ISearchQuery { } projects = ArrayUtil.removeNulls(ICProject.class, allProjects); } else { - Map projectMap = new HashMap(); - Set pathFilter = new HashSet(); + Map projectMap = new HashMap<>(); + Set pathFilter = new HashSet<>(); boolean needFilter= false; for (int i = 0; i < scope.length; ++i) { ICProject project = scope[i].getCProject(); @@ -195,8 +195,7 @@ public abstract class CSearchQuery implements ISearchQuery { label, scope); } - String countLabel = Messages.format(CSearchMessages.CSearchResultCollector_matches, - new Integer(matchCount)); + String countLabel = Messages.format(CSearchMessages.CSearchResultCollector_matches, matchCount); return label + " " + countLabel; //$NON-NLS-1$ } @@ -238,7 +237,7 @@ public abstract class CSearchQuery implements ISearchQuery { IIndexFile file = name.getFile(); Set matches = fileMatches.get(file); if (matches == null) { - matches = new HashSet(); + matches = new HashSet<>(); fileMatches.put(file, matches); } int nodeOffset = loc.getNodeOffset(); @@ -269,7 +268,7 @@ public abstract class CSearchQuery implements ISearchQuery { long timestamp = file.getTimestamp(); IPositionConverter converter = CCorePlugin.getPositionTrackerManager().findPositionConverter(path, timestamp); if (converter != null) { - Set convertedMatches = new HashSet(); + Set convertedMatches = new HashSet<>(); for (Match match : matches) { IRegion region = new Region(match.getOffset(), match.getLength()); region = converter.historicToActual(region); @@ -288,12 +287,12 @@ public abstract class CSearchQuery implements ISearchQuery { private void collectNames(IIndex index, Collection names, Collection polymorphicNames) throws CoreException { // group all matched names by files - Map> fileMatches = new HashMap>(); + Map> fileMatches = new HashMap<>(); createMatchesFromNames(index, fileMatches, names, false); createMatchesFromNames(index, fileMatches, polymorphicNames, true); // compute mapping from paths to dirty text editors IEditorPart[] dirtyEditors = CUIPlugin.getDirtyEditors(); - Map pathsDirtyEditors = new HashMap(); + Map pathsDirtyEditors = new HashMap<>(); for (IEditorPart editorPart : dirtyEditors) { if (editorPart instanceof ITextEditor) { ITextEditor textEditor = (ITextEditor)editorPart; @@ -348,9 +347,9 @@ public abstract class CSearchQuery implements ISearchQuery { protected void createMatches(IIndex index, IBinding[] bindings) throws CoreException { if (bindings == null) return; - List names= new ArrayList(); + List names= new ArrayList<>(); List polymorphicNames= null; - HashSet handled= new HashSet(); + HashSet handled= new HashSet<>(); for (IBinding binding : bindings) { if (binding != null && handled.add(binding)) { @@ -374,7 +373,7 @@ public abstract class CSearchQuery implements ISearchQuery { ICPPMethod[] msInBases = ClassTypeHelper.findOverridden(m, point); if (msInBases.length > 0) { if (polymorphicNames == null) { - polymorphicNames= new ArrayList(); + polymorphicNames= new ArrayList<>(); } for (ICPPMethod mInBase : msInBases) { if (mInBase != null && handled.add(mInBase)) { @@ -425,13 +424,13 @@ public abstract class CSearchQuery implements ISearchQuery { protected void createLocalMatches(IASTTranslationUnit ast, IBinding binding) throws CoreException { if (binding != null) { - Set names= new HashSet(); + Set names= new HashSet<>(); names.addAll(Arrays.asList(ast.getDeclarationsInAST(binding))); names.addAll(Arrays.asList(ast.getDefinitionsInAST(binding))); names.addAll(Arrays.asList(ast.getReferences(binding))); // Collect local matches from AST IIndexFileLocation fileLocation = null; - Set localMatches = new HashSet(); + Set localMatches = new HashSet<>(); for (IASTName name : names) { if (((flags & FIND_DECLARATIONS) != 0 && name.isDeclaration()) || ((flags & FIND_DEFINITIONS) != 0 && name.isDefinition()) || diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java index 047a94bd09d..88b9d259579 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/CSearchResult.java @@ -112,7 +112,7 @@ public class CSearchResult extends AbstractTextSearchResult implements IEditorMa private Match[] computeContainedMatches(AbstractTextSearchResult result, String filename) throws CoreException { IPath pfilename= new Path(filename); - List list = new ArrayList(); + List list = new ArrayList<>(); Object[] elements = result.getElements(); for (int i = 0; i < elements.length; ++i) { if (pfilename.equals(IndexLocationFactory.getAbsolutePath(((CSearchElement) elements[i]).getLocation()))) {