mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-20 23:45:23 +02:00
Put the PDOM back to per project. Increased the Chunk size in the database to 16K so that less handles are created on Windows.
This commit is contained in:
parent
f2d17fffb6
commit
9df742ada4
32 changed files with 269 additions and 220 deletions
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
|
import org.eclipse.cdt.core.dom.ast.gnu.c.GCCLanguage;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
||||||
|
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.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
|
@ -50,10 +51,12 @@ public class AllTypesCache {
|
||||||
private abstract static class TypesCollector implements IPDOMVisitor {
|
private abstract static class TypesCollector implements IPDOMVisitor {
|
||||||
private final int[] kinds;
|
private final int[] kinds;
|
||||||
protected final List types;
|
protected final List types;
|
||||||
|
protected final ICProject project;
|
||||||
|
|
||||||
protected TypesCollector(int[] kinds, List types) {
|
protected TypesCollector(int[] kinds, List types, ICProject project) {
|
||||||
this.kinds = kinds;
|
this.kinds = kinds;
|
||||||
this.types = types;
|
this.types = types;
|
||||||
|
this.project = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void visitKind(IPDOMNode node, int kind);
|
protected abstract void visitKind(IPDOMNode node, int kind);
|
||||||
|
@ -70,8 +73,8 @@ public class AllTypesCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CTypesCollector extends TypesCollector {
|
private static class CTypesCollector extends TypesCollector {
|
||||||
public CTypesCollector(int[] kinds, List types) {
|
public CTypesCollector(int[] kinds, List types, ICProject project) {
|
||||||
super(kinds, types);
|
super(kinds, types, project);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void visitKind(IPDOMNode node, int kind) {
|
protected void visitKind(IPDOMNode node, int kind) {
|
||||||
|
@ -82,7 +85,7 @@ public class AllTypesCache {
|
||||||
return;
|
return;
|
||||||
case ICElement.C_STRUCT:
|
case ICElement.C_STRUCT:
|
||||||
if (node instanceof PDOMCStructure)
|
if (node instanceof PDOMCStructure)
|
||||||
types.add(new PDOMTypeInfo((PDOMBinding)node, kind));
|
types.add(new PDOMTypeInfo((PDOMBinding)node, kind, project));
|
||||||
return;
|
return;
|
||||||
case ICElement.C_UNION:
|
case ICElement.C_UNION:
|
||||||
return;
|
return;
|
||||||
|
@ -95,8 +98,8 @@ public class AllTypesCache {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CPPTypesCollector extends TypesCollector {
|
private static class CPPTypesCollector extends TypesCollector {
|
||||||
public CPPTypesCollector(int[] kinds, List types) {
|
public CPPTypesCollector(int[] kinds, List types, ICProject project) {
|
||||||
super(kinds, types);
|
super(kinds, types, project);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void visitKind(IPDOMNode node, int kind) {
|
protected void visitKind(IPDOMNode node, int kind) {
|
||||||
|
@ -104,22 +107,22 @@ public class AllTypesCache {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case ICElement.C_NAMESPACE:
|
case ICElement.C_NAMESPACE:
|
||||||
if (node instanceof PDOMCPPNamespace || node instanceof PDOMCPPNamespaceAlias)
|
if (node instanceof PDOMCPPNamespace || node instanceof PDOMCPPNamespaceAlias)
|
||||||
types.add(new PDOMTypeInfo((PDOMBinding)node, kind));
|
types.add(new PDOMTypeInfo((PDOMBinding)node, kind, project));
|
||||||
return;
|
return;
|
||||||
case ICElement.C_CLASS:
|
case ICElement.C_CLASS:
|
||||||
if (node instanceof PDOMCPPClassType
|
if (node instanceof PDOMCPPClassType
|
||||||
&& ((PDOMCPPClassType)node).getKey() == ICPPClassType.k_class)
|
&& ((PDOMCPPClassType)node).getKey() == ICPPClassType.k_class)
|
||||||
types.add(new PDOMTypeInfo((PDOMBinding)node, kind));
|
types.add(new PDOMTypeInfo((PDOMBinding)node, kind, project));
|
||||||
return;
|
return;
|
||||||
case ICElement.C_STRUCT:
|
case ICElement.C_STRUCT:
|
||||||
if (node instanceof PDOMCPPClassType
|
if (node instanceof PDOMCPPClassType
|
||||||
&& ((PDOMCPPClassType)node).getKey() == ICPPClassType.k_struct)
|
&& ((PDOMCPPClassType)node).getKey() == ICPPClassType.k_struct)
|
||||||
types.add(new PDOMTypeInfo((PDOMBinding)node, kind));
|
types.add(new PDOMTypeInfo((PDOMBinding)node, kind, project));
|
||||||
return;
|
return;
|
||||||
case ICElement.C_UNION:
|
case ICElement.C_UNION:
|
||||||
if (node instanceof PDOMCPPClassType
|
if (node instanceof PDOMCPPClassType
|
||||||
&& ((PDOMCPPClassType)node).getKey() == ICPPClassType.k_union)
|
&& ((PDOMCPPClassType)node).getKey() == ICPPClassType.k_union)
|
||||||
types.add(new PDOMTypeInfo((PDOMBinding)node, kind));
|
types.add(new PDOMTypeInfo((PDOMBinding)node, kind, project));
|
||||||
return;
|
return;
|
||||||
case ICElement.C_ENUMERATION:
|
case ICElement.C_ENUMERATION:
|
||||||
return;
|
return;
|
||||||
|
@ -136,14 +139,17 @@ public class AllTypesCache {
|
||||||
List types = new ArrayList();
|
List types = new ArrayList();
|
||||||
IPDOMManager pdomManager = CCorePlugin.getPDOMManager();
|
IPDOMManager pdomManager = CCorePlugin.getPDOMManager();
|
||||||
|
|
||||||
CTypesCollector cCollector = new CTypesCollector(kinds, types);
|
for (int i = 0; i < projects.length; ++i) {
|
||||||
CPPTypesCollector cppCollector = new CPPTypesCollector(kinds, types);
|
ICProject project = projects[i];
|
||||||
|
CTypesCollector cCollector = new CTypesCollector(kinds, types, project);
|
||||||
|
CPPTypesCollector cppCollector = new CPPTypesCollector(kinds, types, project);
|
||||||
|
|
||||||
PDOM pdom = (PDOM)pdomManager.getPDOM();
|
PDOM pdom = (PDOM)pdomManager.getPDOM(project);
|
||||||
PDOMLinkage cLinkage = pdom.getLinkage(GCCLanguage.getDefault());
|
PDOMLinkage cLinkage = pdom.getLinkage(GCCLanguage.getDefault());
|
||||||
cLinkage.accept(cCollector);
|
cLinkage.accept(cCollector);
|
||||||
PDOMLinkage cppLinkage = pdom.getLinkage(GPPLanguage.getDefault());
|
PDOMLinkage cppLinkage = pdom.getLinkage(GPPLanguage.getDefault());
|
||||||
cppLinkage.accept(cppCollector);
|
cppLinkage.accept(cppCollector);
|
||||||
|
}
|
||||||
|
|
||||||
return (ITypeInfo[])types.toArray(new ITypeInfo[types.size()]);
|
return (ITypeInfo[])types.toArray(new ITypeInfo[types.size()]);
|
||||||
}
|
}
|
||||||
|
@ -153,20 +159,8 @@ public class AllTypesCache {
|
||||||
*/
|
*/
|
||||||
public static ITypeInfo[] getAllTypes() {
|
public static ITypeInfo[] getAllTypes() {
|
||||||
try {
|
try {
|
||||||
List types = new ArrayList();
|
ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
|
||||||
IPDOMManager pdomManager = CCorePlugin.getPDOMManager();
|
return getTypes(projects, ITypeInfo.KNOWN_TYPES);
|
||||||
|
|
||||||
int[] kinds = ITypeInfo.KNOWN_TYPES;
|
|
||||||
CTypesCollector cCollector = new CTypesCollector(kinds, types);
|
|
||||||
CPPTypesCollector cppCollector = new CPPTypesCollector(kinds, types);
|
|
||||||
|
|
||||||
PDOM pdom = (PDOM)pdomManager.getPDOM();
|
|
||||||
PDOMLinkage cLinkage = pdom.getLinkage(GCCLanguage.getDefault());
|
|
||||||
cLinkage.accept(cCollector);
|
|
||||||
PDOMLinkage cppLinkage = pdom.getLinkage(GPPLanguage.getDefault());
|
|
||||||
cppLinkage.accept(cppCollector);
|
|
||||||
|
|
||||||
return (ITypeInfo[])types.toArray(new ITypeInfo[types.size()]);
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return new ITypeInfo[0];
|
return new ITypeInfo[0];
|
||||||
|
|
|
@ -27,10 +27,12 @@ public class PDOMTypeInfo implements ITypeInfo {
|
||||||
|
|
||||||
private final PDOMBinding binding;
|
private final PDOMBinding binding;
|
||||||
private final int elementType;
|
private final int elementType;
|
||||||
|
private final ICProject project;
|
||||||
|
|
||||||
public PDOMTypeInfo(PDOMBinding binding, int elementType) {
|
public PDOMTypeInfo(PDOMBinding binding, int elementType, ICProject project) {
|
||||||
this.binding = binding;
|
this.binding = binding;
|
||||||
this.elementType = elementType;
|
this.elementType = elementType;
|
||||||
|
this.project = project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addDerivedReference(ITypeReference location) {
|
public void addDerivedReference(ITypeReference location) {
|
||||||
|
@ -74,7 +76,7 @@ public class PDOMTypeInfo implements ITypeInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICProject getEnclosingProject() {
|
public ICProject getEnclosingProject() {
|
||||||
throw new PDOMNotImplementedError();
|
return project;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITypeInfo getEnclosingType() {
|
public ITypeInfo getEnclosingType() {
|
||||||
|
@ -103,7 +105,7 @@ public class PDOMTypeInfo implements ITypeInfo {
|
||||||
public ITypeReference getResolvedReference() {
|
public ITypeReference getResolvedReference() {
|
||||||
try {
|
try {
|
||||||
PDOMName name = binding.getFirstDefinition();
|
PDOMName name = binding.getFirstDefinition();
|
||||||
return name != null ? new PDOMTypeReference(name) : null;
|
return name != null ? new PDOMTypeReference(name, project) : null;
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
return null;
|
return null;
|
||||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.core.browser;
|
||||||
|
|
||||||
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.ICProject;
|
||||||
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.dom.PDOMName;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||||
|
@ -29,16 +30,13 @@ import org.eclipse.core.runtime.Path;
|
||||||
public class PDOMTypeReference implements ITypeReference {
|
public class PDOMTypeReference implements ITypeReference {
|
||||||
|
|
||||||
private final PDOMName name;
|
private final PDOMName name;
|
||||||
private final IPath path;
|
private final ICProject project;
|
||||||
private ITranslationUnit tu;
|
private final IPath path;
|
||||||
|
|
||||||
public PDOMTypeReference(PDOMName name) {
|
public PDOMTypeReference(PDOMName name, ICProject project) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.project = project;
|
||||||
this.path = new Path(name.getFileLocation().getFileName());
|
this.path = new Path(name.getFileLocation().getFileName());
|
||||||
|
|
||||||
ICElement element = CoreModel.getDefault().create(path);
|
|
||||||
if (element instanceof ITranslationUnit)
|
|
||||||
tu = (ITranslationUnit)element;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICElement[] getCElements() {
|
public ICElement[] getCElements() {
|
||||||
|
@ -62,7 +60,7 @@ public class PDOMTypeReference implements ITypeReference {
|
||||||
}
|
}
|
||||||
|
|
||||||
public IProject getProject() {
|
public IProject getProject() {
|
||||||
return tu != null ? tu.getUnderlyingResource().getProject() : null;
|
throw new PDOMNotImplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IPath getRelativeIncludePath(IProject project) {
|
public IPath getRelativeIncludePath(IProject project) {
|
||||||
|
@ -78,7 +76,7 @@ public class PDOMTypeReference implements ITypeReference {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ITranslationUnit getTranslationUnit() {
|
public ITranslationUnit getTranslationUnit() {
|
||||||
return tu;
|
return CoreModel.getDefault().createTranslationUnitFrom(project, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IWorkingCopy getWorkingCopy() {
|
public IWorkingCopy getWorkingCopy() {
|
||||||
|
|
|
@ -24,9 +24,9 @@ public interface IPDOMIndexer {
|
||||||
|
|
||||||
public void setProject(ICProject project);
|
public void setProject(ICProject project);
|
||||||
public ICProject getProject();
|
public ICProject getProject();
|
||||||
|
|
||||||
public void handleDelta(ICElementDelta delta) throws CoreException;
|
public void handleDelta(ICElementDelta delta) throws CoreException;
|
||||||
|
|
||||||
public void indexAll() throws CoreException;
|
public void reindex() throws CoreException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import org.eclipse.core.runtime.jobs.ISchedulingRule;
|
||||||
public interface IPDOMManager {
|
public interface IPDOMManager {
|
||||||
|
|
||||||
// Getting the PDOM
|
// Getting the PDOM
|
||||||
public IPDOM getPDOM() throws CoreException;
|
public IPDOM getPDOM(ICProject project) throws CoreException;
|
||||||
|
|
||||||
// Get the indexer for a given project
|
// Get the indexer for a given project
|
||||||
public IPDOMIndexer getIndexer(ICProject project);
|
public IPDOMIndexer getIndexer(ICProject project);
|
||||||
|
@ -38,9 +38,6 @@ public interface IPDOMManager {
|
||||||
// Enqueue and indexer sub job
|
// Enqueue and indexer sub job
|
||||||
public void enqueue(IPDOMIndexerTask subjob);
|
public void enqueue(IPDOMIndexerTask subjob);
|
||||||
|
|
||||||
// Reindex the workspace
|
|
||||||
public void reindex();
|
|
||||||
|
|
||||||
// Scheduling rule used by indexers to make sure we don't get
|
// Scheduling rule used by indexers to make sure we don't get
|
||||||
// Too much indexing going on.
|
// Too much indexing going on.
|
||||||
public ISchedulingRule getIndexerSchedulingRule();
|
public ISchedulingRule getIndexerSchedulingRule();
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast;
|
package org.eclipse.cdt.core.dom.ast;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.core.dom.IPDOM;
|
||||||
import org.eclipse.cdt.core.model.ILanguage;
|
import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||||
|
|
||||||
|
@ -189,6 +190,20 @@ public interface IASTTranslationUnit extends IASTNode {
|
||||||
*/
|
*/
|
||||||
public ParserLanguage getParserLanguage();
|
public ParserLanguage getParserLanguage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the Index associated with this translation unit.
|
||||||
|
*
|
||||||
|
* @return the Index for this translation unit
|
||||||
|
*/
|
||||||
|
public IPDOM getIndex();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the Index to be used for this translation unit.
|
||||||
|
*
|
||||||
|
* @param index
|
||||||
|
*/
|
||||||
|
public void setIndex(IPDOM index);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the language for this translation unit.
|
* Returns the language for this translation unit.
|
||||||
*
|
*
|
||||||
|
@ -196,17 +211,4 @@ public interface IASTTranslationUnit extends IASTNode {
|
||||||
*/
|
*/
|
||||||
public ILanguage getLanguage();
|
public ILanguage getLanguage();
|
||||||
|
|
||||||
/**
|
|
||||||
* Set whether to use the index when resolving bindings in this TU.
|
|
||||||
*
|
|
||||||
* @param value
|
|
||||||
*/
|
|
||||||
public void useIndex(boolean value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Is the index used to resolve bindings in this TU.
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public boolean useIndex();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
|
||||||
public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) throws CoreException {
|
public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) throws CoreException {
|
||||||
ICodeReaderFactory fileCreator;
|
ICodeReaderFactory fileCreator;
|
||||||
if ((style & (ILanguage.AST_SKIP_INDEXED_HEADERS | ILanguage.AST_SKIP_ALL_HEADERS)) != 0) {
|
if ((style & (ILanguage.AST_SKIP_INDEXED_HEADERS | ILanguage.AST_SKIP_ALL_HEADERS)) != 0) {
|
||||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM().getAdapter(PDOM.class);
|
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(file.getCProject()).getAdapter(PDOM.class);
|
||||||
fileCreator = new PDOMCodeReaderFactory(pdom);
|
fileCreator = new PDOMCodeReaderFactory(pdom);
|
||||||
} else
|
} else
|
||||||
fileCreator = SavedCodeReaderFactory.getInstance();
|
fileCreator = SavedCodeReaderFactory.getInstance();
|
||||||
|
@ -134,7 +134,8 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
|
||||||
|
|
||||||
// Parse
|
// Parse
|
||||||
IASTTranslationUnit ast = parser.parse();
|
IASTTranslationUnit ast = parser.parse();
|
||||||
ast.useIndex((style & AST_USE_INDEX) != 0);
|
if ((style & AST_USE_INDEX) != 0)
|
||||||
|
ast.setIndex(CCorePlugin.getPDOMManager().getPDOM(file.getCProject()));
|
||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,7 +155,7 @@ public class GCCLanguage extends PlatformObject implements ILanguage {
|
||||||
scanInfo = new ScannerInfo();
|
scanInfo = new ScannerInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM().getAdapter(PDOM.class);
|
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(workingCopy.getCProject()).getAdapter(PDOM.class);
|
||||||
ICodeReaderFactory fileCreator = new PDOMCodeReaderFactory(pdom);
|
ICodeReaderFactory fileCreator = new PDOMCodeReaderFactory(pdom);
|
||||||
|
|
||||||
String path
|
String path
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
|
||||||
public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) throws CoreException {
|
public IASTTranslationUnit getASTTranslationUnit(ITranslationUnit file, int style) throws CoreException {
|
||||||
ICodeReaderFactory fileCreator;
|
ICodeReaderFactory fileCreator;
|
||||||
if ((style & (ILanguage.AST_SKIP_INDEXED_HEADERS | ILanguage.AST_SKIP_ALL_HEADERS)) != 0) {
|
if ((style & (ILanguage.AST_SKIP_INDEXED_HEADERS | ILanguage.AST_SKIP_ALL_HEADERS)) != 0) {
|
||||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM().getAdapter(PDOM.class);
|
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(file.getCProject()).getAdapter(PDOM.class);
|
||||||
fileCreator = new PDOMCodeReaderFactory(pdom);
|
fileCreator = new PDOMCodeReaderFactory(pdom);
|
||||||
} else
|
} else
|
||||||
fileCreator = SavedCodeReaderFactory.getInstance();
|
fileCreator = SavedCodeReaderFactory.getInstance();
|
||||||
|
@ -133,7 +133,8 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
|
||||||
|
|
||||||
// Parse
|
// Parse
|
||||||
IASTTranslationUnit ast = parser.parse();
|
IASTTranslationUnit ast = parser.parse();
|
||||||
ast.useIndex((style & AST_USE_INDEX) != 0);
|
if ((style & AST_USE_INDEX) != 0)
|
||||||
|
ast.setIndex(CCorePlugin.getPDOMManager().getPDOM(file.getCProject()));
|
||||||
return ast;
|
return ast;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +154,7 @@ public class GPPLanguage extends PlatformObject implements ILanguage {
|
||||||
scanInfo = new ScannerInfo();
|
scanInfo = new ScannerInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM().getAdapter(PDOM.class);
|
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(workingCopy.getCProject()).getAdapter(PDOM.class);
|
||||||
ICodeReaderFactory fileCreator = new PDOMCodeReaderFactory(pdom);
|
ICodeReaderFactory fileCreator = new PDOMCodeReaderFactory(pdom);
|
||||||
|
|
||||||
CodeReader reader = new CodeReader(resource.getLocation().toOSString(), workingCopy.getContents());
|
CodeReader reader = new CodeReader(resource.getLocation().toOSString(), workingCopy.getContents());
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
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.IPDOMResolver;
|
import org.eclipse.cdt.core.dom.IPDOMResolver;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator;
|
||||||
|
@ -65,7 +66,7 @@ public class CASTTranslationUnit extends CASTNode implements
|
||||||
|
|
||||||
private ILocationResolver resolver;
|
private ILocationResolver resolver;
|
||||||
|
|
||||||
private boolean useIndex;
|
private IPDOM pdom;
|
||||||
|
|
||||||
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
|
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
|
||||||
|
|
||||||
|
@ -129,10 +130,9 @@ public class CASTTranslationUnit extends CASTNode implements
|
||||||
}
|
}
|
||||||
IASTName[] names = CVisitor.getDeclarations(this, binding);
|
IASTName[] names = CVisitor.getDeclarations(this, binding);
|
||||||
|
|
||||||
if (names.length == 0 && useIndex) {
|
if (names.length == 0 && pdom != null) {
|
||||||
try {
|
try {
|
||||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM();
|
binding = ((PDOM)pdom).getLinkage(getLanguage()).adaptBinding(binding);
|
||||||
binding = pdom.getLinkage(getLanguage()).adaptBinding(binding);
|
|
||||||
if (binding != null)
|
if (binding != null)
|
||||||
names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDeclarations(binding);
|
names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDeclarations(binding);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -163,10 +163,9 @@ public class CASTTranslationUnit extends CASTNode implements
|
||||||
}
|
}
|
||||||
names = (IASTName[])ArrayUtil.removeNulls(IASTName.class, names);
|
names = (IASTName[])ArrayUtil.removeNulls(IASTName.class, names);
|
||||||
|
|
||||||
if (names.length == 0 && useIndex) {
|
if (names.length == 0 && pdom != null) {
|
||||||
try {
|
try {
|
||||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM();
|
binding = ((PDOM)pdom).getLinkage(getLanguage()).adaptBinding(binding);
|
||||||
binding = pdom.getLinkage(getLanguage()).adaptBinding(binding);
|
|
||||||
if (binding != null)
|
if (binding != null)
|
||||||
names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDefinitions(binding);
|
names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDefinitions(binding);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -560,12 +559,12 @@ public class CASTTranslationUnit extends CASTNode implements
|
||||||
return new GCCLanguage();
|
return new GCCLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean useIndex() {
|
public IPDOM getIndex() {
|
||||||
return useIndex;
|
return pdom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void useIndex(boolean value) {
|
public void setIndex(IPDOM pdom) {
|
||||||
this.useIndex = value;
|
this.pdom = pdom;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||||
|
|
||||||
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.IPDOMResolver;
|
import org.eclipse.cdt.core.dom.IPDOMResolver;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
|
@ -1306,13 +1305,9 @@ public class CVisitor {
|
||||||
if( blockItem != null) {
|
if( blockItem != null) {
|
||||||
// We're at the end of our rope, check the PDOM if we can
|
// We're at the end of our rope, check the PDOM if we can
|
||||||
IASTTranslationUnit tu = (IASTTranslationUnit)blockItem;
|
IASTTranslationUnit tu = (IASTTranslationUnit)blockItem;
|
||||||
if (tu.useIndex()) {
|
IPDOM pdom = tu.getIndex();
|
||||||
IPDOM pdom = null;
|
if (pdom != null) {
|
||||||
try {
|
binding = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).resolveBinding(name);
|
||||||
pdom = CCorePlugin.getPDOMManager().getPDOM();
|
|
||||||
binding = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).resolveBinding(name);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (binding == null)
|
if (binding == null)
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
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.IPDOMResolver;
|
import org.eclipse.cdt.core.dom.IPDOMResolver;
|
||||||
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.DOMException;
|
||||||
|
@ -80,7 +81,7 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
|
||||||
|
|
||||||
private ILocationResolver resolver;
|
private ILocationResolver resolver;
|
||||||
|
|
||||||
private boolean useIndex;
|
private IPDOM pdom;
|
||||||
|
|
||||||
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
|
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_STATEMENT_ARRAY = new IASTPreprocessorStatement[0];
|
||||||
|
|
||||||
|
@ -187,11 +188,10 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
|
||||||
return resolver.getDeclarations( (IMacroBinding)b );
|
return resolver.getDeclarations( (IMacroBinding)b );
|
||||||
}
|
}
|
||||||
IASTName[] names = CPPVisitor.getDeclarations( this, b );
|
IASTName[] names = CPPVisitor.getDeclarations( this, b );
|
||||||
if (names.length == 0 && useIndex) {
|
if (names.length == 0 && pdom != null) {
|
||||||
try {
|
try {
|
||||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM();
|
b = ((PDOM)pdom).getLinkage(getLanguage()).adaptBinding(b);
|
||||||
b = pdom.getLinkage(getLanguage()).adaptBinding(b);
|
if (binding != null)
|
||||||
if (b != null)
|
|
||||||
names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDeclarations(b);
|
names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDeclarations(b);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
|
@ -221,10 +221,9 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
|
||||||
}
|
}
|
||||||
names = (IASTName[])ArrayUtil.removeNulls(IASTName.class, names);
|
names = (IASTName[])ArrayUtil.removeNulls(IASTName.class, names);
|
||||||
|
|
||||||
if (names.length == 0 && useIndex) {
|
if (names.length == 0 && pdom != null) {
|
||||||
try {
|
try {
|
||||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM();
|
binding = ((PDOM)pdom).getLinkage(getLanguage()).adaptBinding(binding);
|
||||||
binding = pdom.getLinkage(getLanguage()).adaptBinding(binding);
|
|
||||||
if (binding != null)
|
if (binding != null)
|
||||||
names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDefinitions(binding);
|
names = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).getDefinitions(binding);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
|
@ -611,12 +610,12 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
|
||||||
return new GPPLanguage();
|
return new GPPLanguage();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean useIndex() {
|
public IPDOM getIndex() {
|
||||||
return useIndex;
|
return pdom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void useIndex(boolean value) {
|
public void setIndex(IPDOM pdom) {
|
||||||
this.useIndex = value;
|
this.pdom = pdom;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
*/
|
*/
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||||
|
|
||||||
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.IPDOMResolver;
|
import org.eclipse.cdt.core.dom.IPDOMResolver;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
|
@ -127,7 +126,6 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil.ArrayWrapper;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author aniefer
|
* @author aniefer
|
||||||
|
@ -749,13 +747,9 @@ public class CPPSemantics {
|
||||||
}
|
}
|
||||||
if( binding == null ){
|
if( binding == null ){
|
||||||
// Let's try the pdom
|
// Let's try the pdom
|
||||||
if (name.getTranslationUnit().useIndex()) {
|
IPDOM pdom = name.getTranslationUnit().getIndex();
|
||||||
IPDOM pdom = null;
|
if (pdom != null) {
|
||||||
try {
|
binding = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).resolveBinding(name);
|
||||||
pdom = CCorePlugin.getPDOMManager().getPDOM();
|
|
||||||
binding = ((IPDOMResolver)pdom.getAdapter(IPDOMResolver.class)).resolveBinding(name);
|
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're still null...
|
// If we're still null...
|
||||||
|
|
|
@ -51,9 +51,6 @@ import org.eclipse.core.runtime.PlatformObject;
|
||||||
public class PDOM extends PlatformObject
|
public class PDOM extends PlatformObject
|
||||||
implements IPDOM, IPDOMResolver, IPDOMWriter {
|
implements IPDOM, IPDOMResolver, IPDOMWriter {
|
||||||
|
|
||||||
private static final String dbName = "pdom"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
private final IPath dbPath;
|
|
||||||
private Database db;
|
private Database db;
|
||||||
|
|
||||||
public static final int VERSION = 6;
|
public static final int VERSION = 6;
|
||||||
|
@ -71,17 +68,12 @@ public class PDOM extends PlatformObject
|
||||||
// Local caches
|
// Local caches
|
||||||
private BTree fileIndex;
|
private BTree fileIndex;
|
||||||
private Map linkageCache = new HashMap();
|
private Map linkageCache = new HashMap();
|
||||||
|
|
||||||
public PDOM() throws CoreException {
|
public PDOM(IPath dbPath) throws CoreException {
|
||||||
// Load up the database
|
// Load up the database
|
||||||
dbPath = CCorePlugin.getDefault().getStateLocation().append(dbName);
|
|
||||||
db = new Database(dbPath.toOSString());
|
db = new Database(dbPath.toOSString());
|
||||||
|
|
||||||
// Check the version and force a rebuild if needed.
|
if (db.getVersion() == VERSION) {
|
||||||
// TODO Conversion might be a nicer story down the road
|
|
||||||
if (db.getVersion() != VERSION) {
|
|
||||||
CCorePlugin.getPDOMManager().reindex();
|
|
||||||
} else {
|
|
||||||
// populate the linkage cache
|
// populate the linkage cache
|
||||||
PDOMLinkage linkage = getFirstLinkage();
|
PDOMLinkage linkage = getFirstLinkage();
|
||||||
while (linkage != null) {
|
while (linkage != null) {
|
||||||
|
@ -90,6 +82,10 @@ public class PDOM extends PlatformObject
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean versionMismatch() {
|
||||||
|
return db.getVersion() != VERSION;
|
||||||
|
}
|
||||||
|
|
||||||
public Object getAdapter(Class adapter) {
|
public Object getAdapter(Class adapter) {
|
||||||
if (adapter == IPDOM.class)
|
if (adapter == IPDOM.class)
|
||||||
|
|
|
@ -31,6 +31,7 @@ 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.IConfigurationElement;
|
||||||
import org.eclipse.core.runtime.IExtension;
|
import org.eclipse.core.runtime.IExtension;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.IStatus;
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.Platform;
|
import org.eclipse.core.runtime.Platform;
|
||||||
|
@ -54,9 +55,12 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
||||||
|
|
||||||
private static final QualifiedName indexerProperty
|
private static final QualifiedName indexerProperty
|
||||||
= new QualifiedName(CCorePlugin.PLUGIN_ID, "pdomIndexer"); //$NON-NLS-1$
|
= new QualifiedName(CCorePlugin.PLUGIN_ID, "pdomIndexer"); //$NON-NLS-1$
|
||||||
|
private static final QualifiedName dbNameProperty
|
||||||
|
= new QualifiedName(CCorePlugin.PLUGIN_ID, "pdomName"); //$NON-NLS-1$
|
||||||
|
private static final QualifiedName pdomProperty
|
||||||
|
= new QualifiedName(CCorePlugin.PLUGIN_ID, "pdom"); //$NON-NLS-1$
|
||||||
|
|
||||||
private IProgressMonitor group;
|
private IProgressMonitor group;
|
||||||
private IPDOM pdom;
|
|
||||||
|
|
||||||
private final ISchedulingRule indexerSchedulingRule = new ISchedulingRule() {
|
private final ISchedulingRule indexerSchedulingRule = new ISchedulingRule() {
|
||||||
public boolean contains(ISchedulingRule rule) {
|
public boolean contains(ISchedulingRule rule) {
|
||||||
|
@ -67,9 +71,22 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public synchronized IPDOM getPDOM() throws CoreException {
|
public synchronized IPDOM getPDOM(ICProject project) throws CoreException {
|
||||||
if (pdom == null)
|
IProject rproject = project.getProject();
|
||||||
pdom = new PDOM();
|
PDOM pdom = (PDOM)rproject.getSessionProperty(pdomProperty);
|
||||||
|
if (pdom == null) {
|
||||||
|
String dbName = rproject.getPersistentProperty(dbNameProperty);
|
||||||
|
if (dbName == null) {
|
||||||
|
dbName = project.getElementName() + "."
|
||||||
|
+ System.currentTimeMillis() + ".pdom";
|
||||||
|
rproject.setPersistentProperty(dbNameProperty, dbName);
|
||||||
|
}
|
||||||
|
IPath dbPath = CCorePlugin.getDefault().getStateLocation().append(dbName);
|
||||||
|
pdom = new PDOM(dbPath);
|
||||||
|
rproject.setSessionProperty(pdomProperty, pdom);
|
||||||
|
if (pdom.versionMismatch())
|
||||||
|
getIndexer(project).reindex();
|
||||||
|
}
|
||||||
return pdom;
|
return pdom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -294,33 +311,6 @@ public class PDOMManager implements IPDOMManager, IElementChangedListener {
|
||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class Reindex extends Job {
|
|
||||||
public Reindex() {
|
|
||||||
super("Reindex"); //$NON-NLS-1$
|
|
||||||
setSystem(true);
|
|
||||||
}
|
|
||||||
protected IStatus run(IProgressMonitor monitor) {
|
|
||||||
try {
|
|
||||||
pdom.acquireWriteLock();
|
|
||||||
pdom.clear();
|
|
||||||
pdom.releaseWriteLock();
|
|
||||||
|
|
||||||
ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
|
|
||||||
for (int i = 0; i < projects.length; ++i)
|
|
||||||
getIndexer(projects[i]).indexAll();
|
|
||||||
|
|
||||||
return Status.OK_STATUS;
|
|
||||||
} catch (Exception e) {
|
|
||||||
CCorePlugin.log(e);
|
|
||||||
return Status.CANCEL_STATUS;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void reindex() {
|
|
||||||
new Reindex().schedule();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Startup the PDOM. This mainly sets us up to handle model
|
* Startup the PDOM. This mainly sets us up to handle model
|
||||||
* change events.
|
* change events.
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class Database {
|
||||||
|
|
||||||
// public for tests only, you shouldn't need these
|
// public for tests only, you shouldn't need these
|
||||||
public static final int VERSION_OFFSET = 0;
|
public static final int VERSION_OFFSET = 0;
|
||||||
public static final int CHUNK_SIZE = 4096;
|
public static final int CHUNK_SIZE = 1024 * 16;
|
||||||
public static final int MIN_SIZE = 16;
|
public static final int MIN_SIZE = 16;
|
||||||
public static final int INT_SIZE = 4;
|
public static final int INT_SIZE = 4;
|
||||||
public static final int CHAR_SIZE = 2;
|
public static final int CHAR_SIZE = 2;
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class PDOMBindingAdapterFactory implements IAdapterFactory {
|
||||||
IBinding binding = (IBinding)adaptableObject;
|
IBinding binding = (IBinding)adaptableObject;
|
||||||
ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
|
ICProject[] projects = CoreModel.getDefault().getCModel().getCProjects();
|
||||||
for (int i = 0; i < projects.length; ++i) {
|
for (int i = 0; i < projects.length; ++i) {
|
||||||
IPDOM ipdom = CCorePlugin.getPDOMManager().getPDOM();
|
IPDOM ipdom = CCorePlugin.getPDOMManager().getPDOM(projects[i]);
|
||||||
if (ipdom == null || !(ipdom instanceof PDOM))
|
if (ipdom == null || !(ipdom instanceof PDOM))
|
||||||
continue;
|
continue;
|
||||||
PDOM pdom = (PDOM)ipdom;
|
PDOM pdom = (PDOM)ipdom;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.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;
|
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
@ -108,14 +109,14 @@ public class PDOMTranslationUnit implements IASTTranslationUnit {
|
||||||
throw new PDOMNotImplementedError();
|
throw new PDOMNotImplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean useIndex() {
|
public IPDOM getIndex() {
|
||||||
throw new PDOMNotImplementedError();
|
throw new PDOMNotImplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void useIndex(boolean value) {
|
public void setIndex(IPDOM pdom) {
|
||||||
throw new PDOMNotImplementedError();
|
throw new PDOMNotImplementedError();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTTranslationUnit getTranslationUnit() {
|
public IASTTranslationUnit getTranslationUnit() {
|
||||||
throw new PDOMNotImplementedError();
|
throw new PDOMNotImplementedError();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public class CtagsIndexer implements IPDOMIndexer {
|
||||||
new CtagsHandleDelta(this,delta).schedule();
|
new CtagsHandleDelta(this,delta).schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void indexAll() throws CoreException {
|
public void reindex() throws CoreException {
|
||||||
new CtagsReindex(this).schedule();
|
new CtagsReindex(this).schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,7 +150,7 @@ public class CtagsIndexer implements IPDOMIndexer {
|
||||||
} catch (BackingStoreException e) {
|
} catch (BackingStoreException e) {
|
||||||
CCorePlugin.log(e);
|
CCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
indexAll();
|
reindex();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public abstract class CtagsIndexerJob extends Job {
|
||||||
public CtagsIndexerJob(CtagsIndexer indexer) throws CoreException {
|
public CtagsIndexerJob(CtagsIndexer indexer) throws CoreException {
|
||||||
super("ctags Indexer: " + indexer.getProject().getElementName());
|
super("ctags Indexer: " + indexer.getProject().getElementName());
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
this.pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM();
|
this.pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(indexer.getProject());
|
||||||
setRule(CCorePlugin.getPDOMManager().getIndexerSchedulingRule());
|
setRule(CCorePlugin.getPDOMManager().getIndexerSchedulingRule());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class PDOMFastIndexer implements IPDOMIndexer {
|
||||||
new PDOMFastHandleDelta(this, delta));
|
new PDOMFastHandleDelta(this, delta));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void indexAll() throws CoreException {
|
public void reindex() throws CoreException {
|
||||||
CCorePlugin.getPDOMManager().enqueue(
|
CCorePlugin.getPDOMManager().enqueue(
|
||||||
new PDOMFastReindex(this));
|
new PDOMFastReindex(this));
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public abstract class PDOMFastIndexerJob implements IPDOMIndexerTask {
|
||||||
|
|
||||||
public PDOMFastIndexerJob(PDOMFastIndexer indexer) throws CoreException {
|
public PDOMFastIndexerJob(PDOMFastIndexer indexer) throws CoreException {
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
this.pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM();
|
this.pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(indexer.getProject());
|
||||||
this.codeReaderFactory = new PDOMCodeReaderFactory(pdom);
|
this.codeReaderFactory = new PDOMCodeReaderFactory(pdom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -56,6 +56,9 @@ public class PDOMFastReindex extends PDOMFastIndexerJob {
|
||||||
try {
|
try {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
|
|
||||||
|
// First clear the pdom
|
||||||
|
pdom.clear();
|
||||||
|
|
||||||
ISourceRoot[] roots = indexer.getProject().getAllSourceRoots();
|
ISourceRoot[] roots = indexer.getProject().getAllSourceRoots();
|
||||||
for (int i = 0; i < roots.length; ++i)
|
for (int i = 0; i < roots.length; ++i)
|
||||||
addSources(roots[i], monitor);
|
addSources(roots[i], monitor);
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class PDOMFullIndexer implements IPDOMIndexer {
|
||||||
new PDOMFullHandleDelta(this, delta).schedule();
|
new PDOMFullHandleDelta(this, delta).schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void indexAll() throws CoreException {
|
public void reindex() throws CoreException {
|
||||||
new PDOMFullReindex(this).schedule();
|
new PDOMFullReindex(this).schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ public abstract class PDOMFullIndexerJob extends Job {
|
||||||
public PDOMFullIndexerJob(PDOMFullIndexer indexer) throws CoreException {
|
public PDOMFullIndexerJob(PDOMFullIndexer indexer) throws CoreException {
|
||||||
super("Full Indexer: " + indexer.getProject().getElementName());
|
super("Full Indexer: " + indexer.getProject().getElementName());
|
||||||
this.indexer = indexer;
|
this.indexer = indexer;
|
||||||
this.pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM();
|
this.pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(indexer.getProject());
|
||||||
setRule(CCorePlugin.getPDOMManager().getIndexerSchedulingRule());
|
setRule(CCorePlugin.getPDOMManager().getIndexerSchedulingRule());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class PDOMNullIndexer implements IPDOMIndexer {
|
||||||
public void handleDelta(ICElementDelta delta) {
|
public void handleDelta(ICElementDelta delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void indexAll() throws CoreException {
|
public void reindex() throws CoreException {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ public class PDOMUpdateProjectAction implements IObjectActionDelegate {
|
||||||
ICProject project = (ICProject)objs[i];
|
ICProject project = (ICProject)objs[i];
|
||||||
IPDOMIndexer indexer = CCorePlugin.getPDOMManager().getIndexer(project);
|
IPDOMIndexer indexer = CCorePlugin.getPDOMManager().getIndexer(project);
|
||||||
try {
|
try {
|
||||||
indexer.indexAll();
|
indexer.reindex();
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CUIPlugin.getDefault().log(e);
|
CUIPlugin.getDefault().log(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ package org.eclipse.cdt.internal.ui.indexview;
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMNode;
|
import org.eclipse.cdt.core.dom.IPDOMNode;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
import org.eclipse.cdt.core.dom.IPDOMVisitor;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
||||||
|
@ -13,6 +14,8 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMMacro;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.jface.dialogs.MessageDialog;
|
import org.eclipse.jface.dialogs.MessageDialog;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.viewers.TreeViewer;
|
import org.eclipse.jface.viewers.TreeViewer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,36 +29,54 @@ public class CountNodeAction extends IndexAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean valid() {
|
public boolean valid() {
|
||||||
return true;
|
ISelection selection = viewer.getSelection();
|
||||||
|
if (!(selection instanceof IStructuredSelection))
|
||||||
|
return false;
|
||||||
|
Object[] objs = ((IStructuredSelection)selection).toArray();
|
||||||
|
for (int i = 0; i < objs.length; ++i)
|
||||||
|
if (objs[i] instanceof ICProject)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
final int[] count = new int[1];
|
final int[] count = new int[1];
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM();
|
ISelection selection = viewer.getSelection();
|
||||||
pdom.getFileIndex().accept(new IBTreeVisitor() {
|
if (!(selection instanceof IStructuredSelection))
|
||||||
public int compare(int record) throws CoreException {
|
return;
|
||||||
return 1;
|
|
||||||
}
|
Object[] objs = ((IStructuredSelection)selection).toArray();
|
||||||
public boolean visit(int record) throws CoreException {
|
for (int i = 0; i < objs.length; ++i) {
|
||||||
if (record != 0) {
|
if (!(objs[i] instanceof ICProject))
|
||||||
PDOMFile file = new PDOMFile(pdom, record);
|
continue;
|
||||||
PDOMMacro macro = file.getFirstMacro();
|
|
||||||
while (macro != null) {
|
ICProject project = (ICProject)objs[i];
|
||||||
++count[0];
|
final PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(project);
|
||||||
macro = macro.getNextMacro();
|
pdom.getFileIndex().accept(new IBTreeVisitor() {
|
||||||
}
|
public int compare(int record) throws CoreException {
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
return true;
|
public boolean visit(int record) throws CoreException {
|
||||||
}
|
if (record != 0) {
|
||||||
});
|
PDOMFile file = new PDOMFile(pdom, record);
|
||||||
pdom.accept(new IPDOMVisitor() {
|
PDOMMacro macro = file.getFirstMacro();
|
||||||
public boolean visit(IPDOMNode node) throws CoreException {
|
while (macro != null) {
|
||||||
count[0]++;
|
++count[0];
|
||||||
return true;
|
macro = macro.getNextMacro();
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
pdom.accept(new IPDOMVisitor() {
|
||||||
|
public boolean visit(IPDOMNode node) throws CoreException {
|
||||||
|
count[0]++;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CUIPlugin.getDefault().log(e);
|
CUIPlugin.getDefault().log(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,9 @@ import org.eclipse.cdt.core.dom.ast.IFunction;
|
||||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||||
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
import org.eclipse.cdt.core.model.ICModel;
|
||||||
import org.eclipse.cdt.core.model.ICProject;
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
|
@ -71,7 +74,6 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
||||||
private ToggleLinkingAction toggleLinkingAction;
|
private ToggleLinkingAction toggleLinkingAction;
|
||||||
private IndexAction rebuildAction;
|
private IndexAction rebuildAction;
|
||||||
private IndexAction countSymbolsAction;
|
private IndexAction countSymbolsAction;
|
||||||
private IndexAction setFastIndexAction;
|
|
||||||
private IndexAction discardExternalDefsAction;
|
private IndexAction discardExternalDefsAction;
|
||||||
private IndexAction openDefinitionAction;
|
private IndexAction openDefinitionAction;
|
||||||
private IndexAction findDeclarationsAction;
|
private IndexAction findDeclarationsAction;
|
||||||
|
@ -180,7 +182,22 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
||||||
private class IndexContentProvider implements ITreeContentProvider {
|
private class IndexContentProvider implements ITreeContentProvider {
|
||||||
public Object[] getChildren(Object parentElement) {
|
public Object[] getChildren(Object parentElement) {
|
||||||
try {
|
try {
|
||||||
if (parentElement instanceof IPDOMNode) {
|
if (parentElement instanceof ICProject) {
|
||||||
|
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM((ICProject)parentElement);
|
||||||
|
int n = 0;
|
||||||
|
PDOMLinkage firstLinkage = pdom.getFirstLinkage();
|
||||||
|
for (PDOMLinkage linkage = firstLinkage; linkage != null; linkage = linkage.getNextLinkage())
|
||||||
|
++n;
|
||||||
|
if (n == 1) {
|
||||||
|
// Skip linkages in hierarchy if there is only one
|
||||||
|
return getChildren(firstLinkage);
|
||||||
|
}
|
||||||
|
PDOMLinkage[] linkages = new PDOMLinkage[n];
|
||||||
|
int i = 0;
|
||||||
|
for (PDOMLinkage linkage = pdom.getFirstLinkage(); linkage != null; linkage = linkage.getNextLinkage())
|
||||||
|
linkages[i++] = linkage;
|
||||||
|
return linkages;
|
||||||
|
} else if (parentElement instanceof IPDOMNode) {
|
||||||
IPDOMNode node = (IPDOMNode)parentElement;
|
IPDOMNode node = (IPDOMNode)parentElement;
|
||||||
Counter counter = new Counter();
|
Counter counter = new Counter();
|
||||||
node.accept(counter);
|
node.accept(counter);
|
||||||
|
@ -202,8 +219,8 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
||||||
|
|
||||||
public boolean hasChildren(Object element) {
|
public boolean hasChildren(Object element) {
|
||||||
try {
|
try {
|
||||||
if (element instanceof PDOM) {
|
if (element instanceof ICProject) {
|
||||||
PDOM pdom = (PDOM)element;
|
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM((ICProject)element);
|
||||||
PDOMLinkage[] linkages = pdom.getLinkages();
|
PDOMLinkage[] linkages = pdom.getLinkages();
|
||||||
if (linkages.length == 0)
|
if (linkages.length == 0)
|
||||||
return false;
|
return false;
|
||||||
|
@ -229,11 +246,16 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getElements(Object inputElement) {
|
public Object[] getElements(Object inputElement) {
|
||||||
if (inputElement instanceof PDOM) {
|
try {
|
||||||
PDOM pdom = (PDOM)inputElement;
|
if (inputElement instanceof ICModel) {
|
||||||
return pdom.getLinkages();
|
ICModel model = (ICModel)inputElement;
|
||||||
} else
|
return model.getCProjects();
|
||||||
return new Object[0];
|
}
|
||||||
|
} catch (CModelException e) {
|
||||||
|
CUIPlugin.getDefault().log(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Object[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
|
@ -300,10 +322,15 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
||||||
viewer.setContentProvider(new IndexContentProvider());
|
viewer.setContentProvider(new IndexContentProvider());
|
||||||
viewer.setLabelProvider(new IndexLabelProvider());
|
viewer.setLabelProvider(new IndexLabelProvider());
|
||||||
|
|
||||||
|
ICModel model = CoreModel.getDefault().getCModel();
|
||||||
|
viewer.setInput(model);
|
||||||
try {
|
try {
|
||||||
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM();
|
ICProject[] projects = model.getCProjects();
|
||||||
pdom.addListener(this);
|
for (int i = 0; i < projects.length; ++i) {
|
||||||
viewer.setInput(pdom);
|
PDOM pdom = (PDOM)CCorePlugin.getPDOMManager().getPDOM(projects[i]);
|
||||||
|
pdom.addListener(this);
|
||||||
|
}
|
||||||
|
viewer.setChildCount(model, projects.length);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CUIPlugin.getDefault().log(e);
|
CUIPlugin.getDefault().log(e);
|
||||||
}
|
}
|
||||||
|
@ -340,7 +367,6 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
||||||
private void makeActions() {
|
private void makeActions() {
|
||||||
rebuildAction = new RebuildIndexAction(viewer);
|
rebuildAction = new RebuildIndexAction(viewer);
|
||||||
countSymbolsAction = new CountNodeAction(viewer);
|
countSymbolsAction = new CountNodeAction(viewer);
|
||||||
setFastIndexAction = new SetFastIndexerAction(viewer);
|
|
||||||
discardExternalDefsAction = new DiscardExternalDefsAction(viewer, this);
|
discardExternalDefsAction = new DiscardExternalDefsAction(viewer, this);
|
||||||
toggleLinkingAction = new ToggleLinkingAction(this);
|
toggleLinkingAction = new ToggleLinkingAction(this);
|
||||||
openDefinitionAction = new OpenDefinitionAction(viewer);
|
openDefinitionAction = new OpenDefinitionAction(viewer);
|
||||||
|
@ -366,8 +392,6 @@ public class IndexView extends ViewPart implements PDOM.IListener {
|
||||||
manager.add(rebuildAction);
|
manager.add(rebuildAction);
|
||||||
if (countSymbolsAction.valid())
|
if (countSymbolsAction.valid())
|
||||||
manager.add(countSymbolsAction);
|
manager.add(countSymbolsAction);
|
||||||
if (setFastIndexAction.valid())
|
|
||||||
manager.add(setFastIndexAction);
|
|
||||||
if (discardExternalDefsAction.valid())
|
if (discardExternalDefsAction.valid())
|
||||||
manager.add(discardExternalDefsAction);
|
manager.add(discardExternalDefsAction);
|
||||||
if (openDefinitionAction.valid())
|
if (openDefinitionAction.valid())
|
||||||
|
|
|
@ -12,7 +12,12 @@
|
||||||
package org.eclipse.cdt.internal.ui.indexview;
|
package org.eclipse.cdt.internal.ui.indexview;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.IPDOMIndexer;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.jface.viewers.ISelection;
|
||||||
|
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||||
import org.eclipse.jface.viewers.TreeViewer;
|
import org.eclipse.jface.viewers.TreeViewer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,11 +31,34 @@ public class RebuildIndexAction extends IndexAction {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
CCorePlugin.getPDOMManager().reindex();
|
ISelection selection = viewer.getSelection();
|
||||||
|
if (!(selection instanceof IStructuredSelection))
|
||||||
|
return;
|
||||||
|
|
||||||
|
Object[] objs = ((IStructuredSelection)selection).toArray();
|
||||||
|
for (int i = 0; i < objs.length; ++i) {
|
||||||
|
if (!(objs[i] instanceof ICProject))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
ICProject project = (ICProject)objs[i];
|
||||||
|
IPDOMIndexer indexer = CCorePlugin.getPDOMManager().getIndexer(project);
|
||||||
|
try {
|
||||||
|
indexer.reindex();
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CUIPlugin.getDefault().log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean valid() {
|
public boolean valid() {
|
||||||
return true;
|
ISelection selection = viewer.getSelection();
|
||||||
|
if (!(selection instanceof IStructuredSelection))
|
||||||
|
return false;
|
||||||
|
Object[] objs = ((IStructuredSelection)selection).toArray();
|
||||||
|
for (int i = 0; i < objs.length; ++i)
|
||||||
|
if (objs[i] instanceof ICProject)
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ 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.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
|
import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
|
@ -61,15 +62,16 @@ public class PDOMSearchPatternQuery extends PDOMSearchQuery {
|
||||||
|
|
||||||
public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
|
public IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
|
||||||
try {
|
try {
|
||||||
searchIndex(monitor);
|
for (int i = 0; i < projects.length; ++i)
|
||||||
|
searchProject(projects[i], monitor);
|
||||||
return Status.OK_STATUS;
|
return Status.OK_STATUS;
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
return e.getStatus();
|
return e.getStatus();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void searchIndex(IProgressMonitor monitor) throws CoreException {
|
private void searchProject(ICProject project, IProgressMonitor monitor) throws CoreException {
|
||||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM();
|
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(project);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
pdom.acquireReadLock();
|
pdom.acquireReadLock();
|
||||||
|
|
|
@ -117,17 +117,19 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
||||||
|
|
||||||
protected void createMatches(ILanguage language, IBinding binding) throws CoreException {
|
protected void createMatches(ILanguage language, IBinding binding) throws CoreException {
|
||||||
IPDOMManager manager = CCorePlugin.getPDOMManager();
|
IPDOMManager manager = CCorePlugin.getPDOMManager();
|
||||||
PDOM pdom = (PDOM)manager.getPDOM();
|
for (int i = 0; i < projects.length; ++i) {
|
||||||
PDOMBinding pdomBinding = (PDOMBinding)pdom.getLinkage(language).adaptBinding(binding);
|
PDOM pdom = (PDOM)manager.getPDOM(projects[i]);
|
||||||
if (pdomBinding != null) {
|
PDOMBinding pdomBinding = (PDOMBinding)pdom.getLinkage(language).adaptBinding(binding);
|
||||||
if ((flags & FIND_DECLARATIONS) != 0) {
|
if (pdomBinding != null) {
|
||||||
collectNames(pdomBinding.getFirstDeclaration());
|
if ((flags & FIND_DECLARATIONS) != 0) {
|
||||||
}
|
collectNames(pdomBinding.getFirstDeclaration());
|
||||||
if ((flags & FIND_DECLARATIONS) != 0) {
|
}
|
||||||
collectNames(pdomBinding.getFirstDefinition());
|
if ((flags & FIND_DECLARATIONS) != 0) {
|
||||||
}
|
collectNames(pdomBinding.getFirstDefinition());
|
||||||
if ((flags & FIND_REFERENCES) != 0) {
|
}
|
||||||
collectNames(pdomBinding.getFirstReference());
|
if ((flags & FIND_REFERENCES) != 0) {
|
||||||
|
collectNames(pdomBinding.getFirstReference());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class PDOMCompletionContributor extends DOMCompletionContributor implemen
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM();
|
IPDOM pdom = CCorePlugin.getPDOMManager().getPDOM(workingCopy.getCProject());
|
||||||
IASTName[] names = completionNode.getNames();
|
IASTName[] names = completionNode.getNames();
|
||||||
for (int i = 0; i < names.length; ++i) {
|
for (int i = 0; i < names.length; ++i) {
|
||||||
IASTName name = names[i];
|
IASTName name = names[i];
|
||||||
|
|
Loading…
Add table
Reference in a new issue