Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2004, 2006 IBM Corporation and others. |
2 |
* Copyright (c) 2004, 2007 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 8-13
Link Here
|
8 |
* Contributors: |
8 |
* Contributors: |
9 |
* IBM - Initial API and implementation |
9 |
* IBM - Initial API and implementation |
10 |
* Markus Schorn (Wind River Systems) |
10 |
* Markus Schorn (Wind River Systems) |
|
|
11 |
* Bryan Wilkinson (QNX) |
11 |
*******************************************************************************/ |
12 |
*******************************************************************************/ |
12 |
/* |
13 |
/* |
13 |
* Created on Dec 8, 2004 |
14 |
* Created on Dec 8, 2004 |
Lines 90-95
Link Here
|
90 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement; |
91 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTWhileStatement; |
91 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; |
92 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase; |
92 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; |
93 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType; |
|
|
94 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope; |
93 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; |
95 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope; |
94 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; |
96 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; |
95 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; |
97 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; |
Lines 116-121
Link Here
|
116 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; |
118 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter; |
117 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration; |
119 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration; |
118 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; |
120 |
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier; |
|
|
121 |
import org.eclipse.cdt.core.index.IIndex; |
119 |
import org.eclipse.cdt.core.index.IIndexBinding; |
122 |
import org.eclipse.cdt.core.index.IIndexBinding; |
120 |
import org.eclipse.cdt.core.parser.util.ArrayUtil; |
123 |
import org.eclipse.cdt.core.parser.util.ArrayUtil; |
121 |
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; |
124 |
import org.eclipse.cdt.core.parser.util.CharArrayObjectMap; |
Lines 127-132
Link Here
|
127 |
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; |
130 |
import org.eclipse.cdt.internal.core.dom.parser.ASTNode; |
128 |
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; |
131 |
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; |
129 |
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; |
132 |
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; |
|
|
133 |
import org.eclipse.core.runtime.CoreException; |
130 |
|
134 |
|
131 |
/** |
135 |
/** |
132 |
* @author aniefer |
136 |
* @author aniefer |
Lines 1023-1028
Link Here
|
1023 |
b= scope.getBinding( data.astName, false ); |
1027 |
b= scope.getBinding( data.astName, false ); |
1024 |
if (b instanceof CPPImplicitFunction || b instanceof CPPImplicitTypedef) |
1028 |
if (b instanceof CPPImplicitFunction || b instanceof CPPImplicitTypedef) |
1025 |
mergeResults( data, b, true ); |
1029 |
mergeResults( data, b, true ); |
|
|
1030 |
} else if (data.prefixLookup && data.astName != null) { |
1031 |
IASTNode parent = ASTInternal.getPhysicalNodeOfScope(scope); |
1032 |
if (parent == null && scope instanceof IIndexBinding) { |
1033 |
IBinding[] bindings = scope.find(data.astName.toString(), data.prefixLookup); |
1034 |
mergeResults(data, bindings, true); |
1035 |
} else if (scope instanceof ICPPNamespaceScope && !(scope instanceof ICPPBlockScope)) { |
1036 |
ICPPNamespaceScope ns = (ICPPNamespaceScope) scope; |
1037 |
IIndex index = parent.getTranslationUnit().getIndex(); |
1038 |
if (index != null) { |
1039 |
try { |
1040 |
IIndexBinding binding = index.findBinding(ns.getScopeName()); |
1041 |
if (binding instanceof ICPPNamespaceScope) { |
1042 |
ICPPNamespaceScope indexNs = (ICPPNamespaceScope) binding; |
1043 |
IBinding[] bindings = indexNs.find(data.astName.toString(), data.prefixLookup); |
1044 |
mergeResults(data, bindings, true); |
1045 |
} |
1046 |
} catch (CoreException e) { |
1047 |
} |
1048 |
} |
1049 |
} |
1026 |
} |
1050 |
} |
1027 |
IASTName[] inScope = lookupInScope( data, scope, blockItem ); |
1051 |
IASTName[] inScope = lookupInScope( data, scope, blockItem ); |
1028 |
if (inScope != null) { |
1052 |
if (inScope != null) { |
Lines 1789-1796
Link Here
|
1789 |
} |
1813 |
} |
1790 |
char[] c = potential.toCharArray(); |
1814 |
char[] c = potential.toCharArray(); |
1791 |
char [] n = data.name(); |
1815 |
char [] n = data.name(); |
1792 |
return ( (data.prefixLookup && CharArrayUtils.equals( c, 0, n.length, n )) || |
1816 |
return (data.prefixLookup && CharArrayUtils.equals(c, 0, n.length, n, false)) |
1793 |
(!data.prefixLookup && CharArrayUtils.equals( c, n )) ); |
1817 |
|| (!data.prefixLookup && CharArrayUtils.equals(c, n)); |
1794 |
} |
1818 |
} |
1795 |
|
1819 |
|
1796 |
private static void addDefinition( IBinding binding, IASTName name ){ |
1820 |
private static void addDefinition( IBinding binding, IASTName name ){ |
Lines 3251-3265
Link Here
|
3251 |
return null; |
3275 |
return null; |
3252 |
} |
3276 |
} |
3253 |
|
3277 |
|
3254 |
public static IBinding[] findBindings( IScope scope, String name, boolean qualified ) throws DOMException{ |
3278 |
public static IBinding[] findBindings( IScope scope, String name, boolean qualified, boolean prefixLookup ) throws DOMException{ |
3255 |
return findBindings( scope, name.toCharArray(), qualified ); |
3279 |
return findBindings( scope, name.toCharArray(), qualified, prefixLookup ); |
3256 |
} |
3280 |
} |
3257 |
public static IBinding[] findBindings( IScope scope, char []name, boolean qualified ) throws DOMException{ |
3281 |
public static IBinding[] findBindings( IScope scope, char []name, boolean qualified, boolean prefixLookup ) throws DOMException{ |
3258 |
CPPASTName astName = new CPPASTName(); |
3282 |
CPPASTName astName = new CPPASTName(); |
3259 |
astName.setName( name ); |
3283 |
astName.setName( name ); |
3260 |
astName.setParent( ASTInternal.getPhysicalNodeOfScope(scope)); |
3284 |
astName.setParent( ASTInternal.getPhysicalNodeOfScope(scope)); |
3261 |
astName.setPropertyInParent( STRING_LOOKUP_PROPERTY ); |
3285 |
astName.setPropertyInParent( STRING_LOOKUP_PROPERTY ); |
3262 |
|
3286 |
|
|
|
3287 |
if (prefixLookup) { |
3288 |
return prefixLookup(astName, scope); |
3289 |
} |
3290 |
|
3263 |
LookupData data = new LookupData( astName ); |
3291 |
LookupData data = new LookupData( astName ); |
3264 |
data.forceQualified = qualified; |
3292 |
data.forceQualified = qualified; |
3265 |
|
3293 |
|
Lines 3296-3308
Link Here
|
3296 |
return (IBinding[]) set.keyArray( IBinding.class ); |
3324 |
return (IBinding[]) set.keyArray( IBinding.class ); |
3297 |
} |
3325 |
} |
3298 |
|
3326 |
|
3299 |
public static IBinding [] prefixLookup( IASTName name ){ |
3327 |
public static IBinding [] prefixLookup( IASTName name ){ |
|
|
3328 |
return prefixLookup(name, name); |
3329 |
} |
3330 |
|
3331 |
public static IBinding [] prefixLookup( IASTName name, Object start ){ |
3300 |
LookupData data = createLookupData( name, true ); |
3332 |
LookupData data = createLookupData( name, true ); |
3301 |
data.prefixLookup = true; |
3333 |
data.prefixLookup = true; |
3302 |
data.foundItems = new CharArrayObjectMap( 2 ); |
3334 |
data.foundItems = new CharArrayObjectMap( 2 ); |
3303 |
|
3335 |
|
3304 |
try { |
3336 |
try { |
3305 |
lookup( data, name ); |
3337 |
lookup( data, start ); |
3306 |
} catch ( DOMException e ) { |
3338 |
} catch ( DOMException e ) { |
3307 |
} |
3339 |
} |
3308 |
CharArrayObjectMap map = (CharArrayObjectMap) data.foundItems; |
3340 |
CharArrayObjectMap map = (CharArrayObjectMap) data.foundItems; |