mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 02:06:01 +02:00
Cosmetics.
This commit is contained in:
parent
5c26443c41
commit
83d83c5165
5 changed files with 183 additions and 192 deletions
|
@ -87,15 +87,15 @@ public class DBTest extends BaseTestCase {
|
||||||
try {
|
try {
|
||||||
new Database(tmp, ChunkCache.getSharedInstance(), 0, false);
|
new Database(tmp, ChunkCache.getSharedInstance(), 0, false);
|
||||||
fail("A readonly file should not be openable with write-access");
|
fail("A readonly file should not be openable with write-access");
|
||||||
} catch(CoreException ioe) {
|
} catch (CoreException e) {
|
||||||
// we expect to get a failure here
|
// we expect to get a failure here
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check opening a readonly file for read access does not fail */
|
/* check opening a readonly file for read access does not fail */
|
||||||
try {
|
try {
|
||||||
new Database(tmp, ChunkCache.getSharedInstance(), 0, true);
|
new Database(tmp, ChunkCache.getSharedInstance(), 0, true);
|
||||||
} catch(CoreException ce) {
|
} catch (CoreException e) {
|
||||||
fail("A readonly file should be readable by a permanently readonly database "+ce);
|
fail("A readonly file should be readable by a permanently readonly database "+e);
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
tmp.delete(); // this may be pointless on some platforms
|
tmp.delete(); // this may be pointless on some platforms
|
||||||
|
@ -150,7 +150,6 @@ public class DBTest extends BaseTestCase {
|
||||||
public long getRecord() {
|
public long getRecord() {
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testStringsInBTree() throws Exception {
|
public void testStringsInBTree() throws Exception {
|
||||||
|
@ -194,6 +193,7 @@ public class DBTest extends BaseTestCase {
|
||||||
return string1.compare(string2, true);
|
return string1.compare(string2, true);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
BTree btree = new BTree(db, Database.DATA_AREA, comparator);
|
BTree btree = new BTree(db, Database.DATA_AREA, comparator);
|
||||||
for (int i = 0; i < names.length; ++i) {
|
for (int i = 0; i < names.length; ++i) {
|
||||||
String name = names[i];
|
String name = names[i];
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.pdom.tests;
|
package org.eclipse.cdt.internal.pdom.tests;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
@ -32,8 +31,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for verifying whether the PDOM correctly stores information about
|
* Tests for verifying whether the PDOM correctly stores information about C++ namespaces.
|
||||||
* C++ namespaces.
|
|
||||||
*
|
*
|
||||||
* @author Vivian Kong
|
* @author Vivian Kong
|
||||||
*/
|
*/
|
||||||
|
@ -65,7 +63,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);
|
||||||
assertTrue(namespaces[0] instanceof ICPPNamespace);
|
assertTrue(namespaces[0] instanceof ICPPNamespace);
|
||||||
|
@ -88,18 +86,15 @@ public class NamespaceTests extends PDOMTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testNested() throws Exception {
|
public void testNested() throws Exception {
|
||||||
|
// Find deeply nested namespace
|
||||||
/* Find deeply nested namespace */
|
|
||||||
Pattern[] patterns = {Pattern.compile("namespace1"), Pattern.compile("namespace2"), Pattern.compile("namespace3")};
|
Pattern[] patterns = {Pattern.compile("namespace1"), Pattern.compile("namespace2"), Pattern.compile("namespace3")};
|
||||||
IBinding[] namespaces = pdom.findBindings(patterns, false, INDEX_FILTER, NULL_MONITOR);
|
IBinding[] namespaces = pdom.findBindings(patterns, false, INDEX_FILTER, NULL_MONITOR);
|
||||||
assertEquals(1, namespaces.length);
|
assertEquals(1, namespaces.length);
|
||||||
assertTrue(namespaces[0] instanceof ICPPNamespace);
|
assertTrue(namespaces[0] instanceof ICPPNamespace);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMemberDefinition() throws Exception {
|
public void testMemberDefinition() throws Exception {
|
||||||
|
// Find the definition of a member declared in a namespace
|
||||||
/* Find the definition of a member declared in a namespace */
|
|
||||||
Pattern[] patterns = {Pattern.compile("namespace1"), Pattern.compile("namespace2"), Pattern.compile("foo")};
|
Pattern[] patterns = {Pattern.compile("namespace1"), Pattern.compile("namespace2"), Pattern.compile("foo")};
|
||||||
IBinding[] members = pdom.findBindings(patterns, false, INDEX_FILTER, NULL_MONITOR);
|
IBinding[] members = pdom.findBindings(patterns, false, INDEX_FILTER, NULL_MONITOR);
|
||||||
assertEquals(1, members.length);
|
assertEquals(1, members.length);
|
||||||
|
@ -114,12 +109,10 @@ public class NamespaceTests extends PDOMTestBase {
|
||||||
assertEquals(1, defs.length);
|
assertEquals(1, defs.length);
|
||||||
loc = defs[0].getFileLocation();
|
loc = defs[0].getFileLocation();
|
||||||
assertEquals(offset("namespace.cpp", "::foo()") + 2, loc.getNodeOffset()); // character offset
|
assertEquals(offset("namespace.cpp", "::foo()") + 2, loc.getNodeOffset()); // character offset
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testExtend() throws Exception {
|
public void testExtend() throws Exception {
|
||||||
|
// Extending a namespace
|
||||||
/* Extending a namespace */
|
|
||||||
IBinding[] namespaces = pdom.findBindings(Pattern.compile("ns1"), false, INDEX_FILTER, NULL_MONITOR);
|
IBinding[] namespaces = pdom.findBindings(Pattern.compile("ns1"), false, INDEX_FILTER, NULL_MONITOR);
|
||||||
assertEquals(1, namespaces.length);
|
assertEquals(1, namespaces.length);
|
||||||
assertTrue(namespaces[0] instanceof ICPPNamespace);
|
assertTrue(namespaces[0] instanceof ICPPNamespace);
|
||||||
|
@ -130,7 +123,6 @@ public class NamespaceTests extends PDOMTestBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testOverload() throws Exception {
|
public void testOverload() throws Exception {
|
||||||
|
|
||||||
// Function overloading in namespace
|
// Function overloading in namespace
|
||||||
Pattern[] patterns = {Pattern.compile("ns3"), Pattern.compile("blah")};
|
Pattern[] patterns = {Pattern.compile("ns3"), Pattern.compile("blah")};
|
||||||
IBinding[] functions = pdom.findBindings(patterns, false, INDEX_FILTER, NULL_MONITOR);
|
IBinding[] functions = pdom.findBindings(patterns, false, INDEX_FILTER, NULL_MONITOR);
|
||||||
|
@ -152,12 +144,10 @@ public class NamespaceTests extends PDOMTestBase {
|
||||||
assertEquals(1, refs.length);
|
assertEquals(1, refs.length);
|
||||||
loc = refs[0].getFileLocation();
|
loc = refs[0].getFileLocation();
|
||||||
assertEquals(offset("overload.cpp", "blah('a')"), loc.getNodeOffset()); // character offset
|
assertEquals(offset("overload.cpp", "blah('a')"), loc.getNodeOffset()); // character offset
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUnnamed() throws Exception {
|
public void testUnnamed_162226() throws Exception {
|
||||||
// test case for Bugzilla 162226
|
// Unnamed Namespace
|
||||||
/* Unnamed Namespace */
|
|
||||||
IBinding[] functions = pdom.findBindings(Pattern.compile("function1"), true, INDEX_FILTER, NULL_MONITOR);
|
IBinding[] functions = pdom.findBindings(Pattern.compile("function1"), true, INDEX_FILTER, NULL_MONITOR);
|
||||||
assertEquals(1, functions.length);
|
assertEquals(1, functions.length);
|
||||||
assertTrue(functions[0] instanceof ICPPFunction);
|
assertTrue(functions[0] instanceof ICPPFunction);
|
||||||
|
@ -177,12 +167,10 @@ public class NamespaceTests extends PDOMTestBase {
|
||||||
assertEquals(1, refs.length);
|
assertEquals(1, refs.length);
|
||||||
loc = refs[0].getFileLocation();
|
loc = refs[0].getFileLocation();
|
||||||
assertEquals(offset("unnamed.cpp", "function1();"), loc.getNodeOffset()); // character offset
|
assertEquals(offset("unnamed.cpp", "function1();"), loc.getNodeOffset()); // character offset
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testFriend() throws Exception {
|
public void testFriend_162011() throws Exception {
|
||||||
/* Friend in namespace - function2 is not in Class1*/
|
// Friend in namespace - function2 is not in Class1
|
||||||
// Bugzilla 162011
|
|
||||||
IBinding[] functions = pdom.findBindings(Pattern.compile("function2"), false, INDEX_FILTER, NULL_MONITOR);
|
IBinding[] functions = pdom.findBindings(Pattern.compile("function2"), false, INDEX_FILTER, NULL_MONITOR);
|
||||||
assertEquals(1, functions.length);
|
assertEquals(1, functions.length);
|
||||||
assertTrue(functions[0] instanceof ICPPFunction);
|
assertTrue(functions[0] instanceof ICPPFunction);
|
||||||
|
@ -202,7 +190,6 @@ public class NamespaceTests extends PDOMTestBase {
|
||||||
assertEquals(1, refs.length);
|
assertEquals(1, refs.length);
|
||||||
loc = refs[0].getFileLocation();
|
loc = refs[0].getFileLocation();
|
||||||
assertEquals(offset("friend.cpp", "ns4::function2(element)") + 5, loc.getNodeOffset()); // character offset
|
assertEquals(offset("friend.cpp", "ns4::function2(element)") + 5, loc.getNodeOffset()); // character offset
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testUsingDirective() throws Exception {
|
public void testUsingDirective() throws Exception {
|
||||||
|
|
|
@ -65,7 +65,7 @@ import com.ibm.icu.text.MessageFormat;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Database {
|
public class Database {
|
||||||
// public for tests only, you shouldn't need these
|
// Public for tests only, you shouldn't need these.
|
||||||
public static final int INT_SIZE = 4;
|
public static final int INT_SIZE = 4;
|
||||||
public static final int CHUNK_SIZE = 1024 * 4;
|
public static final int CHUNK_SIZE = 1024 * 4;
|
||||||
public static final int OFFSET_IN_CHUNK_MASK= CHUNK_SIZE-1;
|
public static final int OFFSET_IN_CHUNK_MASK= CHUNK_SIZE-1;
|
||||||
|
@ -82,7 +82,6 @@ public class Database {
|
||||||
public static final int ARGUMENT_SIZE = TYPE_SIZE; // size of a template argument in the database in bytes
|
public static final int ARGUMENT_SIZE = TYPE_SIZE; // size of a template argument in the database in bytes
|
||||||
public static final long MAX_DB_SIZE= ((long) 1 << (Integer.SIZE + BLOCK_SIZE_DELTA_BITS));
|
public static final long MAX_DB_SIZE= ((long) 1 << (Integer.SIZE + BLOCK_SIZE_DELTA_BITS));
|
||||||
|
|
||||||
|
|
||||||
public static final int VERSION_OFFSET = 0;
|
public static final int VERSION_OFFSET = 0;
|
||||||
public static final int DATA_AREA = (CHUNK_SIZE / BLOCK_SIZE_DELTA - MIN_BLOCK_DELTAS + 2) * INT_SIZE;
|
public static final int DATA_AREA = (CHUNK_SIZE / BLOCK_SIZE_DELTA - MIN_BLOCK_DELTAS + 2) * INT_SIZE;
|
||||||
|
|
||||||
|
@ -92,8 +91,8 @@ public class Database {
|
||||||
private final File fLocation;
|
private final File fLocation;
|
||||||
private final boolean fReadOnly;
|
private final boolean fReadOnly;
|
||||||
private RandomAccessFile fFile;
|
private RandomAccessFile fFile;
|
||||||
private boolean fExclusiveLock; // necessary for any write operation
|
private boolean fExclusiveLock; // Necessary for any write operation.
|
||||||
private boolean fLocked; // necessary for any operation.
|
private boolean fLocked; // Necessary for any operation.
|
||||||
private boolean fIsMarkedIncomplete;
|
private boolean fIsMarkedIncomplete;
|
||||||
|
|
||||||
private int fVersion;
|
private int fVersion;
|
||||||
|
@ -125,7 +124,7 @@ public class Database {
|
||||||
|
|
||||||
int nChunksOnDisk = (int) (fFile.length() / CHUNK_SIZE);
|
int nChunksOnDisk = (int) (fFile.length() / CHUNK_SIZE);
|
||||||
fHeaderChunk= new Chunk(this, 0);
|
fHeaderChunk= new Chunk(this, 0);
|
||||||
fHeaderChunk.fLocked= true; // never makes it into the cache, needed to satisfy assertions
|
fHeaderChunk.fLocked= true; // Never makes it into the cache, needed to satisfy assertions.
|
||||||
if (nChunksOnDisk <= 0) {
|
if (nChunksOnDisk <= 0) {
|
||||||
fVersion= version;
|
fVersion= version;
|
||||||
fChunks= new Chunk[1];
|
fChunks= new Chunk[1];
|
||||||
|
@ -188,7 +187,7 @@ public class Database {
|
||||||
while (position < size) {
|
while (position < size) {
|
||||||
nRead = from.transferTo(position, 4096 * 16, target);
|
nRead = from.transferTo(position, 4096 * 16, target);
|
||||||
if (nRead == 0) {
|
if (nRead == 0) {
|
||||||
break; // Should not happen
|
break; // Should not happen.
|
||||||
} else {
|
} else {
|
||||||
position+= nRead;
|
position+= nRead;
|
||||||
}
|
}
|
||||||
|
@ -214,14 +213,14 @@ public class Database {
|
||||||
removeChunksFromCache();
|
removeChunksFromCache();
|
||||||
|
|
||||||
fVersion= version;
|
fVersion= version;
|
||||||
// clear the first chunk.
|
// Clear the first chunk.
|
||||||
fHeaderChunk.clear(0, CHUNK_SIZE);
|
fHeaderChunk.clear(0, CHUNK_SIZE);
|
||||||
// chunks have been removed from the cache, so we may just reset the array of chunks.
|
// Chunks have been removed from the cache, so we may just reset the array of chunks.
|
||||||
fChunks = new Chunk[] {null};
|
fChunks = new Chunk[] {null};
|
||||||
fChunksUsed = fChunksAllocated = fChunks.length;
|
fChunksUsed = fChunksAllocated = fChunks.length;
|
||||||
try {
|
try {
|
||||||
fHeaderChunk.flush(); // zero out header chunk
|
fHeaderChunk.flush(); // Zero out header chunk.
|
||||||
fFile.getChannel().truncate(CHUNK_SIZE); // truncate database
|
fFile.getChannel().truncate(CHUNK_SIZE); // Truncate database.
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
|
@ -303,7 +302,7 @@ public class Database {
|
||||||
needDeltas= MIN_BLOCK_DELTAS;
|
needDeltas= MIN_BLOCK_DELTAS;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Which block size
|
// Which block size.
|
||||||
long freeblock = 0;
|
long freeblock = 0;
|
||||||
int useDeltas;
|
int useDeltas;
|
||||||
for (useDeltas= needDeltas; useDeltas <= MAX_BLOCK_DELTAS; useDeltas++) {
|
for (useDeltas= needDeltas; useDeltas <= MAX_BLOCK_DELTAS; useDeltas++) {
|
||||||
|
@ -312,10 +311,10 @@ public class Database {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the block
|
// Get the block.
|
||||||
Chunk chunk;
|
Chunk chunk;
|
||||||
if (freeblock == 0) {
|
if (freeblock == 0) {
|
||||||
// allocate a new chunk
|
// Allocate a new chunk.
|
||||||
freeblock= createNewChunk();
|
freeblock= createNewChunk();
|
||||||
useDeltas = MAX_BLOCK_DELTAS;
|
useDeltas = MAX_BLOCK_DELTAS;
|
||||||
chunk = getChunk(freeblock);
|
chunk = getChunk(freeblock);
|
||||||
|
@ -326,16 +325,16 @@ public class Database {
|
||||||
|
|
||||||
final int unusedDeltas = useDeltas-needDeltas;
|
final int unusedDeltas = useDeltas-needDeltas;
|
||||||
if (unusedDeltas >= MIN_BLOCK_DELTAS) {
|
if (unusedDeltas >= MIN_BLOCK_DELTAS) {
|
||||||
// Add in the unused part of our block
|
// Add in the unused part of our block.
|
||||||
addBlock(chunk, unusedDeltas*BLOCK_SIZE_DELTA, freeblock + needDeltas*BLOCK_SIZE_DELTA);
|
addBlock(chunk, unusedDeltas*BLOCK_SIZE_DELTA, freeblock + needDeltas*BLOCK_SIZE_DELTA);
|
||||||
useDeltas= needDeltas;
|
useDeltas= needDeltas;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make our size negative to show in use
|
// Make our size negative to show in use.
|
||||||
final int usedSize= useDeltas*BLOCK_SIZE_DELTA;
|
final int usedSize= useDeltas*BLOCK_SIZE_DELTA;
|
||||||
chunk.putShort(freeblock, (short) -usedSize);
|
chunk.putShort(freeblock, (short) -usedSize);
|
||||||
|
|
||||||
// Clear out the block, lots of people are expecting this
|
// Clear out the block, lots of people are expecting this.
|
||||||
chunk.clear(freeblock + BLOCK_HEADER_SIZE, usedSize-BLOCK_HEADER_SIZE);
|
chunk.clear(freeblock + BLOCK_HEADER_SIZE, usedSize-BLOCK_HEADER_SIZE);
|
||||||
|
|
||||||
malloced+= usedSize;
|
malloced+= usedSize;
|
||||||
|
@ -419,7 +418,7 @@ public class Database {
|
||||||
long nextblock = chunk.getFreeRecPtr(block + BLOCK_NEXT_OFFSET);
|
long nextblock = chunk.getFreeRecPtr(block + BLOCK_NEXT_OFFSET);
|
||||||
if (prevblock != 0) {
|
if (prevblock != 0) {
|
||||||
putFreeRecPtr(prevblock + BLOCK_NEXT_OFFSET, nextblock);
|
putFreeRecPtr(prevblock + BLOCK_NEXT_OFFSET, nextblock);
|
||||||
} else { // we were the head
|
} else { // We were the head.
|
||||||
setFirstBlock(blocksize, nextblock);
|
setFirstBlock(blocksize, nextblock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,7 +431,7 @@ public class Database {
|
||||||
// Mark our size
|
// Mark our size
|
||||||
chunk.putShort(block, (short) blocksize);
|
chunk.putShort(block, (short) blocksize);
|
||||||
|
|
||||||
// Add us to the head of the list
|
// Add us to the head of the list.
|
||||||
long prevfirst = getFirstBlock(blocksize);
|
long prevfirst = getFirstBlock(blocksize);
|
||||||
chunk.putFreeRecPtr(block + BLOCK_PREV_OFFSET, 0);
|
chunk.putFreeRecPtr(block + BLOCK_PREV_OFFSET, 0);
|
||||||
chunk.putFreeRecPtr(block + BLOCK_NEXT_OFFSET, prevfirst);
|
chunk.putFreeRecPtr(block + BLOCK_NEXT_OFFSET, prevfirst);
|
||||||
|
@ -448,13 +447,14 @@ public class Database {
|
||||||
*/
|
*/
|
||||||
public void free(long offset) throws CoreException {
|
public void free(long offset) throws CoreException {
|
||||||
assert fExclusiveLock;
|
assert fExclusiveLock;
|
||||||
// TODO - look for opportunities to merge blocks
|
// TODO Look for opportunities to merge blocks
|
||||||
long block = offset - BLOCK_HEADER_SIZE;
|
long block = offset - BLOCK_HEADER_SIZE;
|
||||||
Chunk chunk = getChunk(block);
|
Chunk chunk = getChunk(block);
|
||||||
int blocksize = - chunk.getShort(block);
|
int blocksize = - chunk.getShort(block);
|
||||||
if (blocksize < 0) {
|
if (blocksize < 0) {
|
||||||
// already freed
|
// Already freed.
|
||||||
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, 0, "Already Freed", new Exception())); //$NON-NLS-1$
|
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, 0,
|
||||||
|
"Already freed", new Exception())); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
addBlock(chunk, blocksize, block);
|
addBlock(chunk, blocksize, block);
|
||||||
freed += blocksize;
|
freed += blocksize;
|
||||||
|
@ -614,7 +614,7 @@ public class Database {
|
||||||
flush();
|
flush();
|
||||||
removeChunksFromCache();
|
removeChunksFromCache();
|
||||||
|
|
||||||
// chunks have been removed from the cache, so we are fine
|
// Chunks have been removed from the cache, so we are fine.
|
||||||
fHeaderChunk.clear(0, CHUNK_SIZE);
|
fHeaderChunk.clear(0, CHUNK_SIZE);
|
||||||
fHeaderChunk.fDirty= false;
|
fHeaderChunk.fDirty= false;
|
||||||
fChunks= new Chunk[] { null };
|
fChunks= new Chunk[] { null };
|
||||||
|
@ -672,15 +672,15 @@ public class Database {
|
||||||
Chunk chunk= fChunks[i];
|
Chunk chunk= fChunks[i];
|
||||||
if (chunk != null) {
|
if (chunk != null) {
|
||||||
if (chunk.fCacheIndex < 0) {
|
if (chunk.fCacheIndex < 0) {
|
||||||
// locked chunk that has been removed from cache.
|
// Locked chunk that has been removed from cache.
|
||||||
if (chunk.fDirty) {
|
if (chunk.fDirty) {
|
||||||
dirtyChunks.add(chunk); // keep in fChunks until it is flushed.
|
dirtyChunks.add(chunk); // Keep in fChunks until it is flushed.
|
||||||
} else {
|
} else {
|
||||||
chunk.fLocked= false;
|
chunk.fLocked= false;
|
||||||
fChunks[i]= null;
|
fChunks[i]= null;
|
||||||
}
|
}
|
||||||
} else if (chunk.fLocked) {
|
} else if (chunk.fLocked) {
|
||||||
// locked chunk, still in cache.
|
// Locked chunk, still in cache.
|
||||||
if (chunk.fDirty) {
|
if (chunk.fDirty) {
|
||||||
if (flush) {
|
if (flush) {
|
||||||
dirtyChunks.add(chunk);
|
dirtyChunks.add(chunk);
|
||||||
|
@ -689,12 +689,12 @@ public class Database {
|
||||||
chunk.fLocked= false;
|
chunk.fLocked= false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
assert !chunk.fDirty; // dirty chunks must be locked.
|
assert !chunk.fDirty; // Dirty chunks must be locked.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// also handles header chunk
|
// Also handles header chunk.
|
||||||
flushAndUnlockChunks(dirtyChunks, flush);
|
flushAndUnlockChunks(dirtyChunks, flush);
|
||||||
} finally {
|
} finally {
|
||||||
fExclusiveLock= false;
|
fExclusiveLock= false;
|
||||||
|
@ -713,7 +713,7 @@ public class Database {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// be careful as other readers may access chunks concurrently
|
// Be careful as other readers may access chunks concurrently.
|
||||||
ArrayList<Chunk> dirtyChunks= new ArrayList<Chunk>();
|
ArrayList<Chunk> dirtyChunks= new ArrayList<Chunk>();
|
||||||
synchronized (fCache) {
|
synchronized (fCache) {
|
||||||
for (int i= 1; i < fChunksUsed ; i++) {
|
for (int i= 1; i < fChunksUsed ; i++) {
|
||||||
|
@ -724,7 +724,7 @@ public class Database {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// also handles header chunk
|
// Also handles header chunk.
|
||||||
flushAndUnlockChunks(dirtyChunks, true);
|
flushAndUnlockChunks(dirtyChunks, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -742,7 +742,7 @@ public class Database {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// only after the chunks are flushed we may unlock and release them.
|
// Only after the chunks are flushed we may unlock and release them.
|
||||||
synchronized (fCache) {
|
synchronized (fCache) {
|
||||||
for (Chunk chunk : dirtyChunks) {
|
for (Chunk chunk : dirtyChunks) {
|
||||||
chunk.fLocked= false;
|
chunk.fLocked= false;
|
||||||
|
|
|
@ -60,7 +60,8 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||||
|
|
||||||
private volatile ICPPTemplateParameter[] params; // Cached template parameters.
|
private volatile ICPPTemplateParameter[] params; // Cached template parameters.
|
||||||
|
|
||||||
public PDOMCPPClassTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPClassTemplate template) throws CoreException, DOMException {
|
public PDOMCPPClassTemplate(PDOMCPPLinkage linkage, PDOMNode parent, ICPPClassTemplate template)
|
||||||
|
throws CoreException, DOMException {
|
||||||
super(linkage, parent, template);
|
super(linkage, parent, template);
|
||||||
|
|
||||||
final Database db = getDB();
|
final Database db = getDB();
|
||||||
|
@ -127,7 +128,8 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateTemplateParameters(PDOMLinkage linkage, ICPPTemplateParameter[] newParams) throws CoreException, DOMException {
|
private void updateTemplateParameters(PDOMLinkage linkage, ICPPTemplateParameter[] newParams)
|
||||||
|
throws CoreException, DOMException {
|
||||||
final Database db = getDB();
|
final Database db = getDB();
|
||||||
long rec= db.getRecPtr(record + PARAMETERS);
|
long rec= db.getRecPtr(record + PARAMETERS);
|
||||||
IPDOMCPPTemplateParameter[] allParams;
|
IPDOMCPPTemplateParameter[] allParams;
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.core.runtime.Assert;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collects methods to store an argument list in the database
|
* Collects methods to store an argument list in the database.
|
||||||
*/
|
*/
|
||||||
public class PDOMTemplateParameterArray {
|
public class PDOMTemplateParameterArray {
|
||||||
/**
|
/**
|
||||||
|
@ -67,7 +67,8 @@ public class PDOMTemplateParameterArray {
|
||||||
/**
|
/**
|
||||||
* Creates template parameters in the pdom
|
* Creates template parameters in the pdom
|
||||||
*/
|
*/
|
||||||
public static IPDOMCPPTemplateParameter[] createPDOMTemplateParameters(PDOMLinkage linkage, PDOMNode parent, ICPPTemplateParameter[] origParams) throws CoreException, DOMException {
|
public static IPDOMCPPTemplateParameter[] createPDOMTemplateParameters(PDOMLinkage linkage,
|
||||||
|
PDOMNode parent, ICPPTemplateParameter[] origParams) throws CoreException, DOMException {
|
||||||
IPDOMCPPTemplateParameter[] params= new IPDOMCPPTemplateParameter[origParams.length];
|
IPDOMCPPTemplateParameter[] params= new IPDOMCPPTemplateParameter[origParams.length];
|
||||||
for (int i = 0; i < origParams.length; i++) {
|
for (int i = 0; i < origParams.length; i++) {
|
||||||
params[i]= createPDOMTemplateParameter(linkage, parent, origParams[i]);
|
params[i]= createPDOMTemplateParameter(linkage, parent, origParams[i]);
|
||||||
|
@ -78,7 +79,8 @@ public class PDOMTemplateParameterArray {
|
||||||
/**
|
/**
|
||||||
* Creates a template parameter in the pdom
|
* Creates a template parameter in the pdom
|
||||||
*/
|
*/
|
||||||
public static IPDOMCPPTemplateParameter createPDOMTemplateParameter(PDOMLinkage linkage, PDOMNode parent, ICPPTemplateParameter origParam) throws CoreException, DOMException {
|
public static IPDOMCPPTemplateParameter createPDOMTemplateParameter(PDOMLinkage linkage,
|
||||||
|
PDOMNode parent, ICPPTemplateParameter origParam) throws CoreException, DOMException {
|
||||||
IPDOMCPPTemplateParameter param= null;
|
IPDOMCPPTemplateParameter param= null;
|
||||||
if (origParam instanceof ICPPTemplateNonTypeParameter) {
|
if (origParam instanceof ICPPTemplateNonTypeParameter) {
|
||||||
param= new PDOMCPPTemplateNonTypeParameter(linkage, parent, (ICPPTemplateNonTypeParameter) origParam);
|
param= new PDOMCPPTemplateNonTypeParameter(linkage, parent, (ICPPTemplateNonTypeParameter) origParam);
|
||||||
|
|
Loading…
Add table
Reference in a new issue