mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixed PDOM rebuilding. Fixed file names to be paths in file system instead of workspace. Fixed BTree visit problem that showed off as names appearing more than once in the Bindings View.
This commit is contained in:
parent
1ca39e56f9
commit
3851ae5ee1
5 changed files with 38 additions and 24 deletions
|
@ -31,6 +31,7 @@ import org.eclipse.cdt.core.parser.ParserUtil;
|
|||
import org.eclipse.cdt.core.parser.ScannerInfo;
|
||||
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPField;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
||||
|
@ -105,6 +106,8 @@ public class GPPLanguage implements ILanguage {
|
|||
if (binding == null)
|
||||
return null;
|
||||
|
||||
if (binding instanceof CPPField)
|
||||
return null;
|
||||
if (binding instanceof CPPVariable)
|
||||
return new PDOMCPPVariable(pdom, name, (CPPVariable)binding);
|
||||
|
||||
|
|
|
@ -27,7 +27,9 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
|||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.IStatus;
|
||||
import org.eclipse.core.runtime.QualifiedName;
|
||||
import org.eclipse.core.runtime.Status;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -118,11 +120,9 @@ public class PDOMDatabase implements IPDOM {
|
|||
}
|
||||
|
||||
public void delete() throws CoreException {
|
||||
db = null;
|
||||
getDB().clear();
|
||||
bindingIndex = null;
|
||||
fileIndex = null;
|
||||
System.gc();
|
||||
dbPath.toFile().delete();
|
||||
}
|
||||
|
||||
public ICodeReaderFactory getCodeReaderFactory() {
|
||||
|
|
|
@ -243,7 +243,7 @@ public class BTree {
|
|||
}
|
||||
}
|
||||
|
||||
return visit(getChild(chunk, node, i), visitor, found);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -51,22 +51,12 @@ public class Database {
|
|||
}
|
||||
|
||||
toc = new Chunk[(int)nChunks];
|
||||
|
||||
// Load in the magic chunk zero
|
||||
toc[0] = new Chunk(file, 0);
|
||||
int oldversion = toc[0].getInt(0);
|
||||
if (oldversion != version) {
|
||||
// Conversion?
|
||||
toc[0].putInt(0, version);
|
||||
}
|
||||
init(version);
|
||||
} catch (IOException e) {
|
||||
throw new CoreException(new DBStatus(e));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the database, including chunk zero and the b-trees.
|
||||
*/
|
||||
|
||||
private void create() throws CoreException {
|
||||
try {
|
||||
file.seek(0);
|
||||
|
@ -75,6 +65,27 @@ public class Database {
|
|||
throw new CoreException(new DBStatus(e));
|
||||
}
|
||||
}
|
||||
|
||||
private void init(int version) throws CoreException {
|
||||
// Load in the magic chunk zero
|
||||
toc[0] = new Chunk(file, 0);
|
||||
int oldversion = toc[0].getInt(0);
|
||||
if (oldversion != version) {
|
||||
// Conversion?
|
||||
toc[0].putInt(0, version);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty the contents of the Database, make it ready to start again
|
||||
* @throws CoreException
|
||||
*/
|
||||
public void clear() throws CoreException {
|
||||
int version = toc[0].getInt(0);
|
||||
create();
|
||||
toc = new Chunk[1];
|
||||
init(version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the Chunk that contains the given offset.
|
||||
|
@ -158,15 +169,15 @@ public class Database {
|
|||
|
||||
private int createChunk() throws CoreException {
|
||||
try {
|
||||
int offset = (int)file.length();
|
||||
Chunk[] oldtoc = toc;
|
||||
int n = oldtoc.length;
|
||||
int offset = n * CHUNK_SIZE;
|
||||
file.seek(offset);
|
||||
file.write(new byte[CHUNK_SIZE]);
|
||||
Chunk[] oldtoc = toc;
|
||||
int i = oldtoc.length;
|
||||
toc = new Chunk[i + 1];
|
||||
System.arraycopy(oldtoc, 0, toc, 0, i);
|
||||
toc[i] = new Chunk(file, offset);
|
||||
return i;
|
||||
toc = new Chunk[n + 1];
|
||||
System.arraycopy(oldtoc, 0, toc, 0, n);
|
||||
toc[n] = new Chunk(file, offset);
|
||||
return n;
|
||||
} catch (IOException e) {
|
||||
throw new CoreException(new DBStatus(e));
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ public class SavedCodeReaderFactory implements ICodeReaderFactory {
|
|||
}
|
||||
|
||||
public CodeReader createCodeReaderForTranslationUnit(ITranslationUnit tu) {
|
||||
return new CodeReader(tu.getPath().toOSString(), tu.getContents());
|
||||
return new CodeReader(tu.getResource().getLocation().toOSString(), tu.getContents());
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
|
Loading…
Add table
Reference in a new issue