mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Bug 356955: Lookup for overloaded operator.
This commit is contained in:
parent
e75a7388a0
commit
7902fd1c77
3 changed files with 50 additions and 25 deletions
|
@ -18,6 +18,7 @@ import junit.framework.TestSuite;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTImplicitName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
|
@ -1308,4 +1309,31 @@ public class IndexCPPBindingResolutionBugs extends IndexBindingResolutionTestBas
|
|||
IFunction f= getBindingFromASTName("fun", 0);
|
||||
ITypedef t= getBindingFromASTName("Type", 0);
|
||||
}
|
||||
|
||||
// struct base {
|
||||
// virtual void operator+(base const &) { }
|
||||
// virtual void operator-(base const &) { }
|
||||
// };
|
||||
|
||||
// #include "header.h"
|
||||
// struct inter : public base {
|
||||
// virtual void operator+(base const &){}
|
||||
// };
|
||||
// struct sub : public inter {
|
||||
// void doSomething() {
|
||||
// base *left, *right;
|
||||
//
|
||||
// *left + *right;
|
||||
// *left - *right;
|
||||
// }
|
||||
// };
|
||||
public void test_Bug356982() throws Exception {
|
||||
IASTName name= findName("+ ", 1);
|
||||
assertTrue(name instanceof IASTImplicitName);
|
||||
assertEquals("base", name.resolveBinding().getOwner().getName());
|
||||
|
||||
name= findName("- ", 1);
|
||||
assertTrue(name instanceof IASTImplicitName);
|
||||
assertEquals("base", name.resolveBinding().getOwner().getName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.index.tests;
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
|
||||
IIndex index;
|
||||
|
||||
protected StringBuffer[] getContentsForTest(int blocks) throws IOException {
|
||||
protected StringBuilder[] getContentsForTest(int blocks) throws IOException {
|
||||
return TestSourceReader.getContentsForTest(
|
||||
CTestPlugin.getDefault().getBundle(), "parser", getClass(), getName(), blocks);
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
|
||||
// class B {};
|
||||
public void testPairDisjointContent() throws Exception {
|
||||
StringBuffer[] contents = getContentsForTest(2);
|
||||
CharSequence[] contents = getContentsForTest(2);
|
||||
List projects = new ArrayList();
|
||||
|
||||
try {
|
||||
|
@ -96,7 +96,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
setIndex(cprojA, REFD); assertBCount(1, 1);
|
||||
setIndex(cprojA, BOTH); assertBCount(2, 2);
|
||||
} finally {
|
||||
for(Iterator i = projects.iterator(); i.hasNext(); )
|
||||
for (Iterator i = projects.iterator(); i.hasNext();)
|
||||
((ICProject)i.next()).getProject().delete(true, true, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
// void foo(X::B2 c) {}
|
||||
// namespace X { class A2 {}; B2 b; C2 c; }
|
||||
public void testTripleLinear() throws Exception {
|
||||
StringBuffer[] contents = getContentsForTest(3);
|
||||
CharSequence[] contents = getContentsForTest(3);
|
||||
List projects = new ArrayList();
|
||||
|
||||
try {
|
||||
|
@ -203,7 +203,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
assertNamespaceXMemberCount(5);
|
||||
assertFieldCount("C1", 1);
|
||||
} finally {
|
||||
for(Iterator i = projects.iterator(); i.hasNext(); )
|
||||
for (Iterator i = projects.iterator(); i.hasNext();)
|
||||
((ICProject)i.next()).getProject().delete(true, true, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
@ -224,10 +224,8 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
// namespace X { class A2 {}; }
|
||||
// B1 ab;
|
||||
public void testTripleUpwardV() throws Exception {
|
||||
StringBuffer[] contents = getContentsForTest(3);
|
||||
CharSequence[] contents = getContentsForTest(3);
|
||||
List projects = new ArrayList();
|
||||
|
||||
|
||||
|
||||
try {
|
||||
ProjectBuilder pb = new ProjectBuilder("projB"+System.currentTimeMillis(), true);
|
||||
|
@ -294,7 +292,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
assertBCount(7+4+4-2, 7+4+4-2 +2+1+1);
|
||||
assertNamespaceXMemberCount(4);
|
||||
} finally {
|
||||
for(Iterator i = projects.iterator(); i.hasNext(); )
|
||||
for (Iterator i = projects.iterator(); i.hasNext();)
|
||||
((ICProject)i.next()).getProject().delete(true, true, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
@ -313,7 +311,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
// void foo(A1 a, A1 b) {}
|
||||
// namespace X { class A2 {}; }
|
||||
public void testTripleDownwardV() throws Exception {
|
||||
StringBuffer[] contents = getContentsForTest(3);
|
||||
CharSequence[] contents = getContentsForTest(3);
|
||||
List projects = new ArrayList();
|
||||
|
||||
try {
|
||||
|
@ -349,7 +347,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
assertBCount(6, 6+1);
|
||||
assertNamespaceXMemberCount(1);
|
||||
setIndex(cprojC, REFD);
|
||||
assertBCount(6+4+1-1, 6+4+1-1 +1+1+1+1 );
|
||||
assertBCount(6+4+1-1, 6+4+1-1 +1+1+1+1);
|
||||
assertNamespaceXMemberCount(4);
|
||||
setIndex(cprojC, BOTH);
|
||||
assertBCount(6+4+3-2, 6+4+3-2 +1+2+1);
|
||||
|
@ -375,24 +373,22 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
assertBCount(3, 3 +1);
|
||||
assertNamespaceXMemberCount(1);
|
||||
setIndex(cprojA, REFD);
|
||||
assertBCount(4+2+3-1-1, 4+2+3-1-1 +2+1 );
|
||||
assertBCount(4+2+3-1-1, 4+2+3-1-1 +2+1);
|
||||
assertNamespaceXMemberCount(4);
|
||||
setIndex(cprojA, BOTH);
|
||||
assertBCount(6+4+3-2, 6+4+3-2 +1+2+1);
|
||||
assertNamespaceXMemberCount(4);
|
||||
} finally {
|
||||
for(Iterator i = projects.iterator(); i.hasNext(); )
|
||||
for (Iterator i = projects.iterator(); i.hasNext();)
|
||||
((ICProject)i.next()).getProject().delete(true, true, new NullProgressMonitor());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts binding counts, and returns the index tested against
|
||||
* @param cprojA the project to obtain the index for
|
||||
* @param options the options to obtain the index for
|
||||
* @param global the number of bindings expected to be found at global scope
|
||||
* @param all the number of bindings expected to be found at all scopes
|
||||
* @return
|
||||
* @return the index
|
||||
* @throws CoreException
|
||||
*/
|
||||
private IIndex assertBCount(int global, int all) throws CoreException {
|
||||
|
@ -416,7 +412,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
}
|
||||
|
||||
private void setIndex(ICProject project, int options) throws CoreException, InterruptedException {
|
||||
if(index!=null) {
|
||||
if (index != null) {
|
||||
index.releaseReadLock();
|
||||
}
|
||||
index = CCorePlugin.getIndexManager().getIndex(project, options);
|
||||
|
@ -424,7 +420,7 @@ public class IndexCompositeTests extends BaseTestCase {
|
|||
}
|
||||
|
||||
protected void tearDown() throws Exception {
|
||||
if(index!=null) {
|
||||
if (index != null) {
|
||||
index.releaseReadLock();
|
||||
}
|
||||
super.tearDown();
|
||||
|
@ -450,22 +446,23 @@ class ProjectBuilder {
|
|||
return this;
|
||||
}
|
||||
|
||||
ProjectBuilder addFile(String relativePath, StringBuffer content) {
|
||||
ProjectBuilder addFile(String relativePath, CharSequence content) {
|
||||
path2content.put(relativePath, content.toString());
|
||||
return this;
|
||||
}
|
||||
|
||||
ICProject create() throws CoreException {
|
||||
ICProject result = cpp ? CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER)
|
||||
: CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
|
||||
ICProject result = cpp ?
|
||||
CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER) :
|
||||
CProjectHelper.createCCProject(name, "bin", IPDOMManager.ID_NO_INDEXER);
|
||||
|
||||
for(Iterator i = path2content.entrySet().iterator(); i.hasNext(); ) {
|
||||
for (Iterator i = path2content.entrySet().iterator(); i.hasNext();) {
|
||||
Map.Entry entry = (Map.Entry) i.next();
|
||||
TestSourceReader.createFile(result.getProject(), new Path((String)entry.getKey()), (String) entry.getValue());
|
||||
}
|
||||
|
||||
IProjectDescription desc = result.getProject().getDescription();
|
||||
desc.setReferencedProjects( (IProject[]) dependencies.toArray(new IProject[dependencies.size()]) );
|
||||
desc.setReferencedProjects((IProject[]) dependencies.toArray(new IProject[dependencies.size()]));
|
||||
result.getProject().setDescription(desc, new NullProgressMonitor());
|
||||
|
||||
CCorePlugin.getIndexManager().setIndexerId(result, IPDOMManager.ID_FAST_INDEXER);
|
||||
|
|
|
@ -969,7 +969,7 @@ public class CPPSemantics {
|
|||
return;
|
||||
|
||||
// Lookup in base classes
|
||||
if (!data.usingDirectivesOnly && scope instanceof ICPPClassScope) {
|
||||
if (!data.usingDirectivesOnly && scope instanceof ICPPClassScope && !data.ignoreMembers) {
|
||||
BaseClassLookup.lookupInBaseClasses(data, (ICPPClassScope) scope, fileSet);
|
||||
if (!data.contentAssist && data.hasResultOrProblem())
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue