1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Working on getting language and type info into the bindings. Fixed up the name of the pdom.dom package. Pushed IOExceptions as low down as I could.

This commit is contained in:
Doug Schaefer 2005-11-28 04:35:36 +00:00
parent 56254fd6f3
commit a39da76e9e
28 changed files with 357 additions and 624 deletions

View file

@ -1,7 +1,6 @@
package org.eclipse.cdt.internal.pdom.tests;
import java.io.File;
import java.io.IOException;
import junit.framework.TestCase;
@ -10,6 +9,7 @@ import org.eclipse.cdt.internal.core.pdom.db.BTree;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.db.StringComparator;
import org.eclipse.cdt.internal.core.pdom.db.StringVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
public class DBTest extends TestCase {
@ -79,12 +79,12 @@ public class DBTest extends TestCase {
super(db, Database.INT_SIZE, key);
}
public boolean visit(int record) throws IOException {
public boolean visit(int record) throws CoreException {
this.record = record;
return false;
}
public int findIn(BTree btree) throws IOException {
public int findIn(BTree btree) throws CoreException {
btree.visit(this);
return record;
}

View file

@ -56,6 +56,7 @@ Export-Package: .,
org.eclipse.cdt.internal.core.parser.util,
org.eclipse.cdt.internal.core.pdom,
org.eclipse.cdt.internal.core.pdom.db,
org.eclipse.cdt.internal.core.pdom.dom,
org.eclipse.cdt.internal.core.search,
org.eclipse.cdt.internal.core.search.indexing,
org.eclipse.cdt.internal.core.search.matching,
@ -64,7 +65,6 @@ Export-Package: .,
org.eclipse.cdt.internal.core.util,
org.eclipse.cdt.internal.errorparsers,
org.eclipse.cdt.internal.formatter,
org.eclipse.cdt.internal.pdom.dom,
org.eclipse.cdt.utils,
org.eclipse.cdt.utils.coff,
org.eclipse.cdt.utils.coff.parser,

View file

@ -17,7 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
import org.eclipse.cdt.internal.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.core.runtime.CoreException;
/**
@ -92,14 +92,14 @@ public interface ILanguage {
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, IASTName name) throws CoreException;
/**
* Return a new PDOM Binding that has the given language specific type.
* The type id is extracted from the PDOM Database.
* Creates a language specific binding given the generic binding extracted
* from the PDOM database.
*
* @param pdom
* @param bindingType
* @param binding
*
* @return
*/
public PDOMBinding createPDOMBinding(PDOMDatabase pdom, int bindingType);
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, PDOMBinding binding) throws CoreException;
}

View file

@ -15,12 +15,9 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.ILanguage;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.CodeReader;
@ -40,13 +37,10 @@ import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
import org.eclipse.cdt.internal.core.parser.scanner2.GCCScannerExtensionConfiguration;
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
import org.eclipse.cdt.internal.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
/**
* @author Doug Schaefer
@ -103,38 +97,15 @@ public class GCCLanguage implements ILanguage {
}
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, IASTName name) throws CoreException {
try {
IBinding binding = name.resolveBinding();
if (binding == null)
return null;
IScope scope = binding.getScope();
if (scope == null)
return null;
PDOMBinding pdomBinding = null;
IASTName scopeName = scope.getScopeName();
if (scopeName == null) {
pdomBinding = new PDOMBinding(pdom, name, binding);
new PDOMName(pdom, name, pdomBinding);
} else {
IBinding scopeBinding = scopeName.resolveBinding();
if (scopeBinding instanceof IType) {
pdomBinding = new PDOMBinding(pdom, name, binding);
new PDOMName(pdom, name, pdomBinding);
}
}
return null;
} catch (DOMException e) {
throw new CoreException(new Status(IStatus.ERROR,
CCorePlugin.PLUGIN_ID, 0, "DOM Exception", e));
}
}
public PDOMBinding createPDOMBinding(PDOMDatabase pdom, int bindingType) {
// TODO Auto-generated method stub
return null;
}
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, PDOMBinding binding) throws CoreException {
return binding;
}
}

View file

@ -15,12 +15,9 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.ILanguage;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.CodeReader;
@ -34,19 +31,18 @@ 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.CPPVariable;
import org.eclipse.cdt.internal.core.dom.parser.cpp.GNUCPPSourceParser;
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
import org.eclipse.cdt.internal.core.parser.scanner2.DOMScanner;
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
import org.eclipse.cdt.internal.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPVariable;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
/**
* @author Doug Schaefer
@ -101,39 +97,27 @@ public class GPPLanguage implements ILanguage {
return null;
}
// Binding types
public static final int CPPVARIABLE = 1;
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, IASTName name) throws CoreException {
try {
IBinding binding = name.resolveBinding();
if (binding == null)
return null;
IScope scope = binding.getScope();
if (scope == null)
return null;
if (binding instanceof CPPVariable)
return new PDOMCPPVariable(pdom, name, (CPPVariable)binding);
PDOMBinding pdomBinding = null;
IASTName scopeName = scope.getScopeName();
if (scopeName == null) {
pdomBinding = new PDOMBinding(pdom, name, binding);
new PDOMName(pdom, name, pdomBinding);
} else {
IBinding scopeBinding = scopeName.resolveBinding();
if (scopeBinding instanceof IType) {
pdomBinding = new PDOMBinding(pdom, name, binding);
new PDOMName(pdom, name, pdomBinding);
}
}
return null;
} catch (DOMException e) {
throw new CoreException(new Status(IStatus.ERROR,
CCorePlugin.PLUGIN_ID, 0, "DOM Exception", e));
}
}
public PDOMBinding createPDOMBinding(PDOMDatabase pdom, int bindingType) {
// TODO Auto-generated method stub
return null;
}
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, PDOMBinding binding) throws CoreException {
switch (binding.getBindingType()) {
case CPPVARIABLE:
return new PDOMCPPVariable(pdom, binding.getRecord());
}
return binding;
}
}

View file

@ -22,7 +22,7 @@ import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.internal.pdom.dom.PDOMFile;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@ -69,7 +69,7 @@ public class PDOMCodeReaderFactory implements ICodeReaderFactory {
}
if (PDOMFile.find(pdom, path) != null)
return null;
} catch (IOException e) {
} catch (CoreException e) {
CCorePlugin.log(new CoreException(new Status(IStatus.ERROR,
CCorePlugin.PLUGIN_ID, 0, "PDOM Exception", e)));
}

View file

@ -10,32 +10,24 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom;
import java.io.IOException;
import java.util.ArrayList;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
import org.eclipse.cdt.core.dom.ILanguage;
import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.core.model.IWorkingCopy;
import org.eclipse.cdt.internal.core.pdom.db.BTree;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.pdom.dom.PDOMName;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
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;
/**
@ -46,13 +38,10 @@ import org.eclipse.core.runtime.Status;
public class PDOMDatabase implements IPDOM {
private final IPath dbPath;
private final Database db;
private Database db;
private static final int VERSION = 0;
public static final int STRING_INDEX = Database.DATA_AREA + 0 * Database.INT_SIZE;
private BTree stringIndex;
public static final int FILE_INDEX = Database.DATA_AREA + 1 * Database.INT_SIZE;
private BTree fileIndex;
@ -71,34 +60,25 @@ public class PDOMDatabase implements IPDOM {
}
dbPath = CCorePlugin.getDefault().getStateLocation().append(dbName);
try {
db = new Database(dbPath.toOSString(), VERSION);
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR,
CCorePlugin.PLUGIN_ID, 0, "Failed to create database", e));
}
}
public Database getDB() {
public Database getDB() throws CoreException {
if (db == null)
db = new Database(dbPath.toOSString(), VERSION);
return db;
}
public BTree getStringIndex() {
if (stringIndex == null)
stringIndex = new BTree(db, STRING_INDEX);
return stringIndex;
}
public BTree getFileIndex() {
public BTree getFileIndex() throws CoreException {
if (fileIndex == null)
fileIndex = new BTree(db, FILE_INDEX);
fileIndex = new BTree(getDB(), FILE_INDEX);
return fileIndex;
}
public BTree getBindingIndex() {
public BTree getBindingIndex() throws CoreException {
if (bindingIndex == null)
bindingIndex = new BTree(db, BINDING_INDEX);
bindingIndex = new BTree(getDB(), BINDING_INDEX);
return bindingIndex;
}
@ -119,8 +99,11 @@ public class PDOMDatabase implements IPDOM {
public int visit(IASTName name) {
try {
if (name.toCharArray().length > 0)
language.getPDOMBinding(PDOMDatabase.this, name);
if (name.toCharArray().length > 0) {
PDOMBinding binding = language.getPDOMBinding(PDOMDatabase.this, name);
if (binding != null)
new PDOMName(PDOMDatabase.this, name, binding);
}
return PROCESS_CONTINUE;
} catch (CoreException e) {
CCorePlugin.log(e);
@ -135,7 +118,11 @@ public class PDOMDatabase implements IPDOM {
}
public void delete() throws CoreException {
// TODO Auto-generated method stub
db = null;
bindingIndex = null;
fileIndex = null;
System.gc();
dbPath.toFile().delete();
}
public ICodeReaderFactory getCodeReaderFactory() {
@ -154,45 +141,18 @@ public class PDOMDatabase implements IPDOM {
return new IASTName[0];
return new IASTName[] { name };
}
} catch (IOException e) {
} catch (CoreException e) {
CCorePlugin.log(e);
}
return new IASTName[0];
}
public IBinding resolveBinding(IASTName name) {
try {
return new PDOMBinding(this, name, null);
} catch (CoreException e) {
CCorePlugin.log(e);
return null;
}
}
public IBinding[] resolvePrefix(IASTName name) {
// try {
final String prefix = new String(name.toCharArray());
final ArrayList bindings = new ArrayList();
// getStringIndex().visit(new PDOMString.Visitor(db, prefix) {
// public boolean visit(int record) throws IOException {
// String value = new String(new PDOMString(PDOMDatabase.this, record).getString());
// if (value.startsWith(prefix)) {
// PDOMBinding pdomBinding = PDOMBinding.find(PDOMDatabase.this, record);
// if (pdomBinding != null)
// bindings.add(pdomBinding);
// return true;
// } else
// return false;
// }
// });
return (IBinding[])bindings.toArray(new IBinding[bindings.size()]);
// } catch (IOException e) {
// PDOMCorePlugin.log(new CoreException(new Status(IStatus.ERROR,
// PDOMCorePlugin.ID, 0, "resolvePrefix", e)));
// return null;
// }
return new IBinding[0];
}
}

View file

@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.pdom;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.IPDOMProvider;
import org.eclipse.cdt.core.model.ElementChangedEvent;
import org.eclipse.cdt.core.model.IElementChangedListener;
import org.eclipse.core.resources.IProject;
@ -28,7 +27,7 @@ import org.eclipse.core.runtime.jobs.IJobChangeListener;
*
* @author Doug Schaefer
*/
public class PDOMManager implements IPDOMProvider, IElementChangedListener, IJobChangeListener {
public class PDOMManager implements IElementChangedListener, IJobChangeListener {
private static PDOMManager instance;
private PDOMUpdator currJob;

View file

@ -15,10 +15,8 @@ import java.util.LinkedList;
import java.util.List;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ILanguage;
import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.PDOM;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.model.ICElementDelta;

View file

@ -3,10 +3,9 @@
*/
package org.eclipse.cdt.internal.core.pdom;
import java.io.IOException;
import org.eclipse.cdt.internal.core.pdom.db.Chunk;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.core.runtime.CoreException;
/**
* @author dschaefer
@ -14,7 +13,7 @@ import org.eclipse.cdt.internal.core.pdom.db.Database;
*/
public class PDOMUtils {
public static int stringCompare(Database db, int record1, int record2) throws IOException {
public static int stringCompare(Database db, int record1, int record2) throws CoreException {
Chunk chunk1 = db.getChunk(record1);
Chunk chunk2 = db.getChunk(record2);
@ -43,7 +42,7 @@ public class PDOMUtils {
return 1;
}
public static int stringCompare(Database db, int record1, char[] record2) throws IOException {
public static int stringCompare(Database db, int record1, char[] record2) throws CoreException {
Chunk chunk1 = db.getChunk(record1);
int i1 = record1;

View file

@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.db;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
/**
* @author Doug Schaefer
@ -37,7 +37,7 @@ public class BTree {
this.rootPointer = rootPointer;
}
protected int getRoot() throws IOException {
protected int getRoot() throws CoreException {
return db.getInt(rootPointer);
}
@ -65,7 +65,7 @@ public class BTree {
* @param offset of the record
* @return
*/
public int insert(int record, IBTreeComparator comparator) throws IOException {
public int insert(int record, IBTreeComparator comparator) throws CoreException {
int root = getRoot();
// is this our first time in
@ -77,7 +77,7 @@ public class BTree {
return insert(null, 0, 0, root, record, comparator);
}
private int insert(Chunk pChunk, int parent, int iParent, int node, int record, IBTreeComparator comparator) throws IOException {
private int insert(Chunk pChunk, int parent, int iParent, int node, int record, IBTreeComparator comparator) throws CoreException {
Chunk chunk = db.getChunk(node);
// if this node is full (last record isn't null), split it
@ -164,7 +164,7 @@ public class BTree {
}
}
private void firstInsert(int record) throws IOException {
private void firstInsert(int record) throws CoreException {
// create the node and save it as root
int root = allocateNode();
db.putInt(rootPointer, root);
@ -172,7 +172,7 @@ public class BTree {
putRecord(db.getChunk(root), root, 0, record);
}
private int allocateNode() throws IOException {
private int allocateNode() throws CoreException {
return db.malloc((2 * NUM_RECORDS - 1) * Database.INT_SIZE);
}
@ -191,11 +191,11 @@ public class BTree {
*
* @param visitor
*/
public void visit(IBTreeVisitor visitor) throws IOException {
public void visit(IBTreeVisitor visitor) throws CoreException {
visit(db.getInt(rootPointer), visitor, false);
}
private boolean visit(int node, IBTreeVisitor visitor, boolean found) throws IOException {
private boolean visit(int node, IBTreeVisitor visitor, boolean found) throws CoreException {
// if found is false, we are still in search mode
// once found is true visit everything
// return false when ready to quit
@ -246,81 +246,4 @@ public class BTree {
return visit(getChild(chunk, node, i), visitor, found);
}
public int getHeight() throws IOException {
int root = getRoot();
if (root == 0)
return 0;
return getHeight(root);
}
private int getHeight(int node) throws IOException {
int height = 0;
Chunk chunk = db.getChunk(node);
for (int i = 0; i < NUM_CHILDREN; ++i) {
int child = getChild(chunk, node, i);
if (child == 0)
break;
int n = getHeight(child);
if (n == -1)
return -1;
if (height != 0 && height != n)
return -1;
height = n;
}
return height + 1;
}
public int getRecordCount() throws IOException {
int root = getRoot();
if (root == 0)
return 0;
return getRecordCount(root);
}
private int getRecordCount(int node) throws IOException {
Chunk chunk = db.getChunk(node);
int count;
for (count = 0; count < NUM_RECORDS; ++count)
if (getRecord(chunk, node, count) == 0)
break;
for (int i = 0; i < NUM_CHILDREN; ++i) {
int child = getChild(chunk, node, i);
if (child != 0)
count += getRecordCount(child);
}
return count;
}
public int getNodeCount() throws IOException {
int root = getRoot();
if (root == 0)
return 0;
return getNodeCount(root);
}
private int getNodeCount(int node) throws IOException {
Chunk chunk = db.getChunk(node);
int count = 1;
for (int i = 0; i < NUM_CHILDREN; ++i) {
int child = getChild(chunk, node, i);
if (child != 0)
count += getNodeCount(child);
}
return count;
}
}

View file

@ -15,6 +15,8 @@ import java.io.RandomAccessFile;
import java.nio.MappedByteBuffer;
import java.nio.channels.FileChannel.MapMode;
import org.eclipse.core.runtime.CoreException;
/**
* @author Doug Schaefer
*
@ -29,9 +31,13 @@ public class Chunk {
private Chunk prevChunk;
private Chunk nextChunk;
Chunk(RandomAccessFile file, int offset) throws IOException {
Chunk(RandomAccessFile file, int offset) throws CoreException {
try {
index = offset / Database.CHUNK_SIZE;
buffer = file.getChannel().map(MapMode.READ_WRITE, offset, Database.CHUNK_SIZE);
} catch (IOException e) {
throw new CoreException(new DBStatus(e));
}
}
public void putInt(int offset, int value) {

View file

@ -8,30 +8,26 @@
* Contributors:
* QNX - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom;
import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.IPDOMProvider;
import org.eclipse.cdt.core.model.IElementChangedListener;
import org.eclipse.core.resources.IProject;
package org.eclipse.cdt.internal.core.pdom.db;
import java.io.IOException;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
/**
* @author Doug Schaefer
*
*/
public class NullPDOMProvider implements IPDOMProvider {
public class DBStatus extends Status {
public IPDOM getPDOM(IProject project) {
// by default return null.
return null;
}
public IElementChangedListener getElementChangedListener() {
// here too
return null;
}
public void deletePDOM(IProject project) {
/**
* @param exception
*/
public DBStatus(IOException exception) {
super(IStatus.ERROR, CCorePlugin.PLUGIN_ID, 0, "IOException", exception);
}
}

View file

@ -13,6 +13,8 @@ package org.eclipse.cdt.internal.core.pdom.db;
import java.io.IOException;
import java.io.RandomAccessFile;
import org.eclipse.core.runtime.CoreException;
/**
* @author Doug Schaefer
*
@ -37,7 +39,8 @@ public class Database {
public static final int NEXT_OFFSET = INT_SIZE * 2;
public static final int DATA_AREA = CHUNK_SIZE / MIN_SIZE * INT_SIZE + INT_SIZE;
public Database(String filename, int version) throws IOException {
public Database(String filename, int version) throws CoreException {
try {
file = new RandomAccessFile(filename, "rw"); //$NON-NLS-1$
// Allocate chunk table, make sure we have at least one
@ -56,14 +59,21 @@ public class Database {
// Conversion?
toc[0].putInt(0, version);
}
} catch (IOException e) {
throw new CoreException(new DBStatus(e));
}
}
/**
* Create the database, including chunk zero and the b-trees.
*/
private void create() throws IOException {
private void create() throws CoreException {
try {
file.seek(0);
file.write(new byte[CHUNK_SIZE]); // the header chunk
} catch (IOException e) {
throw new CoreException(new DBStatus(e));
}
}
/**
@ -72,7 +82,7 @@ public class Database {
* @param offset
* @return
*/
public Chunk getChunk(int offset) throws IOException {
public Chunk getChunk(int offset) throws CoreException {
int index = offset / CHUNK_SIZE;
Chunk chunk = toc[index];
if (chunk == null) {
@ -107,7 +117,7 @@ public class Database {
* @param size
* @return
*/
public int malloc(int size) throws IOException {
public int malloc(int size) throws CoreException {
// Which block size
int freeblock = 0;
int blocksize;
@ -146,7 +156,8 @@ public class Database {
return freeblock + INT_SIZE;
}
private int createChunk() throws IOException {
private int createChunk() throws CoreException {
try {
int offset = (int)file.length();
file.seek(offset);
file.write(new byte[CHUNK_SIZE]);
@ -156,6 +167,9 @@ public class Database {
System.arraycopy(oldtoc, 0, toc, 0, i);
toc[i] = new Chunk(file, offset);
return i;
} catch (IOException e) {
throw new CoreException(new DBStatus(e));
}
}
private int getFirstBlock(int blocksize) {
@ -166,7 +180,7 @@ public class Database {
toc[0].putInt((blocksize / MIN_SIZE) * INT_SIZE, block);
}
private void removeBlock(Chunk chunk, int blocksize, int block) throws IOException {
private void removeBlock(Chunk chunk, int blocksize, int block) throws CoreException {
int prevblock = chunk.getInt(block + PREV_OFFSET);
int nextblock = chunk.getInt(block + NEXT_OFFSET);
if (prevblock != 0)
@ -178,7 +192,7 @@ public class Database {
putInt(nextblock + PREV_OFFSET, prevblock);
}
private void addBlock(Chunk chunk, int blocksize, int block) throws IOException {
private void addBlock(Chunk chunk, int blocksize, int block) throws CoreException {
// Mark our size
chunk.putInt(block, blocksize);
@ -196,7 +210,7 @@ public class Database {
*
* @param offset
*/
public void free(int offset) throws IOException {
public void free(int offset) throws CoreException {
// TODO - look for opportunities to merge blocks
int block = offset - INT_SIZE;
Chunk chunk = getChunk(block);
@ -204,32 +218,42 @@ public class Database {
addBlock(chunk, blocksize, block);
}
public void putInt(int offset, int value) throws IOException {
public void putInt(int offset, int value) throws CoreException {
Chunk chunk = getChunk(offset);
chunk.putInt(offset, value);
}
public int getInt(int offset) throws IOException {
public int getInt(int offset) throws CoreException {
Chunk chunk = getChunk(offset);
return chunk.getInt(offset);
}
public void putChars(int offset, char[] value) throws IOException {
public void putChar(int offset, char value) throws CoreException {
Chunk chunk = getChunk(offset);
chunk.putChar(offset, value);
}
public char getChar(int offset) throws CoreException {
Chunk chunk = getChunk(offset);
return chunk.getChar(offset);
}
public void putChars(int offset, char[] value) throws CoreException {
Chunk chunk = getChunk(offset);
chunk.putChars(offset, value);
}
public char[] getChars(int offset) throws IOException {
public char[] getChars(int offset) throws CoreException {
Chunk chunk = getChunk(offset);
return chunk.getChars(offset);
}
public void putString(int offset, String value) throws IOException {
public void putString(int offset, String value) throws CoreException {
Chunk chunk = getChunk(offset);
chunk.putString(offset, value);
}
public String getString(int offset) throws IOException {
public String getString(int offset) throws CoreException {
Chunk chunk = getChunk(offset);
return chunk.getString(offset);
}

View file

@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.db;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
/**
* @author Doug Schaefer
@ -26,6 +26,6 @@ public interface IBTreeComparator {
* @return
* @throws IOException
*/
public abstract int compare(int record1, int record2) throws IOException;
public abstract int compare(int record1, int record2) throws CoreException;
}

View file

@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.db;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
/**
* @author Doug Schaefer
@ -31,7 +31,7 @@ public interface IBTreeVisitor {
* @return -1 if record < key, 0 if record == key, 1 if record > key
* @throws IOException
*/
public abstract int compare(int record) throws IOException;
public abstract int compare(int record) throws CoreException;
/**
* Visit a given record and return whether to continue or not.
@ -40,6 +40,6 @@ public interface IBTreeVisitor {
* @return
* @throws IOException
*/
public abstract boolean visit(int record) throws IOException;
public abstract boolean visit(int record) throws CoreException;
}

View file

@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.db;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
/**
* @author Doug Schaefer
@ -26,7 +26,7 @@ public class StringComparator implements IBTreeComparator {
this.offset = offset;
}
public int compare(int record1, int record2) throws IOException {
public int compare(int record1, int record2) throws CoreException {
Chunk chunk1 = db.getChunk(record1);
Chunk chunk2 = db.getChunk(record2);

View file

@ -10,7 +10,7 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.db;
import java.io.IOException;
import org.eclipse.core.runtime.CoreException;
/**
* @author Doug Schaefer
@ -28,7 +28,7 @@ public abstract class StringVisitor implements IBTreeVisitor {
this.key = key;
}
public int compare(int record) throws IOException {
public int compare(int record) throws CoreException {
Chunk chunk = db.getChunk(record);
int i1 = record + offset;
int i2 = 0;

View file

@ -8,7 +8,7 @@
* Contributors:
* QNX - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.dom;
package org.eclipse.cdt.internal.core.pdom.dom;
import java.io.IOException;
@ -55,9 +55,10 @@ public class PDOMBinding implements IBinding {
this.db = db;
}
public int compare(int record1, int record2) throws IOException {
public int compare(int record1, int record2) throws CoreException {
int string1 = db.getInt(record1 + STRING_REC_OFFSET);
int string2 = db.getInt(record2 + STRING_REC_OFFSET);
// Need to deal with language and type
return PDOMUtils.stringCompare(db, string1, string2);
}
@ -69,13 +70,14 @@ public class PDOMBinding implements IBinding {
private Database db;
private char[] key;
public Visitor(Database db, char[] key) {
public Visitor(Database db, char[] key, int language, int type) {
this.db = db;
this.key = key;
}
public int compare(int record1) throws IOException {
public int compare(int record1) throws CoreException {
int string1 = db.getInt(record1 + STRING_REC_OFFSET);
// Need to deal with language and type
return PDOMUtils.stringCompare(db, string1, key);
}
@ -86,45 +88,43 @@ public class PDOMBinding implements IBinding {
private int record;
public FindVisitor(Database db, char[] stringKey) {
super(db, stringKey);
public FindVisitor(Database db, char[] stringKey, int language, int type) {
super(db, stringKey, language, type);
}
public boolean visit(int record) throws IOException {
public boolean visit(int record) throws CoreException {
this.record = record;
return false;
}
public int findIn(BTree btree) throws IOException {
public int findIn(BTree btree) throws CoreException {
btree.visit(this);
return record;
}
}
public PDOMBinding(PDOMDatabase pdom, IASTName name, IBinding binding) throws CoreException {
try {
public PDOMBinding(PDOMDatabase pdom, IASTName name, int language, int type) throws CoreException {
this.pdom = pdom;
char[] namechars = name.toCharArray();
BTree index = pdom.getBindingIndex();
record = new FindVisitor(pdom.getDB(), namechars).findIn(index);
record = new FindVisitor(pdom.getDB(), namechars, language, type).findIn(index);
if (record == 0) {
Database db = pdom.getDB();
record = db.malloc(getRecordSize());
db.putChar(record + LANGUAGE_OFFSET, (char)language);
db.putChar(record + TYPE_OFFSET, (char)type);
int stringRecord = db.malloc((namechars.length + 1) * Database.CHAR_SIZE);
db.putChars(stringRecord, namechars);
db.putInt(record + STRING_REC_OFFSET, stringRecord);
pdom.getBindingIndex().insert(record, new Comparator(db));
}
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR,
CCorePlugin.PLUGIN_ID, 0, "Failed to allocate binding", e));
}
}
public PDOMBinding(PDOMDatabase pdom, int bindingRecord) {
@ -136,7 +136,15 @@ public class PDOMBinding implements IBinding {
return record;
}
public void addDeclaration(PDOMName name) throws IOException {
public int getLanguage() throws CoreException {
return pdom.getDB().getChar(record + LANGUAGE_OFFSET);
}
public int getBindingType() throws CoreException {
return pdom.getDB().getChar(record + TYPE_OFFSET);
}
public void addDeclaration(PDOMName name) throws CoreException {
PDOMName firstDeclaration = getFirstDeclaration();
if (firstDeclaration != null) {
firstDeclaration.setPrevInBinding(name);
@ -145,9 +153,14 @@ public class PDOMBinding implements IBinding {
pdom.getDB().putInt(record + FIRST_DECL_OFFSET, name.getRecord());
}
public PDOMName getFirstDeclaration() throws IOException {
public PDOMName getFirstDeclaration() throws CoreException {
try {
int firstDeclRec = pdom.getDB().getInt(record + FIRST_DECL_OFFSET);
return firstDeclRec != 0 ? new PDOMName(pdom, firstDeclRec) : null;
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR,
CCorePlugin.PLUGIN_ID, 0, "PDOM", e));
}
}
public String getName() {
@ -155,10 +168,10 @@ public class PDOMBinding implements IBinding {
Database db = pdom.getDB();
int stringRecord = db.getInt(record + STRING_REC_OFFSET);
return db.getString(stringRecord);
} catch (IOException e) {
} catch (CoreException e) {
CCorePlugin.log(e);
return "";
}
return "";
}
public char[] getNameCharArray() {
@ -166,10 +179,10 @@ public class PDOMBinding implements IBinding {
Database db = pdom.getDB();
int stringRecord = db.getInt(record + STRING_REC_OFFSET);
return db.getChars(stringRecord);
} catch (IOException e) {
} catch (CoreException e) {
CCorePlugin.log(e);
return new char[0];
}
return new char[0];
}
public IScope getScope() throws DOMException {
@ -177,9 +190,9 @@ public class PDOMBinding implements IBinding {
return null;
}
public static PDOMBinding find(PDOMDatabase pdom, char[] name) throws IOException {
public static PDOMBinding find(PDOMDatabase pdom, char[] name, int language, int type) throws CoreException {
BTree index = pdom.getBindingIndex();
int bindingRecord = new FindVisitor(pdom.getDB(), name).findIn(index);
int bindingRecord = new FindVisitor(pdom.getDB(), name, language, type).findIn(index);
if (bindingRecord != 0)
return new PDOMBinding(pdom, bindingRecord);
else

View file

@ -8,19 +8,14 @@
* Contributors:
* QNX - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.dom;
package org.eclipse.cdt.internal.core.pdom.dom;
import java.io.IOException;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
import org.eclipse.cdt.internal.core.pdom.db.BTree;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.cdt.internal.core.pdom.db.StringComparator;
import org.eclipse.cdt.internal.core.pdom.db.StringVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
/**
* Represents a file containing names.
@ -58,19 +53,19 @@ public class PDOMFile {
super(db, key);
}
public boolean visit(int record) throws IOException {
public boolean visit(int record) throws CoreException {
this.record = record;
return false;
}
public int findIn(BTree btree) throws IOException {
public int findIn(BTree btree) throws CoreException {
btree.visit(this);
return record;
}
}
public static PDOMFile insert(PDOMDatabase pdom, String filename) throws IOException {
public static PDOMFile insert(PDOMDatabase pdom, String filename) throws CoreException {
BTree index = pdom.getFileIndex();
PDOMFile pdomFile = find(pdom, filename);
if (pdomFile == null) {
@ -84,7 +79,7 @@ public class PDOMFile {
return pdomFile;
}
public static PDOMFile find(PDOMDatabase pdom, String filename) throws IOException {
public static PDOMFile find(PDOMDatabase pdom, String filename) throws CoreException {
BTree index = pdom.getFileIndex();
int record = new FindVisitor(pdom.getDB(), filename).findIn(index);
return (record != 0) ? new PDOMFile(pdom, record) : null;
@ -99,25 +94,20 @@ public class PDOMFile {
return record;
}
public String getFileName() throws IOException {
public String getFileName() throws CoreException {
return pdom.getDB().getString(record + FILE_NAME_OFFSET);
}
public int getFirstName() throws IOException {
public int getFirstName() throws CoreException {
return pdom.getDB().getInt(record + FIRST_NAME_OFFSET);
}
public void setFirstName(int firstName) throws IOException {
public void setFirstName(int firstName) throws CoreException {
pdom.getDB().putInt(record + FIRST_NAME_OFFSET, firstName);
}
public void free() throws CoreException {
try {
pdom.getDB().free(record);
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR,
CCorePlugin.PLUGIN_ID, 0, "Failed to free string", e));
}
}
}

View file

@ -8,7 +8,7 @@
* Contributors:
* QNX - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.dom;
package org.eclipse.cdt.internal.core.pdom.dom;
import java.io.IOException;
@ -25,8 +25,6 @@ import org.eclipse.cdt.core.dom.ast.IScope2;
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
import org.eclipse.cdt.internal.core.pdom.db.Database;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
/**
* @author Doug Schaefer
@ -49,7 +47,6 @@ public class PDOMName implements IASTName, IASTFileLocation {
private static final int RECORD_SIZE = 8 * Database.INT_SIZE;
public PDOMName(PDOMDatabase pdom, IASTName name, PDOMBinding binding) throws CoreException {
try {
this.pdom = pdom;
Database db = pdom.getDB();
record = db.malloc(RECORD_SIZE);
@ -75,10 +72,6 @@ public class PDOMName implements IASTName, IASTFileLocation {
db.putInt(record + NODE_OFFSET_OFFSET, fileloc.getNodeOffset());
db.putInt(record + NODE_LENGTH_OFFSET, fileloc.getNodeLength());
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR,
CCorePlugin.PLUGIN_ID, 0, "Failed to allocate name", e));
}
}
public PDOMName(PDOMDatabase pdom, int nameRecord) throws IOException {
@ -90,15 +83,15 @@ public class PDOMName implements IASTName, IASTFileLocation {
return record;
}
public void setBinding(PDOMBinding binding) throws IOException {
public void setBinding(PDOMBinding binding) throws CoreException {
pdom.getDB().putInt(record + BINDING_REC_OFFET, binding.getRecord());
}
public void setPrevInBinding(PDOMName prevName) throws IOException {
public void setPrevInBinding(PDOMName prevName) throws CoreException {
pdom.getDB().putInt(record + BINDING_PREV_OFFSET, prevName.getRecord());
}
public void setNextInBinding(PDOMName nextName) throws IOException {
public void setNextInBinding(PDOMName nextName) throws CoreException {
pdom.getDB().putInt(record + BINDING_NEXT_OFFSET, nextName.getRecord());
}
@ -106,7 +99,7 @@ public class PDOMName implements IASTName, IASTFileLocation {
try {
int bindingRecord = pdom.getDB().getInt(record + BINDING_REC_OFFET);
return new PDOMBinding(pdom, bindingRecord);
} catch (IOException e) {
} catch (CoreException e) {
CCorePlugin.log(e);
return null;
}
@ -132,7 +125,7 @@ public class PDOMName implements IASTName, IASTFileLocation {
return null;
return new PDOMBinding(pdom, bindingRec).getNameCharArray();
} catch (IOException e) {
} catch (CoreException e) {
CCorePlugin.log(e);
return null;
}
@ -198,7 +191,7 @@ public class PDOMName implements IASTName, IASTFileLocation {
public String getFileName() {
try {
return new PDOMFile(pdom, pdom.getDB().getInt(record + FILE_REC_OFFSET)).getFileName();
} catch (IOException e) {
} catch (CoreException e) {
CCorePlugin.log(e);
return null;
}
@ -215,7 +208,7 @@ public class PDOMName implements IASTName, IASTFileLocation {
public int getNodeLength() {
try {
return pdom.getDB().getInt(record + NODE_LENGTH_OFFSET);
} catch (IOException e) {
} catch (CoreException e) {
CCorePlugin.log(e);
return 0;
}
@ -224,7 +217,7 @@ public class PDOMName implements IASTName, IASTFileLocation {
public int getNodeOffset() {
try {
return pdom.getDB().getInt(record + NODE_OFFSET_OFFSET);
} catch (IOException e) {
} catch (CoreException e) {
CCorePlugin.log(e);
return 0;
}

View file

@ -8,7 +8,7 @@
* Contributors:
* QNX - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.dom;
package org.eclipse.cdt.internal.core.pdom.dom;
/**
* @author Doug Schaefer

View file

@ -8,7 +8,7 @@
* Contributors:
* QNX - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.dom;
package org.eclipse.cdt.internal.core.pdom.dom;
import org.eclipse.cdt.core.dom.IPDOM;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;

View file

@ -0,0 +1,86 @@
/*******************************************************************************
* Copyright (c) 2005 QNX 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:
* QNX - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable;
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
import org.eclipse.core.runtime.CoreException;
/**
* @author Doug Schaefer
*
*/
public class PDOMCPPVariable extends PDOMBinding implements ICPPVariable {
/**
* @param pdom
* @param name
* @param binding
* @throws CoreException
*/
public PDOMCPPVariable(PDOMDatabase pdom, IASTName name, CPPVariable binding)
throws CoreException {
super(pdom, name, GPPLanguage.GPP_ID, GPPLanguage.CPPVARIABLE);
}
/**
* @param pdom
* @param bindingRecord
*/
public PDOMCPPVariable(PDOMDatabase pdom, int bindingRecord) {
super(pdom, bindingRecord);
}
public boolean isMutable() throws DOMException {
throw new PDOMNotImplementedError();
}
public IType getType() throws DOMException {
throw new PDOMNotImplementedError();
}
public boolean isAuto() throws DOMException {
throw new PDOMNotImplementedError();
}
public boolean isExtern() throws DOMException {
throw new PDOMNotImplementedError();
}
public boolean isRegister() throws DOMException {
throw new PDOMNotImplementedError();
}
public boolean isStatic() throws DOMException {
throw new PDOMNotImplementedError();
}
public String[] getQualifiedName() throws DOMException {
throw new PDOMNotImplementedError();
}
public char[][] getQualifiedNameCharArray() throws DOMException {
throw new PDOMNotImplementedError();
}
public boolean isGloballyQualified() throws DOMException {
throw new PDOMNotImplementedError();
}
}

View file

@ -43,7 +43,6 @@
<extension-point id="PathEntryContainerInitializer" name="%PathEntryContainerInitializer" schema="schema/PathEntryContainerInitializer.exsd"/>
<extension-point id="CodeFormatter" name="%CodeFormatter.name" schema="schema/CodeFormatter.exsd"/>
<extension-point id="CIndexer" name="C/C++ Indexer" schema="schema/CIndexer.exsd"/>
<extension-point id="PDOMProvider" name="%PDOMProviderName" schema="schema/PDOMProvider.exsd"/>
<extension-point id="language" name="%language.name" schema="schema/language.exsd"/>
<!-- =================================================================================== -->
<!-- Define the list of the Binary Parser provided by the CDT -->

View file

@ -1,119 +0,0 @@
<?xml version='1.0' encoding='UTF-8'?>
<!-- Schema file written by PDE -->
<schema targetNamespace="org.eclipse.cdt.core">
<annotation>
<appInfo>
<meta.schema plugin="org.eclipse.cdt.core" id="PDOMProvider" name="%PDOMProviderName"/>
</appInfo>
<documentation>
[Enter description of this extension point.]
</documentation>
</annotation>
<element name="extension">
<complexType>
<sequence>
<element ref="provider"/>
</sequence>
<attribute name="point" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute translatable="true"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<element name="provider">
<complexType>
<attribute name="id" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="name" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
<attribute name="class" type="string" use="required">
<annotation>
<documentation>
</documentation>
<appInfo>
<meta.attribute kind="java" basedOn="org.eclipse.cdt.core.dom.IPDOMProvider"/>
</appInfo>
</annotation>
</attribute>
</complexType>
</element>
<annotation>
<appInfo>
<meta.section type="since"/>
</appInfo>
<documentation>
[Enter the first release in which this extension point appears.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="examples"/>
</appInfo>
<documentation>
[Enter extension point usage example here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="apiInfo"/>
</appInfo>
<documentation>
[Enter API information here.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="implementation"/>
</appInfo>
<documentation>
[Enter information about supplied implementation of this extension point.]
</documentation>
</annotation>
<annotation>
<appInfo>
<meta.section type="copyright"/>
</appInfo>
<documentation>
</documentation>
</annotation>
</schema>

View file

@ -1,54 +0,0 @@
/*******************************************************************************
* Copyright (c) 2005 QNX 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:
* QNX - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.core.dom;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.IElementChangedListener;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
/**
* @author Doug Schaefer
*
* This is the interface to a PDOM Provider. The provider manages the
* relationships between PDOMs and projects and provides implementations of
* the PDOM interfaces.
*/
public interface IPDOMProvider {
public static final String ID
= CCorePlugin.PLUGIN_ID + ".PDOMProvider"; //$NON-NLS-1$
/**
* Get the PDOM for the given project. If the PDOM is unavailable for this
* project, null is returned.
*
* @param project
* @return the PDOM for the project
*/
public IPDOM getPDOM(IProject project);
/**
* Delete the PDOM for the given project.
*
* @param project
*/
public void deletePDOM(IProject project) throws CoreException;
/**
* Return the element changed listener that will handled change
* events that require the PDOM be updated.
*
* @return the element changed listener
*/
public IElementChangedListener getElementChangedListener();
}

View file

@ -13,15 +13,10 @@ package org.eclipse.cdt.core.dom;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.IElementChangedListener;
import org.eclipse.cdt.internal.core.dom.NullPDOMProvider;
import org.eclipse.cdt.internal.core.pdom.PDOMManager;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.osgi.service.prefs.BackingStoreException;
@ -32,36 +27,6 @@ import org.osgi.service.prefs.BackingStoreException;
*/
public class PDOM {
private static IPDOMProvider pdomProvider;
private static synchronized void initPDOMProvider() {
IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(IPDOMProvider.ID);
IExtension[] extensions = extensionPoint.getExtensions();
if (extensions.length > 0) {
// For now just take the first one
IConfigurationElement[] elements= extensions[0].getConfigurationElements();
if (elements.length > 0) {
// For now just take the first provider
try {
pdomProvider = (IPDOMProvider)elements[0].createExecutableExtension("class"); //$NON-NLS-1$
return;
} catch (CoreException e) {
}
}
}
// Couldn't find one
pdomProvider = new NullPDOMProvider();
}
private static IPDOMProvider getPDOMProvider() {
if (pdomProvider == null) {
initPDOMProvider();
}
return pdomProvider;
}
private static final String PDOM_NODE = CCorePlugin.PLUGIN_ID + ".pdom"; //$NON-NLS-1$
private static final String ENABLED_KEY = "enabled"; //$NON-NLS-1$
@ -108,7 +73,7 @@ public class PDOM {
public static void deletePDOM(IProject project) throws CoreException {
if (isEnabled(project))
getPDOMProvider().getPDOM(project).delete();
PDOMManager.getInstance().getPDOM(project).delete();
}
/**
@ -116,7 +81,7 @@ public class PDOM {
* change events.
*/
public static void startup() {
IElementChangedListener listener = getPDOMProvider().getElementChangedListener();
IElementChangedListener listener = PDOMManager.getInstance();
if (listener != null) {
CoreModel.getDefault().addElementChangedListener(listener);
}