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