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:
parent
56254fd6f3
commit
a39da76e9e
28 changed files with 357 additions and 624 deletions
|
@ -1,7 +1,6 @@
|
||||||
package org.eclipse.cdt.internal.pdom.tests;
|
package org.eclipse.cdt.internal.pdom.tests;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
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.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.StringComparator;
|
import org.eclipse.cdt.internal.core.pdom.db.StringComparator;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.StringVisitor;
|
import org.eclipse.cdt.internal.core.pdom.db.StringVisitor;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
public class DBTest extends TestCase {
|
public class DBTest extends TestCase {
|
||||||
|
@ -79,12 +79,12 @@ public class DBTest extends TestCase {
|
||||||
super(db, Database.INT_SIZE, key);
|
super(db, Database.INT_SIZE, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean visit(int record) throws IOException {
|
public boolean visit(int record) throws CoreException {
|
||||||
this.record = record;
|
this.record = record;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int findIn(BTree btree) throws IOException {
|
public int findIn(BTree btree) throws CoreException {
|
||||||
btree.visit(this);
|
btree.visit(this);
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,6 +56,7 @@ Export-Package: .,
|
||||||
org.eclipse.cdt.internal.core.parser.util,
|
org.eclipse.cdt.internal.core.parser.util,
|
||||||
org.eclipse.cdt.internal.core.pdom,
|
org.eclipse.cdt.internal.core.pdom,
|
||||||
org.eclipse.cdt.internal.core.pdom.db,
|
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,
|
||||||
org.eclipse.cdt.internal.core.search.indexing,
|
org.eclipse.cdt.internal.core.search.indexing,
|
||||||
org.eclipse.cdt.internal.core.search.matching,
|
org.eclipse.cdt.internal.core.search.matching,
|
||||||
|
@ -64,7 +65,6 @@ Export-Package: .,
|
||||||
org.eclipse.cdt.internal.core.util,
|
org.eclipse.cdt.internal.core.util,
|
||||||
org.eclipse.cdt.internal.errorparsers,
|
org.eclipse.cdt.internal.errorparsers,
|
||||||
org.eclipse.cdt.internal.formatter,
|
org.eclipse.cdt.internal.formatter,
|
||||||
org.eclipse.cdt.internal.pdom.dom,
|
|
||||||
org.eclipse.cdt.utils,
|
org.eclipse.cdt.utils,
|
||||||
org.eclipse.cdt.utils.coff,
|
org.eclipse.cdt.utils.coff,
|
||||||
org.eclipse.cdt.utils.coff.parser,
|
org.eclipse.cdt.utils.coff.parser,
|
||||||
|
|
|
@ -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.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
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;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,14 +92,14 @@ public interface ILanguage {
|
||||||
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, IASTName name) throws CoreException;
|
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, IASTName name) throws CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a new PDOM Binding that has the given language specific type.
|
* Creates a language specific binding given the generic binding extracted
|
||||||
* The type id is extracted from the PDOM Database.
|
* from the PDOM database.
|
||||||
*
|
*
|
||||||
* @param pdom
|
* @param pdom
|
||||||
* @param bindingType
|
* @param binding
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public PDOMBinding createPDOMBinding(PDOMDatabase pdom, int bindingType);
|
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, PDOMBinding binding) throws CoreException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,9 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
import org.eclipse.cdt.core.dom.ILanguage;
|
import org.eclipse.cdt.core.dom.ILanguage;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
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.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
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.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
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.GCCScannerExtensionConfiguration;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
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.cdt.internal.pdom.dom.PDOMName;
|
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -94,7 +88,7 @@ public class GCCLanguage implements ILanguage {
|
||||||
|
|
||||||
if ((style & AST_USE_INDEX) != 0)
|
if ((style & AST_USE_INDEX) != 0)
|
||||||
ast.setIndex(tu.getCProject().getIndex());
|
ast.setIndex(tu.getCProject().getIndex());
|
||||||
|
|
||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,38 +97,15 @@ public class GCCLanguage implements ILanguage {
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, IASTName name) throws CoreException {
|
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, IASTName name) throws CoreException {
|
||||||
try {
|
IBinding binding = name.resolveBinding();
|
||||||
IBinding binding = name.resolveBinding();
|
if (binding == null)
|
||||||
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;
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, PDOMBinding binding) throws CoreException {
|
||||||
|
return binding;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,9 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
import org.eclipse.cdt.core.dom.ILanguage;
|
import org.eclipse.cdt.core.dom.ILanguage;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
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.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
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.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
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.core.parser.ScannerInfo;
|
||||||
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
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.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.GNUCPPSourceParser;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPParserExtensionConfiguration;
|
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.DOMScanner;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfiguration;
|
||||||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
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.cdt.internal.pdom.dom.PDOMName;
|
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPVariable;
|
||||||
import org.eclipse.core.resources.IFile;
|
import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -100,40 +96,28 @@ public class GPPLanguage implements ILanguage {
|
||||||
int offset) {
|
int offset) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Binding types
|
||||||
|
public static final int CPPVARIABLE = 1;
|
||||||
|
|
||||||
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, IASTName name) throws CoreException {
|
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, IASTName name) throws CoreException {
|
||||||
try {
|
IBinding binding = name.resolveBinding();
|
||||||
IBinding binding = name.resolveBinding();
|
if (binding == null)
|
||||||
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;
|
return null;
|
||||||
} catch (DOMException e) {
|
|
||||||
throw new CoreException(new Status(IStatus.ERROR,
|
if (binding instanceof CPPVariable)
|
||||||
CCorePlugin.PLUGIN_ID, 0, "DOM Exception", e));
|
return new PDOMCPPVariable(pdom, name, (CPPVariable)binding);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public PDOMBinding createPDOMBinding(PDOMDatabase pdom, int bindingType) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, PDOMBinding binding) throws CoreException {
|
||||||
|
switch (binding.getBindingType()) {
|
||||||
|
case CPPVARIABLE:
|
||||||
|
return new PDOMCPPVariable(pdom, binding.getRecord());
|
||||||
|
}
|
||||||
|
|
||||||
|
return binding;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,7 +22,7 @@ import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.ICodeReaderCache;
|
import org.eclipse.cdt.core.parser.ICodeReaderCache;
|
||||||
import org.eclipse.cdt.core.parser.ParserUtil;
|
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.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
|
@ -69,7 +69,7 @@ public class PDOMCodeReaderFactory implements ICodeReaderFactory {
|
||||||
}
|
}
|
||||||
if (PDOMFile.find(pdom, path) != null)
|
if (PDOMFile.find(pdom, path) != null)
|
||||||
return null;
|
return null;
|
||||||
} catch (IOException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(new CoreException(new Status(IStatus.ERROR,
|
CCorePlugin.log(new CoreException(new Status(IStatus.ERROR,
|
||||||
CCorePlugin.PLUGIN_ID, 0, "PDOM Exception", e)));
|
CCorePlugin.PLUGIN_ID, 0, "PDOM Exception", e)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,32 +10,24 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom;
|
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.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
import org.eclipse.cdt.core.dom.ILanguage;
|
import org.eclipse.cdt.core.dom.ILanguage;
|
||||||
import org.eclipse.cdt.core.dom.IPDOM;
|
import org.eclipse.cdt.core.dom.IPDOM;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
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.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
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.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
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.Database;
|
||||||
import org.eclipse.cdt.internal.pdom.dom.PDOMBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
import org.eclipse.cdt.internal.pdom.dom.PDOMName;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.QualifiedName;
|
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 {
|
public class PDOMDatabase implements IPDOM {
|
||||||
|
|
||||||
private final IPath dbPath;
|
private final IPath dbPath;
|
||||||
private final Database db;
|
private Database db;
|
||||||
|
|
||||||
private static final int VERSION = 0;
|
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;
|
public static final int FILE_INDEX = Database.DATA_AREA + 1 * Database.INT_SIZE;
|
||||||
private BTree fileIndex;
|
private BTree fileIndex;
|
||||||
|
|
||||||
|
@ -71,34 +60,25 @@ public class PDOMDatabase implements IPDOM {
|
||||||
}
|
}
|
||||||
|
|
||||||
dbPath = CCorePlugin.getDefault().getStateLocation().append(dbName);
|
dbPath = CCorePlugin.getDefault().getStateLocation().append(dbName);
|
||||||
|
db = new Database(dbPath.toOSString(), VERSION);
|
||||||
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;
|
return db;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BTree getStringIndex() {
|
public BTree getFileIndex() throws CoreException {
|
||||||
if (stringIndex == null)
|
|
||||||
stringIndex = new BTree(db, STRING_INDEX);
|
|
||||||
return stringIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BTree getFileIndex() {
|
|
||||||
if (fileIndex == null)
|
if (fileIndex == null)
|
||||||
fileIndex = new BTree(db, FILE_INDEX);
|
fileIndex = new BTree(getDB(), FILE_INDEX);
|
||||||
return fileIndex;
|
return fileIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BTree getBindingIndex() {
|
public BTree getBindingIndex() throws CoreException {
|
||||||
if (bindingIndex == null)
|
if (bindingIndex == null)
|
||||||
bindingIndex = new BTree(db, BINDING_INDEX);
|
bindingIndex = new BTree(getDB(), BINDING_INDEX);
|
||||||
return bindingIndex;
|
return bindingIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,8 +99,11 @@ public class PDOMDatabase implements IPDOM {
|
||||||
|
|
||||||
public int visit(IASTName name) {
|
public int visit(IASTName name) {
|
||||||
try {
|
try {
|
||||||
if (name.toCharArray().length > 0)
|
if (name.toCharArray().length > 0) {
|
||||||
language.getPDOMBinding(PDOMDatabase.this, name);
|
PDOMBinding binding = language.getPDOMBinding(PDOMDatabase.this, name);
|
||||||
|
if (binding != null)
|
||||||
|
new PDOMName(PDOMDatabase.this, name, binding);
|
||||||
|
}
|
||||||
return PROCESS_CONTINUE;
|
return PROCESS_CONTINUE;
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
@ -135,7 +118,11 @@ public class PDOMDatabase implements IPDOM {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void delete() throws CoreException {
|
public void delete() throws CoreException {
|
||||||
// TODO Auto-generated method stub
|
db = null;
|
||||||
|
bindingIndex = null;
|
||||||
|
fileIndex = null;
|
||||||
|
System.gc();
|
||||||
|
dbPath.toFile().delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICodeReaderFactory getCodeReaderFactory() {
|
public ICodeReaderFactory getCodeReaderFactory() {
|
||||||
|
@ -154,45 +141,18 @@ public class PDOMDatabase implements IPDOM {
|
||||||
return new IASTName[0];
|
return new IASTName[0];
|
||||||
return new IASTName[] { name };
|
return new IASTName[] { name };
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
return new IASTName[0];
|
return new IASTName[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding resolveBinding(IASTName name) {
|
public IBinding resolveBinding(IASTName name) {
|
||||||
try {
|
return null;
|
||||||
return new PDOMBinding(this, name, null);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding[] resolvePrefix(IASTName name) {
|
public IBinding[] resolvePrefix(IASTName name) {
|
||||||
// try {
|
return new IBinding[0];
|
||||||
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;
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.core.pdom;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOM;
|
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.ElementChangedEvent;
|
||||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
import org.eclipse.cdt.core.model.IElementChangedListener;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
|
@ -28,7 +27,7 @@ import org.eclipse.core.runtime.jobs.IJobChangeListener;
|
||||||
*
|
*
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*/
|
*/
|
||||||
public class PDOMManager implements IPDOMProvider, IElementChangedListener, IJobChangeListener {
|
public class PDOMManager implements IElementChangedListener, IJobChangeListener {
|
||||||
|
|
||||||
private static PDOMManager instance;
|
private static PDOMManager instance;
|
||||||
private PDOMUpdator currJob;
|
private PDOMUpdator currJob;
|
||||||
|
|
|
@ -15,10 +15,8 @@ import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
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.IPDOM;
|
||||||
import org.eclipse.cdt.core.dom.PDOM;
|
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.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.ICElementDelta;
|
import org.eclipse.cdt.core.model.ICElementDelta;
|
||||||
|
|
|
@ -3,10 +3,9 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.pdom;
|
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.Chunk;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author dschaefer
|
* @author dschaefer
|
||||||
|
@ -14,7 +13,7 @@ import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
*/
|
*/
|
||||||
public class PDOMUtils {
|
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 chunk1 = db.getChunk(record1);
|
||||||
Chunk chunk2 = db.getChunk(record2);
|
Chunk chunk2 = db.getChunk(record2);
|
||||||
|
|
||||||
|
@ -43,7 +42,7 @@ public class PDOMUtils {
|
||||||
return 1;
|
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);
|
Chunk chunk1 = db.getChunk(record1);
|
||||||
|
|
||||||
int i1 = record1;
|
int i1 = record1;
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.db;
|
package org.eclipse.cdt.internal.core.pdom.db;
|
||||||
|
|
||||||
import java.io.IOException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -37,7 +37,7 @@ public class BTree {
|
||||||
this.rootPointer = rootPointer;
|
this.rootPointer = rootPointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getRoot() throws IOException {
|
protected int getRoot() throws CoreException {
|
||||||
return db.getInt(rootPointer);
|
return db.getInt(rootPointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ public class BTree {
|
||||||
* @param offset of the record
|
* @param offset of the record
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int insert(int record, IBTreeComparator comparator) throws IOException {
|
public int insert(int record, IBTreeComparator comparator) throws CoreException {
|
||||||
int root = getRoot();
|
int root = getRoot();
|
||||||
|
|
||||||
// is this our first time in
|
// is this our first time in
|
||||||
|
@ -77,7 +77,7 @@ public class BTree {
|
||||||
return insert(null, 0, 0, root, record, comparator);
|
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);
|
Chunk chunk = db.getChunk(node);
|
||||||
|
|
||||||
// if this node is full (last record isn't null), split it
|
// 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
|
// create the node and save it as root
|
||||||
int root = allocateNode();
|
int root = allocateNode();
|
||||||
db.putInt(rootPointer, root);
|
db.putInt(rootPointer, root);
|
||||||
|
@ -172,7 +172,7 @@ public class BTree {
|
||||||
putRecord(db.getChunk(root), root, 0, record);
|
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);
|
return db.malloc((2 * NUM_RECORDS - 1) * Database.INT_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,11 +191,11 @@ public class BTree {
|
||||||
*
|
*
|
||||||
* @param visitor
|
* @param visitor
|
||||||
*/
|
*/
|
||||||
public void visit(IBTreeVisitor visitor) throws IOException {
|
public void visit(IBTreeVisitor visitor) throws CoreException {
|
||||||
visit(db.getInt(rootPointer), visitor, false);
|
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
|
// if found is false, we are still in search mode
|
||||||
// once found is true visit everything
|
// once found is true visit everything
|
||||||
// return false when ready to quit
|
// return false when ready to quit
|
||||||
|
@ -246,81 +246,4 @@ public class BTree {
|
||||||
return visit(getChild(chunk, node, i), visitor, found);
|
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,8 @@ import java.io.RandomAccessFile;
|
||||||
import java.nio.MappedByteBuffer;
|
import java.nio.MappedByteBuffer;
|
||||||
import java.nio.channels.FileChannel.MapMode;
|
import java.nio.channels.FileChannel.MapMode;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*
|
*
|
||||||
|
@ -29,9 +31,13 @@ public class Chunk {
|
||||||
private Chunk prevChunk;
|
private Chunk prevChunk;
|
||||||
private Chunk nextChunk;
|
private Chunk nextChunk;
|
||||||
|
|
||||||
Chunk(RandomAccessFile file, int offset) throws IOException {
|
Chunk(RandomAccessFile file, int offset) throws CoreException {
|
||||||
index = offset / Database.CHUNK_SIZE;
|
try {
|
||||||
buffer = file.getChannel().map(MapMode.READ_WRITE, offset, Database.CHUNK_SIZE);
|
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) {
|
public void putInt(int offset, int value) {
|
||||||
|
|
|
@ -8,30 +8,26 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.IPDOM;
|
package org.eclipse.cdt.internal.core.pdom.db;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMProvider;
|
|
||||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
import java.io.IOException;
|
||||||
import org.eclipse.core.resources.IProject;
|
|
||||||
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class NullPDOMProvider implements IPDOMProvider {
|
public class DBStatus extends Status {
|
||||||
|
|
||||||
public IPDOM getPDOM(IProject project) {
|
/**
|
||||||
// by default return null.
|
* @param exception
|
||||||
return null;
|
*/
|
||||||
|
public DBStatus(IOException exception) {
|
||||||
|
super(IStatus.ERROR, CCorePlugin.PLUGIN_ID, 0, "IOException", exception);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IElementChangedListener getElementChangedListener() {
|
|
||||||
// here too
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void deletePDOM(IProject project) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
|
@ -13,6 +13,8 @@ package org.eclipse.cdt.internal.core.pdom.db;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
|
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
*
|
*
|
||||||
|
@ -37,33 +39,41 @@ public class Database {
|
||||||
public static final int NEXT_OFFSET = INT_SIZE * 2;
|
public static final int NEXT_OFFSET = INT_SIZE * 2;
|
||||||
public static final int DATA_AREA = CHUNK_SIZE / MIN_SIZE * INT_SIZE + INT_SIZE;
|
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 {
|
||||||
file = new RandomAccessFile(filename, "rw"); //$NON-NLS-1$
|
try {
|
||||||
|
file = new RandomAccessFile(filename, "rw"); //$NON-NLS-1$
|
||||||
// Allocate chunk table, make sure we have at least one
|
|
||||||
long nChunks = file.length() / CHUNK_SIZE;
|
// Allocate chunk table, make sure we have at least one
|
||||||
if (nChunks == 0) {
|
long nChunks = file.length() / CHUNK_SIZE;
|
||||||
create();
|
if (nChunks == 0) {
|
||||||
++nChunks;
|
create();
|
||||||
}
|
++nChunks;
|
||||||
|
}
|
||||||
toc = new Chunk[(int)nChunks];
|
|
||||||
|
toc = new Chunk[(int)nChunks];
|
||||||
// Load in the magic chunk zero
|
|
||||||
toc[0] = new Chunk(file, 0);
|
// Load in the magic chunk zero
|
||||||
int oldversion = toc[0].getInt(0);
|
toc[0] = new Chunk(file, 0);
|
||||||
if (oldversion != version) {
|
int oldversion = toc[0].getInt(0);
|
||||||
// Conversion?
|
if (oldversion != version) {
|
||||||
toc[0].putInt(0, version);
|
// 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.
|
* Create the database, including chunk zero and the b-trees.
|
||||||
*/
|
*/
|
||||||
private void create() throws IOException {
|
private void create() throws CoreException {
|
||||||
file.seek(0);
|
try {
|
||||||
file.write(new byte[CHUNK_SIZE]); // the header chunk
|
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
|
* @param offset
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Chunk getChunk(int offset) throws IOException {
|
public Chunk getChunk(int offset) throws CoreException {
|
||||||
int index = offset / CHUNK_SIZE;
|
int index = offset / CHUNK_SIZE;
|
||||||
Chunk chunk = toc[index];
|
Chunk chunk = toc[index];
|
||||||
if (chunk == null) {
|
if (chunk == null) {
|
||||||
|
@ -107,7 +117,7 @@ public class Database {
|
||||||
* @param size
|
* @param size
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int malloc(int size) throws IOException {
|
public int malloc(int size) throws CoreException {
|
||||||
// Which block size
|
// Which block size
|
||||||
int freeblock = 0;
|
int freeblock = 0;
|
||||||
int blocksize;
|
int blocksize;
|
||||||
|
@ -146,16 +156,20 @@ public class Database {
|
||||||
return freeblock + INT_SIZE;
|
return freeblock + INT_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int createChunk() throws IOException {
|
private int createChunk() throws CoreException {
|
||||||
int offset = (int)file.length();
|
try {
|
||||||
file.seek(offset);
|
int offset = (int)file.length();
|
||||||
file.write(new byte[CHUNK_SIZE]);
|
file.seek(offset);
|
||||||
Chunk[] oldtoc = toc;
|
file.write(new byte[CHUNK_SIZE]);
|
||||||
int i = oldtoc.length;
|
Chunk[] oldtoc = toc;
|
||||||
toc = new Chunk[i + 1];
|
int i = oldtoc.length;
|
||||||
System.arraycopy(oldtoc, 0, toc, 0, i);
|
toc = new Chunk[i + 1];
|
||||||
toc[i] = new Chunk(file, offset);
|
System.arraycopy(oldtoc, 0, toc, 0, i);
|
||||||
return i;
|
toc[i] = new Chunk(file, offset);
|
||||||
|
return i;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new CoreException(new DBStatus(e));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getFirstBlock(int blocksize) {
|
private int getFirstBlock(int blocksize) {
|
||||||
|
@ -166,7 +180,7 @@ public class Database {
|
||||||
toc[0].putInt((blocksize / MIN_SIZE) * INT_SIZE, block);
|
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 prevblock = chunk.getInt(block + PREV_OFFSET);
|
||||||
int nextblock = chunk.getInt(block + NEXT_OFFSET);
|
int nextblock = chunk.getInt(block + NEXT_OFFSET);
|
||||||
if (prevblock != 0)
|
if (prevblock != 0)
|
||||||
|
@ -178,7 +192,7 @@ public class Database {
|
||||||
putInt(nextblock + PREV_OFFSET, prevblock);
|
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
|
// Mark our size
|
||||||
chunk.putInt(block, blocksize);
|
chunk.putInt(block, blocksize);
|
||||||
|
|
||||||
|
@ -196,7 +210,7 @@ public class Database {
|
||||||
*
|
*
|
||||||
* @param offset
|
* @param offset
|
||||||
*/
|
*/
|
||||||
public void free(int offset) throws IOException {
|
public void free(int offset) throws CoreException {
|
||||||
// TODO - look for opportunities to merge blocks
|
// TODO - look for opportunities to merge blocks
|
||||||
int block = offset - INT_SIZE;
|
int block = offset - INT_SIZE;
|
||||||
Chunk chunk = getChunk(block);
|
Chunk chunk = getChunk(block);
|
||||||
|
@ -204,32 +218,42 @@ public class Database {
|
||||||
addBlock(chunk, blocksize, block);
|
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 chunk = getChunk(offset);
|
||||||
chunk.putInt(offset, value);
|
chunk.putInt(offset, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInt(int offset) throws IOException {
|
public int getInt(int offset) throws CoreException {
|
||||||
Chunk chunk = getChunk(offset);
|
Chunk chunk = getChunk(offset);
|
||||||
return chunk.getInt(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 chunk = getChunk(offset);
|
||||||
chunk.putChars(offset, value);
|
chunk.putChars(offset, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] getChars(int offset) throws IOException {
|
public char[] getChars(int offset) throws CoreException {
|
||||||
Chunk chunk = getChunk(offset);
|
Chunk chunk = getChunk(offset);
|
||||||
return chunk.getChars(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 chunk = getChunk(offset);
|
||||||
chunk.putString(offset, value);
|
chunk.putString(offset, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getString(int offset) throws IOException {
|
public String getString(int offset) throws CoreException {
|
||||||
Chunk chunk = getChunk(offset);
|
Chunk chunk = getChunk(offset);
|
||||||
return chunk.getString(offset);
|
return chunk.getString(offset);
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.db;
|
package org.eclipse.cdt.internal.core.pdom.db;
|
||||||
|
|
||||||
import java.io.IOException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -26,6 +26,6 @@ public interface IBTreeComparator {
|
||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public abstract int compare(int record1, int record2) throws IOException;
|
public abstract int compare(int record1, int record2) throws CoreException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.db;
|
package org.eclipse.cdt.internal.core.pdom.db;
|
||||||
|
|
||||||
import java.io.IOException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -31,7 +31,7 @@ public interface IBTreeVisitor {
|
||||||
* @return -1 if record < key, 0 if record == key, 1 if record > key
|
* @return -1 if record < key, 0 if record == key, 1 if record > key
|
||||||
* @throws IOException
|
* @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.
|
* Visit a given record and return whether to continue or not.
|
||||||
|
@ -40,6 +40,6 @@ public interface IBTreeVisitor {
|
||||||
* @return
|
* @return
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
public abstract boolean visit(int record) throws IOException;
|
public abstract boolean visit(int record) throws CoreException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.db;
|
package org.eclipse.cdt.internal.core.pdom.db;
|
||||||
|
|
||||||
import java.io.IOException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -26,7 +26,7 @@ public class StringComparator implements IBTreeComparator {
|
||||||
this.offset = offset;
|
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 chunk1 = db.getChunk(record1);
|
||||||
Chunk chunk2 = db.getChunk(record2);
|
Chunk chunk2 = db.getChunk(record2);
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.pdom.db;
|
package org.eclipse.cdt.internal.core.pdom.db;
|
||||||
|
|
||||||
import java.io.IOException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -28,7 +28,7 @@ public abstract class StringVisitor implements IBTreeVisitor {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compare(int record) throws IOException {
|
public int compare(int record) throws CoreException {
|
||||||
Chunk chunk = db.getChunk(record);
|
Chunk chunk = db.getChunk(record);
|
||||||
int i1 = record + offset;
|
int i1 = record + offset;
|
||||||
int i2 = 0;
|
int i2 = 0;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* 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 java.io.IOException;
|
||||||
|
|
||||||
|
@ -55,9 +55,10 @@ public class PDOMBinding implements IBinding {
|
||||||
this.db = db;
|
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 string1 = db.getInt(record1 + STRING_REC_OFFSET);
|
||||||
int string2 = db.getInt(record2 + STRING_REC_OFFSET);
|
int string2 = db.getInt(record2 + STRING_REC_OFFSET);
|
||||||
|
// Need to deal with language and type
|
||||||
|
|
||||||
return PDOMUtils.stringCompare(db, string1, string2);
|
return PDOMUtils.stringCompare(db, string1, string2);
|
||||||
}
|
}
|
||||||
|
@ -69,13 +70,14 @@ public class PDOMBinding implements IBinding {
|
||||||
private Database db;
|
private Database db;
|
||||||
private char[] key;
|
private char[] key;
|
||||||
|
|
||||||
public Visitor(Database db, char[] key) {
|
public Visitor(Database db, char[] key, int language, int type) {
|
||||||
this.db = db;
|
this.db = db;
|
||||||
this.key = key;
|
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);
|
int string1 = db.getInt(record1 + STRING_REC_OFFSET);
|
||||||
|
// Need to deal with language and type
|
||||||
|
|
||||||
return PDOMUtils.stringCompare(db, string1, key);
|
return PDOMUtils.stringCompare(db, string1, key);
|
||||||
}
|
}
|
||||||
|
@ -86,44 +88,42 @@ public class PDOMBinding implements IBinding {
|
||||||
|
|
||||||
private int record;
|
private int record;
|
||||||
|
|
||||||
public FindVisitor(Database db, char[] stringKey) {
|
public FindVisitor(Database db, char[] stringKey, int language, int type) {
|
||||||
super(db, stringKey);
|
super(db, stringKey, language, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean visit(int record) throws IOException {
|
public boolean visit(int record) throws CoreException {
|
||||||
this.record = record;
|
this.record = record;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int findIn(BTree btree) throws IOException {
|
public int findIn(BTree btree) throws CoreException {
|
||||||
btree.visit(this);
|
btree.visit(this);
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMBinding(PDOMDatabase pdom, IASTName name, IBinding binding) throws CoreException {
|
public PDOMBinding(PDOMDatabase pdom, IASTName name, int language, int type) throws CoreException {
|
||||||
try {
|
this.pdom = pdom;
|
||||||
this.pdom = pdom;
|
|
||||||
|
|
||||||
char[] namechars = name.toCharArray();
|
char[] namechars = name.toCharArray();
|
||||||
|
|
||||||
BTree index = pdom.getBindingIndex();
|
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) {
|
if (record == 0) {
|
||||||
Database db = pdom.getDB();
|
Database db = pdom.getDB();
|
||||||
record = db.malloc(getRecordSize());
|
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);
|
int stringRecord = db.malloc((namechars.length + 1) * Database.CHAR_SIZE);
|
||||||
db.putChars(stringRecord, namechars);
|
db.putChars(stringRecord, namechars);
|
||||||
|
|
||||||
db.putInt(record + STRING_REC_OFFSET, stringRecord);
|
db.putInt(record + STRING_REC_OFFSET, stringRecord);
|
||||||
pdom.getBindingIndex().insert(record, new Comparator(db));
|
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,15 @@ public class PDOMBinding implements IBinding {
|
||||||
return record;
|
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();
|
PDOMName firstDeclaration = getFirstDeclaration();
|
||||||
if (firstDeclaration != null) {
|
if (firstDeclaration != null) {
|
||||||
firstDeclaration.setPrevInBinding(name);
|
firstDeclaration.setPrevInBinding(name);
|
||||||
|
@ -145,9 +153,14 @@ public class PDOMBinding implements IBinding {
|
||||||
pdom.getDB().putInt(record + FIRST_DECL_OFFSET, name.getRecord());
|
pdom.getDB().putInt(record + FIRST_DECL_OFFSET, name.getRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMName getFirstDeclaration() throws IOException {
|
public PDOMName getFirstDeclaration() throws CoreException {
|
||||||
int firstDeclRec = pdom.getDB().getInt(record + FIRST_DECL_OFFSET);
|
try {
|
||||||
return firstDeclRec != 0 ? new PDOMName(pdom, firstDeclRec) : null;
|
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() {
|
public String getName() {
|
||||||
|
@ -155,10 +168,10 @@ public class PDOMBinding implements IBinding {
|
||||||
Database db = pdom.getDB();
|
Database db = pdom.getDB();
|
||||||
int stringRecord = db.getInt(record + STRING_REC_OFFSET);
|
int stringRecord = db.getInt(record + STRING_REC_OFFSET);
|
||||||
return db.getString(stringRecord);
|
return db.getString(stringRecord);
|
||||||
} catch (IOException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return "";
|
|
||||||
}
|
}
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public char[] getNameCharArray() {
|
public char[] getNameCharArray() {
|
||||||
|
@ -166,10 +179,10 @@ public class PDOMBinding implements IBinding {
|
||||||
Database db = pdom.getDB();
|
Database db = pdom.getDB();
|
||||||
int stringRecord = db.getInt(record + STRING_REC_OFFSET);
|
int stringRecord = db.getInt(record + STRING_REC_OFFSET);
|
||||||
return db.getChars(stringRecord);
|
return db.getChars(stringRecord);
|
||||||
} catch (IOException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return new char[0];
|
|
||||||
}
|
}
|
||||||
|
return new char[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public IScope getScope() throws DOMException {
|
public IScope getScope() throws DOMException {
|
||||||
|
@ -177,9 +190,9 @@ public class PDOMBinding implements IBinding {
|
||||||
return null;
|
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();
|
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)
|
if (bindingRecord != 0)
|
||||||
return new PDOMBinding(pdom, bindingRecord);
|
return new PDOMBinding(pdom, bindingRecord);
|
||||||
else
|
else
|
|
@ -8,19 +8,14 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* 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.PDOMDatabase;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
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.Database;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.StringComparator;
|
import org.eclipse.cdt.internal.core.pdom.db.StringComparator;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.StringVisitor;
|
import org.eclipse.cdt.internal.core.pdom.db.StringVisitor;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a file containing names.
|
* Represents a file containing names.
|
||||||
|
@ -58,19 +53,19 @@ public class PDOMFile {
|
||||||
super(db, key);
|
super(db, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean visit(int record) throws IOException {
|
public boolean visit(int record) throws CoreException {
|
||||||
this.record = record;
|
this.record = record;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int findIn(BTree btree) throws IOException {
|
public int findIn(BTree btree) throws CoreException {
|
||||||
btree.visit(this);
|
btree.visit(this);
|
||||||
return record;
|
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();
|
BTree index = pdom.getFileIndex();
|
||||||
PDOMFile pdomFile = find(pdom, filename);
|
PDOMFile pdomFile = find(pdom, filename);
|
||||||
if (pdomFile == null) {
|
if (pdomFile == null) {
|
||||||
|
@ -84,7 +79,7 @@ public class PDOMFile {
|
||||||
return 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();
|
BTree index = pdom.getFileIndex();
|
||||||
int record = new FindVisitor(pdom.getDB(), filename).findIn(index);
|
int record = new FindVisitor(pdom.getDB(), filename).findIn(index);
|
||||||
return (record != 0) ? new PDOMFile(pdom, record) : null;
|
return (record != 0) ? new PDOMFile(pdom, record) : null;
|
||||||
|
@ -99,25 +94,20 @@ public class PDOMFile {
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getFileName() throws IOException {
|
public String getFileName() throws CoreException {
|
||||||
return pdom.getDB().getString(record + FILE_NAME_OFFSET);
|
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);
|
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);
|
pdom.getDB().putInt(record + FIRST_NAME_OFFSET, firstName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void free() throws CoreException {
|
public void free() throws CoreException {
|
||||||
try {
|
pdom.getDB().free(record);
|
||||||
pdom.getDB().free(record);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new CoreException(new Status(IStatus.ERROR,
|
|
||||||
CCorePlugin.PLUGIN_ID, 0, "Failed to free string", e));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* 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 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.PDOMDatabase;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
|
||||||
import org.eclipse.core.runtime.Status;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
||||||
|
@ -49,36 +47,31 @@ public class PDOMName implements IASTName, IASTFileLocation {
|
||||||
private static final int RECORD_SIZE = 8 * Database.INT_SIZE;
|
private static final int RECORD_SIZE = 8 * Database.INT_SIZE;
|
||||||
|
|
||||||
public PDOMName(PDOMDatabase pdom, IASTName name, PDOMBinding binding) throws CoreException {
|
public PDOMName(PDOMDatabase pdom, IASTName name, PDOMBinding binding) throws CoreException {
|
||||||
try {
|
this.pdom = pdom;
|
||||||
this.pdom = pdom;
|
Database db = pdom.getDB();
|
||||||
Database db = pdom.getDB();
|
record = db.malloc(RECORD_SIZE);
|
||||||
record = db.malloc(RECORD_SIZE);
|
|
||||||
|
|
||||||
// Hook us up to the binding
|
// Hook us up to the binding
|
||||||
if (binding != null) {
|
if (binding != null) {
|
||||||
db.putInt(record + BINDING_REC_OFFET, binding.getRecord());
|
db.putInt(record + BINDING_REC_OFFET, binding.getRecord());
|
||||||
if (name.isDeclaration())
|
if (name.isDeclaration())
|
||||||
binding.addDeclaration(this);
|
binding.addDeclaration(this);
|
||||||
}
|
|
||||||
|
|
||||||
// Hook us up the the liked name list from file
|
|
||||||
IASTFileLocation fileloc = name.getFileLocation();
|
|
||||||
String filename = fileloc.getFileName();
|
|
||||||
PDOMFile pdomFile = PDOMFile.insert(pdom, filename);
|
|
||||||
db.putInt(record + FILE_REC_OFFSET, pdomFile.getRecord());
|
|
||||||
int firstName = pdomFile.getFirstName();
|
|
||||||
if (firstName != 0) {
|
|
||||||
db.putInt(record + FILE_NEXT_OFFSET, firstName);
|
|
||||||
db.putInt(firstName + FILE_PREV_OFFSET, record);
|
|
||||||
}
|
|
||||||
pdomFile.setFirstName(record);
|
|
||||||
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Hook us up the the liked name list from file
|
||||||
|
IASTFileLocation fileloc = name.getFileLocation();
|
||||||
|
String filename = fileloc.getFileName();
|
||||||
|
PDOMFile pdomFile = PDOMFile.insert(pdom, filename);
|
||||||
|
db.putInt(record + FILE_REC_OFFSET, pdomFile.getRecord());
|
||||||
|
int firstName = pdomFile.getFirstName();
|
||||||
|
if (firstName != 0) {
|
||||||
|
db.putInt(record + FILE_NEXT_OFFSET, firstName);
|
||||||
|
db.putInt(firstName + FILE_PREV_OFFSET, record);
|
||||||
|
}
|
||||||
|
pdomFile.setFirstName(record);
|
||||||
|
|
||||||
|
db.putInt(record + NODE_OFFSET_OFFSET, fileloc.getNodeOffset());
|
||||||
|
db.putInt(record + NODE_LENGTH_OFFSET, fileloc.getNodeLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
public PDOMName(PDOMDatabase pdom, int nameRecord) throws IOException {
|
public PDOMName(PDOMDatabase pdom, int nameRecord) throws IOException {
|
||||||
|
@ -90,15 +83,15 @@ public class PDOMName implements IASTName, IASTFileLocation {
|
||||||
return record;
|
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());
|
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());
|
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());
|
pdom.getDB().putInt(record + BINDING_NEXT_OFFSET, nextName.getRecord());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,7 +99,7 @@ public class PDOMName implements IASTName, IASTFileLocation {
|
||||||
try {
|
try {
|
||||||
int bindingRecord = pdom.getDB().getInt(record + BINDING_REC_OFFET);
|
int bindingRecord = pdom.getDB().getInt(record + BINDING_REC_OFFET);
|
||||||
return new PDOMBinding(pdom, bindingRecord);
|
return new PDOMBinding(pdom, bindingRecord);
|
||||||
} catch (IOException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +125,7 @@ public class PDOMName implements IASTName, IASTFileLocation {
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new PDOMBinding(pdom, bindingRec).getNameCharArray();
|
return new PDOMBinding(pdom, bindingRec).getNameCharArray();
|
||||||
} catch (IOException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -198,7 +191,7 @@ public class PDOMName implements IASTName, IASTFileLocation {
|
||||||
public String getFileName() {
|
public String getFileName() {
|
||||||
try {
|
try {
|
||||||
return new PDOMFile(pdom, pdom.getDB().getInt(record + FILE_REC_OFFSET)).getFileName();
|
return new PDOMFile(pdom, pdom.getDB().getInt(record + FILE_REC_OFFSET)).getFileName();
|
||||||
} catch (IOException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -215,7 +208,7 @@ public class PDOMName implements IASTName, IASTFileLocation {
|
||||||
public int getNodeLength() {
|
public int getNodeLength() {
|
||||||
try {
|
try {
|
||||||
return pdom.getDB().getInt(record + NODE_LENGTH_OFFSET);
|
return pdom.getDB().getInt(record + NODE_LENGTH_OFFSET);
|
||||||
} catch (IOException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -224,7 +217,7 @@ public class PDOMName implements IASTName, IASTFileLocation {
|
||||||
public int getNodeOffset() {
|
public int getNodeOffset() {
|
||||||
try {
|
try {
|
||||||
return pdom.getDB().getInt(record + NODE_OFFSET_OFFSET);
|
return pdom.getDB().getInt(record + NODE_OFFSET_OFFSET);
|
||||||
} catch (IOException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* QNX - Initial API and implementation
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.pdom.dom;
|
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Doug Schaefer
|
* @author Doug Schaefer
|
|
@ -8,7 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX - Initial API and implementation
|
* 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.IPDOM;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
|
@ -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();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -43,7 +43,6 @@
|
||||||
<extension-point id="PathEntryContainerInitializer" name="%PathEntryContainerInitializer" schema="schema/PathEntryContainerInitializer.exsd"/>
|
<extension-point id="PathEntryContainerInitializer" name="%PathEntryContainerInitializer" schema="schema/PathEntryContainerInitializer.exsd"/>
|
||||||
<extension-point id="CodeFormatter" name="%CodeFormatter.name" schema="schema/CodeFormatter.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="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"/>
|
<extension-point id="language" name="%language.name" schema="schema/language.exsd"/>
|
||||||
<!-- =================================================================================== -->
|
<!-- =================================================================================== -->
|
||||||
<!-- Define the list of the Binary Parser provided by the CDT -->
|
<!-- Define the list of the Binary Parser provided by the CDT -->
|
||||||
|
|
|
@ -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>
|
|
|
@ -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();
|
|
||||||
|
|
||||||
}
|
|
|
@ -13,15 +13,10 @@ package org.eclipse.cdt.core.dom;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.IElementChangedListener;
|
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.cdt.internal.core.pdom.PDOMManager;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.ProjectScope;
|
import org.eclipse.core.resources.ProjectScope;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
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.IEclipsePreferences;
|
||||||
import org.eclipse.core.runtime.preferences.IScopeContext;
|
import org.eclipse.core.runtime.preferences.IScopeContext;
|
||||||
import org.osgi.service.prefs.BackingStoreException;
|
import org.osgi.service.prefs.BackingStoreException;
|
||||||
|
@ -32,36 +27,6 @@ import org.osgi.service.prefs.BackingStoreException;
|
||||||
*/
|
*/
|
||||||
public class PDOM {
|
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 PDOM_NODE = CCorePlugin.PLUGIN_ID + ".pdom"; //$NON-NLS-1$
|
||||||
private static final String ENABLED_KEY = "enabled"; //$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 {
|
public static void deletePDOM(IProject project) throws CoreException {
|
||||||
if (isEnabled(project))
|
if (isEnabled(project))
|
||||||
getPDOMProvider().getPDOM(project).delete();
|
PDOMManager.getInstance().getPDOM(project).delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -116,7 +81,7 @@ public class PDOM {
|
||||||
* change events.
|
* change events.
|
||||||
*/
|
*/
|
||||||
public static void startup() {
|
public static void startup() {
|
||||||
IElementChangedListener listener = getPDOMProvider().getElementChangedListener();
|
IElementChangedListener listener = PDOMManager.getInstance();
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
CoreModel.getDefault().addElementChangedListener(listener);
|
CoreModel.getDefault().addElementChangedListener(listener);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue