diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceScope.java index 7739a98f88b..e53ca360bb9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespaceScope.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2004, 2013 IBM Corporation and others. + * Copyright (c) 2004, 2014 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 @@ -81,7 +81,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace private void initUsingDirectives() { if (fUsingDirectives == null) { - fUsingDirectives= new ArrayList(1); + fUsingDirectives= new ArrayList<>(1); // Insert a using directive for every inline namespace found in the index. for (ICPPInternalNamespaceScope inline : getIndexInlineNamespaces()) { if (!(inline instanceof CPPNamespaceScope)) { @@ -107,7 +107,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace } public IScope findNamespaceScope(IIndexScope scope) { - final ArrayList parentChain = new ArrayList(); + final ArrayList parentChain = new ArrayList<>(); for (IBinding binding= scope.getScopeBinding(); binding != null; binding= binding.getOwner()) { parentChain.add(binding); } @@ -260,7 +260,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace populateCache(); Set result= null; if (fInlineNamespaceDefinitions != null) { - result= new HashSet(fInlineNamespaceDefinitions.size()); + result= new HashSet<>(fInlineNamespaceDefinitions.size()); for (ICPPASTNamespaceDefinition nsdef : fInlineNamespaceDefinitions) { final IScope scope = nsdef.getScope(); if (scope instanceof ICPPInternalNamespaceScope) { @@ -271,7 +271,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace for (ICPPInternalNamespaceScope inline : getIndexInlineNamespaces()) { if (result == null) - result = new HashSet(); + result = new HashSet<>(); result.add(inline); } @@ -284,7 +284,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace private ICPPInternalNamespaceScope[] getIndexInlineNamespaces() { IASTTranslationUnit tu= getPhysicalNode().getTranslationUnit(); if (tu instanceof CPPASTTranslationUnit) { - CPPASTTranslationUnit cpptu= (CPPASTTranslationUnit) tu; + CPPASTTranslationUnit ast= (CPPASTTranslationUnit) tu; IIndex index= tu.getIndex(); if (index != null) { IScope[] inlineScopes= null; @@ -301,12 +301,10 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace if (inlineScopes != null) { List result= null; for (IScope scope : inlineScopes) { - if (scope instanceof IIndexScope) { - scope= cpptu.mapToASTScope((IIndexScope) scope); - } + scope= ast.mapToASTScope(scope); if (scope instanceof ICPPInternalNamespaceScope) { if (result == null) { - result= new ArrayList(); + result= new ArrayList<>(); } result.add((ICPPInternalNamespaceScope) scope); } @@ -325,7 +323,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace */ public void addInlineNamespace(ICPPASTNamespaceDefinition nsDef) { if (fInlineNamespaceDefinitions == null) { - fInlineNamespaceDefinitions= new ArrayList(); + fInlineNamespaceDefinitions= new ArrayList<>(); } fInlineNamespaceDefinitions.add(nsDef); } @@ -342,7 +340,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace } } - Set result= new HashSet(); + Set result= new HashSet<>(); result.add(nsScope); addInlineNamespaces(nsScope, result); return result.toArray(new ICPPNamespaceScope[result.size()]); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java index 54bbc436bcd..80b840251c8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPScopeMapper.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -49,7 +49,6 @@ import org.eclipse.cdt.internal.core.index.IIndexScope; * scopes that can be reopened, i.e. namespaces. */ public class CPPScopeMapper { - /** * Used for implicit inline directives for inline namespaces found in the index. */ @@ -141,7 +140,7 @@ public class CPPScopeMapper { private void initUsingDirectives() { if (fUsingDirectives == null) { - fUsingDirectives= new ArrayList(1); + fUsingDirectives= new ArrayList<>(1); // Insert a using directive for every inline namespace for (ICPPInternalNamespaceScope inline: getInlineNamespaces()) { fUsingDirectives.add(new InlineNamespaceDirective(this, inline)); @@ -248,13 +247,12 @@ public class CPPScopeMapper { } } - private final HashMap fMappedScopes= new HashMap(); - private final HashMap fNamespaceWrappers= new HashMap(); - private final Map> fPerName= new HashMap>(); + private final HashMap fMappedScopes= new HashMap<>(); + private final HashMap fNamespaceWrappers= new HashMap<>(); + private final Map> fPerName= new HashMap<>(); private final CPPASTTranslationUnit fTu; protected CharArrayMap fClasses; - public CPPScopeMapper(CPPASTTranslationUnit tu) { fTu= tu; } @@ -386,7 +384,7 @@ public class CPPScopeMapper { } if (fClasses == null) { - fClasses= new CharArrayMap(); + fClasses= new CharArrayMap<>(); fTu.accept(new Visitor()); } IASTName[] names= fClasses.get(type.getNameCharArray()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java index c8e013ae562..ed550d69ca5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java @@ -484,15 +484,12 @@ public class LookupData extends ScopeLookupData { } public IType[] getFunctionArgumentTypes() { - if (functionArgTypes == null) { - if (functionArgs != null) { - ICPPEvaluation[] exprs= functionArgs; - functionArgTypes= new IType[exprs.length]; - for (int i = 0; i < exprs.length; i++) { - ICPPEvaluation e = exprs[i]; - functionArgTypes[i]= getSimplifiedType(e.getTypeOrFunctionSet(getLookupPoint())); - } - } + if (functionArgTypes == null && functionArgs != null) { + functionArgTypes= new IType[functionArgs.length]; + for (int i = 0; i < functionArgs.length; i++) { + ICPPEvaluation e = functionArgs[i]; + functionArgTypes[i]= getSimplifiedType(e.getTypeOrFunctionSet(getLookupPoint())); + } } return functionArgTypes; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java index 7009a805f7e..e514d00c275 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplate.java @@ -244,7 +244,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType } // Need a class template. - if (type instanceof ICPPClassTemplate == false || type instanceof ProblemBinding) + if (!(type instanceof ICPPClassTemplate) || type instanceof ProblemBinding) return false; // Exclude other kinds of class templates.