From 773b11c2046b3d29ae93846b34d2c1977f585951 Mon Sep 17 00:00:00 2001 From: Andrew Ferguson Date: Thu, 23 Nov 2006 18:31:38 +0000 Subject: [PATCH] 165213: undo misadventure with abstraction --- .../index/tests/TrilogyPerformanceTest.java | 71 ++++++++ .../resources/indexTests/trilogy/trilogy.cpp | 5 + .../org.eclipse.cdt.core/META-INF/MANIFEST.MF | 1 - .../bid/AbstractCLocalBindingIdentity.java | 54 ------ .../bid/CLocalBindingIdentityComparator.java | 77 --------- .../core/dom/bid/IBindingIdentityFactory.java | 35 ---- .../core/dom/bid/ICLocalBindingIdentity.java | 37 ----- .../core/dom/bid/ILocalBindingIdentity.java | 28 ---- .../bid/ILocalBindingIdentityComparator.java | 52 ------ .../internal/core/pdom/dom/FindBinding.java | 87 ++++++++++ .../dom/FindBindingByLinkageConstant.java | 70 -------- .../core/pdom/dom/FindEquivalentBinding.java | 74 --------- .../internal/core/pdom/dom/PDOMBinding.java | 7 +- .../internal/core/pdom/dom/PDOMLinkage.java | 17 +- .../internal/core/pdom/dom/PDOMNamedNode.java | 7 +- .../core/pdom/dom/c/CBindingIdentity.java | 47 ------ .../core/pdom/dom/c/PDOMCLinkage.java | 58 ++----- .../core/pdom/dom/cpp/CPPBindingIdentity.java | 112 ------------- .../core/pdom/dom/cpp/CPPFindBinding.java | 154 ++++++++++++++++++ .../core/pdom/dom/cpp/PDOMCPPClassType.java | 33 +--- .../core/pdom/dom/cpp/PDOMCPPFunction.java | 46 +++++- .../core/pdom/dom/cpp/PDOMCPPLinkage.java | 134 +++++---------- .../core/pdom/dom/cpp/PDOMCPPMethod.java | 117 ++----------- .../core/pdom/dom/cpp/PDOMCPPNamespace.java | 27 +-- 24 files changed, 446 insertions(+), 904 deletions(-) create mode 100644 core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TrilogyPerformanceTest.java create mode 100644 core/org.eclipse.cdt.core.tests/resources/indexTests/trilogy/trilogy.cpp delete mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/AbstractCLocalBindingIdentity.java delete mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/CLocalBindingIdentityComparator.java delete mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/IBindingIdentityFactory.java delete mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/ICLocalBindingIdentity.java delete mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/ILocalBindingIdentity.java delete mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/ILocalBindingIdentityComparator.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/FindBinding.java delete mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/FindBindingByLinkageConstant.java delete mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/FindEquivalentBinding.java delete mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/CBindingIdentity.java delete mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/CPPBindingIdentity.java create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/CPPFindBinding.java diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TrilogyPerformanceTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TrilogyPerformanceTest.java new file mode 100644 index 00000000000..312c8254d34 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/TrilogyPerformanceTest.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2006 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.index.tests; + +import java.util.regex.Pattern; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.index.IndexFilter; +import org.eclipse.cdt.core.model.ICProject; +import org.eclipse.cdt.core.testplugin.CTestPlugin; +import org.eclipse.cdt.core.testplugin.TestScannerProvider; +import org.eclipse.cdt.internal.core.CCoreInternals; +import org.eclipse.cdt.utils.spawner.EnvironmentReader; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Platform; +import org.osgi.framework.Bundle; + +/** + * aftodo - it would be nice to have this as a real performance test + * + * n.b. this is intentionally not added to any test suite at the moment + */ +public class TrilogyPerformanceTest extends IndexTestBase { + ICProject cproject; + + public TrilogyPerformanceTest() { + super("TrilogyPerformance"); + } + + protected void setUp() throws Exception { + Bundle b = CTestPlugin.getDefault().getBundle(); + if (cproject == null) { + cproject= createProject(true, "resources/indexTests/trilogy"); + } + } + + protected void tearDown() throws Exception { + cproject.getProject().delete(true, new NullProgressMonitor()); + } + + // you must have the Windows SDK installed and the INETSDK env var setup + public void testIndexTrilogyPerformanceTimes() throws CoreException { + if(Platform.getOS().equals(Platform.OS_WIN32)) { + assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); + TestScannerProvider.sIncludes = new String[]{EnvironmentReader.getEnvVar("INETSDK")+"\\Include"}; + try { + CCoreInternals.getPDOMManager().setIndexAllFiles(cproject, true); + long start = System.currentTimeMillis(); + CCorePlugin.getPDOMManager().reindex(cproject); + assertTrue(CCorePlugin.getIndexManager().joinIndexer(360000, new NullProgressMonitor())); + System.out.println("Took: "+(System.currentTimeMillis() - start)); + IIndex index= CCorePlugin.getIndexManager().getIndex(cproject); + IBinding[] binding = index.findBindings(Pattern.compile("IXMLElementCollection"), false, IndexFilter.ALL, new NullProgressMonitor()); + assertEquals(1, binding.length); + } finally { + TestScannerProvider.sIncludes = null; + } + } + } +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.core.tests/resources/indexTests/trilogy/trilogy.cpp b/core/org.eclipse.cdt.core.tests/resources/indexTests/trilogy/trilogy.cpp new file mode 100644 index 00000000000..33acf943fd7 --- /dev/null +++ b/core/org.eclipse.cdt.core.tests/resources/indexTests/trilogy/trilogy.cpp @@ -0,0 +1,5 @@ +#include +#include +#include + +int main() { return 0; } diff --git a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF index f071ab7bbd7..74312c4bbf9 100644 --- a/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core/META-INF/MANIFEST.MF @@ -28,7 +28,6 @@ Export-Package: org.eclipse.cdt.core, org.eclipse.cdt.internal.core;x-friends:="org.eclipse.cdt.ui", org.eclipse.cdt.internal.core.browser.util;x-internal:=true, org.eclipse.cdt.internal.core.dom;x-friends:="org.eclipse.cdt.ui,org.eclipse.cdt.refactoring", - org.eclipse.cdt.internal.core.dom.bid, org.eclipse.cdt.internal.core.dom.parser;x-friends:="org.eclipse.cdt.refactoring", org.eclipse.cdt.internal.core.dom.parser.c;x-friends:="org.eclipse.cdt.refactoring", org.eclipse.cdt.internal.core.dom.parser.cpp;x-friends:="org.eclipse.cdt.ui,org.eclipse.cdt.refactoring", diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/AbstractCLocalBindingIdentity.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/AbstractCLocalBindingIdentity.java deleted file mode 100644 index 144bd46389c..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/AbstractCLocalBindingIdentity.java +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Symbian Software 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 API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.bid; - -import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; -import org.eclipse.core.runtime.CoreException; - -/** - * - */ -public abstract class AbstractCLocalBindingIdentity implements ICLocalBindingIdentity { - protected static final String SEP = " | "; //$NON-NLS-1$ - - protected PDOMLinkage linkage; - protected IBinding binding; - - protected String extendedType; // cached - - protected AbstractCLocalBindingIdentity(IBinding binding, PDOMLinkage linkage) { - if(binding==null || linkage==null) - throw new IllegalArgumentException(); - this.binding = binding; - this.linkage = linkage; - } - - public String getName() { - return binding.getName(); - } - - public abstract int getTypeConstant() throws CoreException; - - public abstract String getExtendedType() throws CoreException; - - public String toString() { - try { - return getName()+SEP+getTypeConstant()+SEP+getExtendedType(); - } catch(CoreException ce) { - throw new RuntimeException(ce); - } - } - - public char[] getNameCharArray() throws CoreException { - return binding.getNameCharArray(); - } -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/CLocalBindingIdentityComparator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/CLocalBindingIdentityComparator.java deleted file mode 100644 index 0a216ef59e0..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/CLocalBindingIdentityComparator.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Symbian Software 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 API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.bid; - -import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.parser.util.CharArrayUtils; -import org.eclipse.core.runtime.CoreException; - -/** - * An implementation of ILocalBindingIdentityComparator for CLocalBinding objects - */ -public class CLocalBindingIdentityComparator implements ILocalBindingIdentityComparator { - protected IBindingIdentityFactory factory; - - public CLocalBindingIdentityComparator(IBindingIdentityFactory factory) { - this.factory = factory; - } - - public int compare(IBinding a, IBinding b) throws CoreException { - ICLocalBindingIdentity aID = (ICLocalBindingIdentity) factory.getLocalBindingIdentity(a); - ICLocalBindingIdentity bID = (ICLocalBindingIdentity) factory.getLocalBindingIdentity(b); - return compare(aID, bID); - } - - public int compare(ILocalBindingIdentity aID, IBinding b) throws CoreException { - ICLocalBindingIdentity bID = (ICLocalBindingIdentity) factory.getLocalBindingIdentity(b); - return compare((ICLocalBindingIdentity) aID, bID); - } - - public int compare(IBinding a, ILocalBindingIdentity bID) throws CoreException { - ICLocalBindingIdentity aID = (ICLocalBindingIdentity) factory.getLocalBindingIdentity(a); - return compare(aID, bID); - } - - public int compare(ILocalBindingIdentity aID, ILocalBindingIdentity bID) throws CoreException { - return compare((ICLocalBindingIdentity) aID, (ICLocalBindingIdentity) bID); - } - - public int compare(ICLocalBindingIdentity aID, ICLocalBindingIdentity bID) throws CoreException { - int cmp = CharArrayUtils.compare(aID.getNameCharArray(), bID.getNameCharArray()); - if(cmp!=0) return cmp; - - int tyConA = aID.getTypeConstant(); - int tyConB = bID.getTypeConstant(); - if(tyConA != tyConB) { - return tyConA < tyConB ? -1 : 1; - } - - cmp = aID.getExtendedType().compareTo(bID.getExtendedType()); - return cmp; - } - - public int compareNameAndConstOnly(IBinding a, char[] bName, int bConst) throws CoreException { - ICLocalBindingIdentity aID = (ICLocalBindingIdentity) factory.getLocalBindingIdentity(a); - - int cmp = CharArrayUtils.compare(aID.getNameCharArray(), bName); - if(cmp!=0) { - return cmp; - } - - int tyCon = aID.getTypeConstant(); - if(tyCon != bConst) { - return tyCon < bConst ? -1 : 1; - } - - return 0; - } -} - diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/IBindingIdentityFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/IBindingIdentityFactory.java deleted file mode 100644 index 98bfafd5b75..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/IBindingIdentityFactory.java +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Symbian Software 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 API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.bid; - -import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.core.runtime.CoreException; - -/** - * A factory for instances of binding identitys - */ -public interface IBindingIdentityFactory { - /** - * Return an IBindingIdentity instance for the named binding. No assumption - * is made about whether the IBinding parameter is from the PDOM or DOM - * @param binding the binding to create a IBindingIdentity for - * @return a binding identity instance - * @throws CoreException - */ - public ILocalBindingIdentity getLocalBindingIdentity(IBinding binding) throws CoreException; - - /* - * aftodo - we might want to introduce a true binding identity (i.e. identifies globally - * not within a scope). I've no client code for this though. - * - * public IBindingIdentity getBindingIdentity(IBinding binding) throws CoreException - */ -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/ICLocalBindingIdentity.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/ICLocalBindingIdentity.java deleted file mode 100644 index 124a230c55b..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/ICLocalBindingIdentity.java +++ /dev/null @@ -1,37 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Symbian Software 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 API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.bid; - -import org.eclipse.core.runtime.CoreException; - -/** - * An IBindingIdentity instance uniquely defines a binding within a scope. Instances - * are provided by an IBindingIdentityFactory and used by datastructures within the - * PDOM to order binding records. - */ -public interface ICLocalBindingIdentity extends ILocalBindingIdentity { - /** - * Returns the constant associated with the coarse-grained type of the - * associated IBinding - * @return the constant associated with the coarse-grained type of the - * associated IBinding - * @throws CoreException - */ - public int getTypeConstant() throws CoreException; - - /** - * Returns a String of unspecified format which uniquely identifies this - * binding within its scope - * @return - * @throws CoreException - */ - public String getExtendedType() throws CoreException; -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/ILocalBindingIdentity.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/ILocalBindingIdentity.java deleted file mode 100644 index 24965a5ce63..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/ILocalBindingIdentity.java +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Symbian Software 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 API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.bid; - -import org.eclipse.core.runtime.CoreException; - -/** - * An ILocalBindingIdentity instance uniquely defines a binding within a scope. - *

- * All LocalBindingIdentity instances are required to order by name as the most significant - * component, and then by any other information. This is for indexing purposes. - */ -public interface ILocalBindingIdentity { - /** - * Get the name of the binding this identity represents - * @return the name of the binding this identity represents - * @throws CoreException - */ - public char[] getNameCharArray() throws CoreException; -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/ILocalBindingIdentityComparator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/ILocalBindingIdentityComparator.java deleted file mode 100644 index 0e319264c85..00000000000 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/bid/ILocalBindingIdentityComparator.java +++ /dev/null @@ -1,52 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2006 Symbian Software 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 API and implementation - *******************************************************************************/ -package org.eclipse.cdt.internal.core.dom.bid; - -import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.core.runtime.CoreException; - -/** - * A comparator for ILocalBindingIdentity objects - */ -public interface ILocalBindingIdentityComparator { - /** - * - * @param a - * @param b - * @return -1 if a<b, 0 if a==b and 1 if a>b - * @throws CoreException - */ - public int compare(IBinding a, IBinding b) throws CoreException; - /** - * - * @param a - * @param b - * @return -1 if a<b, 0 if a==b and 1 if a>b - * @throws CoreException - */ - public int compare(ILocalBindingIdentity a, IBinding b) throws CoreException; - /** - * - * @param a - * @param b - * @return -1 if a<b, 0 if a==b and 1 if a>b - * @throws CoreException - */ - public int compare(IBinding a, ILocalBindingIdentity b) throws CoreException; - /** - * - * @param a - * @param b - * @return -1 if a<b, 0 if a==b and 1 if a>b - * @throws CoreException - */ - public int compare(ILocalBindingIdentity a, ILocalBindingIdentity b) throws CoreException; -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/FindBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/FindBinding.java new file mode 100644 index 00000000000..2361280e887 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/FindBinding.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2006 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 API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.pdom.dom; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.IPDOMNode; +import org.eclipse.cdt.core.dom.IPDOMVisitor; +import org.eclipse.cdt.internal.core.pdom.PDOM; +import org.eclipse.cdt.internal.core.pdom.db.BTree; +import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator; +import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor; +import org.eclipse.cdt.internal.core.pdom.db.IString; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + +/** + * Look up bindings in BTree objects and IPDOMNode objects + */ +public class FindBinding { + public static class DefaultBindingBTreeComparator implements IBTreeComparator { + protected PDOM pdom; + public DefaultBindingBTreeComparator(PDOM pdom) { + this.pdom = pdom; + } + public int compare(int record1, int record2) throws CoreException { + IString nm1 = PDOMNamedNode.getDBName(pdom, record1); + IString nm2 = PDOMNamedNode.getDBName(pdom, record2); + return nm1.compare(nm2); + } + } + + public static PDOMBinding findBinding(BTree btree, final PDOM pdom, final char[]name, final int[] constants) throws CoreException { + final PDOMBinding[] result = new PDOMBinding[1]; + btree.accept(new IBTreeVisitor() { + public int compare(int record) throws CoreException { + IString nm1 = PDOMNamedNode.getDBName(pdom, record); + return nm1.compare(name); + } + public boolean visit(int record) throws CoreException { + result[0] = pdom.getBinding(record); + return false; + } + }); + return result[0]; + } + + public static PDOMBinding findBinding(IPDOMNode node, final PDOM pdom, final char[]name, final int[] constants) { + final PDOMBinding[] result = new PDOMBinding[1]; + try { + node.accept(new IPDOMVisitor() { + public boolean visit(IPDOMNode node) throws CoreException { + if(node instanceof PDOMNamedNode) { + PDOMNamedNode nnode = (PDOMNamedNode) node; + if(nnode.hasName(name)) { + int constant = nnode.getNodeType(); + for(int i=0; i0) { - result.append(','); - } - result.append(ASTTypeUtil.getType(types[i])); - } - result.append(')'); - return result.toString(); - } - - private String renderFunctionType(IFunctionType type) throws DOMException { - IType[] params = type.getParameterTypes(); - return renderTypes(params); - } - - public static class Holder implements ICLocalBindingIdentity { - String name; - int type; - String mangledExtendedType; - - public Holder(String name, int type, IType[] types) throws DOMException { - this.name = name; - this.type = type; - mangledExtendedType = renderTypes(types); - } - - public int getTypeConstant() throws CoreException { - return type; - } - - public String getName() throws CoreException { - return name; - } - - public String getExtendedType() throws CoreException { - return mangledExtendedType; - } - - public String toString() { - return name+" "+type+" "+mangledExtendedType; //$NON-NLS-1$ //$NON-NLS-2$ - } - - public char[] getNameCharArray() throws CoreException { - return name.toCharArray(); - } - } -} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/CPPFindBinding.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/CPPFindBinding.java new file mode 100644 index 00000000000..c38771caaef --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/CPPFindBinding.java @@ -0,0 +1,154 @@ +/******************************************************************************* + * Copyright (c) 2006 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 API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.pdom.dom.cpp; + +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.IPDOMNode; +import org.eclipse.cdt.core.dom.IPDOMVisitor; +import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IFunction; +import org.eclipse.cdt.core.dom.ast.IFunctionType; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.internal.core.pdom.PDOM; +import org.eclipse.cdt.internal.core.pdom.db.BTree; +import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor; +import org.eclipse.cdt.internal.core.pdom.db.IString; +import org.eclipse.cdt.internal.core.pdom.dom.FindBinding; +import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; +import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; +import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode; +import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; + +/** + * Look up bindings in BTree objects and IPDOMNode objects. This additionally + * takes into account function/method parameters for overloading. + */ +public class CPPFindBinding extends FindBinding { + public static PDOMBinding findBinding(BTree btree, final PDOM pdom, final char[]name, final int c2, final IType[] types) throws CoreException { + final PDOMBinding[] result = new PDOMBinding[1]; + try { + final int ty2 = PDOMCPPFunction.getSignatureMemento(types); + btree.accept(new IBTreeVisitor() { + public int compare(int record) throws CoreException { + IString nm1 = PDOMNamedNode.getDBName(pdom, record); + int cmp = nm1.compare(name); + if(cmp==0) { + int c1 = PDOMNode.getNodeType(pdom, record); + cmp = c1 < c2 ? -1 : (c1 > c2 ? 1 : 0); + if(cmp==0) { + PDOMBinding binding = pdom.getBinding(record); + if(binding instanceof PDOMCPPFunction) { + int ty1 = ((PDOMCPPFunction)binding).getSignatureMemento(); + cmp = ty1 < ty2 ? -1 : (ty1 > ty2 ? 1 : 0); + } + } + } + return cmp; + } + public boolean visit(int record) throws CoreException { + result[0] = pdom.getBinding(record); + return false; + } + }); + } catch(DOMException de) { + CCorePlugin.log(de); + } + return result[0]; + } + + + public static PDOMBinding findBinding(PDOMNode node, final PDOM pdom, final char[]name, final int constant, final IType[] types) { + final PDOMBinding[] result = new PDOMBinding[1]; + try { + final int ty2 = PDOMCPPFunction.getSignatureMemento(types); + node.accept(new IPDOMVisitor() { + public boolean visit(IPDOMNode binding) throws CoreException { + if(binding instanceof PDOMNamedNode) { + PDOMNamedNode nnode = (PDOMNamedNode) binding; + if(nnode.hasName(name)) { + if(nnode.getNodeType() == constant) { + if(binding instanceof PDOMCPPFunction) { + int ty1 = ((PDOMCPPFunction)binding).getSignatureMemento(); + if(ty1==ty2) { + result[0] = (PDOMBinding) binding; + throw new CoreException(Status.OK_STATUS); + } + } + } + } + } + return false; + } + public void leave(IPDOMNode node) throws CoreException {} + }); + } catch(CoreException ce) { + if(ce.getStatus().getCode()==IStatus.OK) { + return result[0]; + } else { + CCorePlugin.log(ce); + } + } catch(DOMException de) { + CCorePlugin.log(de); + } + return null; + } + + + public static PDOMBinding findBinding(BTree btree, PDOMLinkage linkage, IBinding binding) throws CoreException { + if(binding instanceof IFunction) { + try { + IFunctionType type = ((IFunction) binding).getType(); + return findBinding(btree, linkage.getPDOM(), binding.getNameCharArray(), linkage.getBindingType(binding), type.getParameterTypes()); + } catch(DOMException de) { + CCorePlugin.log(de); + return null; + } + } + return findBinding(btree, linkage.getPDOM(), binding.getNameCharArray(), new int [] {linkage.getBindingType(binding)}); + } + + + public static PDOMBinding findBinding(PDOMNode node, PDOMLinkage linkage, IBinding binding) { + if(binding instanceof IFunction) { + try { + IFunctionType type = ((IFunction) binding).getType(); + return findBinding(node, linkage.getPDOM(), binding.getNameCharArray(), linkage.getBindingType(binding), type.getParameterTypes()); + } catch(DOMException de) { + CCorePlugin.log(de); + return null; + } + } + return findBinding(node, linkage.getPDOM(), binding.getNameCharArray(), new int[] {linkage.getBindingType(binding)}); + } + + public static class CPPBindingBTreeComparator extends FindBinding.DefaultBindingBTreeComparator { + public CPPBindingBTreeComparator(PDOM pdom) { + super(pdom); + } + public int compare(int record1, int record2) throws CoreException { + int cmp = super.compare(record1, record2); + if(cmp==0) { + PDOMBinding binding1 = pdom.getBinding(record1); + PDOMBinding binding2 = pdom.getBinding(record2); + if(binding1 instanceof PDOMCPPFunction && binding2 instanceof PDOMCPPFunction) { + int ty1 = ((PDOMCPPFunction)binding1).getSignatureMemento(); + int ty2 = ((PDOMCPPFunction)binding2).getSignatureMemento(); + cmp = ty1 < ty2 ? -1 : (ty1 > ty2 ? 1 : 0); + } + } + return cmp; + } + } +} diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java index 89291bc97d7..0e4ca876346 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassType.java @@ -42,19 +42,16 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.Util; -import org.eclipse.cdt.internal.core.dom.bid.ILocalBindingIdentity; import org.eclipse.cdt.internal.core.index.IIndexProxyBinding; 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.FindBindingByLinkageConstant; -import org.eclipse.cdt.internal.core.pdom.dom.FindEquivalentBinding; +import org.eclipse.cdt.internal.core.pdom.dom.FindBinding; import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Status; /** * @author Doug Schaefer @@ -388,21 +385,7 @@ ICPPClassScope, IPDOMMemberOwner { try { IType[] types = PDOMCPPLinkage.getTypes(fce.getParameterExpression()); if(types!=null) { - ILocalBindingIdentity bid = new CPPBindingIdentity.Holder( - new String(name.toCharArray()), - PDOMCPPLinkage.CPPFUNCTION, - types); - FindEquivalentBinding feb = new FindEquivalentBinding(getLinkageImpl(), bid); - try { - accept(feb); - } catch(CoreException e) { - if (e.getStatus().equals(Status.OK_STATUS)) { - return feb.getResult(); - } else { - CCorePlugin.log(e); - } - } - return feb.getResult(); + return CPPFindBinding.findBinding(this, getPDOM(), name.toCharArray(), PDOMCPPLinkage.CPPFUNCTION, types); } } catch(DOMException de) { CCorePlugin.log(de); @@ -419,17 +402,7 @@ ICPPClassScope, IPDOMMemberOwner { } private IBinding searchCurrentScope(char[] name, int constant) throws CoreException { - FindBindingByLinkageConstant visitor = new FindBindingByLinkageConstant(getLinkageImpl(), name, constant); - try { - accept(visitor); - } catch(CoreException e) { - if (e.getStatus().equals(Status.OK_STATUS)) { - return visitor.getResult(); - } else { - CCorePlugin.log(e); - } - } - return null; + return FindBinding.findBinding(this, getPDOM(), name, new int [] {constant}); } // Not implemented diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java index 87b9d536127..32ba5521d84 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java @@ -13,7 +13,9 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp; import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.DOMException; +import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IFunctionType; import org.eclipse.cdt.core.dom.ast.IParameter; @@ -48,16 +50,21 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, ICPPFuncti */ private static final int FIRST_PARAM = PDOMBinding.RECORD_SIZE + 4; + /** + * Offset of hash of parameter information to allow fast comparison + */ + private static final int SIGNATURE_MEMENTO = PDOMBinding.RECORD_SIZE + 8; + /** * Offset of annotation information (relative to the beginning of the * record). */ - private static final int ANNOTATION = PDOMBinding.RECORD_SIZE + 8; // byte + protected static final int ANNOTATION = PDOMBinding.RECORD_SIZE + 12; // byte /** * The size in bytes of a PDOMCPPFunction record in the database. */ - protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 9; + protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 13; public PDOMCPPFunction(PDOM pdom, PDOMNode parent, ICPPFunction function) throws CoreException { super(pdom, parent, function.getNameCharArray()); @@ -72,6 +79,8 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, ICPPFuncti setFirstParameter(new PDOMCPPParameter(pdom, this, params[i])); } db.putByte(record + ANNOTATION, PDOMCPPAnnotation.encodeAnnotation(binding)); + IFunctionType ftype = function.getType(); + db.putInt(record + SIGNATURE_MEMENTO, getSignatureMemento(ftype.getParameterTypes())); } catch (DOMException e) { throw new CoreException(Util.createStatus(e)); } @@ -81,6 +90,14 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, ICPPFuncti super(pdom, bindingRecord); } + public int getSignatureMemento() throws CoreException { + return pdom.getDB().getInt(record + SIGNATURE_MEMENTO); + } + + public static int getSignatureMemento(PDOM pdom, int record) throws CoreException { + return pdom.getDB().getInt(record + SIGNATURE_MEMENTO); + } + protected int getRecordSize() { return RECORD_SIZE; } @@ -201,4 +218,29 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, ICPPFuncti throw new PDOMNotImplementedError(); } + public static int getSignatureMemento(IType[] types) throws DOMException { + if(types.length==1) { + if(types[0] instanceof IBasicType) { + if(((IBasicType)types[0]).getType()==IBasicType.t_void) { + types = new IType[0]; + } + } + } + + StringBuffer result = new StringBuffer(); + result.append('('); + for(int i=0; i0) { + result.append(','); + } + result.append(ASTTypeUtil.getType(types[i])); + } + result.append(')'); + return result.toString().hashCode(); + } + + public static int getSignatureMemento(IFunctionType type) throws DOMException { + IType[] params = type.getParameterTypes(); + return getSignatureMemento(params); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java index df0c7e16fb0..715d4519bf2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPLinkage.java @@ -56,29 +56,26 @@ import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage; import org.eclipse.cdt.core.model.ILanguage; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.Util; -import org.eclipse.cdt.internal.core.dom.bid.IBindingIdentityFactory; -import org.eclipse.cdt.internal.core.dom.bid.ILocalBindingIdentity; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPImplicitMethod; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics; import org.eclipse.cdt.internal.core.pdom.PDOM; -import org.eclipse.cdt.internal.core.pdom.dom.FindBindingByLinkageConstant; -import org.eclipse.cdt.internal.core.pdom.dom.FindEquivalentBinding; +import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator; +import org.eclipse.cdt.internal.core.pdom.dom.FindBinding; import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner; import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError; import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.Status; /** * @author Doug Schaefer * */ -class PDOMCPPLinkage extends PDOMLinkage { +public class PDOMCPPLinkage extends PDOMLinkage { public PDOMCPPLinkage(PDOM pdom, int record) { super(pdom, record); } @@ -211,7 +208,7 @@ class PDOMCPPLinkage extends PDOMLinkage { return pdomBinding; } - protected int getBindingType(IBinding binding) { + public int getBindingType(IBinding binding) { if (binding instanceof ICPPTemplateDefinition) // this must be before class type return 0; @@ -257,25 +254,14 @@ class PDOMCPPLinkage extends PDOMLinkage { // so if the binding is from another pdom it has to be adapted. } - FindEquivalentBinding visitor = new FindEquivalentBinding(this, binding); PDOMNode parent = getAdaptedParent(binding); if (parent == this) { - getIndex().accept(visitor); - return visitor.getResult(); + return CPPFindBinding.findBinding(getIndex(), this, binding); } else if (parent instanceof IPDOMMemberOwner) { - IPDOMMemberOwner owner = (IPDOMMemberOwner)parent; - try { - owner.accept(visitor); - } catch (CoreException e) { - if (e.getStatus().equals(Status.OK_STATUS)) - return visitor.getResult(); - else - throw e; - } + return CPPFindBinding.findBinding(parent, this, binding); } else if (parent instanceof PDOMCPPNamespace) { - ((PDOMCPPNamespace)parent).getIndex().accept(visitor); - return visitor.getResult(); + return CPPFindBinding.findBinding(((PDOMCPPNamespace)parent).getIndex(), this, binding); } return null; @@ -344,13 +330,12 @@ class PDOMCPPLinkage extends PDOMLinkage { IASTExpression left = ((IASTBinaryExpression) epParent).getOperand1(); IType type = CPPSemantics.getUltimateType(left.getExpressionType(), false); if (type instanceof IFunctionType) { - ILocalBindingIdentity lbi = new CPPBindingIdentity.Holder( - new String(name.toCharArray()), + return CPPFindBinding.findBinding(getIndex(), + getPDOM(), + name.toCharArray(), CPPFUNCTION, - ((IFunctionType) type).getParameterTypes()); - FindEquivalentBinding feb = new FindEquivalentBinding(this, lbi); - getIndex().accept(feb); - return feb.getResult(); + ((IFunctionType) type).getParameterTypes() + ); } } } @@ -387,17 +372,7 @@ class PDOMCPPLinkage extends PDOMLinkage { IType type = ((ICPPVariable)fieldOwnerBinding).getType(); if(type instanceof ICompositeType) { PDOMBinding pdomFOB = adaptBinding( (ICompositeType) type); - FindBindingByLinkageConstant visitor = new FindBindingByLinkageConstant(this, name.toCharArray(), PDOMCPPLinkage.CPPFIELD); - try { - pdomFOB.accept(visitor); - } catch (CoreException e) { - if (e.getStatus().equals(Status.OK_STATUS)) { - return visitor.getResult(); - } - else { - throw e; - } - } + return FindBinding.findBinding(pdomFOB, getPDOM(), name.toCharArray(), new int [] {PDOMCPPLinkage.CPPFIELD}); } } } @@ -417,12 +392,10 @@ class PDOMCPPLinkage extends PDOMLinkage { } private PDOMBinding searchCurrentScope(char[] name, int constant) throws CoreException { - FindBindingByLinkageConstant visitor = new FindBindingByLinkageConstant(getLinkageImpl(), name, constant); - getIndex().accept(visitor); - return visitor.getResult(); + return FindBinding.findBinding(getIndex(), getPDOM(), name, new int [] {constant}); } - + /** * Read type information from the AST or null if the types could not be determined * @param paramExp the parameter expression to get types for (null indicates void function/method) @@ -477,26 +450,19 @@ class PDOMCPPLinkage extends PDOMLinkage { IType[] types = getTypes(paramExp); if (types != null) { IBinding parentBinding = id.getName().getBinding(); - ILocalBindingIdentity bid = null; if (parentBinding instanceof ICPPVariable) { ICPPVariable v = (ICPPVariable) parentBinding; IType type = v.getType(); if (type instanceof PDOMBinding) { - bid = new CPPBindingIdentity.Holder(new String(name - .toCharArray()), CPPMETHOD, types); - FindEquivalentBinding feb = new FindEquivalentBinding(this, - bid); - try { - ((PDOMBinding) type).accept(feb); - } catch (CoreException e) { - if (e.getStatus().equals(Status.OK_STATUS)) { - return feb.getResult(); - } else { - throw e; - } - } + return CPPFindBinding.findBinding( + ((PDOMBinding) type), + getPDOM(), + name.toCharArray(), + CPPMETHOD, + types + ); } } else { IASTNode expPNode = callExp.getParent(); @@ -508,31 +474,23 @@ class PDOMCPPLinkage extends PDOMLinkage { IASTExpression left = bExp.getOperand1(); IType t = CPPSemantics.getUltimateType(left.getExpressionType(), false); if (t instanceof PDOMCPPClassType) { - bid = new CPPBindingIdentity.Holder( - new String(name.toCharArray()), + return CPPFindBinding.findBinding( + ((PDOMCPPClassType) t), + getPDOM(), + name.toCharArray(), CPPMETHOD, - types); - FindEquivalentBinding feb = new FindEquivalentBinding(this, bid); - try { - ((PDOMCPPClassType) t).accept(feb); - } catch (CoreException e) { - if (e.getStatus().equals(Status.OK_STATUS)) { - return feb.getResult(); - } else { - throw e; - } - } - return null; + types + ); } } } else { // filescope - bid = new CPPBindingIdentity.Holder( - new String(name.toCharArray()), + return CPPFindBinding.findBinding( + getIndex(), + getPDOM(), + name.toCharArray(), CPPFUNCTION, - types); - FindEquivalentBinding feb = new FindEquivalentBinding(this,bid); - getIndex().accept(feb); - return feb.getResult(); + types + ); } } } @@ -549,19 +507,9 @@ class PDOMCPPLinkage extends PDOMLinkage { if(index!=-1) { if (index == 0) { // we are at the root - FindBindingByLinkageConstant finder = new FindBindingByLinkageConstant( - this, name.toCharArray(), CPPNAMESPACE); - - getIndex().accept(finder); - if (finder.getResult() == null) { - finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CPPCLASSTYPE); - getIndex().accept(finder); - } - if (finder.getResult() == null) { - finder = new FindBindingByLinkageConstant(this, name.toCharArray(), CPPNAMESPACEALIAS); - getIndex().accept(finder); - } - return finder.getResult(); + return FindBinding.findBinding(getIndex(), getPDOM(), name.toCharArray(), new int[]{ + CPPNAMESPACE, CPPCLASSTYPE, CPPNAMESPACEALIAS + }); } else { try { PDOMBinding binding = adaptBinding(names[index-1].getBinding()); @@ -638,11 +586,7 @@ class PDOMCPPLinkage extends PDOMLinkage { } } - public ILocalBindingIdentity getLocalBindingIdentity(IBinding b) throws CoreException { - return new CPPBindingIdentity(b, this); - } - - public IBindingIdentityFactory getBindingIdentityFactory() { - return this; + public IBTreeComparator getIndexComparator() { + return new CPPFindBinding.CPPBindingBTreeComparator(pdom); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java index 74e9ceb72ac..17dde593e0d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPMethod.java @@ -16,7 +16,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IFunctionType; -import org.eclipse.cdt.core.dom.ast.IParameter; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType; @@ -25,7 +24,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.internal.core.Util; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.db.Database; -import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode; import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError; import org.eclipse.cdt.internal.core.pdom.dom.c.PDOMCAnnotation; @@ -33,38 +31,20 @@ import org.eclipse.core.runtime.CoreException; /** * @author Doug Schaefer - * + * */ -class PDOMCPPMethod extends PDOMCPPBinding implements ICPPMethod, ICPPFunctionType { +class PDOMCPPMethod extends PDOMCPPFunction implements ICPPMethod, ICPPFunctionType { /** - * Offset of total number of method parameters (relative to the - * beginning of the record). + * Offset of remaining annotation information (relative to the beginning of + * the record). */ - private static final int NUM_PARAMS = PDOMBinding.RECORD_SIZE + 0; - - /** - * Offset of pointer to the first parameter of this method (relative to - * the beginning of the record). - */ - private static final int FIRST_PARAM = PDOMBinding.RECORD_SIZE + 4; + private static final int ANNOTATION1 = PDOMCPPFunction.RECORD_SIZE; // byte - /** - * Offset of first byte of annotation information (relative to the - * beginning of the record). - */ - private static final int ANNOTATION0 = PDOMBinding.RECORD_SIZE + 8; // byte - - /** - * Offset of remaining annotation information (relative to the - * beginning of the record). - */ - private static final int ANNOTATION1 = PDOMBinding.RECORD_SIZE + 9; // byte - /** * The size in bytes of a PDOMCPPMethod record in the database. */ - protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 10; + protected static final int RECORD_SIZE = PDOMCPPFunction.RECORD_SIZE + 1; /** * The bit offset of CV qualifier flags within ANNOTATION1. @@ -72,23 +52,16 @@ class PDOMCPPMethod extends PDOMCPPBinding implements ICPPMethod, ICPPFunctionTy private static final int CV_OFFSET = 2; public PDOMCPPMethod(PDOM pdom, PDOMNode parent, ICPPMethod method) throws CoreException { - super(pdom, parent, method.getNameCharArray()); - + super(pdom, parent, method); + Database db = pdom.getDB(); - + try { - IParameter[] params = method.getParameters(); - db.putInt(record + NUM_PARAMS, params.length); - - for (int i=0; i