mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Let deferred instances rely on template parameter positions, only, bug 252554.
This commit is contained in:
parent
56d888d8ff
commit
947fd5b342
8 changed files with 44 additions and 117 deletions
|
@ -12,6 +12,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||||
|
@ -52,22 +53,14 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization
|
||||||
public synchronized final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
public synchronized final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||||
if (instances == null)
|
if (instances == null)
|
||||||
instances = new ObjectMap(2);
|
instances = new ObjectMap(2);
|
||||||
instances.put(arguments, instance);
|
String key= ASTTypeUtil.getArgumentListString(arguments, true);
|
||||||
|
instances.put(key, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
public synchronized final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||||
if (instances != null) {
|
if (instances != null) {
|
||||||
loop: for (int i=0; i < instances.size(); i++) {
|
String key= ASTTypeUtil.getArgumentListString(arguments, true);
|
||||||
ICPPTemplateArgument[] args = (ICPPTemplateArgument[]) instances.keyAt(i);
|
return (ICPPTemplateInstance) instances.get(key);
|
||||||
if (args.length == arguments.length) {
|
|
||||||
for (int j=0; j < args.length; j++) {
|
|
||||||
if (!args[j].isSameValue(arguments[j])) {
|
|
||||||
continue loop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ICPPTemplateInstance) instances.getAt(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
|
@ -41,22 +42,14 @@ public class CPPFunctionTemplateSpecialization extends CPPFunctionSpecialization
|
||||||
public synchronized final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
public synchronized final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||||
if (instances == null)
|
if (instances == null)
|
||||||
instances = new ObjectMap(2);
|
instances = new ObjectMap(2);
|
||||||
instances.put(arguments, instance);
|
String key= ASTTypeUtil.getArgumentListString(arguments, true);
|
||||||
|
instances.put(key, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
public synchronized final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||||
if (instances != null) {
|
if (instances != null) {
|
||||||
loop: for (int i=0; i < instances.size(); i++) {
|
String key= ASTTypeUtil.getArgumentListString(arguments, true);
|
||||||
ICPPTemplateArgument[] args = (ICPPTemplateArgument[]) instances.keyAt(i);
|
return (ICPPTemplateInstance) instances.get(key);
|
||||||
if (args.length == arguments.length) {
|
|
||||||
for (int j=0; j < args.length; j++) {
|
|
||||||
if (!args[j].isSameValue(arguments[j])) {
|
|
||||||
continue loop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ICPPTemplateInstance) instances.getAt(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ILinkage;
|
import org.eclipse.cdt.core.dom.ILinkage;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
@ -101,22 +102,14 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC
|
||||||
public final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
public final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||||
if (instances == null)
|
if (instances == null)
|
||||||
instances = new ObjectMap(2);
|
instances = new ObjectMap(2);
|
||||||
instances.put(arguments, instance);
|
String key= ASTTypeUtil.getArgumentListString(arguments, true);
|
||||||
|
instances.put(key, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
public final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||||
if (instances != null) {
|
if (instances != null) {
|
||||||
loop: for (int i=0; i < instances.size(); i++) {
|
String key= ASTTypeUtil.getArgumentListString(arguments, true);
|
||||||
ICPPTemplateArgument[] args = (ICPPTemplateArgument[]) instances.keyAt(i);
|
return (ICPPTemplateInstance) instances.get(key);
|
||||||
if (args.length == arguments.length) {
|
|
||||||
for (int j=0; j < args.length; j++) {
|
|
||||||
if (!args[j].isSameValue(arguments[j])) {
|
|
||||||
continue loop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ICPPTemplateInstance) instances.getAt(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
import org.eclipse.cdt.core.dom.ast.IASTExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
@ -189,22 +190,14 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement
|
||||||
public final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
public final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) {
|
||||||
if (instances == null)
|
if (instances == null)
|
||||||
instances = new ObjectMap(2);
|
instances = new ObjectMap(2);
|
||||||
instances.put(arguments, instance);
|
String key= ASTTypeUtil.getArgumentListString(arguments, true);
|
||||||
|
instances.put(key, instance);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
public final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) {
|
||||||
if (instances != null) {
|
if (instances != null) {
|
||||||
loop: for (int i=0; i < instances.size(); i++) {
|
String key= ASTTypeUtil.getArgumentListString(arguments, true);
|
||||||
ICPPTemplateArgument[] args = (ICPPTemplateArgument[]) instances.keyAt(i);
|
return (ICPPTemplateInstance) instances.get(key);
|
||||||
if (args.length == arguments.length) {
|
|
||||||
for (int j=0; j < args.length; j++) {
|
|
||||||
if (!args[j].isSameValue(arguments[j])) {
|
|
||||||
continue loop;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ICPPTemplateInstance) instances.getAt(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -330,7 +330,10 @@ public class CPPSemantics {
|
||||||
useOriginal= false;
|
useOriginal= false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!((IType) par).isSameType(args[i].getTypeValue())) {
|
IType other= args[i].getTypeValue();
|
||||||
|
if (!(other instanceof ICPPTemplateParameter)) {
|
||||||
|
useOriginal= false;
|
||||||
|
} else if (par.getParameterPosition() != ((ICPPTemplateParameter) other).getParameterPosition()) {
|
||||||
useOriginal= false;
|
useOriginal= false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2010,7 +2013,15 @@ public class CPPSemantics {
|
||||||
// Reduce our set of candidate functions to only those who have the right number of parameters
|
// Reduce our set of candidate functions to only those who have the right number of parameters
|
||||||
reduceToViable(data, fns);
|
reduceToViable(data, fns);
|
||||||
|
|
||||||
if (data.forDefinition() || data.forExplicitInstantiation()) {
|
// deferred function instances cannot be disambiguated.
|
||||||
|
boolean deferredOnly= true;
|
||||||
|
for (int i = 0; deferredOnly && i < fns.length; i++) {
|
||||||
|
final IFunction f = fns[i];
|
||||||
|
if (f != null && !(f instanceof ICPPDeferredTemplateInstance)) {
|
||||||
|
deferredOnly= false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (deferredOnly || data.forDefinition() || data.forExplicitInstantiation()) {
|
||||||
for (IFunction fn : fns) {
|
for (IFunction fn : fns) {
|
||||||
if (fn != null) {
|
if (fn != null) {
|
||||||
return fn;
|
return fn;
|
||||||
|
|
|
@ -17,6 +17,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
|
@ -63,7 +64,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDeferredTemplateInstance;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
|
||||||
|
@ -141,6 +141,7 @@ public class CPPTemplates {
|
||||||
*/
|
*/
|
||||||
public static IBinding instantiate(ICPPTemplateDefinition template, ICPPTemplateArgument[] arguments) {
|
public static IBinding instantiate(ICPPTemplateDefinition template, ICPPTemplateArgument[] arguments) {
|
||||||
try {
|
try {
|
||||||
|
arguments= SemanticUtil.getSimplifiedArguments(arguments);
|
||||||
if (template instanceof ICPPTemplateTemplateParameter) {
|
if (template instanceof ICPPTemplateTemplateParameter) {
|
||||||
return deferredInstance(template, arguments);
|
return deferredInstance(template, arguments);
|
||||||
}
|
}
|
||||||
|
@ -167,7 +168,6 @@ public class CPPTemplates {
|
||||||
* Instantiates a partial class template specialization.
|
* Instantiates a partial class template specialization.
|
||||||
*/
|
*/
|
||||||
private static IBinding instantiatePartialSpecialization(ICPPClassTemplatePartialSpecialization partialSpec, ICPPTemplateArgument[] args) throws DOMException {
|
private static IBinding instantiatePartialSpecialization(ICPPClassTemplatePartialSpecialization partialSpec, ICPPTemplateArgument[] args) throws DOMException {
|
||||||
args= SemanticUtil.getSimplifiedArguments(args);
|
|
||||||
ICPPTemplateInstance instance= getInstance(partialSpec, args);
|
ICPPTemplateInstance instance= getInstance(partialSpec, args);
|
||||||
if (instance != null)
|
if (instance != null)
|
||||||
return instance;
|
return instance;
|
||||||
|
@ -209,7 +209,6 @@ public class CPPTemplates {
|
||||||
ICPPTemplateArgument[] actualArgs = new ICPPTemplateArgument[numParams];
|
ICPPTemplateArgument[] actualArgs = new ICPPTemplateArgument[numParams];
|
||||||
boolean argsContainDependentType = false;
|
boolean argsContainDependentType = false;
|
||||||
|
|
||||||
arguments= SemanticUtil.getSimplifiedArguments(arguments);
|
|
||||||
for (int i = 0; i < numParams; i++) {
|
for (int i = 0; i < numParams; i++) {
|
||||||
arg= null;
|
arg= null;
|
||||||
param= parameters[i];
|
param= parameters[i];
|
||||||
|
@ -400,6 +399,7 @@ public class CPPTemplates {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IBinding createBinding(ICPPASTTemplateParameter templateParameter) {
|
public static IBinding createBinding(ICPPASTTemplateParameter templateParameter) {
|
||||||
|
// mstodo allow incomplete bindings
|
||||||
ICPPTemplateDefinition template = getContainingTemplate(templateParameter);
|
ICPPTemplateDefinition template = getContainingTemplate(templateParameter);
|
||||||
|
|
||||||
IBinding binding = null;
|
IBinding binding = null;
|
||||||
|
@ -572,6 +572,7 @@ public class CPPTemplates {
|
||||||
if (templateParams.length != args.length) {
|
if (templateParams.length != args.length) {
|
||||||
return null; // mstodo problem or use default args?
|
return null; // mstodo problem or use default args?
|
||||||
}
|
}
|
||||||
|
args= SemanticUtil.getSimplifiedArguments(args);
|
||||||
for (int i = 0; i < templateParams.length; i++) {
|
for (int i = 0; i < templateParams.length; i++) {
|
||||||
tpMap.put(templateParams[i], args[i]);
|
tpMap.put(templateParams[i], args[i]);
|
||||||
}
|
}
|
||||||
|
@ -773,6 +774,7 @@ public class CPPTemplates {
|
||||||
ICPPTemplateArgument[] arguments= createTemplateArgumentArray(id);
|
ICPPTemplateArgument[] arguments= createTemplateArgumentArray(id);
|
||||||
ICPPTemplateArgument[] result = new ICPPTemplateArgument[templateParameters.length];
|
ICPPTemplateArgument[] result = new ICPPTemplateArgument[templateParameters.length];
|
||||||
|
|
||||||
|
arguments= SemanticUtil.getSimplifiedArguments(arguments);
|
||||||
if (arguments.length == result.length) {
|
if (arguments.length == result.length) {
|
||||||
for (int i = 0; i < templateParameters.length; i++) {
|
for (int i = 0; i < templateParameters.length; i++) {
|
||||||
result[i] = arguments[i];
|
result[i] = arguments[i];
|
||||||
|
@ -1725,7 +1727,6 @@ public class CPPTemplates {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
args= SemanticUtil.getSimplifiedArguments(args);
|
|
||||||
ICPPClassTemplatePartialSpecialization[] specializations = template.getPartialSpecializations();
|
ICPPClassTemplatePartialSpecialization[] specializations = template.getPartialSpecializations();
|
||||||
if (specializations == null) {
|
if (specializations == null) {
|
||||||
return template;
|
return template;
|
||||||
|
@ -1978,7 +1979,7 @@ public class CPPTemplates {
|
||||||
* Attempts to (partially) resolve an unknown binding with the given arguments.
|
* Attempts to (partially) resolve an unknown binding with the given arguments.
|
||||||
*/
|
*/
|
||||||
private static IBinding resolveUnknown(ICPPUnknownBinding unknown, ICPPTemplateParameterMap tpMap, ICPPClassSpecialization within) throws DOMException {
|
private static IBinding resolveUnknown(ICPPUnknownBinding unknown, ICPPTemplateParameterMap tpMap, ICPPClassSpecialization within) throws DOMException {
|
||||||
if (unknown instanceof ICPPDeferredTemplateInstance) {
|
if (unknown instanceof ICPPDeferredClassInstance) {
|
||||||
return resolveDeferredClassInstance((ICPPDeferredClassInstance) unknown, tpMap, within);
|
return resolveDeferredClassInstance((ICPPDeferredClassInstance) unknown, tpMap, within);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2069,12 +2070,9 @@ public class CPPTemplates {
|
||||||
if (m1 == null || m2 == null || m1.length != m2.length)
|
if (m1 == null || m2 == null || m1.length != m2.length)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (int i = 0; i < m1.length; i++) {
|
String s1 = ASTTypeUtil.getArgumentListString(m1, true);
|
||||||
if (!m1[i].isSameValue(m2[i]))
|
String s2 = ASTTypeUtil.getArgumentListString(m2, true);
|
||||||
return false;
|
return s1.equals(s2);
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ICPPTemplateParameterMap createParameterMap(ICPPTemplateDefinition tdef, ICPPTemplateArgument[] args) {
|
public static ICPPTemplateParameterMap createParameterMap(ICPPTemplateDefinition tdef, ICPPTemplateArgument[] args) {
|
||||||
|
|
|
@ -12,10 +12,6 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index;
|
package org.eclipse.cdt.internal.core.index;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
@ -27,7 +23,6 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -70,58 +65,9 @@ public class IndexCPPSignatureUtil {
|
||||||
* <typeName1,typeName2,...>
|
* <typeName1,typeName2,...>
|
||||||
*/
|
*/
|
||||||
public static String getTemplateArgString(ICPPTemplateArgument[] args, boolean qualifyTemplateParameters) throws CoreException, DOMException {
|
public static String getTemplateArgString(ICPPTemplateArgument[] args, boolean qualifyTemplateParameters) throws CoreException, DOMException {
|
||||||
StringBuilder buffer = new StringBuilder();
|
return ASTTypeUtil.getArgumentListString(args, true);
|
||||||
buffer.append('<');
|
|
||||||
for (int i = 0; i < args.length; i++) {
|
|
||||||
if (i>0) {
|
|
||||||
buffer.append(',');
|
|
||||||
}
|
|
||||||
final ICPPTemplateArgument arg= args[i];
|
|
||||||
if (arg.isNonTypeValue()) {
|
|
||||||
buffer.append(arg.getNonTypeValue().getCanonicalRepresentation());
|
|
||||||
} else {
|
|
||||||
final IType type= arg.getTypeValue();
|
|
||||||
if (qualifyTemplateParameters && type instanceof ICPPTemplateParameter) {
|
|
||||||
List<IBinding> parents = new ArrayList<IBinding>();
|
|
||||||
IBinding parent= ((ICPPTemplateParameter) type).getOwner();
|
|
||||||
while (parent != null) {
|
|
||||||
parents.add(parent);
|
|
||||||
parent= parent.getOwner();
|
|
||||||
}
|
|
||||||
//identical template parameters from different template specializations must have unique signatures
|
|
||||||
Collections.reverse(parents);
|
|
||||||
for (IBinding binding : parents) {
|
|
||||||
if (binding != null) {
|
|
||||||
buffer.append(binding.getNameCharArray());
|
|
||||||
if (binding instanceof ICPPTemplateInstance) {
|
|
||||||
ICPPTemplateInstance inst= (ICPPTemplateInstance) binding;
|
|
||||||
appendTemplateArgs(inst.getTemplateArguments(), buffer);
|
|
||||||
}
|
|
||||||
buffer.append("::"); //$NON-NLS-1$
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buffer.append(((ICPPTemplateParameter)type).getName());
|
|
||||||
} else {
|
|
||||||
buffer.append(ASTTypeUtil.getType(type));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
buffer.append('>');
|
|
||||||
return buffer.toString();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void appendTemplateArgs(ICPPTemplateArgument[] values, StringBuilder buffer) {
|
|
||||||
boolean needcomma= false;
|
|
||||||
buffer.append('<');
|
|
||||||
for (final ICPPTemplateArgument val : values) {
|
|
||||||
if (needcomma)
|
|
||||||
buffer.append(',');
|
|
||||||
buffer.append(ASTTypeUtil.getArgumentString(val, true));
|
|
||||||
needcomma= true;
|
|
||||||
}
|
|
||||||
buffer.append('>');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a string in the format:
|
* Constructs a string in the format:
|
||||||
* (paramName1,paramName2,...)
|
* (paramName1,paramName2,...)
|
||||||
|
|
|
@ -117,7 +117,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding
|
||||||
public IBinding[] find(String name) {
|
public IBinding[] find(String name) {
|
||||||
try {
|
try {
|
||||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(),
|
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(),
|
||||||
IndexFilter.ALL_DECLARED_OR_IMPLICIT,false, true);
|
IndexFilter.CPP_DECLARED_OR_IMPLICIT_NO_INSTANCE, false, true);
|
||||||
getIndex().accept(visitor);
|
getIndex().accept(visitor);
|
||||||
return visitor.getBindings();
|
return visitor.getBindings();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue