mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Pretty massive update to the PDOM. Made IBindings adaptable. Introducing the Index View.
This commit is contained in:
parent
7b6a596692
commit
a9d3047502
70 changed files with 1652 additions and 374 deletions
|
@ -9,22 +9,21 @@
|
|||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.dom;
|
||||
package org.eclipse.cdt.core.model;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public interface ILanguage {
|
||||
public interface ILanguage extends IAdaptable {
|
||||
|
||||
//public static final QualifiedName KEY = new QualifiedName(CCorePlugin.PLUGIN_ID, "language"); //$NON-NLS-1$
|
||||
public static final String KEY = "language"; //$NON-NLS-1$
|
||||
|
@ -74,24 +73,4 @@ public interface ILanguage {
|
|||
*/
|
||||
public ASTCompletionNode getCompletionNode(IWorkingCopy workingCopy, int offset);
|
||||
|
||||
/**
|
||||
* Return the PDOM Binding for the given name. Create a new one if necessary
|
||||
* and store it in the PDOM.
|
||||
*
|
||||
* @param binding
|
||||
* @return
|
||||
*/
|
||||
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, int languageId, IASTName name) throws CoreException;
|
||||
|
||||
/**
|
||||
* Creates a language specific binding given the generic binding extracted
|
||||
* from the PDOM database.
|
||||
*
|
||||
* @param pdom
|
||||
* @param binding
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, PDOMBinding binding) throws CoreException;
|
||||
|
||||
}
|
|
@ -12,7 +12,6 @@ package org.eclipse.cdt.core.model;
|
|||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ILanguage;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.model.IBufferFactory;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.core.dom;
|
||||
package org.eclipse.cdt.core.model;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
|
@ -16,12 +16,11 @@ import java.util.HashMap;
|
|||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ILanguage;
|
||||
import org.eclipse.cdt.core.dom.LanguageManager;
|
||||
import org.eclipse.cdt.core.model.CModelException;
|
||||
import org.eclipse.cdt.core.model.IBuffer;
|
||||
import org.eclipse.cdt.core.model.ICElement;
|
||||
import org.eclipse.cdt.core.model.IInclude;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.INamespace;
|
||||
import org.eclipse.cdt.core.model.IParent;
|
||||
import org.eclipse.cdt.core.model.IProblemRequestor;
|
||||
|
@ -30,6 +29,7 @@ import org.eclipse.cdt.core.model.ISourceReference;
|
|||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IUsing;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.core.model.LanguageManager;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
|
|
@ -10,10 +10,12 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast;
|
||||
|
||||
import org.eclipse.core.runtime.IAdaptable;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*/
|
||||
public interface IBinding {
|
||||
public interface IBinding extends IAdaptable {
|
||||
public static final IBinding[] EMPTY_BINDING_ARRAY = new IBinding[0];
|
||||
/**
|
||||
* The name of the binding.
|
||||
|
|
|
@ -32,4 +32,6 @@ public interface ICPPMember extends ICPPBinding{
|
|||
|
||||
public static final int v_public = ICPPASTVisiblityLabel.v_public;
|
||||
|
||||
public ICPPClassType getClassOwner() throws DOMException;
|
||||
|
||||
}
|
||||
|
|
|
@ -13,11 +13,11 @@ package org.eclipse.cdt.core.dom.ast.gnu.c;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.dom.ILanguage;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
|
@ -41,12 +41,13 @@ import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
|||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class GCCLanguage implements ILanguage {
|
||||
public class GCCLanguage extends PlatformObject implements ILanguage {
|
||||
|
||||
protected static final GCCScannerExtensionConfiguration C_GNU_SCANNER_EXTENSION = new GCCScannerExtensionConfiguration();
|
||||
|
||||
|
@ -105,8 +106,8 @@ public class GCCLanguage implements ILanguage {
|
|||
return null;
|
||||
}
|
||||
|
||||
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, PDOMBinding binding) throws CoreException {
|
||||
return binding;
|
||||
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, int record) throws CoreException {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -13,12 +13,12 @@ package org.eclipse.cdt.core.dom.ast.gnu.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.dom.ILanguage;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
|
@ -33,6 +33,7 @@ import org.eclipse.cdt.core.parser.ScannerInfo;
|
|||
import org.eclipse.cdt.internal.core.dom.SavedCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISourceCodeParser;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPField;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod;
|
||||
|
@ -44,23 +45,36 @@ import org.eclipse.cdt.internal.core.parser.scanner2.GPPScannerExtensionConfigur
|
|||
import org.eclipse.cdt.internal.core.parser.scanner2.IScannerExtensionConfiguration;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMCodeReaderFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPClassType;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPField;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPFunction;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPLinkageFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPVariable;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class GPPLanguage implements ILanguage {
|
||||
public class GPPLanguage extends PlatformObject implements ILanguage {
|
||||
|
||||
protected static final GPPScannerExtensionConfiguration CPP_GNU_SCANNER_EXTENSION = new GPPScannerExtensionConfiguration();
|
||||
public static final String ID = CCorePlugin.PLUGIN_ID + ".g++"; //$NON-NLS-1$
|
||||
|
||||
public String getId() {
|
||||
return CCorePlugin.PLUGIN_ID + ".g++"; //$NON-NLS-1$
|
||||
return ID;
|
||||
}
|
||||
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter == IPDOMLinkageFactory.class)
|
||||
return new PDOMCPPLinkageFactory();
|
||||
else
|
||||
return super.getAdapter(adapter);
|
||||
}
|
||||
|
||||
public IASTTranslationUnit getTranslationUnit(ITranslationUnit tu, int style) {
|
||||
|
@ -109,39 +123,4 @@ public class GPPLanguage implements ILanguage {
|
|||
return null;
|
||||
}
|
||||
|
||||
// Binding types
|
||||
public static final int CPPVARIABLE = 1;
|
||||
public static final int CPPFUNCTION = 2;
|
||||
|
||||
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, int languageId, IASTName name) throws CoreException {
|
||||
IBinding binding = name.resolveBinding();
|
||||
if (binding == null)
|
||||
return null;
|
||||
|
||||
if (binding instanceof CPPField) {
|
||||
return null;
|
||||
} else if (binding instanceof CPPVariable) {
|
||||
IScope scope = binding.getScope();
|
||||
if (!(scope instanceof CPPBlockScope))
|
||||
return new PDOMCPPVariable(pdom, languageId, name, (CPPVariable)binding);
|
||||
} else if (binding instanceof CPPMethod) {
|
||||
return null;
|
||||
} else if (binding instanceof CPPFunction) {
|
||||
return new PDOMCPPFunction(pdom, languageId, name, (CPPFunction)binding);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public PDOMBinding getPDOMBinding(PDOMDatabase pdom, PDOMBinding binding) throws CoreException {
|
||||
switch (binding.getBindingType()) {
|
||||
case CPPVARIABLE:
|
||||
return new PDOMCPPVariable(pdom, binding.getRecord());
|
||||
case CPPFUNCTION:
|
||||
return new PDOMCPPFunction(pdom, binding.getRecord());
|
||||
}
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPPointerType;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* This is the IASTBuiltinSymbolProvider used to implement the "Other" built-in GCC symbols defined:
|
||||
|
@ -2295,7 +2296,7 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
|
|||
return (IBinding[])ArrayUtil.trim(IBinding.class, bindings);
|
||||
}
|
||||
|
||||
public static class CBuiltinParameter implements IParameter {
|
||||
public static class CBuiltinParameter extends PlatformObject implements IParameter {
|
||||
|
||||
private static final String BLANK_STRING = ""; //$NON-NLS-1$
|
||||
private IType type=null;
|
||||
|
@ -2353,7 +2354,7 @@ public class GCCBuiltinSymbolProvider implements IASTBuiltinSymbolProvider {
|
|||
|
||||
}
|
||||
|
||||
static public class CPPBuiltinParameter implements ICPPParameter {
|
||||
static public class CPPBuiltinParameter extends PlatformObject implements ICPPParameter {
|
||||
|
||||
private static final String BLANK_STRING = ""; //$NON-NLS-1$
|
||||
private IType type=null;
|
||||
|
|
|
@ -26,11 +26,12 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPSemantics;
|
||||
import org.eclipse.cdt.internal.core.parser.ParserMessages;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class ProblemBinding implements IProblemBinding, IType, IScope {
|
||||
public class ProblemBinding extends PlatformObject implements IProblemBinding, IType, IScope {
|
||||
protected final int id;
|
||||
protected final char [] arg;
|
||||
protected IASTNode node;
|
||||
|
|
|
@ -28,11 +28,12 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTEnumerationSpecifier;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CEnumeration implements IEnumeration {
|
||||
public class CEnumeration extends PlatformObject implements IEnumeration {
|
||||
|
||||
private IASTName [] declarations = null;
|
||||
private IASTName definition = null;
|
||||
|
|
|
@ -24,11 +24,12 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CEnumerator implements IEnumerator {
|
||||
public class CEnumerator extends PlatformObject implements IEnumerator {
|
||||
public static class CEnumeratorProblem extends ProblemBinding implements IEnumerator {
|
||||
public CEnumeratorProblem( IASTNode node, int id, char[] arg ) {
|
||||
super( node, id, arg );
|
||||
|
|
|
@ -20,11 +20,12 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CExternalVariable implements ICExternalBinding, IVariable {
|
||||
public class CExternalVariable extends PlatformObject implements ICExternalBinding, IVariable {
|
||||
private IASTTranslationUnit tu;
|
||||
private IASTName name;
|
||||
/**
|
||||
|
|
|
@ -32,12 +32,13 @@ import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVisitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* Created on Nov 5, 2004
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CFunction implements IFunction, ICInternalFunction {
|
||||
public class CFunction extends PlatformObject implements IFunction, ICInternalFunction {
|
||||
private IASTStandardFunctionDeclarator [] declarators = null;
|
||||
private IASTFunctionDeclarator definition;
|
||||
|
||||
|
|
|
@ -20,13 +20,14 @@ import org.eclipse.cdt.core.dom.ast.IParameter;
|
|||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICASTTypedefNameSpecifier;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* A K&R C parameter.
|
||||
*
|
||||
* @author dsteffle
|
||||
*/
|
||||
public class CKnRParameter implements IParameter {
|
||||
public class CKnRParameter extends PlatformObject implements IParameter {
|
||||
final private IASTDeclaration declaration;
|
||||
final private IASTName name;
|
||||
|
||||
|
|
|
@ -21,11 +21,12 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.ILabel;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CLabel implements ILabel {
|
||||
public class CLabel extends PlatformObject implements ILabel {
|
||||
|
||||
public static class CLabelProblem extends ProblemBinding implements ILabel {
|
||||
public CLabelProblem( IASTNode node, int id, char[] arg ) {
|
||||
|
|
|
@ -27,12 +27,13 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* Created on Nov 5, 2004
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CParameter implements IParameter {
|
||||
public class CParameter extends PlatformObject implements IParameter {
|
||||
public static class CParameterProblem extends ProblemBinding implements IParameter {
|
||||
public CParameterProblem( IASTNode node, int id, char[] arg ) {
|
||||
super( node, id, arg );
|
||||
|
|
|
@ -31,12 +31,13 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.c.ICASTElaboratedTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* Created on Nov 8, 2004
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CStructure implements ICompositeType, ICInternalBinding {
|
||||
public class CStructure extends PlatformObject implements ICompositeType, ICInternalBinding {
|
||||
private IASTName [] declarations = null;
|
||||
private IASTName definition;
|
||||
|
||||
|
|
|
@ -19,12 +19,13 @@ import org.eclipse.cdt.core.dom.ast.IScope;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* Created on Nov 8, 2004
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CTypedef implements ITypedef, ITypeContainer {
|
||||
public class CTypedef extends PlatformObject implements ITypedef, ITypeContainer {
|
||||
private final IASTName name;
|
||||
private IType type = null;
|
||||
|
||||
|
|
|
@ -23,12 +23,13 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* Created on Nov 5, 2004
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CVariable implements IVariable, ICInternalBinding {
|
||||
public class CVariable extends PlatformObject implements IVariable, ICInternalBinding {
|
||||
public static class CVariableProblem extends ProblemBinding implements IVariable {
|
||||
public CVariableProblem( IASTNode node, int id, char[] arg ) {
|
||||
super( node, id, arg );
|
||||
|
|
|
@ -55,11 +55,12 @@ import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
|||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPClassType implements ICPPClassType, ICPPInternalClassType {
|
||||
public class CPPClassType extends PlatformObject implements ICPPClassType, ICPPInternalClassType {
|
||||
public static class CPPClassTypeDelegate extends CPPDelegate implements ICPPClassType, ICPPInternalClassType {
|
||||
public CPPClassTypeDelegate( IASTName name, ICPPClassType cls ){
|
||||
super( name, cls );
|
||||
|
|
|
@ -18,11 +18,12 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPCompositeBinding implements IBinding {
|
||||
public class CPPCompositeBinding extends PlatformObject implements IBinding {
|
||||
|
||||
IBinding [] bindings = null;
|
||||
|
||||
|
|
|
@ -21,11 +21,12 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
|||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPDelegate implements ICPPDelegate, ICPPInternalBinding {
|
||||
public class CPPDelegate extends PlatformObject implements ICPPDelegate, ICPPInternalBinding {
|
||||
private IBinding binding = null;
|
||||
private int type = 0;
|
||||
private IASTName name = null;
|
||||
|
|
|
@ -25,11 +25,12 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPEnumeration implements IEnumeration, ICPPInternalBinding {
|
||||
public class CPPEnumeration extends PlatformObject implements IEnumeration, ICPPInternalBinding {
|
||||
public static class CPPEnumerationDelegate extends CPPDelegate implements IEnumeration {
|
||||
public CPPEnumerationDelegate( IASTName name, IEnumeration binding ) {
|
||||
super( name, binding );
|
||||
|
|
|
@ -25,11 +25,12 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTEnumerationSpecifier.IASTEnumerator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPEnumerator implements IEnumerator, ICPPInternalBinding {
|
||||
public class CPPEnumerator extends PlatformObject implements IEnumerator, ICPPInternalBinding {
|
||||
public static class CPPEnumeratorDelegate extends CPPDelegate implements IEnumerator {
|
||||
public CPPEnumeratorDelegate( IASTName name, IEnumerator binding ) {
|
||||
super( name, binding );
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
|
@ -39,6 +40,9 @@ public class CPPField extends CPPVariable implements ICPPField, ICPPInternalBind
|
|||
public int getVisibility() throws DOMException {
|
||||
return ((ICPPField)getBinding()).getVisibility();
|
||||
}
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
return ((ICPPField)getBinding()).getClassOwner();
|
||||
}
|
||||
}
|
||||
public static class CPPFieldProblem extends CPPVariable.CPPVariableProblem implements ICPPField {
|
||||
/**
|
||||
|
@ -52,6 +56,9 @@ public class CPPField extends CPPVariable implements ICPPField, ICPPInternalBind
|
|||
public int getVisibility() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
public boolean isStatic() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
|
@ -123,6 +130,11 @@ public class CPPField extends CPPVariable implements ICPPField, ICPPInternalBind
|
|||
return ICPPASTVisiblityLabel.v_public;
|
||||
}
|
||||
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
ICPPClassScope scope = (ICPPClassScope) getScope();
|
||||
return scope.getClassType();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable#isMutable()
|
||||
*/
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
|
@ -41,16 +42,14 @@ public class CPPFieldSpecialization extends CPPSpecialization implements ICPPFie
|
|||
return (ICPPField) getSpecializedBinding();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#getVisibility()
|
||||
*/
|
||||
public int getVisibility() throws DOMException {
|
||||
return getField().getVisibility();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#getType()
|
||||
*/
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
return getField().getClassOwner();
|
||||
}
|
||||
|
||||
public IType getType() throws DOMException {
|
||||
if( type == null ){
|
||||
type = CPPTemplates.instantiateType( getField().getType(), argumentMap );
|
||||
|
@ -58,37 +57,22 @@ public class CPPFieldSpecialization extends CPPSpecialization implements ICPPFie
|
|||
return type;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isStatic()
|
||||
*/
|
||||
public boolean isStatic() throws DOMException {
|
||||
return getField().isStatic();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isExtern()
|
||||
*/
|
||||
public boolean isExtern() throws DOMException {
|
||||
return getField().isExtern();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isAuto()
|
||||
*/
|
||||
public boolean isAuto() throws DOMException {
|
||||
return getField().isAuto();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IVariable#isRegister()
|
||||
*/
|
||||
public boolean isRegister() throws DOMException {
|
||||
return getField().isRegister();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable#isMutable()
|
||||
*/
|
||||
public boolean isMutable() throws DOMException {
|
||||
return getField().isMutable();
|
||||
}
|
||||
|
|
|
@ -38,11 +38,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPFunction implements ICPPFunction, ICPPInternalFunction {
|
||||
public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInternalFunction {
|
||||
|
||||
public static class CPPFunctionDelegate extends CPPDelegate implements ICPPFunction, ICPPInternalFunction {
|
||||
public CPPFunctionDelegate( IASTName name, ICPPFunction binding ) {
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisiblityLabel;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
|
||||
|
@ -65,6 +66,11 @@ public class CPPImplicitMethod extends CPPImplicitFunction implements ICPPMethod
|
|||
return ICPPASTVisiblityLabel.v_public;
|
||||
}
|
||||
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
ICPPClassScope scope = (ICPPClassScope)getScope();
|
||||
return scope.getClassType();
|
||||
}
|
||||
|
||||
public IASTDeclaration getPrimaryDeclaration() throws DOMException{
|
||||
//first check if we already know it
|
||||
if( declarations != null ){
|
||||
|
|
|
@ -20,11 +20,12 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.ILabel;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPLabel implements ILabel, ICPPInternalBinding {
|
||||
public class CPPLabel extends PlatformObject implements ILabel, ICPPInternalBinding {
|
||||
private IASTName statement;
|
||||
/**
|
||||
* @param gotoStatement
|
||||
|
|
|
@ -45,6 +45,9 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
|
|||
public int getVisibility() throws DOMException {
|
||||
return ((ICPPMethod)getBinding()).getVisibility();
|
||||
}
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
return ((ICPPMethod)getBinding()).getClassOwner();
|
||||
}
|
||||
public boolean isVirtual() throws DOMException {
|
||||
return ((ICPPMethod)getBinding()).isVirtual();
|
||||
}
|
||||
|
@ -73,6 +76,9 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
|
|||
public int getVisibility() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
public boolean isStatic() throws DOMException {
|
||||
throw new DOMException( this );
|
||||
}
|
||||
|
@ -167,6 +173,11 @@ public class CPPMethod extends CPPFunction implements ICPPMethod {
|
|||
}
|
||||
return ICPPASTVisiblityLabel.v_public;
|
||||
}
|
||||
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
ICPPClassScope scope = (ICPPClassScope)getScope();
|
||||
return scope.getClassType();
|
||||
}
|
||||
|
||||
public IScope getScope() {
|
||||
IASTNode node = (declarations != null && declarations.length > 0) ? declarations[0] : definition;
|
||||
|
|
|
@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
@ -42,6 +43,10 @@ public class CPPMethodInstance extends CPPFunctionInstance implements ICPPMethod
|
|||
return ((ICPPMethod)getTemplateDefinition()).getVisibility();
|
||||
}
|
||||
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
return ((ICPPMethod)getTemplateDefinition()).getClassOwner();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isVirtual()
|
||||
*/
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
@ -36,9 +37,6 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization
|
|||
super(orig, scope, argMap );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isVirtual()
|
||||
*/
|
||||
public boolean isVirtual() throws DOMException {
|
||||
ICPPMethod f = (ICPPMethod) getSpecializedBinding();
|
||||
if( f != null )
|
||||
|
@ -62,9 +60,6 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization
|
|||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#getVisibility()
|
||||
*/
|
||||
public int getVisibility() throws DOMException {
|
||||
ICPPMethod f = (ICPPMethod) getSpecializedBinding();
|
||||
if( f != null )
|
||||
|
@ -72,9 +67,13 @@ public class CPPMethodSpecialization extends CPPFunctionSpecialization
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
|
||||
*/
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
ICPPMethod f = (ICPPMethod) getSpecializedBinding();
|
||||
if( f != null )
|
||||
return f.getClassOwner();
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isDestructor() {
|
||||
char[] name = getNameCharArray();
|
||||
if (name.length > 1 && name[0] == '~')
|
||||
|
|
|
@ -93,9 +93,6 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements
|
|||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#getVisibility()
|
||||
*/
|
||||
public int getVisibility() throws DOMException {
|
||||
IASTDeclaration decl = getPrimaryDeclaration();
|
||||
if( decl == null ){
|
||||
|
@ -125,18 +122,17 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements
|
|||
}
|
||||
return ICPPASTVisiblityLabel.v_public;
|
||||
}
|
||||
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
ICPPClassScope scope = (ICPPClassScope)getScope();
|
||||
return scope.getClassType();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isVirtual()
|
||||
*/
|
||||
public boolean isVirtual() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction#isInline()
|
||||
*/
|
||||
public boolean isInline() throws DOMException {
|
||||
IASTDeclaration decl = getPrimaryDeclaration();
|
||||
if( decl instanceof ICPPASTTemplateDeclaration && ((ICPPASTTemplateDeclaration)decl).getDeclaration() instanceof IASTFunctionDefinition )
|
||||
|
@ -145,9 +141,6 @@ public class CPPMethodTemplate extends CPPFunctionTemplate implements
|
|||
return super.isInline();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
|
||||
*/
|
||||
public boolean isDestructor() {
|
||||
char[] name = getNameCharArray();
|
||||
if (name.length > 1 && name[0] == '~')
|
||||
|
|
|
@ -16,6 +16,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
|
@ -37,27 +38,25 @@ public class CPPMethodTemplateSpecialization extends
|
|||
super(specialized, scope, argumentMap);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isVirtual()
|
||||
*/
|
||||
public boolean isVirtual() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMember#getVisibility()
|
||||
*/
|
||||
public int getVisibility() throws DOMException {
|
||||
IBinding m = getSpecializedBinding();
|
||||
if( m instanceof ICPPMethod )
|
||||
return ((ICPPMethod)m).getVisibility();
|
||||
return 0;
|
||||
}
|
||||
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
IBinding m = getSpecializedBinding();
|
||||
if( m instanceof ICPPMethod )
|
||||
return ((ICPPMethod)m).getClassOwner();
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod#isDestructor()
|
||||
*/
|
||||
public boolean isDestructor() {
|
||||
char[] name = getNameCharArray();
|
||||
if (name.length > 1 && name[0] == '~')
|
||||
|
|
|
@ -38,11 +38,12 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
|||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPNamespace implements ICPPNamespace, ICPPInternalBinding {
|
||||
public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPInternalBinding {
|
||||
public static class CPPNamespaceDelegate extends CPPDelegate implements ICPPNamespace {
|
||||
public CPPNamespaceDelegate( IASTName name, ICPPNamespace binding ) {
|
||||
super( name, binding );
|
||||
|
|
|
@ -24,11 +24,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceScope;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPNamespaceAlias implements ICPPNamespaceAlias, ICPPInternalBinding {
|
||||
public class CPPNamespaceAlias extends PlatformObject implements ICPPNamespaceAlias, ICPPInternalBinding {
|
||||
|
||||
private ICPPNamespace namespace;
|
||||
private IASTName alias;
|
||||
|
|
|
@ -29,11 +29,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPParameter implements ICPPParameter, ICPPInternalBinding {
|
||||
public class CPPParameter extends PlatformObject implements ICPPParameter, ICPPInternalBinding {
|
||||
public static class CPPParameterDelegate extends CPPDelegate implements ICPPParameter {
|
||||
public CPPParameterDelegate( IASTName name, IParameter binding ) {
|
||||
super( name, binding );
|
||||
|
|
|
@ -23,12 +23,13 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*
|
||||
*/
|
||||
public abstract class CPPSpecialization implements ICPPSpecialization, ICPPInternalBinding {
|
||||
public abstract class CPPSpecialization extends PlatformObject implements ICPPSpecialization, ICPPInternalBinding {
|
||||
private IBinding specialized;
|
||||
private ICPPScope scope;
|
||||
protected ObjectMap argumentMap;
|
||||
|
|
|
@ -43,11 +43,12 @@ import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
|||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public abstract class CPPTemplateDefinition implements ICPPTemplateDefinition, ICPPInternalTemplate {
|
||||
public abstract class CPPTemplateDefinition extends PlatformObject implements ICPPTemplateDefinition, ICPPInternalTemplate {
|
||||
public static final class CPPTemplateProblem extends ProblemBinding implements ICPPTemplateDefinition {
|
||||
public CPPTemplateProblem(IASTNode node, int id, char[] arg) {
|
||||
super(node, id, arg);
|
||||
|
|
|
@ -21,11 +21,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPTemplateParameter implements ICPPTemplateParameter, ICPPInternalBinding {
|
||||
public class CPPTemplateParameter extends PlatformObject implements ICPPTemplateParameter, ICPPInternalBinding {
|
||||
private IASTName [] declarations;
|
||||
|
||||
public CPPTemplateParameter( IASTName name ){
|
||||
|
|
|
@ -25,11 +25,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPTypedef implements ITypedef, ITypeContainer, ICPPInternalBinding {
|
||||
public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContainer, ICPPInternalBinding {
|
||||
public static class CPPTypedefDelegate extends CPPDelegate implements ITypedef, ITypeContainer {
|
||||
public CPPTypedefDelegate( IASTName name, ITypedef binding ) {
|
||||
super( name, binding );
|
||||
|
|
|
@ -24,11 +24,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope;
|
||||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPUnknownBinding implements ICPPInternalUnknown {
|
||||
public class CPPUnknownBinding extends PlatformObject implements ICPPInternalUnknown {
|
||||
private ICPPScope unknownScope = null;
|
||||
private IBinding scopeBinding = null;
|
||||
private ICPPScope scope = null;
|
||||
|
|
|
@ -25,11 +25,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPBlockScope;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPDelegate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPUsingDeclaration;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPUsingDeclaration implements ICPPUsingDeclaration, ICPPInternalBinding{
|
||||
public class CPPUsingDeclaration extends PlatformObject implements ICPPUsingDeclaration, ICPPInternalBinding{
|
||||
private IASTName name;
|
||||
private ICPPDelegate [] delegates;
|
||||
|
||||
|
|
|
@ -30,11 +30,12 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
|||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
/**
|
||||
* @author aniefer
|
||||
*/
|
||||
public class CPPVariable implements ICPPVariable, ICPPInternalBinding {
|
||||
public class CPPVariable extends PlatformObject implements ICPPVariable, ICPPInternalBinding {
|
||||
public static class CPPVariableDelegate extends CPPDelegate implements ICPPVariable {
|
||||
public CPPVariableDelegate( IASTName name, ICPPVariable binding ) {
|
||||
super( name, binding );
|
||||
|
|
|
@ -13,8 +13,9 @@ package org.eclipse.cdt.internal.core.parser.scanner2;
|
|||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
public class MacroBinding implements IMacroBinding {
|
||||
public class MacroBinding extends PlatformObject implements IMacroBinding {
|
||||
|
||||
private final char[] name;
|
||||
private final IScope scope;
|
||||
|
|
|
@ -10,27 +10,27 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.dom.ILanguage;
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.LanguageManager;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.model.ILanguage;
|
||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||
import org.eclipse.cdt.core.model.IWorkingCopy;
|
||||
import org.eclipse.cdt.core.model.LanguageManager;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMFile;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
|
@ -50,15 +50,10 @@ public class PDOMDatabase implements IPDOM {
|
|||
|
||||
private static final int VERSION = 0;
|
||||
|
||||
public static final int LANGUAGES = Database.DATA_AREA;
|
||||
public static final int LINKAGES = Database.DATA_AREA;
|
||||
public static final int FILE_INDEX = Database.DATA_AREA + 4;
|
||||
public static final int BINDING_INDEX = Database.DATA_AREA + 8;
|
||||
|
||||
private Map languageCache;
|
||||
private ILanguage[] languages;
|
||||
|
||||
private BTree fileIndex;
|
||||
private BTree bindingIndex;
|
||||
|
||||
private static final QualifiedName dbNameProperty
|
||||
= new QualifiedName(CCorePlugin.PLUGIN_ID, "dbName"); //$NON-NLS-1$
|
||||
|
@ -114,25 +109,21 @@ public class PDOMDatabase implements IPDOM {
|
|||
return fileIndex;
|
||||
}
|
||||
|
||||
public BTree getBindingIndex() throws CoreException {
|
||||
if (bindingIndex == null)
|
||||
bindingIndex = new BTree(getDB(), BINDING_INDEX);
|
||||
return bindingIndex;
|
||||
}
|
||||
|
||||
public void addSymbols(ITranslationUnit tu) throws CoreException {
|
||||
final ILanguage language = tu.getLanguage();
|
||||
if (language == null)
|
||||
return;
|
||||
|
||||
final int languageId = getLanguageId(language);
|
||||
final PDOMLinkage linkage = getLinkage(language);
|
||||
if (linkage == null)
|
||||
return;
|
||||
|
||||
IASTTranslationUnit ast = language.getTranslationUnit(tu,
|
||||
ILanguage.AST_USE_INDEX |
|
||||
ILanguage.AST_SKIP_INDEXED_HEADERS);
|
||||
|
||||
if (ast == null)
|
||||
return;
|
||||
|
||||
|
||||
ast.accept(new ASTVisitor() {
|
||||
{
|
||||
shouldVisitNames = true;
|
||||
|
@ -141,11 +132,7 @@ public class PDOMDatabase implements IPDOM {
|
|||
|
||||
public int visit(IASTName name) {
|
||||
try {
|
||||
if (name.toCharArray().length > 0) {
|
||||
PDOMBinding binding = language.getPDOMBinding(PDOMDatabase.this, languageId, name);
|
||||
if (binding != null)
|
||||
new PDOMName(PDOMDatabase.this, name, binding);
|
||||
}
|
||||
linkage.addName(name);
|
||||
return PROCESS_CONTINUE;
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
|
@ -167,10 +154,7 @@ public class PDOMDatabase implements IPDOM {
|
|||
|
||||
public void delete() throws CoreException {
|
||||
getDB().clear();
|
||||
bindingIndex = null;
|
||||
fileIndex = null;
|
||||
languageCache = null;
|
||||
languages = null;
|
||||
}
|
||||
|
||||
public ICodeReaderFactory getCodeReaderFactory() {
|
||||
|
@ -203,49 +187,42 @@ public class PDOMDatabase implements IPDOM {
|
|||
return new IBinding[0];
|
||||
}
|
||||
|
||||
private void initLanguageMap() throws CoreException {
|
||||
// load in the languages
|
||||
languageCache = new HashMap();
|
||||
int record = db.getInt(LANGUAGES);
|
||||
PDOMLanguage lang = null;
|
||||
if (record != 0)
|
||||
lang = new PDOMLanguage(this, record);
|
||||
while (lang != null) {
|
||||
languageCache.put(lang.getName(), lang);
|
||||
lang = lang.getNext();
|
||||
public PDOMLinkage getLinkage(ILanguage language) throws CoreException {
|
||||
IPDOMLinkageFactory factory = (IPDOMLinkageFactory)language.getAdapter(IPDOMLinkageFactory.class);
|
||||
String id = language.getId();
|
||||
int linkrec = db.getInt(LINKAGES);
|
||||
while (linkrec != 0) {
|
||||
if (id.equals(PDOMLinkage.getId(this, linkrec))) {
|
||||
return factory.getLinkage(this, linkrec);
|
||||
}
|
||||
}
|
||||
|
||||
// map language ids to ILanguage impls.
|
||||
languages = new ILanguage[languageCache.size() + 1]; // + 1 for the empty zero
|
||||
Iterator i = languageCache.values().iterator();
|
||||
while (i.hasNext()) {
|
||||
lang = (PDOMLanguage)i.next();
|
||||
languages[lang.getId()] = LanguageManager.getInstance().getLanguage(lang.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public int getLanguageId(ILanguage language) throws CoreException {
|
||||
if (languageCache == null)
|
||||
initLanguageMap();
|
||||
PDOMLanguage pdomLang = (PDOMLanguage)languageCache.get(language.getId());
|
||||
if (pdomLang == null) {
|
||||
// add it in
|
||||
int next = db.getInt(LANGUAGES);
|
||||
int id = next == 0 ? 1 : new PDOMLanguage(this, next).getId() + 1;
|
||||
pdomLang = new PDOMLanguage(this, language.getId(), id, next);
|
||||
db.putInt(LANGUAGES, pdomLang.getRecord());
|
||||
ILanguage[] oldlangs = languages;
|
||||
languages = new ILanguage[id + 1];
|
||||
System.arraycopy(oldlangs, 0, languages, 0, id);
|
||||
languages[id] = language;
|
||||
return id;
|
||||
} else
|
||||
return pdomLang.getId();
|
||||
return factory.createLinkage(this);
|
||||
}
|
||||
|
||||
public ILanguage getLanguage(int id) throws CoreException {
|
||||
if (languages == null)
|
||||
initLanguageMap();
|
||||
return languages[id];
|
||||
public PDOMLinkage getLinkage(int record) throws CoreException {
|
||||
if (record == 0)
|
||||
return null;
|
||||
|
||||
String id = PDOMLinkage.getId(this, record);
|
||||
ILanguage language = LanguageManager.getInstance().getLanguage(id);
|
||||
return getLinkage(language);
|
||||
}
|
||||
|
||||
public PDOMLinkage getFirstLinkage() throws CoreException {
|
||||
return getLinkage(db.getInt(LINKAGES));
|
||||
}
|
||||
|
||||
public void insertLinkage(PDOMLinkage linkage) throws CoreException {
|
||||
linkage.setNext(db.getInt(LINKAGES));
|
||||
db.putInt(LINKAGES, linkage.getRecord());
|
||||
}
|
||||
|
||||
public PDOMBinding getBinding(int record) throws CoreException {
|
||||
if (record == 0)
|
||||
return null;
|
||||
else
|
||||
return PDOMLinkage.getLinkage(this, record).getBinding(record);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,8 +18,8 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*/
|
||||
public class BTree {
|
||||
|
||||
protected Database db;
|
||||
protected int rootPointer;
|
||||
protected final Database db;
|
||||
protected final int rootPointer;
|
||||
|
||||
protected static final int NUM_RECORDS = 15;
|
||||
protected static final int MEDIAN_RECORD = NUM_RECORDS / 2;
|
||||
|
|
|
@ -271,16 +271,28 @@ public class Database {
|
|||
chunk.putChars(offset, value);
|
||||
}
|
||||
|
||||
public int putChars(char[] value) throws CoreException {
|
||||
int record = malloc((value.length + 1) * 2);
|
||||
putChars(record, value);
|
||||
return record;
|
||||
}
|
||||
|
||||
public char[] getChars(int offset) throws CoreException {
|
||||
Chunk chunk = getChunk(offset);
|
||||
return chunk.getChars(offset);
|
||||
}
|
||||
|
||||
|
||||
public void putString(int offset, String value) throws CoreException {
|
||||
Chunk chunk = getChunk(offset);
|
||||
chunk.putString(offset, value);
|
||||
}
|
||||
|
||||
public int putString(String value) throws CoreException {
|
||||
int record = malloc((value.length() + 1) * 2);
|
||||
putString(record, value);
|
||||
return record;
|
||||
}
|
||||
|
||||
public String getString(int offset) throws CoreException {
|
||||
Chunk chunk = getChunk(offset);
|
||||
return chunk.getString(offset);
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public interface IPDOMLinkageFactory {
|
||||
|
||||
public PDOMLinkage getLinkage(PDOMDatabase pdom, int record);
|
||||
|
||||
public PDOMLinkage createLinkage(PDOMDatabase pdom) throws CoreException;
|
||||
|
||||
}
|
|
@ -11,131 +11,70 @@
|
|||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ILanguage;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMBinding implements IBinding {
|
||||
public abstract class PDOMBinding extends PDOMNode implements IBinding {
|
||||
|
||||
protected final PDOMDatabase pdom;
|
||||
protected int record;
|
||||
private static final int TYPE_OFFSET = PDOMNode.RECORD_SIZE + 4; // size 4
|
||||
private static final int FIRST_DECL_OFFSET = PDOMNode.RECORD_SIZE + 8; // size 4
|
||||
private static final int FIRST_DEF_OFFSET = PDOMNode.RECORD_SIZE + 12; // size 4
|
||||
private static final int FIRST_REF_OFFSET = PDOMNode.RECORD_SIZE + 16; // size 4
|
||||
|
||||
private static final int STRING_REC_OFFSET = 0; // size 4
|
||||
private static final int FIRST_DECL_OFFSET = 4; // size 4
|
||||
private static final int FIRST_DEF_OFFSET = 8; // size 4
|
||||
private static final int FIRST_REF_OFFSET = 12; // size 4
|
||||
private static final int LANGUAGE_OFFSET = 16; // size 2
|
||||
private static final int TYPE_OFFSET = 18; // size 2
|
||||
protected static final int RECORD_SIZE = PDOMNode.RECORD_SIZE + 20;
|
||||
|
||||
protected int getRecordSize() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
public static class Comparator implements IBTreeComparator {
|
||||
|
||||
private Database db;
|
||||
|
||||
public Comparator(Database db) {
|
||||
this.db = db;
|
||||
}
|
||||
|
||||
public int compare(int record1, int record2) throws CoreException {
|
||||
int string1 = db.getInt(record1 + STRING_REC_OFFSET);
|
||||
int string2 = db.getInt(record2 + STRING_REC_OFFSET);
|
||||
// Need to deal with language and type
|
||||
|
||||
return db.stringCompare(string1, string2);
|
||||
}
|
||||
protected PDOMBinding(PDOMDatabase pdom, PDOMNode parent, IASTName name, int type) throws CoreException {
|
||||
super(pdom, parent, name.toCharArray());
|
||||
Database db = pdom.getDB();
|
||||
|
||||
// Binding type
|
||||
db.putInt(record + TYPE_OFFSET, type);
|
||||
}
|
||||
|
||||
public abstract static class Visitor implements IBTreeVisitor {
|
||||
|
||||
private Database db;
|
||||
private char[] key;
|
||||
|
||||
public Visitor(Database db, char[] key, int language, int type) {
|
||||
this.db = db;
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public int compare(int record1) throws CoreException {
|
||||
int string1 = db.getInt(record1 + STRING_REC_OFFSET);
|
||||
// Need to deal with language and type
|
||||
|
||||
return db.stringCompare(string1, key);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class FindVisitor extends Visitor {
|
||||
|
||||
private int record;
|
||||
|
||||
public FindVisitor(Database db, char[] stringKey, int language, int type) {
|
||||
super(db, stringKey, language, type);
|
||||
}
|
||||
|
||||
public boolean visit(int record) throws CoreException {
|
||||
this.record = record;
|
||||
return false;
|
||||
}
|
||||
|
||||
public int findIn(BTree btree) throws CoreException {
|
||||
btree.visit(this);
|
||||
return record;
|
||||
}
|
||||
|
||||
public PDOMBinding(PDOMDatabase pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
||||
public PDOMBinding(PDOMDatabase pdom, IASTName name, int language, int type) throws CoreException {
|
||||
this.pdom = pdom;
|
||||
|
||||
char[] namechars = name.toCharArray();
|
||||
|
||||
BTree index = pdom.getBindingIndex();
|
||||
record = new FindVisitor(pdom.getDB(), namechars, language, type).findIn(index);
|
||||
|
||||
if (record == 0) {
|
||||
Database db = pdom.getDB();
|
||||
record = db.malloc(getRecordSize());
|
||||
|
||||
db.putChar(record + LANGUAGE_OFFSET, (char)language);
|
||||
db.putChar(record + TYPE_OFFSET, (char)type);
|
||||
|
||||
int stringRecord = db.malloc((namechars.length + 1) * Database.CHAR_SIZE);
|
||||
db.putChars(stringRecord, namechars);
|
||||
|
||||
db.putInt(record + STRING_REC_OFFSET, stringRecord);
|
||||
pdom.getBindingIndex().insert(record, new Comparator(db));
|
||||
}
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter == PDOMBinding.class)
|
||||
return this;
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
public PDOMBinding(PDOMDatabase pdom, int bindingRecord) {
|
||||
this.pdom = pdom;
|
||||
this.record = bindingRecord;
|
||||
|
||||
public static int getBindingType(PDOMDatabase pdom, int record) throws CoreException {
|
||||
return pdom.getDB().getInt(record + TYPE_OFFSET);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the binding as the record orphaned, i.e., has no declarations
|
||||
* or references.
|
||||
*
|
||||
* @param pdom
|
||||
* @param record
|
||||
* @return
|
||||
* @throws CoreException
|
||||
*/
|
||||
public static boolean isOrphaned(PDOMDatabase pdom, int record) throws CoreException {
|
||||
Database db = pdom.getDB();
|
||||
return db.getInt(record + FIRST_DECL_OFFSET) == 0
|
||||
&& db.getInt(record + FIRST_DEF_OFFSET) == 0
|
||||
&& db.getInt(record + FIRST_REF_OFFSET) == 0;
|
||||
}
|
||||
|
||||
public int getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
public ILanguage getLanguage() throws CoreException {
|
||||
return pdom.getLanguage(pdom.getDB().getChar(record + LANGUAGE_OFFSET));
|
||||
}
|
||||
|
||||
public int getBindingType() throws CoreException {
|
||||
return pdom.getDB().getChar(record + TYPE_OFFSET);
|
||||
}
|
||||
|
@ -205,9 +144,7 @@ public class PDOMBinding implements IBinding {
|
|||
|
||||
public String getName() {
|
||||
try {
|
||||
Database db = pdom.getDB();
|
||||
int stringRecord = db.getInt(record + STRING_REC_OFFSET);
|
||||
return db.getString(stringRecord);
|
||||
return super.getName();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
|
@ -216,27 +153,20 @@ public class PDOMBinding implements IBinding {
|
|||
|
||||
public char[] getNameCharArray() {
|
||||
try {
|
||||
Database db = pdom.getDB();
|
||||
int stringRecord = db.getInt(record + STRING_REC_OFFSET);
|
||||
return db.getChars(stringRecord);
|
||||
return super.getNameCharArray();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
}
|
||||
return new char[0];
|
||||
}
|
||||
|
||||
public boolean hasName(char[] name) throws CoreException {
|
||||
return pdom.getDB().stringCompare(getNameRecord(), name) == 0;
|
||||
}
|
||||
|
||||
public IScope getScope() throws DOMException {
|
||||
// TODO implement this
|
||||
return null;
|
||||
}
|
||||
|
||||
public static PDOMBinding find(PDOMDatabase pdom, char[] name, int language, int type) throws CoreException {
|
||||
BTree index = pdom.getBindingIndex();
|
||||
int bindingRecord = new FindVisitor(pdom.getDB(), name, language, type).findIn(index);
|
||||
if (bindingRecord != 0)
|
||||
return new PDOMBinding(pdom, bindingRecord);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IAdapterFactory;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
* This factory adapts IBinding object to PDOMBinding object
|
||||
*/
|
||||
public class PDOMBindingAdapterFactory implements IAdapterFactory {
|
||||
|
||||
public Object getAdapter(Object adaptableObject, Class adapterType) {
|
||||
if (adaptableObject instanceof PDOMBinding)
|
||||
return adaptableObject;
|
||||
|
||||
try {
|
||||
IBinding binding = (IBinding)adaptableObject;
|
||||
IScope scope = binding.getScope();
|
||||
IPDOM ipdom = scope.getPhysicalNode().getTranslationUnit().getIndex();
|
||||
if (ipdom == null)
|
||||
return null;
|
||||
PDOMDatabase pdom = (PDOMDatabase)ipdom;
|
||||
|
||||
for (PDOMLinkage linkage = pdom.getFirstLinkage(); linkage != null; linkage = linkage.getNextLinkage()) {
|
||||
PDOMBinding pdomBinding = linkage.adaptBinding(binding);
|
||||
if (binding != null)
|
||||
return pdomBinding;
|
||||
}
|
||||
return null;
|
||||
} catch (DOMException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static Class[] adapterList = {
|
||||
PDOMBinding.class
|
||||
};
|
||||
|
||||
public Class[] getAdapterList() {
|
||||
return adapterList;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,86 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
* This class represents a collection of symbols that can be linked together at
|
||||
* link time. These are generally global symbols specific to a given language.
|
||||
*/
|
||||
public abstract class PDOMLinkage extends PDOMNode {
|
||||
|
||||
private static final int ID_OFFSET = PDOMNode.RECORD_SIZE + 0;
|
||||
private static final int NEXT_OFFSET = PDOMNode.RECORD_SIZE + 4;
|
||||
private static final int INDEX_OFFSET = PDOMNode.RECORD_SIZE + 8;
|
||||
|
||||
protected static final int RECORD_SIZE = PDOMNode.RECORD_SIZE + 12;
|
||||
|
||||
public PDOMLinkage(PDOMDatabase pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
||||
protected PDOMLinkage(PDOMDatabase pdom, String languageId, char[] name) throws CoreException {
|
||||
super(pdom, null, name);
|
||||
Database db = pdom.getDB();
|
||||
|
||||
// id
|
||||
int idrec = db.putString(languageId);
|
||||
db.putInt(record + ID_OFFSET, idrec);
|
||||
|
||||
pdom.insertLinkage(this);
|
||||
}
|
||||
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
public static String getId(PDOMDatabase pdom, int record) throws CoreException {
|
||||
Database db = pdom.getDB();
|
||||
int namerec = db.getInt(record + ID_OFFSET);
|
||||
return db.getString(namerec);
|
||||
}
|
||||
|
||||
public PDOMLinkage getNextLinkage() throws CoreException {
|
||||
return pdom.getLinkage(pdom.getDB().getInt(record + NEXT_OFFSET));
|
||||
}
|
||||
|
||||
public void setNext(int nextrec) throws CoreException {
|
||||
pdom.getDB().putInt(record + NEXT_OFFSET, nextrec);
|
||||
}
|
||||
|
||||
public BTree getIndex() throws CoreException {
|
||||
return new BTree(pdom.getDB(), record + INDEX_OFFSET);
|
||||
}
|
||||
|
||||
public PDOMLinkage getLinkage() throws CoreException {
|
||||
return this;
|
||||
}
|
||||
|
||||
protected void addChild(PDOMNode child) throws CoreException {
|
||||
getIndex().insert(child.getRecord(), child.getIndexComparator());
|
||||
}
|
||||
|
||||
public abstract PDOMBinding addName(IASTName name) throws CoreException;
|
||||
|
||||
public abstract PDOMBinding adaptBinding(IBinding binding) throws CoreException;
|
||||
|
||||
public abstract PDOMBinding getBinding(int record) throws CoreException;
|
||||
|
||||
}
|
|
@ -0,0 +1,69 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.cpp.PDOMCPPClassType;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public abstract class PDOMMember extends PDOMBinding {
|
||||
|
||||
private static final int OWNER = PDOMBinding.RECORD_SIZE + 0;
|
||||
private static final int NEXT_MEMBER = PDOMBinding.RECORD_SIZE + 4;
|
||||
private static final int PREV_MEMBER = PDOMBinding.RECORD_SIZE + 8;
|
||||
|
||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 12;
|
||||
|
||||
public PDOMMember(PDOMDatabase pdom, PDOMNode parent, IASTName name, int type) throws CoreException {
|
||||
super(pdom, parent, name, type);
|
||||
}
|
||||
|
||||
public PDOMMember(PDOMDatabase pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
||||
public PDOMMember getNextMember() throws CoreException {
|
||||
return (PDOMMember)getLinkage().getBinding(
|
||||
pdom.getDB().getInt(record + NEXT_MEMBER));
|
||||
}
|
||||
|
||||
public void setNextMember(PDOMMember member) throws CoreException {
|
||||
pdom.getDB().putInt(record + NEXT_MEMBER,
|
||||
member != null ? member.getRecord() : 0);
|
||||
}
|
||||
|
||||
public PDOMMember getPrevMember() throws CoreException {
|
||||
return (PDOMMember)getLinkage().getBinding(
|
||||
pdom.getDB().getInt(record + PREV_MEMBER));
|
||||
}
|
||||
|
||||
public void setPrevMember(PDOMMember member) throws CoreException {
|
||||
pdom.getDB().putInt(record + PREV_MEMBER,
|
||||
member != null ? member.getRecord() : 0);
|
||||
}
|
||||
|
||||
public PDOMMemberOwner getMemberOwner() throws CoreException {
|
||||
return (PDOMCPPClassType)getLinkage().getBinding(
|
||||
pdom.getDB().getInt(record + OWNER));
|
||||
}
|
||||
|
||||
public void setMemberOwner(PDOMMemberOwner owner) throws CoreException {
|
||||
pdom.getDB().putInt(record + OWNER,
|
||||
owner != null ? owner.getRecord() : 0);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMMemberOwner extends PDOMBinding {
|
||||
|
||||
private static final int FIRST_MEMBER = PDOMBinding.RECORD_SIZE + 0;
|
||||
|
||||
protected static final int RECORD_SIZE = PDOMBinding.RECORD_SIZE + 4;
|
||||
|
||||
public PDOMMemberOwner(PDOMDatabase pdom, PDOMNode parent, IASTName name,
|
||||
int type) throws CoreException {
|
||||
super(pdom, parent, name, type);
|
||||
}
|
||||
|
||||
public PDOMMemberOwner(PDOMDatabase pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
public void addMember(PDOMMember member) throws CoreException {
|
||||
PDOMMember first = getFirstMember();
|
||||
if (first != null) {
|
||||
first.setPrevMember(member);
|
||||
member.setNextMember(first);
|
||||
}
|
||||
setFirstMember(member);
|
||||
member.setMemberOwner(this);
|
||||
}
|
||||
|
||||
public PDOMMember getFirstMember() throws CoreException {
|
||||
return (PDOMMember)getLinkage().getBinding(
|
||||
pdom.getDB().getInt(record + FIRST_MEMBER));
|
||||
}
|
||||
|
||||
public void setFirstMember(PDOMMember member) throws CoreException {
|
||||
int memberrec = member != null ? member.getRecord() : 0;
|
||||
pdom.getDB().putInt(record + FIRST_MEMBER, memberrec);
|
||||
}
|
||||
|
||||
public int getNumMembers() throws CoreException {
|
||||
int n = 0;
|
||||
|
||||
for (PDOMMember member = getFirstMember(); member != null; member = member.getNextMember())
|
||||
++n;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
public PDOMMember[] findMembers(char[] name) throws CoreException {
|
||||
ArrayList members = new ArrayList();
|
||||
|
||||
for (PDOMMember member = getFirstMember(); member != null; member = member.getNextMember())
|
||||
if (member.hasName(name))
|
||||
members.add(member);
|
||||
|
||||
return (PDOMMember[])members.toArray(new PDOMMember[members.size()]);
|
||||
}
|
||||
|
||||
}
|
|
@ -117,7 +117,7 @@ public class PDOMName implements IASTName, IASTFileLocation {
|
|||
|
||||
public PDOMBinding getPDOMBinding() throws CoreException {
|
||||
int bindingrec = getRecField(BINDING_REC_OFFSET);
|
||||
return bindingrec != 0 ? new PDOMBinding(pdom, bindingrec) : null;
|
||||
return pdom.getBinding(bindingrec);
|
||||
}
|
||||
|
||||
public void setBinding(PDOMBinding binding) throws CoreException {
|
||||
|
@ -175,7 +175,7 @@ public class PDOMName implements IASTName, IASTFileLocation {
|
|||
public IBinding resolveBinding() {
|
||||
try {
|
||||
int bindingRecord = pdom.getDB().getInt(record + BINDING_REC_OFFSET);
|
||||
return new PDOMBinding(pdom, bindingRecord);
|
||||
return pdom.getBinding(bindingRecord);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
|
@ -198,10 +198,8 @@ public class PDOMName implements IASTName, IASTFileLocation {
|
|||
try {
|
||||
Database db = pdom.getDB();
|
||||
int bindingRec = db.getInt(record + BINDING_REC_OFFSET);
|
||||
if (bindingRec == 0)
|
||||
return null;
|
||||
|
||||
return new PDOMBinding(pdom, bindingRec).getNameCharArray();
|
||||
PDOMBinding binding = pdom.getBinding(bindingRec);
|
||||
return binding != null ? binding.getNameCharArray() : null;
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom;
|
||||
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeComparator;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
* This is a basic node in the PDOM database.
|
||||
* PDOM nodes form a multi-root tree with linkages being the roots.
|
||||
* This class managed the parent pointer.
|
||||
*/
|
||||
public abstract class PDOMNode {
|
||||
|
||||
private static final int PARENT_OFFSET = 0;
|
||||
private static final int NAME_OFFSET = 4;
|
||||
|
||||
protected static final int RECORD_SIZE = 8;
|
||||
|
||||
protected final PDOMDatabase pdom;
|
||||
protected final int record;
|
||||
|
||||
protected PDOMNode(PDOMDatabase pdom, int record) {
|
||||
this.pdom = pdom;
|
||||
this.record = record;
|
||||
}
|
||||
|
||||
protected PDOMNode(PDOMDatabase pdom, PDOMNode parent, char[] name) throws CoreException {
|
||||
this.pdom = pdom;
|
||||
Database db = pdom.getDB();
|
||||
|
||||
record = db.malloc(getRecordSize());
|
||||
|
||||
// name - must be before parent
|
||||
int namerec = db.putChars(name);
|
||||
db.putInt(record + NAME_OFFSET, namerec);
|
||||
|
||||
// parent
|
||||
if (parent != null) {
|
||||
pdom.getDB().putInt(record + PARENT_OFFSET, parent.getRecord());
|
||||
parent.addChild(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected abstract int getRecordSize();
|
||||
|
||||
public PDOMDatabase getPDOM() {
|
||||
return pdom;
|
||||
}
|
||||
|
||||
public int getRecord() {
|
||||
return record;
|
||||
}
|
||||
|
||||
public PDOMLinkage getLinkage() throws CoreException {
|
||||
return getLinkage(pdom, record);
|
||||
}
|
||||
|
||||
public static PDOMLinkage getLinkage(PDOMDatabase pdom, int record) throws CoreException {
|
||||
Database db = pdom.getDB();
|
||||
int linkagerec = record;
|
||||
int parentrec = db.getInt(linkagerec + PARENT_OFFSET);
|
||||
while (parentrec != 0) {
|
||||
linkagerec = parentrec;
|
||||
parentrec = db.getInt(linkagerec + PARENT_OFFSET);
|
||||
}
|
||||
|
||||
return pdom.getLinkage(linkagerec);
|
||||
}
|
||||
|
||||
public String getName() throws CoreException {
|
||||
Database db = pdom.getDB();
|
||||
int namerec = db.getInt(record + NAME_OFFSET);
|
||||
return db.getString(namerec);
|
||||
}
|
||||
|
||||
public char[] getNameCharArray() throws CoreException {
|
||||
Database db = pdom.getDB();
|
||||
int namerec = db.getInt(record + NAME_OFFSET);
|
||||
return db.getChars(namerec);
|
||||
}
|
||||
|
||||
protected int getNameRecord() throws CoreException {
|
||||
return pdom.getDB().getInt(record + NAME_OFFSET);
|
||||
}
|
||||
|
||||
protected void addChild(PDOMNode child) throws CoreException {
|
||||
// by defaut do nothing
|
||||
}
|
||||
|
||||
public boolean hasName(char[] name) throws CoreException {
|
||||
Database db = pdom.getDB();
|
||||
int namerec = db.getInt(record + NAME_OFFSET);
|
||||
return pdom.getDB().stringCompare(namerec, name) == 0;
|
||||
}
|
||||
|
||||
public IBTreeComparator getIndexComparator() {
|
||||
return new IBTreeComparator() {
|
||||
public int compare(int record1, int record2) throws CoreException {
|
||||
Database db = pdom.getDB();
|
||||
int string1 = db.getInt(record1 + NAME_OFFSET);
|
||||
int string2 = db.getInt(record2 + NAME_OFFSET);
|
||||
return db.stringCompare(string1, string2);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
public abstract static class NodeVisitor implements IBTreeVisitor {
|
||||
protected final PDOMDatabase pdom;
|
||||
protected final char[] name;
|
||||
protected NodeVisitor(PDOMDatabase pdom, char [] name) {
|
||||
this.pdom = pdom;
|
||||
this.name = name;
|
||||
}
|
||||
public int compare(int record) throws CoreException {
|
||||
Database db = pdom.getDB();
|
||||
int namerec = db.getInt(record + NAME_OFFSET);
|
||||
return db.stringCompare(namerec, name);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,119 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IField;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPClassType extends PDOMMemberOwner implements ICPPClassType {
|
||||
|
||||
protected static final int RECORD_SIZE = PDOMMemberOwner.RECORD_SIZE + 0;
|
||||
|
||||
public PDOMCPPClassType(PDOMDatabase pdom, PDOMNode parent, IASTName name) throws CoreException {
|
||||
super(pdom, parent, name, PDOMCPPLinkage.CPPCLASSTYPE);
|
||||
}
|
||||
|
||||
public PDOMCPPClassType(PDOMDatabase pdom, int bindingRecord) {
|
||||
super(pdom, bindingRecord);
|
||||
}
|
||||
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
public boolean isSameType(IType type) {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public Object clone() {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IField findField(String name) throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public ICPPMethod[] getAllDeclaredMethods() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public ICPPBase[] getBases() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public ICPPConstructor[] getConstructors() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public ICPPField[] getDeclaredFields() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public ICPPMethod[] getDeclaredMethods() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IField[] getFields() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IBinding[] getFriends() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public ICPPMethod[] getMethods() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public ICPPClassType[] getNestedClasses() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IScope getCompositeScope() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public int getKey() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,94 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMMember;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPField extends PDOMMember implements ICPPField {
|
||||
|
||||
public PDOMCPPField(PDOMDatabase pdom, PDOMNode parent, IASTName name)
|
||||
throws CoreException {
|
||||
super(pdom, parent, name, PDOMCPPLinkage.CPPFIELD);
|
||||
}
|
||||
|
||||
public PDOMCPPField(PDOMDatabase pdom, int bindingRecord) {
|
||||
super(pdom, bindingRecord);
|
||||
}
|
||||
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
public ICPPClassType getClassOwner() throws DOMException {
|
||||
try {
|
||||
return (ICPPClassType)getMemberOwner();
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public int getVisibility() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isMutable() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public IType getType() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isAuto() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isExtern() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isRegister() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
public boolean isStatic() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
||||
}
|
|
@ -17,10 +17,10 @@ import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
|||
import org.eclipse.cdt.core.dom.ast.IParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -30,25 +30,18 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*/
|
||||
public class PDOMCPPFunction extends PDOMBinding implements ICPPFunction {
|
||||
|
||||
/**
|
||||
* @param pdom
|
||||
* @param name
|
||||
* @param language
|
||||
* @param type
|
||||
* @throws CoreException
|
||||
*/
|
||||
public PDOMCPPFunction(PDOMDatabase pdom, int languageId, IASTName name, CPPFunction binding) throws CoreException {
|
||||
super(pdom, name, languageId, GPPLanguage.CPPFUNCTION);
|
||||
public PDOMCPPFunction(PDOMDatabase pdom, PDOMNode parent, IASTName name) throws CoreException {
|
||||
super(pdom, parent, name, PDOMCPPLinkage.CPPFUNCTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pdom
|
||||
* @param bindingRecord
|
||||
*/
|
||||
public PDOMCPPFunction(PDOMDatabase pdom, int bindingRecord) {
|
||||
super(pdom, bindingRecord);
|
||||
}
|
||||
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
public boolean isInline() throws DOMException {
|
||||
throw new PDOMNotImplementedError();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,160 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBlockScope;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPField;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPFunction;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPMethod;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.BTree;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode.NodeVisitor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPLinkage extends PDOMLinkage {
|
||||
|
||||
public PDOMCPPLinkage(PDOMDatabase pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
||||
public PDOMCPPLinkage(PDOMDatabase pdom)
|
||||
throws CoreException {
|
||||
super(pdom, GPPLanguage.ID, "C++".toCharArray());
|
||||
}
|
||||
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
// Binding types
|
||||
public static final int CPPVARIABLE = 1;
|
||||
public static final int CPPFUNCTION = 2;
|
||||
public static final int CPPCLASSTYPE = 3;
|
||||
public static final int CPPFIELD = 4;
|
||||
|
||||
public PDOMNode getParent(IBinding binding) throws CoreException {
|
||||
PDOMNode parent = this;
|
||||
IScope scope = binding.getScope();
|
||||
if (scope != null) {
|
||||
IASTName scopeName = scope.getScopeName();
|
||||
if (scopeName != null) {
|
||||
IBinding scopeBinding = scopeName.resolveBinding();
|
||||
PDOMBinding scopePDOMBinding = (PDOMBinding)scopeBinding.getAdapter(PDOMBinding.class);
|
||||
if (scopePDOMBinding != null)
|
||||
parent = scopePDOMBinding;
|
||||
}
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
public PDOMBinding addName(IASTName name) throws CoreException {
|
||||
if (name == null)
|
||||
return null;
|
||||
|
||||
IBinding binding = name.resolveBinding();
|
||||
if (binding == null)
|
||||
// Can't tell what it is
|
||||
return null;
|
||||
|
||||
PDOMBinding pdomBinding = (PDOMBinding)binding.getAdapter(PDOMBinding.class);
|
||||
if (pdomBinding == null) {
|
||||
PDOMNode parent = getParent(binding);
|
||||
|
||||
if (binding instanceof PDOMBinding)
|
||||
pdomBinding = (PDOMBinding)binding;
|
||||
else if (binding instanceof CPPField)
|
||||
pdomBinding = new PDOMCPPField(pdom, parent, name);
|
||||
else if (binding instanceof CPPVariable) {
|
||||
if (!(binding.getScope() instanceof CPPBlockScope))
|
||||
pdomBinding = new PDOMCPPVariable(pdom, parent, name);
|
||||
} else if (binding instanceof CPPMethod) {
|
||||
; // TODO
|
||||
} else if (binding instanceof CPPFunction) {
|
||||
pdomBinding = new PDOMCPPFunction(pdom, parent, name);
|
||||
} else if (binding instanceof CPPClassType) {
|
||||
pdomBinding = new PDOMCPPClassType(pdom, parent, name);
|
||||
}
|
||||
}
|
||||
|
||||
// Add in the name
|
||||
if (pdomBinding != null)
|
||||
new PDOMName(pdom, name, pdomBinding);
|
||||
|
||||
return pdomBinding;
|
||||
}
|
||||
|
||||
private static final class FindBinding extends PDOMNode.NodeVisitor {
|
||||
private final IBinding binding;
|
||||
public PDOMBinding pdomBinding;
|
||||
public FindBinding(PDOMDatabase pdom, IBinding binding) {
|
||||
super(pdom, binding.getNameCharArray());
|
||||
this.binding = binding;
|
||||
}
|
||||
public boolean visit(int record) throws CoreException {
|
||||
if (record == 0)
|
||||
return true;
|
||||
PDOMBinding tBinding = pdom.getBinding(record);
|
||||
if (!tBinding.hasName(name))
|
||||
return false;
|
||||
switch (tBinding.getBindingType()) {
|
||||
case CPPVARIABLE:
|
||||
if (binding instanceof ICPPVariable)
|
||||
pdomBinding = tBinding;
|
||||
break;
|
||||
}
|
||||
return pdomBinding == null;
|
||||
}
|
||||
}
|
||||
|
||||
public PDOMBinding adaptBinding(IBinding binding) throws CoreException {
|
||||
PDOMNode parent = getParent(binding);
|
||||
if (parent == this) {
|
||||
FindBinding visitor = new FindBinding(pdom, binding);
|
||||
getIndex().visit(visitor);
|
||||
return visitor.pdomBinding;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public PDOMBinding getBinding(int record) throws CoreException {
|
||||
if (record == 0)
|
||||
return null;
|
||||
|
||||
switch (PDOMBinding.getBindingType(pdom, record)) {
|
||||
case CPPVARIABLE:
|
||||
return new PDOMCPPVariable(pdom, record);
|
||||
case CPPFUNCTION:
|
||||
return new PDOMCPPFunction(pdom, record);
|
||||
case CPPCLASSTYPE:
|
||||
return new PDOMCPPClassType(pdom, record);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMLinkageFactory;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class PDOMCPPLinkageFactory implements IPDOMLinkageFactory {
|
||||
|
||||
public PDOMLinkage getLinkage(PDOMDatabase pdom, int record) {
|
||||
return new PDOMCPPLinkage(pdom, record);
|
||||
}
|
||||
|
||||
public PDOMLinkage createLinkage(PDOMDatabase pdom) throws CoreException {
|
||||
return new PDOMCPPLinkage(pdom);
|
||||
}
|
||||
|
||||
}
|
|
@ -15,10 +15,9 @@ import org.eclipse.cdt.core.dom.ast.DOMException;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPVariable;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -28,23 +27,16 @@ import org.eclipse.core.runtime.CoreException;
|
|||
*/
|
||||
public class PDOMCPPVariable extends PDOMBinding implements ICPPVariable {
|
||||
|
||||
/**
|
||||
* @param pdom
|
||||
* @param name
|
||||
* @param binding
|
||||
* @throws CoreException
|
||||
*/
|
||||
public PDOMCPPVariable(PDOMDatabase pdom, int languageId, IASTName name, CPPVariable binding)
|
||||
throws CoreException {
|
||||
super(pdom, name, languageId, GPPLanguage.CPPVARIABLE);
|
||||
public PDOMCPPVariable(PDOMDatabase pdom, PDOMNode parent, IASTName name) throws CoreException {
|
||||
super(pdom, parent, name, PDOMCPPLinkage.CPPVARIABLE);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param pdom
|
||||
* @param bindingRecord
|
||||
*/
|
||||
public PDOMCPPVariable(PDOMDatabase pdom, int bindingRecord) {
|
||||
super(pdom, bindingRecord);
|
||||
public PDOMCPPVariable(PDOMDatabase pdom, int record) {
|
||||
super(pdom, record);
|
||||
}
|
||||
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
public boolean isMutable() throws DOMException {
|
||||
|
|
|
@ -590,6 +590,14 @@
|
|||
<contentType id="org.eclipse.cdt.core.cxxSource"/>
|
||||
</language>
|
||||
</extension>
|
||||
<extension
|
||||
point="org.eclipse.core.runtime.adapters">
|
||||
<factory
|
||||
adaptableType="org.eclipse.cdt.core.dom.ast.IBinding"
|
||||
class="org.eclipse.cdt.internal.core.pdom.dom.PDOMBindingAdapterFactory">
|
||||
<adapter type="org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding"/>
|
||||
</factory>
|
||||
</extension>
|
||||
|
||||
<!-- =================================================================================== -->
|
||||
<!-- Dynamic Variables -->
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
|
||||
</documentation>
|
||||
<appInfo>
|
||||
<meta.attribute kind="java" basedOn="org.eclipse.cdt.core.dom.ILanguage"/>
|
||||
<meta.attribute kind="java" basedOn="org.eclipse.cdt.core.model.ILanguage"/>
|
||||
</appInfo>
|
||||
</annotation>
|
||||
</attribute>
|
||||
|
|
|
@ -325,3 +325,6 @@ indexerPrefName=Indexer
|
|||
CDTIndexer.domsourceindexer=Full C/C++ Indexer (declarations and cross references)
|
||||
CDTIndexer.ctagsindexer=CTags Indexer (declarations only)
|
||||
CDTIndexer.nullindexer=No Indexer (search-based features will not work correctly)
|
||||
|
||||
IndexView.name=C/C++ Index
|
||||
UpdateIndex.name=Update Index
|
||||
|
|
|
@ -234,6 +234,12 @@
|
|||
class="org.eclipse.cdt.internal.ui.cview.CView"
|
||||
id="org.eclipse.cdt.ui.CView">
|
||||
</view>
|
||||
<view
|
||||
category="org.eclipse.cdt.ui.views"
|
||||
class="org.eclipse.cdt.internal.ui.indexview.IndexView"
|
||||
icon="icons/view16/types.gif"
|
||||
id="org.eclipse.cdt.ui.IndexView"
|
||||
name="%IndexView.name"/>
|
||||
<!--category
|
||||
name="%CBrowsing.viewCategoryName"
|
||||
id="org.eclipse.cdt.ui.c.browsing">
|
||||
|
|
|
@ -319,3 +319,6 @@ CViewDragNDrop.txt = already exists. Would you like to overwrite it?
|
|||
EditorUtility.closedproject = Project is closed
|
||||
Editorutility.closedproject.description = The project {0} containing that declaration is closed.
|
||||
|
||||
# ------- Index View Text -----------
|
||||
IndexView.rebuildIndex.name = Rebuild Index
|
||||
IndexView.openDefinition.name = Open Definition
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
package org.eclipse.cdt.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.core.dom.PDOM;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMUpdator;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.ui.IActionDelegate;
|
||||
import org.eclipse.ui.IObjectActionDelegate;
|
||||
import org.eclipse.ui.IWorkbenchPart;
|
||||
|
||||
public class PDOMUpdateProjectAction implements IObjectActionDelegate {
|
||||
|
||||
private ISelection selection;
|
||||
|
||||
/**
|
||||
* @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
|
||||
*/
|
||||
public void setActivePart(IAction action, IWorkbenchPart targetPart) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IActionDelegate#run(IAction)
|
||||
*/
|
||||
public void run(IAction action) {
|
||||
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 cproject = (ICProject)objs[i];
|
||||
try {
|
||||
PDOM.deletePDOM(cproject.getProject());
|
||||
PDOMUpdator job = new PDOMUpdator(cproject, null);
|
||||
job.schedule();
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see IActionDelegate#selectionChanged(IAction, ISelection)
|
||||
*/
|
||||
public void selectionChanged(IAction action, ISelection selection) {
|
||||
this.selection = selection;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,430 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 QNX Software Systems and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* QNX - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
|
||||
package org.eclipse.cdt.internal.ui.indexview;
|
||||
|
||||
import org.eclipse.cdt.core.dom.IPDOM;
|
||||
import org.eclipse.cdt.core.dom.PDOM;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
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.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.resources.FileStorage;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMDatabase;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOMUpdator;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.IBTreeVisitor;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.ui.util.EditorUtility;
|
||||
import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider;
|
||||
import org.eclipse.cdt.ui.CUIPlugin;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.IPath;
|
||||
import org.eclipse.core.runtime.Path;
|
||||
import org.eclipse.jface.action.Action;
|
||||
import org.eclipse.jface.action.IMenuListener;
|
||||
import org.eclipse.jface.action.IMenuManager;
|
||||
import org.eclipse.jface.action.IToolBarManager;
|
||||
import org.eclipse.jface.action.MenuManager;
|
||||
import org.eclipse.jface.viewers.DoubleClickEvent;
|
||||
import org.eclipse.jface.viewers.IDoubleClickListener;
|
||||
import org.eclipse.jface.viewers.ILazyTreeContentProvider;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
import org.eclipse.jface.viewers.LabelProvider;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.jface.viewers.Viewer;
|
||||
import org.eclipse.swt.SWT;
|
||||
import org.eclipse.swt.graphics.Image;
|
||||
import org.eclipse.swt.widgets.Composite;
|
||||
import org.eclipse.swt.widgets.Menu;
|
||||
import org.eclipse.ui.IActionBars;
|
||||
import org.eclipse.ui.IEditorPart;
|
||||
import org.eclipse.ui.ISharedImages;
|
||||
import org.eclipse.ui.PlatformUI;
|
||||
import org.eclipse.ui.part.ViewPart;
|
||||
import org.eclipse.ui.texteditor.ITextEditor;
|
||||
|
||||
/**
|
||||
* @author Doug Schaefer
|
||||
*
|
||||
*/
|
||||
public class IndexView extends ViewPart implements PDOMDatabase.IListener {
|
||||
|
||||
private TreeViewer viewer;
|
||||
// private DrillDownAdapter drillDownAdapter;
|
||||
private IndexAction rebuildAction;
|
||||
private IndexAction openDefinitionAction;
|
||||
|
||||
private static class BTreeCounter implements IBTreeVisitor {
|
||||
int count;
|
||||
PDOMDatabase pdom;
|
||||
public BTreeCounter(PDOMDatabase pdom) {
|
||||
this.pdom = pdom;
|
||||
}
|
||||
public int compare(int record) throws CoreException {
|
||||
return 1;
|
||||
}
|
||||
public boolean visit(int record) throws CoreException {
|
||||
if (record != 0 && ! PDOMBinding.isOrphaned(pdom, record))
|
||||
++count;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private static class BTreeIndex implements IBTreeVisitor {
|
||||
final int index;
|
||||
int count;
|
||||
int result;
|
||||
PDOMDatabase pdom;
|
||||
public BTreeIndex(PDOMDatabase pdom, int index) {
|
||||
this.pdom = pdom;
|
||||
this.index = index;
|
||||
}
|
||||
public int compare(int record) throws CoreException {
|
||||
return 1;
|
||||
};
|
||||
public boolean visit(int record) throws CoreException {
|
||||
if (record == 0 || PDOMBinding.isOrphaned(pdom, record))
|
||||
return true;
|
||||
|
||||
if (count++ == index) {
|
||||
result = record;
|
||||
return false;
|
||||
} else
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
private class IndexContentProvider implements ILazyTreeContentProvider {
|
||||
|
||||
public Object getParent(Object element) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public void updateElement(Object parent, int index) {
|
||||
try {
|
||||
if (parent instanceof ICModel) {
|
||||
ICModel model = (ICModel)parent;
|
||||
ICProject[] cprojects = model.getCProjects();
|
||||
int n = -1;
|
||||
for (int i = 0; i < cprojects.length; ++i) {
|
||||
ICProject cproject = cprojects[i];
|
||||
PDOMDatabase pdom = (PDOMDatabase)PDOM.getPDOM(cproject.getProject());
|
||||
if (pdom != null)
|
||||
++n;
|
||||
if (n == index) {
|
||||
viewer.replace(parent, index, cproject);
|
||||
int nl = 0;
|
||||
for (PDOMLinkage linkage = pdom.getFirstLinkage(); linkage != null; linkage = linkage.getNextLinkage())
|
||||
++nl;
|
||||
viewer.setChildCount(cproject, nl);
|
||||
|
||||
if (viewer.getExpandedState(cproject))
|
||||
for (int j = 0; j < nl; ++j)
|
||||
updateElement(cproject, j);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
} else if (parent instanceof ICProject) {
|
||||
ICProject cproject = (ICProject)parent;
|
||||
PDOMDatabase pdom = (PDOMDatabase)PDOM.getPDOM(cproject.getProject());
|
||||
PDOMLinkage linkage = pdom.getFirstLinkage();
|
||||
if (linkage == null)
|
||||
return;
|
||||
for (int n = 0; n < index; ++n) {
|
||||
linkage = linkage.getNextLinkage();
|
||||
if (linkage == null)
|
||||
return;
|
||||
}
|
||||
viewer.replace(parent, index, linkage);
|
||||
|
||||
BTreeCounter counter = new BTreeCounter(pdom);
|
||||
linkage.getIndex().visit(counter);
|
||||
viewer.setChildCount(linkage, counter.count);
|
||||
|
||||
if (viewer.getExpandedState(linkage))
|
||||
for (int j = 0; j < counter.count; ++j)
|
||||
updateElement(linkage, j);
|
||||
return;
|
||||
} else if (parent instanceof PDOMLinkage) {
|
||||
PDOMLinkage linkage = (PDOMLinkage)parent;
|
||||
PDOMDatabase pdom = linkage.getPDOM();
|
||||
BTreeIndex visitor = new BTreeIndex(pdom, index);
|
||||
linkage.getIndex().visit(visitor);
|
||||
PDOMBinding binding = pdom.getBinding(visitor.result);
|
||||
if (binding != null)
|
||||
viewer.replace(parent, index, binding);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
}
|
||||
|
||||
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private class IndexLabelProvider extends LabelProvider {
|
||||
public String getText(Object element) {
|
||||
if (element == null) {
|
||||
return "null :(";
|
||||
} else if (element instanceof PDOMNode) {
|
||||
try {
|
||||
return ((PDOMNode)element).getName();
|
||||
} catch (CoreException e) {
|
||||
return e.getMessage();
|
||||
}
|
||||
} else
|
||||
return super.getText(element);
|
||||
}
|
||||
|
||||
public Image getImage(Object element) {
|
||||
if (element instanceof IVariable)
|
||||
return CUIPlugin.getImageDescriptorRegistry().get(
|
||||
CElementImageProvider.getVariableImageDescriptor());
|
||||
else if (element instanceof IFunction)
|
||||
return CUIPlugin.getImageDescriptorRegistry().get(
|
||||
CElementImageProvider.getFunctionImageDescriptor());
|
||||
else if (element instanceof ICPPClassType)
|
||||
return CUIPlugin.getImageDescriptorRegistry().get(
|
||||
CElementImageProvider.getClassImageDescriptor());
|
||||
else if (element instanceof IBinding)
|
||||
return PlatformUI.getWorkbench().getSharedImages().getImage(
|
||||
ISharedImages.IMG_OBJ_ELEMENT);
|
||||
// else if (element instanceof ICProject)
|
||||
// return super.getImage(element);
|
||||
else
|
||||
return PlatformUI.getWorkbench().getSharedImages().getImage(
|
||||
ISharedImages.IMG_OBJ_ELEMENT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void createPartControl(Composite parent) {
|
||||
viewer = new TreeViewer(parent, SWT.VIRTUAL | SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
// drillDownAdapter = new DrillDownAdapter(viewer);
|
||||
viewer.setContentProvider(new IndexContentProvider());
|
||||
viewer.setLabelProvider(new IndexLabelProvider());
|
||||
|
||||
ICModel model = CoreModel.getDefault().getCModel();
|
||||
viewer.setInput(model);
|
||||
try {
|
||||
ICProject[] cprojects = model.getCProjects();
|
||||
int n = 0;
|
||||
for (int i = 0; i < cprojects.length; ++i) {
|
||||
PDOMDatabase pdom = (PDOMDatabase)PDOM.getPDOM(cprojects[i].getProject());
|
||||
if (pdom != null) {
|
||||
++n;
|
||||
pdom.addListener(this);
|
||||
}
|
||||
}
|
||||
viewer.setChildCount(model, n);
|
||||
} catch (CModelException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
|
||||
makeActions();
|
||||
hookContextMenu();
|
||||
hookDoubleClickAction();
|
||||
contributeToActionBars();
|
||||
|
||||
// Menu
|
||||
MenuManager menuMgr = new MenuManager();
|
||||
menuMgr.setRemoveAllWhenShown(true);
|
||||
menuMgr.addMenuListener(new IMenuListener() {
|
||||
private void hideMenuItems(IMenuManager manager) {
|
||||
}
|
||||
|
||||
public void menuAboutToShow(IMenuManager manager) {
|
||||
IndexView.this.fillContextMenu(manager);
|
||||
hideMenuItems(manager);
|
||||
}
|
||||
});
|
||||
Menu menu = menuMgr.createContextMenu(viewer.getControl());
|
||||
viewer.getControl().setMenu(menu);
|
||||
getSite().registerContextMenu(menuMgr, viewer);
|
||||
}
|
||||
|
||||
private abstract static class IndexAction extends Action {
|
||||
public abstract boolean valid();
|
||||
}
|
||||
private void makeActions() {
|
||||
rebuildAction = new IndexAction() {
|
||||
public void run() {
|
||||
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 cproject = (ICProject)objs[i];
|
||||
try {
|
||||
PDOM.deletePDOM(cproject.getProject());
|
||||
PDOMUpdator job = new PDOMUpdator(cproject, null);
|
||||
job.schedule();
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean valid() {
|
||||
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;
|
||||
}
|
||||
};
|
||||
rebuildAction.setText(CUIPlugin.getResourceString("IndexView.rebuildIndex.name")); //$NON-NLS-1$
|
||||
|
||||
openDefinitionAction = new IndexAction() {
|
||||
public void run() {
|
||||
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 PDOMBinding))
|
||||
continue;
|
||||
|
||||
try {
|
||||
PDOMBinding binding = (PDOMBinding)objs[i];
|
||||
PDOMName name = binding.getFirstDefinition();
|
||||
if (name == null)
|
||||
name = binding.getFirstDeclaration();
|
||||
if (name == null)
|
||||
continue;
|
||||
|
||||
IASTFileLocation location = name.getFileLocation();
|
||||
IPath path = new Path(location.getFileName());
|
||||
Object input = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(path);
|
||||
if (input == null)
|
||||
input = new FileStorage(path);
|
||||
|
||||
IEditorPart editor = EditorUtility.openInEditor(input);
|
||||
if (editor != null && editor instanceof ITextEditor) {
|
||||
((ITextEditor)editor).selectAndReveal(location.getNodeOffset(), location.getNodeLength());
|
||||
return;
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
public boolean valid() {
|
||||
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 PDOMBinding)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
openDefinitionAction.setText(CUIPlugin.getResourceString("IndexView.openDefinition.name"));//$NON-NLS-1$
|
||||
}
|
||||
|
||||
private void hookContextMenu() {
|
||||
MenuManager menuMgr = new MenuManager("#PopupMenu");
|
||||
menuMgr.setRemoveAllWhenShown(true);
|
||||
menuMgr.addMenuListener(new IMenuListener() {
|
||||
public void menuAboutToShow(IMenuManager manager) {
|
||||
IndexView.this.fillContextMenu(manager);
|
||||
}
|
||||
});
|
||||
Menu menu = menuMgr.createContextMenu(viewer.getControl());
|
||||
viewer.getControl().setMenu(menu);
|
||||
getSite().registerContextMenu(menuMgr, viewer);
|
||||
}
|
||||
|
||||
private void fillContextMenu(IMenuManager manager) {
|
||||
if (rebuildAction.valid())
|
||||
manager.add(rebuildAction);
|
||||
if (rebuildAction.valid())
|
||||
manager.add(openDefinitionAction);
|
||||
//manager.add(new Separator());
|
||||
//drillDownAdapter.addNavigationActions(manager);
|
||||
}
|
||||
|
||||
private void hookDoubleClickAction() {
|
||||
viewer.addDoubleClickListener(new IDoubleClickListener() {
|
||||
public void doubleClick(DoubleClickEvent event) {
|
||||
openDefinitionAction.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void contributeToActionBars() {
|
||||
IActionBars bars = getViewSite().getActionBars();
|
||||
//fillLocalPullDown(bars.getMenuManager());
|
||||
fillLocalToolBar(bars.getToolBarManager());
|
||||
}
|
||||
|
||||
private void fillLocalToolBar(IToolBarManager manager) {
|
||||
//drillDownAdapter.addNavigationActions(manager);
|
||||
}
|
||||
|
||||
public void setFocus() {
|
||||
viewer.getControl().setFocus();
|
||||
}
|
||||
|
||||
public void handleChange(PDOMDatabase pdom) {
|
||||
try {
|
||||
final ICModel model = (ICModel)viewer.getInput();
|
||||
if (model == null)
|
||||
return;
|
||||
ICProject[] cprojects = model.getCProjects();
|
||||
int n = -1;
|
||||
for (int i = 0; i < cprojects.length; ++i) {
|
||||
ICProject cproject = cprojects[i];
|
||||
IPDOM pp = PDOM.getPDOM(cproject.getProject());
|
||||
if (pp != null) {
|
||||
++n;
|
||||
if (pp == pdom){
|
||||
final int index = n;
|
||||
viewer.getControl().getDisplay().asyncExec(new Runnable() {
|
||||
public void run() {
|
||||
((IndexContentProvider)viewer.getContentProvider()).updateElement(model, index);
|
||||
};
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CUIPlugin.getDefault().log(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue