1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

fix bug in DBProperties use in the PDOM

This commit is contained in:
Andrew Ferguson 2007-02-27 13:58:09 +00:00
parent b320422e75
commit fc38a2a891
3 changed files with 73 additions and 4 deletions

View file

@ -0,0 +1,62 @@
/*******************************************************************************
* 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.pdom.tests;
import junit.framework.Test;
import org.eclipse.cdt.core.dom.IPDOMManager;
import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
import org.eclipse.cdt.internal.core.CCoreInternals;
import org.eclipse.cdt.internal.core.index.IWritableIndexFragment;
import org.eclipse.cdt.internal.core.pdom.WritablePDOM;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.NullProgressMonitor;
/**
* Tests bugs found in the PDOM
*/
public class PDOMBugsTest extends BaseTestCase {
ICProject cproject;
public static Test suite() {
return suite(PDOMBugsTest.class);
}
protected void setUp() throws Exception {
cproject= CProjectHelper.createCCProject("PDOMBugsTest"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER);
super.setUp();
}
protected void tearDown() throws Exception {
if (cproject != null) {
cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor());
}
super.tearDown();
}
public void testPDOMProperties() throws Exception {
IWritableIndexFragment pdom = (IWritableIndexFragment) CCoreInternals.getPDOMManager().getPDOM(cproject);
pdom.acquireWriteLock(0);
try {
WritablePDOM wpdom = (WritablePDOM) pdom;
wpdom.setProperty("a", "b");
assertEquals("b", wpdom.getProperty("a"));
wpdom.setProperty("c", "d");
assertEquals("d", wpdom.getProperty("c"));
wpdom.setProperty("c", "e");
assertEquals("e", wpdom.getProperty("c"));
} finally {
pdom.releaseWriteLock(0);
}
}
}

View file

@ -26,6 +26,7 @@ public class PDOMTests extends TestSuite {
suite.addTest(DBTest.suite());
suite.addTest(DBPropertiesTests.suite());
suite.addTest(PDOMBugsTest.suite());
suite.addTest(PDOMSearchTest.suite());
suite.addTestSuite(PDOMLocationTests.class);
suite.addTestSuite(EnumerationTests.class);

View file

@ -48,9 +48,9 @@ import org.eclipse.cdt.internal.core.index.IIndexFragmentName;
import org.eclipse.cdt.internal.core.pdom.db.BTree;
import org.eclipse.cdt.internal.core.pdom.db.DBProperties;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.dom.ApplyVisitor;
import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
import org.eclipse.cdt.internal.core.pdom.dom.ApplyVisitor;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMInclude;
@ -190,15 +190,21 @@ public class PDOM extends PlatformObject implements IIndexFragment, IPDOM {
return file;
}
protected void clearFileIndex() throws CoreException {
db.putInt(FILE_INDEX, 0);
fileIndex = null;
}
protected void clear() throws CoreException {
Database db = getDB();
// Clear out the database
db.clear(1);
// Zero out the File Index and Linkages
db.putInt(FILE_INDEX, 0);
fileIndex = null;
clearFileIndex();
db.putInt(PROPERTIES, 0);
db.putInt(LINKAGES, 0);
fLinkageIDCache.clear();
}