mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Adapting template related bindings to their counterparts in the index, bug 214017.
This commit is contained in:
parent
eb2d63351a
commit
b46e95b387
11 changed files with 470 additions and 360 deletions
|
@ -59,50 +59,6 @@ import org.eclipse.core.runtime.CoreException;
|
||||||
public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBase {
|
public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBase {
|
||||||
public static class SingleProject extends IndexCPPTemplateResolutionTest {
|
public static class SingleProject extends IndexCPPTemplateResolutionTest {
|
||||||
public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true));}
|
public SingleProject() {setStrategy(new SinglePDOMTestStrategy(true));}
|
||||||
|
|
||||||
// template<typename _TpAllocatorForward>
|
|
||||||
// class Allocator;
|
|
||||||
//
|
|
||||||
// template<>
|
|
||||||
// class Allocator<void> {
|
|
||||||
// public:
|
|
||||||
// template<typename _TpRebind>
|
|
||||||
// struct rebind {
|
|
||||||
// typedef Allocator<_TpRebind> other;
|
|
||||||
// };
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// template<typename _TpAllocator>
|
|
||||||
// class Allocator {
|
|
||||||
// public:
|
|
||||||
// typedef _TpAllocator& alloc_reference;
|
|
||||||
// template<typename _TpRebind>
|
|
||||||
// struct rebind {
|
|
||||||
// typedef Allocator<_TpRebind> other;
|
|
||||||
// };
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// template<typename _TpBase, typename _AllocBase>
|
|
||||||
// class VecBase {
|
|
||||||
// public:
|
|
||||||
// typedef typename _AllocBase::template rebind<_TpBase>::other _Tp_alloc_type;
|
|
||||||
// };
|
|
||||||
//
|
|
||||||
// template<typename _Tp, typename _Alloc = Allocator<_Tp> >
|
|
||||||
// class Vec : protected VecBase<_Tp, _Alloc> {
|
|
||||||
// public:
|
|
||||||
// typedef typename VecBase<_Tp, _Alloc>::_Tp_alloc_type::alloc_reference reference;
|
|
||||||
// };
|
|
||||||
|
|
||||||
// void f(Vec<int>::reference r) {}
|
|
||||||
public void _testRebindPattern_214017_3() throws Exception {
|
|
||||||
IBinding b0= getBindingFromASTName("r)", 1);
|
|
||||||
assertInstance(b0, ICPPVariable.class);
|
|
||||||
IType type = ((ICPPVariable) b0).getType();
|
|
||||||
type = SemanticUtil.getUltimateType(type, false);
|
|
||||||
assertInstance(type, IBasicType.class);
|
|
||||||
assertEquals("int", ASTTypeUtil.getType(type));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class ProjectWithDepProj extends IndexCPPTemplateResolutionTest {
|
public static class ProjectWithDepProj extends IndexCPPTemplateResolutionTest {
|
||||||
|
@ -176,6 +132,50 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
assertEquals("int", ASTTypeUtil.getType(type));
|
assertEquals("int", ASTTypeUtil.getType(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// template<typename _TpAllocatorForward>
|
||||||
|
// class Allocator;
|
||||||
|
//
|
||||||
|
// template<>
|
||||||
|
// class Allocator<void> {
|
||||||
|
// public:
|
||||||
|
// template<typename _TpRebind>
|
||||||
|
// struct rebind {
|
||||||
|
// typedef Allocator<_TpRebind> other;
|
||||||
|
// };
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename _TpAllocator>
|
||||||
|
// class Allocator {
|
||||||
|
// public:
|
||||||
|
// typedef _TpAllocator& alloc_reference;
|
||||||
|
// template<typename _TpRebind>
|
||||||
|
// struct rebind {
|
||||||
|
// typedef Allocator<_TpRebind> other;
|
||||||
|
// };
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename _TpBase, typename _AllocBase>
|
||||||
|
// class VecBase {
|
||||||
|
// public:
|
||||||
|
// typedef typename _AllocBase::template rebind<_TpBase>::other _Tp_alloc_type;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// template<typename _Tp, typename _Alloc = Allocator<_Tp> >
|
||||||
|
// class Vec : protected VecBase<_Tp, _Alloc> {
|
||||||
|
// public:
|
||||||
|
// typedef typename VecBase<_Tp, _Alloc>::_Tp_alloc_type::alloc_reference reference;
|
||||||
|
// };
|
||||||
|
|
||||||
|
// void f(Vec<int>::reference r) {}
|
||||||
|
public void testRebindPattern_214017_3() throws Exception {
|
||||||
|
IBinding b0= getBindingFromASTName("r)", 1);
|
||||||
|
assertInstance(b0, ICPPVariable.class);
|
||||||
|
IType type = ((ICPPVariable) b0).getType();
|
||||||
|
type = SemanticUtil.getUltimateType(type, false);
|
||||||
|
assertInstance(type, IBasicType.class);
|
||||||
|
assertEquals("int", ASTTypeUtil.getType(type));
|
||||||
|
}
|
||||||
|
|
||||||
// class Str1 {
|
// class Str1 {
|
||||||
// public:
|
// public:
|
||||||
// Str1(const char* s) {
|
// Str1(const char* s) {
|
||||||
|
@ -489,9 +489,8 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
||||||
getBindingFromASTName("Z z;", 1)
|
getBindingFromASTName("Z z;", 1)
|
||||||
};
|
};
|
||||||
|
|
||||||
for(int i=0; i<bs.length; i++) {
|
for (IBinding b : bs) {
|
||||||
IBinding b= bs[i];
|
assertInstance(b, ICPPClassType.class);
|
||||||
assertInstance(b, ICPPClassType.class);
|
|
||||||
ICPPClassType C= (ICPPClassType) b;
|
ICPPClassType C= (ICPPClassType) b;
|
||||||
assertEquals(1, C.getBases().length);
|
assertEquals(1, C.getBases().length);
|
||||||
ICPPClassType xb= (ICPPClassType) C.getBases()[0].getBaseClass();
|
ICPPClassType xb= (ICPPClassType) C.getBases()[0].getBaseClass();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 IBM Corporation.
|
* Copyright (c) 2007, 2008 IBM Corporation.
|
||||||
* 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
|
||||||
|
@ -44,6 +44,11 @@ import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PDOMSearchTest extends PDOMTestBase {
|
public class PDOMSearchTest extends PDOMTestBase {
|
||||||
|
final Comparator<IBinding> BINDING_COMPARATOR = new Comparator<IBinding>() {
|
||||||
|
public int compare(IBinding o1, IBinding o2) {
|
||||||
|
return o1.getName().compareTo(o2.getName());
|
||||||
|
}};
|
||||||
|
|
||||||
protected ICProject project;
|
protected ICProject project;
|
||||||
protected PDOM pdom;
|
protected PDOM pdom;
|
||||||
protected IProgressMonitor NULL_MONITOR = new NullProgressMonitor();
|
protected IProgressMonitor NULL_MONITOR = new NullProgressMonitor();
|
||||||
|
@ -152,6 +157,7 @@ public class PDOMSearchTest extends PDOMTestBase {
|
||||||
// fields
|
// fields
|
||||||
IBinding[] fields = class2.getFields();
|
IBinding[] fields = class2.getFields();
|
||||||
assertEquals(2, fields.length);
|
assertEquals(2, fields.length);
|
||||||
|
Arrays.sort(fields, BINDING_COMPARATOR);
|
||||||
assertEquals("class1x", fields[0].getName());
|
assertEquals("class1x", fields[0].getName());
|
||||||
assertEquals("class1y", fields[1].getName());
|
assertEquals("class1y", fields[1].getName());
|
||||||
|
|
||||||
|
@ -179,10 +185,7 @@ public class PDOMSearchTest extends PDOMTestBase {
|
||||||
assertEquals("Class2", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(cls1)));
|
assertEquals("Class2", getBindingQualifiedName(pdom.getLinkageImpls()[0].adaptBinding(cls1)));
|
||||||
methods = cls1.getDeclaredMethods();
|
methods = cls1.getDeclaredMethods();
|
||||||
assertEquals(3, methods.length);
|
assertEquals(3, methods.length);
|
||||||
Arrays.sort(methods, new Comparator<IBinding>() {
|
Arrays.sort(methods, BINDING_COMPARATOR);
|
||||||
public int compare(IBinding o1, IBinding o2) {
|
|
||||||
return o1.getName().compareTo(o2.getName());
|
|
||||||
}});
|
|
||||||
assertEquals("Class2", methods[0].getName());
|
assertEquals("Class2", methods[0].getName());
|
||||||
assertEquals("~Class2", methods[2].getName());
|
assertEquals("~Class2", methods[2].getName());
|
||||||
assertEquals("foo", methods[1].getName());
|
assertEquals("foo", methods[1].getName());
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2005, 2007 IBM Corporation and others.
|
* Copyright (c) 2005, 2008 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM - Initial API and implementation
|
* IBM - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
|
||||||
* Created on Apr 5, 2005
|
|
||||||
*/
|
|
||||||
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.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
@ -112,7 +109,12 @@ public class CPPClassTemplatePartialSpecialization extends CPPClassTemplate impl
|
||||||
*/
|
*/
|
||||||
public ObjectMap getArgumentMap() {
|
public ObjectMap getArgumentMap() {
|
||||||
IType[] arg= getArguments();
|
IType[] arg= getArguments();
|
||||||
ICPPTemplateParameter[] params = getTemplateParameters();
|
ICPPTemplateParameter[] params;
|
||||||
|
try {
|
||||||
|
params = getPrimaryClassTemplate().getTemplateParameters();
|
||||||
|
} catch (DOMException e) {
|
||||||
|
return ObjectMap.EMPTY_MAP;
|
||||||
|
}
|
||||||
|
|
||||||
ObjectMap map = new ObjectMap(params.length);
|
ObjectMap map = new ObjectMap(params.length);
|
||||||
for (int i = 0; i < params.length; i++) {
|
for (int i = 0; i < params.length; i++) {
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
/*******************************************************************************
|
|
||||||
* Copyright (c) 2007 Symbian Software Systems 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:
|
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
|
||||||
*******************************************************************************/
|
|
||||||
package org.eclipse.cdt.internal.core.index;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This interface is possibly interim. It allows determining the owner of a parameter.
|
|
||||||
*/
|
|
||||||
public interface IIndexInternalTemplateParameter {
|
|
||||||
ICPPBinding getParameterOwner() throws CoreException;
|
|
||||||
}
|
|
|
@ -6,11 +6,16 @@
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
|
* Markus Schorn (Wind River Systems)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
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.IName;
|
import org.eclipse.cdt.core.dom.IName;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
|
@ -20,15 +25,15 @@ import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
|
||||||
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.ICPPSpecialization;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition;
|
||||||
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.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateScope;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,39 +95,73 @@ public class IndexCPPSignatureUtil {
|
||||||
* @throws DOMException
|
* @throws DOMException
|
||||||
*/
|
*/
|
||||||
private static String getTemplateArgString(IType[] types, boolean qualifyTemplateParameters) throws CoreException, DOMException {
|
private static String getTemplateArgString(IType[] types, boolean qualifyTemplateParameters) throws CoreException, DOMException {
|
||||||
StringBuffer buffer = new StringBuffer();
|
StringBuilder buffer = new StringBuilder();
|
||||||
buffer.append('<');
|
buffer.append('<');
|
||||||
for (int i = 0; i < types.length; i++) {
|
for (int i = 0; i < types.length; i++) {
|
||||||
if (i>0) {
|
if (i>0) {
|
||||||
buffer.append(',');
|
buffer.append(',');
|
||||||
}
|
}
|
||||||
if (qualifyTemplateParameters && types[i] instanceof ICPPTemplateParameter) {
|
final IType type = types[i];
|
||||||
ICPPBinding parent = null;
|
if (qualifyTemplateParameters && type instanceof ICPPTemplateParameter) {
|
||||||
if (types[i] instanceof IIndexInternalTemplateParameter) {
|
List<IBinding> parents = new ArrayList<IBinding>();
|
||||||
parent = ((IIndexInternalTemplateParameter)types[i]).getParameterOwner();
|
IScope parentScope= ((ICPPTemplateParameter) type).getScope();
|
||||||
} else {
|
while (parentScope != null) {
|
||||||
IName parentName = ((ICPPTemplateParameter)types[i]).getScope().getScopeName();
|
if (parentScope instanceof IIndexScope) {
|
||||||
if (parentName instanceof IASTName) {
|
parents.add(((IIndexScope)parentScope).getScopeBinding());
|
||||||
parent = (ICPPBinding)((IASTName)parentName).resolveBinding();
|
}
|
||||||
|
else {
|
||||||
|
final IName scopeName = parentScope.getScopeName();
|
||||||
|
if (scopeName instanceof IASTName) {
|
||||||
|
parents.add(((IASTName) scopeName).resolveBinding());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
parentScope= parentScope.getParent();
|
||||||
|
while (parentScope instanceof ICPPTemplateScope) {
|
||||||
|
parentScope= parentScope.getParent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//identical template parameters from different templates must have unique signatures
|
//identical template parameters from different templates must have unique signatures
|
||||||
if (parent != null) {
|
Collections.reverse(parents);
|
||||||
buffer.append(CPPVisitor.renderQualifiedName(parent.getQualifiedName()));
|
for (IBinding binding : parents) {
|
||||||
String sig = getSignature(parent);
|
if (binding != null) {
|
||||||
if (sig != null)
|
buffer.append(binding.getNameCharArray());
|
||||||
buffer.append(sig);
|
if (binding instanceof ICPPTemplateDefinition) {
|
||||||
buffer.append("::"); //$NON-NLS-1$
|
if (binding instanceof ICPPSpecialization) {
|
||||||
|
ICPPSpecialization spec= (ICPPSpecialization) binding;
|
||||||
|
appendTemplateParams(spec.getArgumentMap().keyArray(), buffer);
|
||||||
|
appendTemplateParams(spec.getArgumentMap().valueArray(), buffer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
ICPPTemplateDefinition def= (ICPPTemplateDefinition) binding;
|
||||||
|
appendTemplateParams(def.getTemplateParameters(), buffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buffer.append("::"); //$NON-NLS-1$
|
||||||
|
}
|
||||||
}
|
}
|
||||||
buffer.append(((ICPPTemplateParameter)types[i]).getName());
|
buffer.append(((ICPPTemplateParameter)type).getName());
|
||||||
} else {
|
} else {
|
||||||
buffer.append(ASTTypeUtil.getType(types[i]));
|
buffer.append(ASTTypeUtil.getType(type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
buffer.append('>');
|
buffer.append('>');
|
||||||
return buffer.toString();
|
return buffer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void appendTemplateParams(Object[] values, StringBuilder buffer) {
|
||||||
|
boolean needcomma= false;
|
||||||
|
buffer.append('<');
|
||||||
|
for (final Object val : values) {
|
||||||
|
if (val instanceof IType) {
|
||||||
|
if (needcomma)
|
||||||
|
buffer.append(',');
|
||||||
|
needcomma= true;
|
||||||
|
buffer.append(ASTTypeUtil.getType((IType) val));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
buffer.append('>');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a string in the format:
|
* Constructs a string in the format:
|
||||||
* (paramName1,paramName2,...)
|
* (paramName1,paramName2,...)
|
||||||
|
|
|
@ -1,26 +1,22 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 Symbian Software Systems and others.
|
* Copyright (c) 2007, 2008 Symbian Software Systems 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Andrew Ferguson (Symbian) - Initial implementation
|
* Andrew Ferguson (Symbian) - Initial implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexInternalTemplateParameter;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
|
|
||||||
public class CompositeCPPTemplateTypeParameter extends CompositeCPPBinding implements ICPPTemplateTypeParameter, IIndexType, IIndexInternalTemplateParameter {
|
public class CompositeCPPTemplateTypeParameter extends CompositeCPPBinding implements ICPPTemplateTypeParameter, IIndexType {
|
||||||
|
|
||||||
public CompositeCPPTemplateTypeParameter(ICompositesFactory cf, ICPPTemplateTypeParameter binding) {
|
public CompositeCPPTemplateTypeParameter(ICompositesFactory cf, ICPPTemplateTypeParameter binding) {
|
||||||
super(cf, binding);
|
super(cf, binding);
|
||||||
|
@ -34,11 +30,6 @@ public class CompositeCPPTemplateTypeParameter extends CompositeCPPBinding imple
|
||||||
public boolean isSameType(IType type) {
|
public boolean isSameType(IType type) {
|
||||||
return ((IType)rbinding).isSameType(type);
|
return ((IType)rbinding).isSameType(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPBinding getParameterOwner() throws CoreException {
|
|
||||||
IIndexFragmentBinding preresult= (IIndexFragmentBinding) ((IIndexInternalTemplateParameter)rbinding).getParameterOwner();
|
|
||||||
return (ICPPBinding) cf.getCompositeBinding(preresult);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object clone() {
|
public Object clone() {
|
||||||
|
|
|
@ -25,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IField;
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||||
|
@ -178,48 +179,32 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
return new FindBinding.NestedBindingsBTreeComparator(this);
|
return new FindBinding.NestedBindingsBTreeComparator(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract PDOMBinding addBinding(IASTName name) throws CoreException;
|
protected boolean cannotAdapt(final IBinding inputBinding) throws CoreException {
|
||||||
|
if (inputBinding == null || inputBinding instanceof IProblemBinding || inputBinding instanceof IParameter) {
|
||||||
public abstract PDOMBinding addBinding(IBinding binding, IASTName fromName) throws CoreException;
|
return true;
|
||||||
|
|
||||||
public final PDOMBinding adaptBinding(final IBinding inputBinding) throws CoreException {
|
|
||||||
if (inputBinding == null || inputBinding instanceof IProblemBinding) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
if (inputBinding instanceof PDOMBinding) {
|
||||||
IBinding binding= inputBinding;
|
PDOMBinding pdomBinding = (PDOMBinding) inputBinding;
|
||||||
|
if (pdomBinding.getPDOM() != getPDOM() && pdomBinding.isFileLocal()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final PDOMBinding attemptFastAdaptBinding(final IBinding binding) throws CoreException {
|
||||||
if (binding instanceof PDOMBinding) {
|
if (binding instanceof PDOMBinding) {
|
||||||
// there is no guarantee, that the binding is from the same PDOM object.
|
// there is no guarantee, that the binding is from the same PDOM object.
|
||||||
PDOMBinding pdomBinding = (PDOMBinding) binding;
|
PDOMBinding pdomBinding = (PDOMBinding) binding;
|
||||||
if (pdomBinding.getPDOM() == getPDOM()) {
|
if (pdomBinding.getPDOM() == getPDOM()) {
|
||||||
return pdomBinding;
|
return pdomBinding;
|
||||||
}
|
}
|
||||||
// if the binding is from another pdom it has to be adapted. However don't adapt file-local bindings
|
|
||||||
if (pdomBinding.isFileLocal()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return (PDOMBinding) pdom.getCachedResult(binding);
|
||||||
PDOMBinding result= (PDOMBinding) pdom.getCachedResult(inputBinding);
|
|
||||||
if (result != null) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
// assign names to anonymous types.
|
|
||||||
binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(binding);
|
|
||||||
if (binding == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
result= doAdaptBinding(binding);
|
|
||||||
if (result != null) {
|
|
||||||
pdom.putCachedResult(inputBinding, result);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
public abstract PDOMBinding adaptBinding(IBinding binding) throws CoreException;
|
||||||
|
public abstract PDOMBinding addBinding(IASTName name) throws CoreException;
|
||||||
|
|
||||||
protected abstract PDOMBinding doAdaptBinding(IBinding binding) throws CoreException;
|
|
||||||
|
|
||||||
final protected int getLocalToFileRec(PDOMNode parent, IBinding binding) throws CoreException {
|
final protected int getLocalToFileRec(PDOMNode parent, IBinding binding) throws CoreException {
|
||||||
int rec= 0;
|
int rec= 0;
|
||||||
if (parent instanceof PDOMBinding) {
|
if (parent instanceof PDOMBinding) {
|
||||||
|
@ -391,4 +376,14 @@ public abstract class PDOMLinkage extends PDOMNamedNode implements IIndexLinkage
|
||||||
pdom.putCachedResult(key, null);
|
pdom.putCachedResult(key, null);
|
||||||
getMacroIndex().delete(container.getRecord());
|
getMacroIndex().delete(container.getRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For debugging purposes, only.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return getLinkageName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,6 @@ import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IField;
|
import org.eclipse.cdt.core.dom.ast.IField;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunction;
|
import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
@ -78,59 +77,78 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
||||||
return C_LINKAGE_ID;
|
return C_LINKAGE_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private PDOMBinding addBinding(final IBinding inputBinding, IASTName fromName) throws CoreException {
|
||||||
public PDOMBinding addBinding(IBinding binding, IASTName fromName) throws CoreException {
|
if (cannotAdapt(inputBinding)) {
|
||||||
PDOMBinding pdomBinding = adaptBinding(binding);
|
return null;
|
||||||
if (pdomBinding != null) {
|
|
||||||
if (shouldUpdate(pdomBinding, fromName)) {
|
|
||||||
pdomBinding.update(this, fromName.getBinding());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
|
PDOMBinding pdomBinding= attemptFastAdaptBinding(inputBinding);
|
||||||
|
|
||||||
|
if (pdomBinding == null) {
|
||||||
// assign names to anonymous types.
|
// assign names to anonymous types.
|
||||||
binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(binding);
|
IBinding binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(inputBinding);
|
||||||
if (binding == null || binding instanceof IParameter)
|
if (binding == null)
|
||||||
return null; // skip parameters
|
return null;
|
||||||
|
|
||||||
PDOMNode parent = getAdaptedParent(binding);
|
PDOMNode parent = getAdaptedParent(binding);
|
||||||
if (parent == null)
|
if (parent == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (binding instanceof IField) { // must be before IVariable
|
pdomBinding = adaptBinding(parent, binding);
|
||||||
if (parent instanceof IPDOMMemberOwner)
|
if (pdomBinding == null) {
|
||||||
pdomBinding = new PDOMCField(pdom, (IPDOMMemberOwner)parent, (IField) binding);
|
pdomBinding = createBinding(parent, binding);
|
||||||
} else if (binding instanceof IVariable) {
|
if (pdomBinding != null) {
|
||||||
IVariable var= (IVariable) binding;
|
pdom.putCachedResult(inputBinding, pdomBinding);
|
||||||
pdomBinding = new PDOMCVariable(pdom, parent, var);
|
|
||||||
} else if (binding instanceof IFunction) {
|
|
||||||
IFunction func= (IFunction) binding;
|
|
||||||
pdomBinding = new PDOMCFunction(pdom, parent, func);
|
|
||||||
} else if (binding instanceof ICompositeType) {
|
|
||||||
pdomBinding = new PDOMCStructure(pdom, parent, (ICompositeType) binding);
|
|
||||||
} else if (binding instanceof IEnumeration) {
|
|
||||||
pdomBinding = new PDOMCEnumeration(pdom, parent, (IEnumeration) binding);
|
|
||||||
} else if (binding instanceof IEnumerator) {
|
|
||||||
try {
|
|
||||||
IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
|
|
||||||
PDOMBinding pdomEnumeration = adaptBinding(enumeration);
|
|
||||||
if (pdomEnumeration instanceof PDOMCEnumeration)
|
|
||||||
pdomBinding = new PDOMCEnumerator(pdom, parent, (IEnumerator) binding, (PDOMCEnumeration)pdomEnumeration);
|
|
||||||
} catch (DOMException e) {
|
|
||||||
throw new CoreException(Util.createStatus(e));
|
|
||||||
}
|
}
|
||||||
} else if (binding instanceof ITypedef) {
|
return pdomBinding;
|
||||||
pdomBinding = new PDOMCTypedef(pdom, parent, (ITypedef)binding);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pdomBinding != null) {
|
pdom.putCachedResult(inputBinding, pdomBinding);
|
||||||
pdomBinding.setLocalToFileRec(getLocalToFileRec(parent, binding));
|
}
|
||||||
parent.addChild(pdomBinding);
|
|
||||||
afterAddBinding(pdomBinding);
|
if (shouldUpdate(pdomBinding, fromName)) {
|
||||||
}
|
pdomBinding.update(this, fromName.getBinding());
|
||||||
}
|
}
|
||||||
return pdomBinding;
|
return pdomBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PDOMBinding createBinding(PDOMNode parent, IBinding binding) throws CoreException {
|
||||||
|
PDOMBinding pdomBinding= null;
|
||||||
|
|
||||||
|
if (binding instanceof IField) { // must be before IVariable
|
||||||
|
if (parent instanceof IPDOMMemberOwner)
|
||||||
|
pdomBinding = new PDOMCField(pdom, (IPDOMMemberOwner)parent, (IField) binding);
|
||||||
|
} else if (binding instanceof IVariable) {
|
||||||
|
IVariable var= (IVariable) binding;
|
||||||
|
pdomBinding = new PDOMCVariable(pdom, parent, var);
|
||||||
|
} else if (binding instanceof IFunction) {
|
||||||
|
IFunction func= (IFunction) binding;
|
||||||
|
pdomBinding = new PDOMCFunction(pdom, parent, func);
|
||||||
|
} else if (binding instanceof ICompositeType) {
|
||||||
|
pdomBinding = new PDOMCStructure(pdom, parent, (ICompositeType) binding);
|
||||||
|
} else if (binding instanceof IEnumeration) {
|
||||||
|
pdomBinding = new PDOMCEnumeration(pdom, parent, (IEnumeration) binding);
|
||||||
|
} else if (binding instanceof IEnumerator) {
|
||||||
|
try {
|
||||||
|
IEnumeration enumeration = (IEnumeration)((IEnumerator)binding).getType();
|
||||||
|
PDOMBinding pdomEnumeration = adaptBinding(enumeration);
|
||||||
|
if (pdomEnumeration instanceof PDOMCEnumeration)
|
||||||
|
pdomBinding = new PDOMCEnumerator(pdom, parent, (IEnumerator) binding, (PDOMCEnumeration)pdomEnumeration);
|
||||||
|
} catch (DOMException e) {
|
||||||
|
throw new CoreException(Util.createStatus(e));
|
||||||
|
}
|
||||||
|
} else if (binding instanceof ITypedef) {
|
||||||
|
pdomBinding = new PDOMCTypedef(pdom, parent, (ITypedef)binding);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pdomBinding != null) {
|
||||||
|
pdomBinding.setLocalToFileRec(getLocalToFileRec(parent, binding));
|
||||||
|
parent.addChild(pdomBinding);
|
||||||
|
afterAddBinding(pdomBinding);
|
||||||
|
}
|
||||||
|
return pdomBinding;
|
||||||
|
}
|
||||||
|
|
||||||
private boolean shouldUpdate(PDOMBinding pdomBinding, IASTName fromName) throws CoreException {
|
private boolean shouldUpdate(PDOMBinding pdomBinding, IASTName fromName) throws CoreException {
|
||||||
if (fromName != null) {
|
if (fromName != null) {
|
||||||
if (fromName.isDefinition()) {
|
if (fromName.isDefinition()) {
|
||||||
|
@ -154,14 +172,6 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
if (binding == null || binding instanceof IProblemBinding)
|
|
||||||
// can't tell what it is
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (binding instanceof IParameter)
|
|
||||||
// skip parameters
|
|
||||||
return null;
|
|
||||||
|
|
||||||
return addBinding(binding, name);
|
return addBinding(binding, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -264,8 +274,36 @@ class PDOMCLinkage extends PDOMLinkage implements IIndexCBindingConstants {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final PDOMBinding doAdaptBinding(final IBinding binding) throws CoreException {
|
public final PDOMBinding adaptBinding(final IBinding inputBinding) throws CoreException {
|
||||||
PDOMNode parent = getAdaptedParent(binding);
|
return adaptBinding(null, inputBinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding) throws CoreException {
|
||||||
|
if (cannotAdapt(inputBinding)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
PDOMBinding result= attemptFastAdaptBinding(inputBinding);
|
||||||
|
if (result != null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// assign names to anonymous types.
|
||||||
|
IBinding binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(inputBinding);
|
||||||
|
if (binding == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
result= doAdaptBinding(parent, binding);
|
||||||
|
if (result != null) {
|
||||||
|
pdom.putCachedResult(inputBinding, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final PDOMBinding doAdaptBinding(PDOMNode parent, final IBinding binding) throws CoreException {
|
||||||
|
if (parent == null) {
|
||||||
|
parent= getAdaptedParent(binding);
|
||||||
|
}
|
||||||
if (parent == this) {
|
if (parent == this) {
|
||||||
int localToFileRec= getLocalToFileRec(null, binding);
|
int localToFileRec= getLocalToFileRec(null, binding);
|
||||||
return FindBinding.findBinding(getIndex(), getPDOM(), binding.getNameCharArray(), new int[] {getBindingType(binding)}, localToFileRec);
|
return FindBinding.findBinding(getIndex(), getPDOM(), binding.getNameCharArray(), new int[] {getBindingType(binding)}, localToFileRec);
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 QNX Software Systems and others.
|
* Copyright (c) 2007, 2008 QNX Software Systems 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
|
@ -222,7 +222,12 @@ class PDOMCPPClassTemplatePartialSpecialization extends
|
||||||
public ObjectMap getArgumentMap() {
|
public ObjectMap getArgumentMap() {
|
||||||
try {
|
try {
|
||||||
PDOMNodeLinkedList argList = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
|
PDOMNodeLinkedList argList = new PDOMNodeLinkedList(pdom, record + ARGUMENTS, getLinkageImpl());
|
||||||
ICPPTemplateParameter[] params = getTemplateParameters();
|
ICPPTemplateParameter[] params;
|
||||||
|
try {
|
||||||
|
params = getPrimaryClassTemplate().getTemplateParameters();
|
||||||
|
} catch (DOMException e) {
|
||||||
|
return ObjectMap.EMPTY_MAP;
|
||||||
|
}
|
||||||
NodeCollector argVisitor = new NodeCollector();
|
NodeCollector argVisitor = new NodeCollector();
|
||||||
argList.accept(argVisitor);
|
argList.accept(argVisitor);
|
||||||
IPDOMNode[] argNodes = argVisitor.getNodes();
|
IPDOMNode[] argNodes = argVisitor.getNodes();
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
* Andrew Ferguson (Symbian)
|
* Andrew Ferguson (Symbian)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -29,7 +28,6 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
import org.eclipse.cdt.core.dom.ast.IEnumeration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
import org.eclipse.cdt.core.dom.ast.IEnumerator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
@ -201,6 +199,9 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
|
|
||||||
List<Runnable> postProcesses = new ArrayList<Runnable>();
|
List<Runnable> postProcesses = new ArrayList<Runnable>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds or returns existing binding for the given name.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PDOMBinding addBinding(IASTName name) throws CoreException {
|
public PDOMBinding addBinding(IASTName name) throws CoreException {
|
||||||
if (name == null || name instanceof ICPPASTQualifiedName)
|
if (name == null || name instanceof ICPPASTQualifiedName)
|
||||||
|
@ -213,15 +214,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
|
|
||||||
IBinding binding = name.resolveBinding();
|
IBinding binding = name.resolveBinding();
|
||||||
|
|
||||||
if (binding == null || binding instanceof IProblemBinding) {
|
|
||||||
// Can't tell what it is
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (binding instanceof IParameter)
|
|
||||||
// Skip parameters (TODO and others I'm sure)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
PDOMBinding pdomBinding = addBinding(binding, name);
|
PDOMBinding pdomBinding = addBinding(binding, name);
|
||||||
if (pdomBinding instanceof PDOMCPPClassType || pdomBinding instanceof PDOMCPPClassSpecialization) {
|
if (pdomBinding instanceof PDOMCPPClassType || pdomBinding instanceof PDOMCPPClassSpecialization) {
|
||||||
if (binding instanceof ICPPClassType && name.isDefinition()) {
|
if (binding instanceof ICPPClassType && name.isDefinition()) {
|
||||||
|
@ -229,46 +221,59 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePostProcesses();
|
handlePostProcesses();
|
||||||
|
|
||||||
return pdomBinding;
|
return pdomBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public PDOMBinding addBinding(IBinding binding, IASTName fromName) throws CoreException {
|
* Adds or returns existing binding for the given one. If <code>fromName</code> is not <code>null</code>
|
||||||
// assign names to anonymous types.
|
* then an existing binding is updated with the properties of the name.
|
||||||
binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(binding);
|
*/
|
||||||
if (binding == null)
|
private PDOMBinding addBinding(final IBinding inputBinding, IASTName fromName) throws CoreException {
|
||||||
|
if (cannotAdapt(inputBinding)) {
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
final PDOMNode parent= adaptOrAddParent(true, binding);
|
PDOMBinding pdomBinding= attemptFastAdaptBinding(inputBinding);
|
||||||
if (parent == null)
|
if (pdomBinding == null) {
|
||||||
return null;
|
// assign names to anonymous types.
|
||||||
|
IBinding binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(inputBinding);
|
||||||
|
if (binding == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
final PDOMNode parent= adaptOrAddParent(true, binding);
|
||||||
|
if (parent == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
PDOMBinding pdomBinding = adaptBinding(binding);
|
pdomBinding = adaptBinding(parent, binding);
|
||||||
if (pdomBinding != null) {
|
if (pdomBinding != null) {
|
||||||
if (shouldUpdate(pdomBinding, fromName)) {
|
pdom.putCachedResult(inputBinding, pdomBinding);
|
||||||
pdomBinding.update(this, fromName.getBinding());
|
|
||||||
}
|
}
|
||||||
} else {
|
else {
|
||||||
try {
|
try {
|
||||||
if (binding instanceof ICPPSpecialization) {
|
pdomBinding = createBinding(parent, binding);
|
||||||
IBinding specialized= ((ICPPSpecialization)binding).getSpecializedBinding();
|
if (pdomBinding != null) {
|
||||||
addBinding(specialized, null);
|
pdom.putCachedResult(inputBinding, pdomBinding);
|
||||||
}
|
|
||||||
|
|
||||||
pdomBinding = addBinding(parent, binding);
|
|
||||||
if ((pdomBinding instanceof PDOMCPPClassInstance || pdomBinding instanceof PDOMCPPDeferredClassInstance) && binding instanceof ICPPClassType) {
|
|
||||||
// Add instantiated constructors to the index (bug 201174).
|
|
||||||
addConstructors(pdomBinding, (ICPPClassType) binding);
|
|
||||||
if(SemanticUtil.ENABLE_224364) {
|
|
||||||
addConversionOperators(pdomBinding, (ICPPClassType) binding);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (binding instanceof ICPPClassType && (pdomBinding instanceof PDOMCPPClassInstance
|
||||||
|
|| pdomBinding instanceof PDOMCPPDeferredClassInstance)) {
|
||||||
|
// Add instantiated constructors to the index (bug 201174).
|
||||||
|
addConstructors(pdomBinding, (ICPPClassType) binding);
|
||||||
|
if(SemanticUtil.ENABLE_224364) {
|
||||||
|
addConversionOperators(pdomBinding, (ICPPClassType) binding);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (DOMException e) {
|
||||||
|
throw new CoreException(Util.createStatus(e));
|
||||||
}
|
}
|
||||||
} catch (DOMException e) {
|
return pdomBinding;
|
||||||
throw new CoreException(Util.createStatus(e));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (shouldUpdate(pdomBinding, fromName)) {
|
||||||
|
pdomBinding.update(this, fromName.getBinding());
|
||||||
|
}
|
||||||
return pdomBinding;
|
return pdomBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,74 +312,16 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private PDOMBinding addBinding(PDOMNode parent, IBinding binding) throws CoreException, DOMException {
|
private PDOMBinding createBinding(PDOMNode parent, IBinding binding) throws CoreException, DOMException {
|
||||||
PDOMBinding pdomBinding= null;
|
PDOMBinding pdomBinding= null;
|
||||||
|
|
||||||
if (binding instanceof ICPPSpecialization) {
|
if (binding instanceof ICPPSpecialization) {
|
||||||
IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding();
|
IBinding specialized = ((ICPPSpecialization)binding).getSpecializedBinding();
|
||||||
PDOMBinding pdomSpecialized= adaptBinding(specialized);
|
PDOMBinding pdomSpecialized= addBinding(specialized, null);
|
||||||
if (pdomSpecialized == null)
|
if (pdomSpecialized == null)
|
||||||
return null;
|
return null;
|
||||||
if (binding instanceof ICPPDeferredTemplateInstance) {
|
|
||||||
if (binding instanceof ICPPFunction && pdomSpecialized instanceof ICPPFunctionTemplate) {
|
pdomBinding = createSpecializationBinding(parent, pdomSpecialized, binding);
|
||||||
pdomBinding = new PDOMCPPDeferredFunctionInstance(pdom,
|
|
||||||
parent, (ICPPFunction) binding, pdomSpecialized);
|
|
||||||
} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof ICPPClassTemplate) {
|
|
||||||
pdomBinding = new PDOMCPPDeferredClassInstance(pdom,
|
|
||||||
parent, (ICPPClassType) binding, pdomSpecialized);
|
|
||||||
}
|
|
||||||
} else if (binding instanceof ICPPTemplateInstance) {
|
|
||||||
if (binding instanceof ICPPConstructor && pdomSpecialized instanceof ICPPConstructor) {
|
|
||||||
pdomBinding = new PDOMCPPConstructorInstance(pdom, parent,
|
|
||||||
(ICPPConstructor) binding, pdomSpecialized);
|
|
||||||
} else if (binding instanceof ICPPMethod && pdomSpecialized instanceof ICPPMethod) {
|
|
||||||
pdomBinding = new PDOMCPPMethodInstance(pdom, parent,
|
|
||||||
(ICPPMethod) binding, pdomSpecialized);
|
|
||||||
} else if (binding instanceof ICPPFunction && pdomSpecialized instanceof ICPPFunction) {
|
|
||||||
pdomBinding = new PDOMCPPFunctionInstance(pdom, parent,
|
|
||||||
(ICPPFunction) binding, pdomSpecialized);
|
|
||||||
} else if (binding instanceof ICPPClassType && pdomSpecialized instanceof ICPPClassType) {
|
|
||||||
pdomBinding = new PDOMCPPClassInstance(pdom, parent,
|
|
||||||
(ICPPClassType) binding, pdomSpecialized);
|
|
||||||
}
|
|
||||||
} else if (binding instanceof ICPPClassTemplatePartialSpecialization &&
|
|
||||||
pdomSpecialized instanceof PDOMCPPClassTemplate) {
|
|
||||||
pdomBinding = new PDOMCPPClassTemplatePartialSpecialization(
|
|
||||||
pdom, parent, (ICPPClassTemplatePartialSpecialization) binding,
|
|
||||||
(PDOMCPPClassTemplate) pdomSpecialized);
|
|
||||||
} else if (binding instanceof ICPPField) {
|
|
||||||
pdomBinding = new PDOMCPPFieldSpecialization(pdom, parent,
|
|
||||||
(ICPPField) binding, pdomSpecialized);
|
|
||||||
} else if (binding instanceof ICPPFunctionTemplate) {
|
|
||||||
if (binding instanceof ICPPConstructor) {
|
|
||||||
pdomBinding = new PDOMCPPConstructorTemplateSpecialization(
|
|
||||||
pdom, parent, (ICPPConstructor) binding, pdomSpecialized);
|
|
||||||
} else if (binding instanceof ICPPMethod) {
|
|
||||||
pdomBinding = new PDOMCPPMethodTemplateSpecialization(
|
|
||||||
pdom, parent, (ICPPMethod) binding, pdomSpecialized);
|
|
||||||
} else if (binding instanceof ICPPFunction) {
|
|
||||||
pdomBinding = new PDOMCPPFunctionTemplateSpecialization(
|
|
||||||
pdom, parent, (ICPPFunctionTemplate) binding, pdomSpecialized);
|
|
||||||
}
|
|
||||||
} else if (binding instanceof ICPPConstructor) {
|
|
||||||
pdomBinding = new PDOMCPPConstructorSpecialization(pdom, parent,
|
|
||||||
(ICPPConstructor) binding, pdomSpecialized);
|
|
||||||
} else if (binding instanceof ICPPMethod) {
|
|
||||||
pdomBinding = new PDOMCPPMethodSpecialization(pdom, parent,
|
|
||||||
(ICPPMethod) binding, pdomSpecialized);
|
|
||||||
} else if (binding instanceof ICPPFunction) {
|
|
||||||
pdomBinding = new PDOMCPPFunctionSpecialization(pdom, parent,
|
|
||||||
(ICPPFunction) binding, pdomSpecialized);
|
|
||||||
} else if (binding instanceof ICPPClassTemplate) {
|
|
||||||
pdomBinding = new PDOMCPPClassTemplateSpecialization(pdom, parent,
|
|
||||||
(ICPPClassTemplate) binding, pdomSpecialized);
|
|
||||||
} else if (binding instanceof ICPPClassType) {
|
|
||||||
pdomBinding = new PDOMCPPClassSpecialization(pdom, parent,
|
|
||||||
(ICPPClassType) binding, pdomSpecialized);
|
|
||||||
} else if (binding instanceof ITypedef) {
|
|
||||||
pdomBinding = new PDOMCPPTypedefSpecialization(pdom, parent,
|
|
||||||
(ITypedef) binding, pdomSpecialized);
|
|
||||||
}
|
|
||||||
} else if (binding instanceof ICPPTemplateParameter) {
|
} else if (binding instanceof ICPPTemplateParameter) {
|
||||||
if (binding instanceof ICPPTemplateTypeParameter) {
|
if (binding instanceof ICPPTemplateTypeParameter) {
|
||||||
pdomBinding = new PDOMCPPTemplateTypeParameter(pdom, parent, (ICPPTemplateTypeParameter)binding);
|
pdomBinding = new PDOMCPPTemplateTypeParameter(pdom, parent, (ICPPTemplateTypeParameter)binding);
|
||||||
|
@ -453,6 +400,90 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
|
|
||||||
return pdomBinding;
|
return pdomBinding;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private PDOMBinding createSpecializationBinding(PDOMNode parent, PDOMBinding pdomSpecialized,
|
||||||
|
IBinding binding) throws CoreException {
|
||||||
|
if (binding instanceof ICPPDeferredTemplateInstance) {
|
||||||
|
if (binding instanceof ICPPFunction && pdomSpecialized instanceof ICPPFunctionTemplate) {
|
||||||
|
return new PDOMCPPDeferredFunctionInstance(pdom,
|
||||||
|
parent, (ICPPFunction) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPClassType && pdomSpecialized instanceof ICPPClassTemplate) {
|
||||||
|
return new PDOMCPPDeferredClassInstance(pdom,
|
||||||
|
parent, (ICPPClassType) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPTemplateInstance) {
|
||||||
|
if (binding instanceof ICPPConstructor && pdomSpecialized instanceof ICPPConstructor) {
|
||||||
|
return new PDOMCPPConstructorInstance(pdom, parent,
|
||||||
|
(ICPPConstructor) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPMethod && pdomSpecialized instanceof ICPPMethod) {
|
||||||
|
return new PDOMCPPMethodInstance(pdom, parent,
|
||||||
|
(ICPPMethod) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPFunction && pdomSpecialized instanceof ICPPFunction) {
|
||||||
|
return new PDOMCPPFunctionInstance(pdom, parent,
|
||||||
|
(ICPPFunction) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPClassType && pdomSpecialized instanceof ICPPClassType) {
|
||||||
|
return new PDOMCPPClassInstance(pdom, parent,
|
||||||
|
(ICPPClassType) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPClassTemplatePartialSpecialization &&
|
||||||
|
pdomSpecialized instanceof PDOMCPPClassTemplate) {
|
||||||
|
return new PDOMCPPClassTemplatePartialSpecialization(
|
||||||
|
pdom, parent, (ICPPClassTemplatePartialSpecialization) binding,
|
||||||
|
(PDOMCPPClassTemplate) pdomSpecialized);
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPField) {
|
||||||
|
return new PDOMCPPFieldSpecialization(pdom, parent,
|
||||||
|
(ICPPField) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPFunctionTemplate) {
|
||||||
|
if (binding instanceof ICPPConstructor) {
|
||||||
|
return new PDOMCPPConstructorTemplateSpecialization(
|
||||||
|
pdom, parent, (ICPPConstructor) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPMethod) {
|
||||||
|
return new PDOMCPPMethodTemplateSpecialization(
|
||||||
|
pdom, parent, (ICPPMethod) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPFunction) {
|
||||||
|
return new PDOMCPPFunctionTemplateSpecialization(
|
||||||
|
pdom, parent, (ICPPFunctionTemplate) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPConstructor) {
|
||||||
|
return new PDOMCPPConstructorSpecialization(pdom, parent,
|
||||||
|
(ICPPConstructor) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPMethod) {
|
||||||
|
return new PDOMCPPMethodSpecialization(pdom, parent,
|
||||||
|
(ICPPMethod) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPFunction) {
|
||||||
|
return new PDOMCPPFunctionSpecialization(pdom, parent,
|
||||||
|
(ICPPFunction) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPClassTemplate) {
|
||||||
|
return new PDOMCPPClassTemplateSpecialization(pdom, parent,
|
||||||
|
(ICPPClassTemplate) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
if (binding instanceof ICPPClassType) {
|
||||||
|
return new PDOMCPPClassSpecialization(pdom, parent,
|
||||||
|
(ICPPClassType) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
if (binding instanceof ITypedef) {
|
||||||
|
return new PDOMCPPTypedefSpecialization(pdom, parent,
|
||||||
|
(ITypedef) binding, pdomSpecialized);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
private void pushPostProcesses(PDOMBinding pdomBinding, IBinding binding) throws CoreException, DOMException {
|
private void pushPostProcesses(PDOMBinding pdomBinding, IBinding binding) throws CoreException, DOMException {
|
||||||
if (pdomBinding instanceof PDOMCPPClassTemplatePartialSpecialization &&
|
if (pdomBinding instanceof PDOMCPPClassTemplatePartialSpecialization &&
|
||||||
|
@ -480,7 +511,7 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
for (ICPPMethod method : implicit) {
|
for (ICPPMethod method : implicit) {
|
||||||
PDOMBinding pdomBinding= adaptBinding(method);
|
PDOMBinding pdomBinding= adaptBinding(method);
|
||||||
if (pdomBinding == null) {
|
if (pdomBinding == null) {
|
||||||
addBinding(type, method);
|
createBinding(type, method);
|
||||||
} else if (!pdomBinding.hasDefinition()) {
|
} else if (!pdomBinding.hasDefinition()) {
|
||||||
pdomBinding.update(this, method);
|
pdomBinding.update(this, method);
|
||||||
}
|
}
|
||||||
|
@ -596,12 +627,41 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Find the equivalent binding, or binding placeholder within this PDOM
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public PDOMBinding doAdaptBinding(IBinding binding) throws CoreException {
|
public final PDOMBinding adaptBinding(final IBinding inputBinding) throws CoreException {
|
||||||
PDOMNode parent = adaptOrAddParent(false, binding);
|
return adaptBinding(null, inputBinding);
|
||||||
|
}
|
||||||
|
|
||||||
|
private final PDOMBinding adaptBinding(final PDOMNode parent, IBinding inputBinding) throws CoreException {
|
||||||
|
if (cannotAdapt(inputBinding)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
PDOMBinding result= attemptFastAdaptBinding(inputBinding);
|
||||||
|
if (result != null) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// assign names to anonymous types.
|
||||||
|
IBinding binding= PDOMASTAdapter.getAdapterForAnonymousASTBinding(inputBinding);
|
||||||
|
if (binding == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
result= doAdaptBinding(parent, binding);
|
||||||
|
if (result != null) {
|
||||||
|
pdom.putCachedResult(inputBinding, result);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Find the equivalent binding, or binding place holder within this PDOM
|
||||||
|
*/
|
||||||
|
private final PDOMBinding doAdaptBinding(PDOMNode parent, IBinding binding) throws CoreException {
|
||||||
|
if (parent == null) {
|
||||||
|
parent= adaptOrAddParent(false, binding);
|
||||||
|
}
|
||||||
if (parent == this) {
|
if (parent == this) {
|
||||||
int localToFileRec= getLocalToFileRec(null, binding);
|
int localToFileRec= getLocalToFileRec(null, binding);
|
||||||
return CPPFindBinding.findBinding(getIndex(), this, binding, localToFileRec);
|
return CPPFindBinding.findBinding(getIndex(), this, binding, localToFileRec);
|
||||||
|
@ -611,14 +671,6 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
return CPPFindBinding.findBinding(((PDOMCPPNamespace)parent).getIndex(), this, binding,
|
return CPPFindBinding.findBinding(((PDOMCPPNamespace)parent).getIndex(), this, binding,
|
||||||
localToFileRec);
|
localToFileRec);
|
||||||
}
|
}
|
||||||
// TODO(sprigogin): Hack. There should be a better way to adapt unknown bindings.
|
|
||||||
if (parent instanceof ICPPInternalUnknown) {
|
|
||||||
if (binding instanceof ICPPInternalUnknownClassInstance) {
|
|
||||||
return new PDOMCPPUnknownClassInstance(getPDOM(), parent, (ICPPInternalUnknownClassInstance) binding);
|
|
||||||
} else if (binding instanceof ICPPInternalUnknownClassType) {
|
|
||||||
return new PDOMCPPUnknownClassType(getPDOM(), parent, (ICPPInternalUnknownClassType) binding);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (parent instanceof IPDOMMemberOwner) {
|
if (parent instanceof IPDOMMemberOwner) {
|
||||||
int localToFileRec= getLocalToFileRec(parent, binding);
|
int localToFileRec= getLocalToFileRec(parent, binding);
|
||||||
return CPPFindBinding.findBinding(parent, this, binding, localToFileRec);
|
return CPPFindBinding.findBinding(parent, this, binding, localToFileRec);
|
||||||
|
@ -641,9 +693,11 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
private final PDOMNode adaptOrAddParent(boolean add, IBinding binding) throws CoreException {
|
private final PDOMNode adaptOrAddParent(boolean add, IBinding binding) throws CoreException {
|
||||||
try {
|
try {
|
||||||
IBinding scopeBinding = null;
|
IBinding scopeBinding = null;
|
||||||
|
// all instances are stored with their template definition
|
||||||
if (binding instanceof ICPPTemplateInstance) {
|
if (binding instanceof ICPPTemplateInstance) {
|
||||||
scopeBinding = ((ICPPTemplateInstance)binding).getTemplateDefinition();
|
scopeBinding= ((ICPPTemplateInstance) binding).getTemplateDefinition();
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
IScope scope = binding.getScope();
|
IScope scope = binding.getScope();
|
||||||
if (binding instanceof IIndexBinding) {
|
if (binding instanceof IIndexBinding) {
|
||||||
IIndexBinding ib= (IIndexBinding) binding;
|
IIndexBinding ib= (IIndexBinding) binding;
|
||||||
|
@ -651,72 +705,58 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
||||||
if (ib.isFileLocal()) {
|
if (ib.isFileLocal()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
// in an index the null scope represents global scope.
|
||||||
if (scope == null) {
|
if (scope == null) {
|
||||||
if (binding instanceof ICPPInternalUnknownClassType) {
|
|
||||||
if (binding instanceof PDOMBinding) {
|
|
||||||
return adaptOrAddBinding(add, ((PDOMBinding) binding).getParentBinding());
|
|
||||||
}
|
|
||||||
// what if we have a composite binding??
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// in an index the null scope represents global scope.
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (scope == null) {
|
if (scope == null) {
|
||||||
if (binding instanceof ICPPSpecialization) {
|
|
||||||
if (((ICPPSpecialization) binding).getSpecializedBinding() instanceof IIndexBinding) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope instanceof ICPPTemplateScope &&
|
if (scope instanceof ICPPTemplateScope && !(binding instanceof ICPPTemplateParameter)) {
|
||||||
!(binding instanceof ICPPTemplateParameter || binding instanceof ICPPTemplateInstance)) {
|
|
||||||
scope = scope.getParent();
|
scope = scope.getParent();
|
||||||
if (scope == null) {
|
if (scope == null) {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scope instanceof IIndexScope) {
|
if (scope instanceof IIndexScope) {
|
||||||
if (scope instanceof CompositeScope) { // we special case for performance
|
if (scope instanceof CompositeScope) { // we special case for performance
|
||||||
return adaptOrAddBinding(add, ((CompositeScope) scope).getRawScopeBinding());
|
return adaptOrAddBinding(add, ((CompositeScope) scope).getRawScopeBinding());
|
||||||
}
|
}
|
||||||
return adaptOrAddBinding(add, ((IIndexScope) scope).getScopeBinding());
|
return adaptOrAddBinding(add, ((IIndexScope) scope).getScopeBinding());
|
||||||
}
|
}
|
||||||
|
|
||||||
// the scope is from the ast
|
// the scope is from the ast
|
||||||
while (scope instanceof ICPPNamespaceScope) {
|
while (scope instanceof ICPPNamespaceScope) {
|
||||||
IName name= scope.getScopeName();
|
final IName name= scope.getScopeName();
|
||||||
if (name != null && name.toCharArray().length == 0) {
|
if (name == null || name.toCharArray().length > 0) {
|
||||||
// skip unnamed namespaces
|
|
||||||
scope= scope.getParent();
|
|
||||||
} else {
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
// skip unnamed namespaces
|
||||||
|
scope= scope.getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
IASTNode scopeNode = ASTInternal.getPhysicalNodeOfScope(scope);
|
IASTNode scopeNode = ASTInternal.getPhysicalNodeOfScope(scope);
|
||||||
if (scopeNode instanceof IASTCompoundStatement) {
|
if (scopeNode instanceof IASTCompoundStatement) {
|
||||||
return null;
|
return null;
|
||||||
} else if (scopeNode instanceof IASTTranslationUnit) {
|
}
|
||||||
|
if (scopeNode instanceof IASTTranslationUnit) {
|
||||||
return this;
|
return this;
|
||||||
|
}
|
||||||
|
if (scope instanceof ICPPClassScope) {
|
||||||
|
scopeBinding = ((ICPPClassScope)scope).getClassType();
|
||||||
|
} else if (scope instanceof ICPPInternalUnknownScope) {
|
||||||
|
scopeBinding = ((ICPPInternalUnknownScope) scope).getScopeBinding();
|
||||||
} else {
|
} else {
|
||||||
if (scope instanceof ICPPClassScope) {
|
IName scopeName = scope.getScopeName();
|
||||||
scopeBinding = ((ICPPClassScope)scope).getClassType();
|
if (scopeName instanceof IASTName) {
|
||||||
} else if (scope instanceof ICPPInternalUnknownScope) {
|
scopeBinding = ((IASTName) scopeName).resolveBinding();
|
||||||
scopeBinding = ((ICPPInternalUnknownScope) scope).getScopeBinding();
|
|
||||||
} else {
|
|
||||||
IName scopeName = scope.getScopeName();
|
|
||||||
if (scopeName instanceof IASTName) {
|
|
||||||
scopeBinding = ((IASTName) scopeName).resolveBinding();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
assert scopeBinding != binding;
|
||||||
if (scopeBinding != null && scopeBinding != binding) {
|
if (scopeBinding != null && scopeBinding != binding) {
|
||||||
return adaptOrAddBinding(add, scopeBinding);
|
return adaptOrAddBinding(add, scopeBinding);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2007 QNX Software Systems and others.
|
* Copyright (c) 2007, 2008 QNX Software Systems 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
|
||||||
* http://www.eclipse.org/legal/epl-v10.html
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
* Sergey Prigogin (Google)
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
|
@ -26,25 +27,27 @@ import org.eclipse.cdt.internal.core.Util;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknown;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexInternalTemplateParameter;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||||
|
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Bryan Wilkinson
|
* @author Bryan Wilkinson
|
||||||
*/
|
*/
|
||||||
class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements
|
class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements IPDOMMemberOwner,
|
||||||
ICPPTemplateTypeParameter, ICPPInternalUnknown, IIndexType, IIndexInternalTemplateParameter {
|
ICPPTemplateTypeParameter, ICPPInternalUnknown, IIndexType {
|
||||||
|
|
||||||
private static final int DEFAULT_TYPE = PDOMCPPBinding.RECORD_SIZE + 0;
|
private static final int DEFAULT_TYPE = PDOMCPPBinding.RECORD_SIZE + 0;
|
||||||
|
private static final int MEMBERLIST = PDOMCPPBinding.RECORD_SIZE + 4;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The size in bytes of a PDOMCPPTemplateTypeParameter record in the database.
|
* The size in bytes of a PDOMCPPTemplateTypeParameter record in the database.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("hiding")
|
@SuppressWarnings("hiding")
|
||||||
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 4;
|
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + 8;
|
||||||
|
|
||||||
public PDOMCPPTemplateTypeParameter(PDOM pdom, PDOMNode parent,
|
public PDOMCPPTemplateTypeParameter(PDOM pdom, PDOMNode parent,
|
||||||
ICPPTemplateTypeParameter param) throws CoreException {
|
ICPPTemplateTypeParameter param) throws CoreException {
|
||||||
|
@ -77,6 +80,22 @@ class PDOMCPPTemplateTypeParameter extends PDOMCPPBinding implements
|
||||||
return IIndexCPPBindingConstants.CPP_TEMPLATE_TYPE_PARAMETER;
|
return IIndexCPPBindingConstants.CPP_TEMPLATE_TYPE_PARAMETER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addChild(PDOMNode member) throws CoreException {
|
||||||
|
addMember(member);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMember(PDOMNode member) throws CoreException {
|
||||||
|
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
|
||||||
|
list.addMember(member);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void accept(IPDOMVisitor visitor) throws CoreException {
|
||||||
|
PDOMNodeLinkedList list = new PDOMNodeLinkedList(pdom, record + MEMBERLIST, getLinkageImpl());
|
||||||
|
list.accept(visitor);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isSameType(IType type) {
|
public boolean isSameType(IType type) {
|
||||||
if (type instanceof ITypedef) {
|
if (type instanceof ITypedef) {
|
||||||
return type.isSameType(this);
|
return type.isSameType(this);
|
||||||
|
|
Loading…
Add table
Reference in a new issue