diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java index 2cca0472454..7b9ab93f919 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsJob.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009, 2012 Wind River Systems, Inc. and others. + * Copyright (c) 2009, 2014 Wind River Systems, Inc. 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 @@ -259,7 +259,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { while (declNames.length == 0 && binding instanceof ICPPSpecialization) { binding = ((ICPPSpecialization) binding).getSpecializedBinding(); if (binding != null && !(binding instanceof IProblemBinding)) { - declNames = findNames(fIndex, ast, NameKind.DEFINITION, binding); + declNames = findNames(fIndex, ast, NameKind.REFERENCE, binding); } } if (declNames.length == 0 && binding instanceof ICPPMethod) { @@ -280,12 +280,12 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { if (kind == NameKind.DEFINITION) { declNames= findDeclarations(index, ast, binding); } else { - declNames= findDefinitions(index, ast, kind, binding); + declNames= findDefinitions(index, ast, binding); } if (declNames.length == 0) { if (kind == NameKind.DEFINITION) { - declNames= findDefinitions(index, ast, kind, binding); + declNames= findDefinitions(index, ast, binding); } else { declNames= findDeclarations(index, ast, binding); } @@ -293,8 +293,8 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { return declNames; } - private IName[] findDefinitions(IIndex index, IASTTranslationUnit ast, NameKind kind, IBinding binding) throws CoreException { - List declNames= new ArrayList(); + private IName[] findDefinitions(IIndex index, IASTTranslationUnit ast, IBinding binding) throws CoreException { + List declNames= new ArrayList<>(); declNames.addAll(Arrays.asList(ast.getDefinitionsInAST(binding))); for (Iterator i = declNames.iterator(); i.hasNext();) { IASTName name= i.next(); @@ -333,7 +333,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { astNames[i]= null; } else if (CPPVisitor.findAncestorWithType(name, ICPPASTUsingDeclaration.class) != null) { if (usingDeclarations == null) - usingDeclarations = new ArrayList(1); + usingDeclarations = new ArrayList<>(1); usingDeclarations.add(name); astNames[i]= null; } @@ -483,7 +483,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { } private boolean navigateViaCElements(ICProject project, IIndex index, IName[] declNames) { - final ArrayList elements= new ArrayList(); + final ArrayList elements= new ArrayList<>(); convertToCElements(project, index, declNames, elements); return navigateCElements(elements); } @@ -498,10 +498,10 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { uniqueElements= elements; } else { // Make sure only one element per location is proposed - Set sigs= new HashSet(); + Set sigs= new HashSet<>(); sigs.add(null); - uniqueElements= new ArrayList(); + uniqueElements= new ArrayList<>(); for (ICElement elem : elements) { if (sigs.add(getLocationSignature((ISourceReference) elem))) { uniqueElements.add(elem); @@ -636,10 +636,10 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { try { final ICProject project = fTranslationUnit.getCProject(); final char[] name = fSelectedText.toCharArray(); - List elems= new ArrayList(); + List elems= new ArrayList<>(); // Bug 252549, search for names in the AST first. - Set primaryBindings= new HashSet(); + Set primaryBindings= new HashSet<>(); ASTNameCollector nc= new ASTNameCollector(fSelectedText); ast.accept(nc); IASTName[] candidates= nc.getNames(); @@ -743,7 +743,7 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { } private Collection cppRemoveSecondaryBindings(Set primaryBindings, IASTName sourceName) { - List result= new ArrayList(); + List result= new ArrayList<>(); String[] sourceQualifiedName= null; int funcArgCount= -1; if (sourceName != null) { @@ -768,8 +768,8 @@ class OpenDeclarationsJob extends Job implements ASTRunnable { continue; } } - if (funcArgCount != -1) { - // For c++ we can check the number of parameters. + if (funcArgCount >= 0) { + // For C++ we can check the number of parameters. if (binding instanceof ICPPFunction) { ICPPFunction f= (ICPPFunction) binding; if (f.getRequiredArgumentCount() > funcArgCount) {