mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
fix one more race condition in unit tests, and _testAlias in NamespaceTests
This commit is contained in:
parent
63d86012bd
commit
807f6f54de
3 changed files with 30 additions and 4 deletions
|
@ -62,7 +62,7 @@ public class NamespaceTests extends PDOMTestBase {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void _testAlias() throws Exception {
|
public void testAlias() throws Exception {
|
||||||
/* Find all the namespace */
|
/* Find all the namespace */
|
||||||
IBinding[] namespaces = pdom.findBindings(Pattern.compile("namespace1"), false, INDEX_FILTER, NULL_MONITOR);
|
IBinding[] namespaces = pdom.findBindings(Pattern.compile("namespace1"), false, INDEX_FILTER, NULL_MONITOR);
|
||||||
assertEquals(1, namespaces.length);
|
assertEquals(1, namespaces.length);
|
||||||
|
|
|
@ -133,10 +133,14 @@ public class PDOMManager implements IPDOMManager, IWritableIndexManager, IListen
|
||||||
* change events.
|
* change events.
|
||||||
*/
|
*/
|
||||||
public void startup() {
|
public void startup() {
|
||||||
|
// the model listener is attached outside of the job in
|
||||||
|
// order to avoid a race condition where its not noticed
|
||||||
|
// that new projects are being created
|
||||||
|
final CoreModel model = CoreModel.getDefault();
|
||||||
|
model.addElementChangedListener(fCModelListener);
|
||||||
|
|
||||||
Job startup= new Job(Messages.PDOMManager_StartJob_name) {
|
Job startup= new Job(Messages.PDOMManager_StartJob_name) {
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
protected IStatus run(IProgressMonitor monitor) {
|
||||||
CoreModel model = CoreModel.getDefault();
|
|
||||||
model.addElementChangedListener(fCModelListener);
|
|
||||||
ICProject[] projects;
|
ICProject[] projects;
|
||||||
try {
|
try {
|
||||||
projects = model.getCModel().getCProjects();
|
projects = model.getCModel().getCProjects();
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
|
|
||||||
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.List;
|
||||||
|
|
||||||
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.IPDOMVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
|
@ -124,6 +127,25 @@ class PDOMCPPNamespace extends PDOMCPPBinding implements ICPPNamespace, ICPPName
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] getMemberBindings() throws DOMException {fail(); return null;}
|
public IBinding[] getMemberBindings() throws DOMException {
|
||||||
|
IBinding[] result = null;
|
||||||
|
final List preresult = new ArrayList();
|
||||||
|
try {
|
||||||
|
getIndex().accept(new IBTreeVisitor() {
|
||||||
|
public int compare(int record) throws CoreException {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
public boolean visit(int record) throws CoreException {
|
||||||
|
preresult.add(getLinkageImpl().getNode(record));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result = (IBinding[]) preresult.toArray(new IBinding[preresult.size()]);
|
||||||
|
} catch(CoreException ce) {
|
||||||
|
CCorePlugin.log(ce);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public void addUsingDirective(IASTNode directive) throws DOMException {fail();}
|
public void addUsingDirective(IASTNode directive) throws DOMException {fail();}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue