1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-13 19:25:38 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2014-11-24 20:12:07 -08:00
parent 39dce1d497
commit ef9d90c4f5
4 changed files with 23 additions and 30 deletions

View file

@ -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 * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -81,7 +81,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace
private void initUsingDirectives() { private void initUsingDirectives() {
if (fUsingDirectives == null) { if (fUsingDirectives == null) {
fUsingDirectives= new ArrayList<ICPPUsingDirective>(1); fUsingDirectives= new ArrayList<>(1);
// Insert a using directive for every inline namespace found in the index. // Insert a using directive for every inline namespace found in the index.
for (ICPPInternalNamespaceScope inline : getIndexInlineNamespaces()) { for (ICPPInternalNamespaceScope inline : getIndexInlineNamespaces()) {
if (!(inline instanceof CPPNamespaceScope)) { if (!(inline instanceof CPPNamespaceScope)) {
@ -107,7 +107,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace
} }
public IScope findNamespaceScope(IIndexScope scope) { public IScope findNamespaceScope(IIndexScope scope) {
final ArrayList<IBinding> parentChain = new ArrayList<IBinding>(); final ArrayList<IBinding> parentChain = new ArrayList<>();
for (IBinding binding= scope.getScopeBinding(); binding != null; binding= binding.getOwner()) { for (IBinding binding= scope.getScopeBinding(); binding != null; binding= binding.getOwner()) {
parentChain.add(binding); parentChain.add(binding);
} }
@ -260,7 +260,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace
populateCache(); populateCache();
Set<ICPPInternalNamespaceScope> result= null; Set<ICPPInternalNamespaceScope> result= null;
if (fInlineNamespaceDefinitions != null) { if (fInlineNamespaceDefinitions != null) {
result= new HashSet<ICPPInternalNamespaceScope>(fInlineNamespaceDefinitions.size()); result= new HashSet<>(fInlineNamespaceDefinitions.size());
for (ICPPASTNamespaceDefinition nsdef : fInlineNamespaceDefinitions) { for (ICPPASTNamespaceDefinition nsdef : fInlineNamespaceDefinitions) {
final IScope scope = nsdef.getScope(); final IScope scope = nsdef.getScope();
if (scope instanceof ICPPInternalNamespaceScope) { if (scope instanceof ICPPInternalNamespaceScope) {
@ -271,7 +271,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace
for (ICPPInternalNamespaceScope inline : getIndexInlineNamespaces()) { for (ICPPInternalNamespaceScope inline : getIndexInlineNamespaces()) {
if (result == null) if (result == null)
result = new HashSet<ICPPInternalNamespaceScope>(); result = new HashSet<>();
result.add(inline); result.add(inline);
} }
@ -284,7 +284,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace
private ICPPInternalNamespaceScope[] getIndexInlineNamespaces() { private ICPPInternalNamespaceScope[] getIndexInlineNamespaces() {
IASTTranslationUnit tu= getPhysicalNode().getTranslationUnit(); IASTTranslationUnit tu= getPhysicalNode().getTranslationUnit();
if (tu instanceof CPPASTTranslationUnit) { if (tu instanceof CPPASTTranslationUnit) {
CPPASTTranslationUnit cpptu= (CPPASTTranslationUnit) tu; CPPASTTranslationUnit ast= (CPPASTTranslationUnit) tu;
IIndex index= tu.getIndex(); IIndex index= tu.getIndex();
if (index != null) { if (index != null) {
IScope[] inlineScopes= null; IScope[] inlineScopes= null;
@ -301,12 +301,10 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace
if (inlineScopes != null) { if (inlineScopes != null) {
List<ICPPInternalNamespaceScope> result= null; List<ICPPInternalNamespaceScope> result= null;
for (IScope scope : inlineScopes) { for (IScope scope : inlineScopes) {
if (scope instanceof IIndexScope) { scope= ast.mapToASTScope(scope);
scope= cpptu.mapToASTScope((IIndexScope) scope);
}
if (scope instanceof ICPPInternalNamespaceScope) { if (scope instanceof ICPPInternalNamespaceScope) {
if (result == null) { if (result == null) {
result= new ArrayList<ICPPInternalNamespaceScope>(); result= new ArrayList<>();
} }
result.add((ICPPInternalNamespaceScope) scope); result.add((ICPPInternalNamespaceScope) scope);
} }
@ -325,7 +323,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace
*/ */
public void addInlineNamespace(ICPPASTNamespaceDefinition nsDef) { public void addInlineNamespace(ICPPASTNamespaceDefinition nsDef) {
if (fInlineNamespaceDefinitions == null) { if (fInlineNamespaceDefinitions == null) {
fInlineNamespaceDefinitions= new ArrayList<ICPPASTNamespaceDefinition>(); fInlineNamespaceDefinitions= new ArrayList<>();
} }
fInlineNamespaceDefinitions.add(nsDef); fInlineNamespaceDefinitions.add(nsDef);
} }
@ -342,7 +340,7 @@ public class CPPNamespaceScope extends CPPScope implements ICPPInternalNamespace
} }
} }
Set<ICPPInternalNamespaceScope> result= new HashSet<ICPPInternalNamespaceScope>(); Set<ICPPInternalNamespaceScope> result= new HashSet<>();
result.add(nsScope); result.add(nsScope);
addInlineNamespaces(nsScope, result); addInlineNamespaces(nsScope, result);
return result.toArray(new ICPPNamespaceScope[result.size()]); return result.toArray(new ICPPNamespaceScope[result.size()]);

View file

@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html * http://www.eclipse.org/legal/epl-v10.html
* *
* Contributors: * Contributors:
* Markus Schorn - initial API and implementation * Markus Schorn - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp; 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. * scopes that can be reopened, i.e. namespaces.
*/ */
public class CPPScopeMapper { public class CPPScopeMapper {
/** /**
* Used for implicit inline directives for inline namespaces found in the index. * Used for implicit inline directives for inline namespaces found in the index.
*/ */
@ -141,7 +140,7 @@ public class CPPScopeMapper {
private void initUsingDirectives() { private void initUsingDirectives() {
if (fUsingDirectives == null) { if (fUsingDirectives == null) {
fUsingDirectives= new ArrayList<ICPPUsingDirective>(1); fUsingDirectives= new ArrayList<>(1);
// Insert a using directive for every inline namespace // Insert a using directive for every inline namespace
for (ICPPInternalNamespaceScope inline: getInlineNamespaces()) { for (ICPPInternalNamespaceScope inline: getInlineNamespaces()) {
fUsingDirectives.add(new InlineNamespaceDirective(this, inline)); fUsingDirectives.add(new InlineNamespaceDirective(this, inline));
@ -248,13 +247,12 @@ public class CPPScopeMapper {
} }
} }
private final HashMap<IIndexScope, IScope> fMappedScopes= new HashMap<IIndexScope, IScope>(); private final HashMap<IIndexScope, IScope> fMappedScopes= new HashMap<>();
private final HashMap<String, NamespaceScopeWrapper> fNamespaceWrappers= new HashMap<String, NamespaceScopeWrapper>(); private final HashMap<String, NamespaceScopeWrapper> fNamespaceWrappers= new HashMap<>();
private final Map<String, List<UsingDirectiveWrapper>> fPerName= new HashMap<String, List<UsingDirectiveWrapper>>(); private final Map<String, List<UsingDirectiveWrapper>> fPerName= new HashMap<>();
private final CPPASTTranslationUnit fTu; private final CPPASTTranslationUnit fTu;
protected CharArrayMap<IASTName[]> fClasses; protected CharArrayMap<IASTName[]> fClasses;
public CPPScopeMapper(CPPASTTranslationUnit tu) { public CPPScopeMapper(CPPASTTranslationUnit tu) {
fTu= tu; fTu= tu;
} }
@ -386,7 +384,7 @@ public class CPPScopeMapper {
} }
if (fClasses == null) { if (fClasses == null) {
fClasses= new CharArrayMap<IASTName[]>(); fClasses= new CharArrayMap<>();
fTu.accept(new Visitor()); fTu.accept(new Visitor());
} }
IASTName[] names= fClasses.get(type.getNameCharArray()); IASTName[] names= fClasses.get(type.getNameCharArray());

View file

@ -484,15 +484,12 @@ public class LookupData extends ScopeLookupData {
} }
public IType[] getFunctionArgumentTypes() { public IType[] getFunctionArgumentTypes() {
if (functionArgTypes == null) { if (functionArgTypes == null && functionArgs != null) {
if (functionArgs != null) { functionArgTypes= new IType[functionArgs.length];
ICPPEvaluation[] exprs= functionArgs; for (int i = 0; i < functionArgs.length; i++) {
functionArgTypes= new IType[exprs.length]; ICPPEvaluation e = functionArgs[i];
for (int i = 0; i < exprs.length; i++) { functionArgTypes[i]= getSimplifiedType(e.getTypeOrFunctionSet(getLookupPoint()));
ICPPEvaluation e = exprs[i]; }
functionArgTypes[i]= getSimplifiedType(e.getTypeOrFunctionSet(getLookupPoint()));
}
}
} }
return functionArgTypes; return functionArgTypes;
} }

View file

@ -244,7 +244,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
} }
// Need a class template. // Need a class template.
if (type instanceof ICPPClassTemplate == false || type instanceof ProblemBinding) if (!(type instanceof ICPPClassTemplate) || type instanceof ProblemBinding)
return false; return false;
// Exclude other kinds of class templates. // Exclude other kinds of class templates.