mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 253080.
This commit is contained in:
parent
2aedcbec84
commit
a63dcf4071
5 changed files with 60 additions and 6 deletions
|
@ -609,7 +609,7 @@ public class IndexBugsTests extends BaseTestCase {
|
|||
|
||||
// template <class U1> class Test;
|
||||
// template <class U2> void f();
|
||||
public void _test253080() throws Exception {
|
||||
public void test253080() throws Exception {
|
||||
waitForIndexer();
|
||||
|
||||
String[] testData = getContentsForTest(3);
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007, 2008 Google, 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
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
|
||||
/**
|
||||
* Common interface for PDOM template definitions.
|
||||
*/
|
||||
public interface IPDOMCPPTemplateParameterOwner {
|
||||
ICPPTemplateParameter adaptTemplateParameter(ICPPTemplateParameter param);
|
||||
}
|
|
@ -9,6 +9,7 @@
|
|||
* QNX - Initial API and implementation
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
|
@ -41,7 +42,8 @@ import org.eclipse.core.runtime.CoreException;
|
|||
/**
|
||||
* @author Bryan Wilkinson
|
||||
*/
|
||||
public class PDOMCPPClassTemplate extends PDOMCPPClassType implements ICPPClassTemplate, ICPPInstanceCache {
|
||||
public class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||
implements ICPPClassTemplate, ICPPInstanceCache, IPDOMCPPTemplateParameterOwner {
|
||||
private static final int PARAMETERS = PDOMCPPClassType.RECORD_SIZE + 0;
|
||||
private static final int FIRST_PARTIAL = PDOMCPPClassType.RECORD_SIZE + 4;
|
||||
|
||||
|
@ -102,7 +104,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType implements ICPPClassT
|
|||
System.arraycopy(params, 0, result, 0, params.length);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private PDOMCPPClassTemplatePartialSpecialization getFirstPartial() throws CoreException {
|
||||
int value = pdom.getDB().getInt(record + FIRST_PARTIAL);
|
||||
return value != 0 ? new PDOMCPPClassTemplatePartialSpecialization(pdom, value) : null;
|
||||
|
@ -232,4 +234,19 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType implements ICPPClassT
|
|||
public ICPPTemplateInstance[] getAllInstances() {
|
||||
return PDOMInstanceCache.getCache(this).getAllInstances();
|
||||
}
|
||||
|
||||
public ICPPTemplateParameter adaptTemplateParameter(ICPPTemplateParameter param) {
|
||||
// Template parameters are identified by their position in the parameter list.
|
||||
int pos = param.getParameterPosition() & 0xFFFF;
|
||||
if (params != null) {
|
||||
return pos < params.length ? params[pos] : null;
|
||||
}
|
||||
try {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + PARAMETERS, getLinkageImpl());
|
||||
return (ICPPTemplateParameter) list.getNodeAt(pos);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
|
@ -37,7 +38,7 @@ import org.eclipse.core.runtime.CoreException;
|
|||
* @author Bryan Wilkinson
|
||||
*/
|
||||
class PDOMCPPFunctionTemplate extends PDOMCPPFunction
|
||||
implements ICPPFunctionTemplate, ICPPInstanceCache, IPDOMMemberOwner {
|
||||
implements ICPPFunctionTemplate, ICPPInstanceCache, IPDOMMemberOwner, IPDOMCPPTemplateParameterOwner {
|
||||
|
||||
private static final int TEMPLATE_PARAMS = PDOMCPPFunction.RECORD_SIZE + 0;
|
||||
|
||||
|
@ -97,7 +98,7 @@ class PDOMCPPFunctionTemplate extends PDOMCPPFunction
|
|||
return new ICPPTemplateParameter[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addChild(PDOMNode member) throws CoreException {
|
||||
if (member instanceof ICPPTemplateParameter) {
|
||||
|
@ -124,4 +125,16 @@ class PDOMCPPFunctionTemplate extends PDOMCPPFunction
|
|||
public ICPPTemplateInstance[] getAllInstances() {
|
||||
return PDOMInstanceCache.getCache(this).getAllInstances();
|
||||
}
|
||||
|
||||
public ICPPTemplateParameter adaptTemplateParameter(ICPPTemplateParameter param) {
|
||||
// Template parameters are identified by their position in the parameter list.
|
||||
int pos = param.getParameterPosition() & 0xFFFF;
|
||||
try {
|
||||
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + TEMPLATE_PARAMS, getLinkageImpl());
|
||||
return (ICPPTemplateParameter) list.getNodeAt(pos);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -619,9 +619,13 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
}
|
||||
if (parent instanceof PDOMCPPNamespace) {
|
||||
int localToFileRec= getLocalToFileRec(parent, binding);
|
||||
return CPPFindBinding.findBinding(((PDOMCPPNamespace)parent).getIndex(), this, binding,
|
||||
return CPPFindBinding.findBinding(((PDOMCPPNamespace) parent).getIndex(), this, binding,
|
||||
localToFileRec);
|
||||
}
|
||||
if (binding instanceof ICPPTemplateParameter && parent instanceof IPDOMCPPTemplateParameterOwner) {
|
||||
return (PDOMBinding) ((IPDOMCPPTemplateParameterOwner) parent).adaptTemplateParameter(
|
||||
(ICPPTemplateParameter) binding);
|
||||
}
|
||||
if (parent instanceof IPDOMMemberOwner) {
|
||||
int localToFileRec= getLocalToFileRec(parent, binding);
|
||||
return CPPFindBinding.findBinding(parent, this, binding, localToFileRec);
|
||||
|
|
Loading…
Add table
Reference in a new issue